blob: ec832f9686cdc99715ad1c89527d993f22dbe3c9 [file]
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CHPP_WIFI_TYPES_H_
#define CHPP_WIFI_TYPES_H_
// This file was automatically generated by chre_api_to_chpp.py
// Date: 2022-02-03 23:05:31 UTC
// Source: chre_api/include/chre_api/chre/wifi.h @ commit b5a92e457
// DO NOT modify this file directly, as those changes will be lost the next
// time the script is executed
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "chpp/app.h"
#include "chpp/common/common_types.h"
#include "chpp/macros.h"
#include "chre_api/chre/version.h"
#include "chre_api/chre/wifi.h"
#ifdef __cplusplus
extern "C" {
#endif
CHPP_PACKED_START
//! See {@link chreWifiNanDiscoveryEvent} for details
struct ChppWifiNanDiscoveryEvent {
uint32_t subscribeId;
uint32_t publishId;
uint8_t publisherAddress[6];
struct ChppOffset serviceSpecificInfo; // References serviceSpecificInfoSize
// instances of struct ChppOffset
uint32_t serviceSpecificInfoSize;
} CHPP_PACKED_ATTR;
//! See {@link chreWifiNanRangingParams} for details
struct ChppWifiNanRangingParams {
uint8_t macAddress[6];
} CHPP_PACKED_ATTR;
//! See {@link chreWifiNanSessionLostEvent} for details
struct ChppWifiNanSessionLostEvent {
uint32_t id;
uint32_t peerId;
} CHPP_PACKED_ATTR;
//! See {@link chreWifiNanSessionTerminatedEvent} for details
struct ChppWifiNanSessionTerminatedEvent {
uint32_t id;
uint8_t reason;
uint8_t reserved[3];
} CHPP_PACKED_ATTR;
//! See {@link chreWifiNanSubscribeConfig} for details
struct ChppWifiNanSubscribeConfig {
uint8_t subscribeType;
struct ChppOffset service;
struct ChppOffset serviceSpecificInfo; // References serviceSpecificInfoSize
// instances of struct ChppOffset
uint32_t serviceSpecificInfoSize;
struct ChppOffset matchFilter; // References matchFilterLength instances of
// struct ChppOffset
uint32_t matchFilterLength;
} CHPP_PACKED_ATTR;
//! See {@link chreWifiLci} for details
struct ChppWifiLci {
int64_t latitude;
int64_t longitude;
int32_t altitude;
uint8_t latitudeUncertainty;
uint8_t longitudeUncertainty;
uint8_t altitudeType;
uint8_t altitudeUncertainty;
} CHPP_PACKED_ATTR;
//! See {@link chreWifiRangingResult} for details
struct ChppWifiRangingResult {
uint64_t timestamp;
uint8_t macAddress[6];
uint8_t status;
int8_t rssi;
uint32_t distance;
uint32_t distanceStdDev;
struct ChppWifiLci lci;
uint8_t flags;
uint8_t reserved[7]; // Input ignored; always set to 0
} CHPP_PACKED_ATTR;
//! See {@link chreWifiRangingEvent} for details
struct ChppWifiRangingEvent {
uint8_t
version; // Input ignored; always set to CHRE_WIFI_RANGING_EVENT_VERSION
uint8_t resultCount;
uint8_t reserved[2]; // Input ignored; always set to 0
struct ChppOffset
results; // References resultCount instances of struct ChppOffset
} CHPP_PACKED_ATTR;
//! See {@link chreWifiRangingTarget} for details
struct ChppWifiRangingTarget {
uint8_t macAddress[6];
uint32_t primaryChannel;
uint32_t centerFreqPrimary;
uint32_t centerFreqSecondary;
uint8_t channelWidth;
uint8_t reserved[3]; // Input ignored; always set to 0
} CHPP_PACKED_ATTR;
//! See {@link chreWifiRangingParams} for details
struct ChppWifiRangingParams {
uint8_t targetListLen;
struct ChppOffset
targetList; // References targetListLen instances of struct ChppOffset
} CHPP_PACKED_ATTR;
//! See {@link chreWifiScanResult} for details
struct ChppWifiScanResult {
uint32_t ageMs;
uint16_t capabilityInfo;
uint8_t ssidLen;
uint8_t ssid[32];
uint8_t bssid[6];
uint8_t flags;
int8_t rssi;
uint8_t band;
uint32_t primaryChannel;
uint32_t centerFreqPrimary;
uint32_t centerFreqSecondary;
uint8_t channelWidth;
uint8_t securityMode;
uint8_t radioChain;
int8_t rssiChain0;
int8_t rssiChain1;
uint8_t reserved[7]; // Input ignored; always set to 0
} CHPP_PACKED_ATTR;
//! See {@link chreWifiScanEvent} for details
struct ChppWifiScanEvent {
uint8_t version; // Input ignored; always set to CHRE_WIFI_SCAN_EVENT_VERSION
uint8_t resultCount;
uint8_t resultTotal;
uint8_t eventIndex;
uint8_t scanType;
uint8_t ssidSetSize;
uint16_t scannedFreqListLen;
uint64_t referenceTime;
struct ChppOffset scannedFreqList; // References scannedFreqListLen instances
// of struct ChppOffset
struct ChppOffset
results; // References resultCount instances of struct ChppOffset
uint8_t radioChainPref;
} CHPP_PACKED_ATTR;
//! See {@link chreWifiSsidListItem} for details
struct ChppWifiSsidListItem {
uint8_t ssidLen;
uint8_t ssid[32];
} CHPP_PACKED_ATTR;
//! See {@link chreWifiScanParams} for details
struct ChppWifiScanParams {
uint8_t scanType;
uint32_t maxScanAgeMs;
uint16_t frequencyListLen;
struct ChppOffset frequencyList; // References frequencyListLen instances of
// struct ChppOffset
uint8_t ssidListLen;
struct ChppOffset
ssidList; // References ssidListLen instances of struct ChppOffset
uint8_t radioChainPref;
uint8_t channelSet;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiScanEventWithHeader
struct ChppWifiScanEventWithHeader {
struct ChppAppHeader header;
struct ChppWifiScanEvent payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiScanParamsWithHeader
struct ChppWifiScanParamsWithHeader {
struct ChppAppHeader header;
struct ChppWifiScanParams payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiRangingEventWithHeader
struct ChppWifiRangingEventWithHeader {
struct ChppAppHeader header;
struct ChppWifiRangingEvent payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiRangingParamsWithHeader
struct ChppWifiRangingParamsWithHeader {
struct ChppAppHeader header;
struct ChppWifiRangingParams payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiNanSubscribeConfigWithHeader
struct ChppWifiNanSubscribeConfigWithHeader {
struct ChppAppHeader header;
struct ChppWifiNanSubscribeConfig payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiNanDiscoveryEventWithHeader
struct ChppWifiNanDiscoveryEventWithHeader {
struct ChppAppHeader header;
struct ChppWifiNanDiscoveryEvent payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiNanSessionLostEventWithHeader
struct ChppWifiNanSessionLostEventWithHeader {
struct ChppAppHeader header;
struct ChppWifiNanSessionLostEvent payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiNanSessionTerminatedEventWithHeader
struct ChppWifiNanSessionTerminatedEventWithHeader {
struct ChppAppHeader header;
struct ChppWifiNanSessionTerminatedEvent payload;
} CHPP_PACKED_ATTR;
//! CHPP app header plus struct ChppWifiNanRangingParamsWithHeader
struct ChppWifiNanRangingParamsWithHeader {
struct ChppAppHeader header;
struct ChppWifiNanRangingParams payload;
} CHPP_PACKED_ATTR;
CHPP_PACKED_END
// Encoding functions (CHRE --> CHPP)
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiScanEventFromChre(const struct chreWifiScanEvent *in,
struct ChppWifiScanEventWithHeader **out,
size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiScanParamsFromChre(const struct chreWifiScanParams *in,
struct ChppWifiScanParamsWithHeader **out,
size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiRangingEventFromChre(const struct chreWifiRangingEvent *in,
struct ChppWifiRangingEventWithHeader **out,
size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiRangingParamsFromChre(const struct chreWifiRangingParams *in,
struct ChppWifiRangingParamsWithHeader **out,
size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiNanSubscribeConfigFromChre(
const struct chreWifiNanSubscribeConfig *in,
struct ChppWifiNanSubscribeConfigWithHeader **out, size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiNanDiscoveryEventFromChre(
const struct chreWifiNanDiscoveryEvent *in,
struct ChppWifiNanDiscoveryEventWithHeader **out, size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiNanSessionLostEventFromChre(
const struct chreWifiNanSessionLostEvent *in,
struct ChppWifiNanSessionLostEventWithHeader **out, size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiNanSessionTerminatedEventFromChre(
const struct chreWifiNanSessionTerminatedEvent *in,
struct ChppWifiNanSessionTerminatedEventWithHeader **out, size_t *outSize);
/**
* Converts from given CHRE structure to serialized CHPP type.
*
* @param in Fully-formed CHRE structure.
* @param out Upon success, will point to a buffer allocated with chppMalloc().
* It is the responsibility of the caller to set the values of the CHPP app
* layer header, and to free the buffer when it is no longer needed via
* chppFree() or CHPP_FREE_AND_NULLIFY().
* @param outSize Upon success, will be set to the size of the output buffer, in
* bytes.
*
* @return true on success, false if memory allocation failed.
*/
bool chppWifiNanRangingParamsFromChre(
const struct chreWifiNanRangingParams *in,
struct ChppWifiNanRangingParamsWithHeader **out, size_t *outSize);
// Decoding functions (CHPP --> CHRE)
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiScanEvent *chppWifiScanEventToChre(
const struct ChppWifiScanEvent *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiScanParams *chppWifiScanParamsToChre(
const struct ChppWifiScanParams *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiRangingEvent *chppWifiRangingEventToChre(
const struct ChppWifiRangingEvent *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiRangingParams *chppWifiRangingParamsToChre(
const struct ChppWifiRangingParams *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiNanSubscribeConfig *chppWifiNanSubscribeConfigToChre(
const struct ChppWifiNanSubscribeConfig *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiNanDiscoveryEvent *chppWifiNanDiscoveryEventToChre(
const struct ChppWifiNanDiscoveryEvent *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiNanSessionLostEvent *chppWifiNanSessionLostEventToChre(
const struct ChppWifiNanSessionLostEvent *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiNanSessionTerminatedEvent *
chppWifiNanSessionTerminatedEventToChre(
const struct ChppWifiNanSessionTerminatedEvent *in, size_t inSize);
/**
* Converts from serialized CHPP structure to a CHRE type.
*
* @param in Fully-formed CHPP structure.
* @param in Size of the CHPP structure in bytes.
*
* @return If successful, a pointer to a CHRE structure allocated with
* chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
* to free the buffer when it is no longer needed via chppFree() or
* CHPP_FREE_AND_NULLIFY().
*/
struct chreWifiNanRangingParams *chppWifiNanRangingParamsToChre(
const struct ChppWifiNanRangingParams *in, size_t inSize);
#ifdef __cplusplus
}
#endif
#endif // CHPP_WIFI_TYPES_H_