• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef CHPP_WIFI_TYPES_H_
17 #define CHPP_WIFI_TYPES_H_
18 
19 // This file was automatically generated by chre_api_to_chpp.py
20 // Date: 2022-02-03 23:05:31 UTC
21 // Source: chre_api/include/chre_api/chre/wifi.h @ commit b5a92e457
22 
23 // DO NOT modify this file directly, as those changes will be lost the next
24 // time the script is executed
25 
26 #include <stdbool.h>
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 #include "chpp/app.h"
31 #include "chpp/common/common_types.h"
32 #include "chpp/macros.h"
33 #include "chre_api/chre/version.h"
34 #include "chre_api/chre/wifi.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 CHPP_PACKED_START
41 
42 //! See {@link chreWifiNanDiscoveryEvent} for details
43 struct ChppWifiNanDiscoveryEvent {
44   uint32_t subscribeId;
45   uint32_t publishId;
46   uint8_t publisherAddress[6];
47   struct ChppOffset serviceSpecificInfo;  // References serviceSpecificInfoSize
48                                           // instances of struct ChppOffset
49   uint32_t serviceSpecificInfoSize;
50 } CHPP_PACKED_ATTR;
51 
52 //! See {@link chreWifiNanRangingParams} for details
53 struct ChppWifiNanRangingParams {
54   uint8_t macAddress[6];
55 } CHPP_PACKED_ATTR;
56 
57 //! See {@link chreWifiNanSessionLostEvent} for details
58 struct ChppWifiNanSessionLostEvent {
59   uint32_t id;
60   uint32_t peerId;
61 } CHPP_PACKED_ATTR;
62 
63 //! See {@link chreWifiNanSessionTerminatedEvent} for details
64 struct ChppWifiNanSessionTerminatedEvent {
65   uint32_t id;
66   uint8_t reason;
67   uint8_t reserved[3];
68 } CHPP_PACKED_ATTR;
69 
70 //! See {@link chreWifiNanSubscribeConfig} for details
71 struct ChppWifiNanSubscribeConfig {
72   uint8_t subscribeType;
73   struct ChppOffset service;
74   struct ChppOffset serviceSpecificInfo;  // References serviceSpecificInfoSize
75                                           // instances of struct ChppOffset
76   uint32_t serviceSpecificInfoSize;
77   struct ChppOffset matchFilter;  // References matchFilterLength instances of
78                                   // struct ChppOffset
79   uint32_t matchFilterLength;
80 } CHPP_PACKED_ATTR;
81 
82 //! See {@link chreWifiLci} for details
83 struct ChppWifiLci {
84   int64_t latitude;
85   int64_t longitude;
86   int32_t altitude;
87   uint8_t latitudeUncertainty;
88   uint8_t longitudeUncertainty;
89   uint8_t altitudeType;
90   uint8_t altitudeUncertainty;
91 } CHPP_PACKED_ATTR;
92 
93 //! See {@link chreWifiRangingResult} for details
94 struct ChppWifiRangingResult {
95   uint64_t timestamp;
96   uint8_t macAddress[6];
97   uint8_t status;
98   int8_t rssi;
99   uint32_t distance;
100   uint32_t distanceStdDev;
101   struct ChppWifiLci lci;
102   uint8_t flags;
103   uint8_t reserved[7];  // Input ignored; always set to 0
104 } CHPP_PACKED_ATTR;
105 
106 //! See {@link chreWifiRangingEvent} for details
107 struct ChppWifiRangingEvent {
108   uint8_t
109       version;  // Input ignored; always set to CHRE_WIFI_RANGING_EVENT_VERSION
110   uint8_t resultCount;
111   uint8_t reserved[2];  // Input ignored; always set to 0
112   struct ChppOffset
113       results;  // References resultCount instances of struct ChppOffset
114 } CHPP_PACKED_ATTR;
115 
116 //! See {@link chreWifiRangingTarget} for details
117 struct ChppWifiRangingTarget {
118   uint8_t macAddress[6];
119   uint32_t primaryChannel;
120   uint32_t centerFreqPrimary;
121   uint32_t centerFreqSecondary;
122   uint8_t channelWidth;
123   uint8_t reserved[3];  // Input ignored; always set to 0
124 } CHPP_PACKED_ATTR;
125 
126 //! See {@link chreWifiRangingParams} for details
127 struct ChppWifiRangingParams {
128   uint8_t targetListLen;
129   struct ChppOffset
130       targetList;  // References targetListLen instances of struct ChppOffset
131 } CHPP_PACKED_ATTR;
132 
133 //! See {@link chreWifiScanResult} for details
134 struct ChppWifiScanResult {
135   uint32_t ageMs;
136   uint16_t capabilityInfo;
137   uint8_t ssidLen;
138   uint8_t ssid[32];
139   uint8_t bssid[6];
140   uint8_t flags;
141   int8_t rssi;
142   uint8_t band;
143   uint32_t primaryChannel;
144   uint32_t centerFreqPrimary;
145   uint32_t centerFreqSecondary;
146   uint8_t channelWidth;
147   uint8_t securityMode;
148   uint8_t radioChain;
149   int8_t rssiChain0;
150   int8_t rssiChain1;
151   uint8_t reserved[7];  // Input ignored; always set to 0
152 } CHPP_PACKED_ATTR;
153 
154 //! See {@link chreWifiScanEvent} for details
155 struct ChppWifiScanEvent {
156   uint8_t version;  // Input ignored; always set to CHRE_WIFI_SCAN_EVENT_VERSION
157   uint8_t resultCount;
158   uint8_t resultTotal;
159   uint8_t eventIndex;
160   uint8_t scanType;
161   uint8_t ssidSetSize;
162   uint16_t scannedFreqListLen;
163   uint64_t referenceTime;
164   struct ChppOffset scannedFreqList;  // References scannedFreqListLen instances
165                                       // of struct ChppOffset
166   struct ChppOffset
167       results;  // References resultCount instances of struct ChppOffset
168   uint8_t radioChainPref;
169 } CHPP_PACKED_ATTR;
170 
171 //! See {@link chreWifiSsidListItem} for details
172 struct ChppWifiSsidListItem {
173   uint8_t ssidLen;
174   uint8_t ssid[32];
175 } CHPP_PACKED_ATTR;
176 
177 //! See {@link chreWifiScanParams} for details
178 struct ChppWifiScanParams {
179   uint8_t scanType;
180   uint32_t maxScanAgeMs;
181   uint16_t frequencyListLen;
182   struct ChppOffset frequencyList;  // References frequencyListLen instances of
183                                     // struct ChppOffset
184   uint8_t ssidListLen;
185   struct ChppOffset
186       ssidList;  // References ssidListLen instances of struct ChppOffset
187   uint8_t radioChainPref;
188   uint8_t channelSet;
189 } CHPP_PACKED_ATTR;
190 
191 //! CHPP app header plus struct ChppWifiScanEventWithHeader
192 struct ChppWifiScanEventWithHeader {
193   struct ChppAppHeader header;
194   struct ChppWifiScanEvent payload;
195 } CHPP_PACKED_ATTR;
196 
197 //! CHPP app header plus struct ChppWifiScanParamsWithHeader
198 struct ChppWifiScanParamsWithHeader {
199   struct ChppAppHeader header;
200   struct ChppWifiScanParams payload;
201 } CHPP_PACKED_ATTR;
202 
203 //! CHPP app header plus struct ChppWifiRangingEventWithHeader
204 struct ChppWifiRangingEventWithHeader {
205   struct ChppAppHeader header;
206   struct ChppWifiRangingEvent payload;
207 } CHPP_PACKED_ATTR;
208 
209 //! CHPP app header plus struct ChppWifiRangingParamsWithHeader
210 struct ChppWifiRangingParamsWithHeader {
211   struct ChppAppHeader header;
212   struct ChppWifiRangingParams payload;
213 } CHPP_PACKED_ATTR;
214 
215 //! CHPP app header plus struct ChppWifiNanSubscribeConfigWithHeader
216 struct ChppWifiNanSubscribeConfigWithHeader {
217   struct ChppAppHeader header;
218   struct ChppWifiNanSubscribeConfig payload;
219 } CHPP_PACKED_ATTR;
220 
221 //! CHPP app header plus struct ChppWifiNanDiscoveryEventWithHeader
222 struct ChppWifiNanDiscoveryEventWithHeader {
223   struct ChppAppHeader header;
224   struct ChppWifiNanDiscoveryEvent payload;
225 } CHPP_PACKED_ATTR;
226 
227 //! CHPP app header plus struct ChppWifiNanSessionLostEventWithHeader
228 struct ChppWifiNanSessionLostEventWithHeader {
229   struct ChppAppHeader header;
230   struct ChppWifiNanSessionLostEvent payload;
231 } CHPP_PACKED_ATTR;
232 
233 //! CHPP app header plus struct ChppWifiNanSessionTerminatedEventWithHeader
234 struct ChppWifiNanSessionTerminatedEventWithHeader {
235   struct ChppAppHeader header;
236   struct ChppWifiNanSessionTerminatedEvent payload;
237 } CHPP_PACKED_ATTR;
238 
239 //! CHPP app header plus struct ChppWifiNanRangingParamsWithHeader
240 struct ChppWifiNanRangingParamsWithHeader {
241   struct ChppAppHeader header;
242   struct ChppWifiNanRangingParams payload;
243 } CHPP_PACKED_ATTR;
244 
245 CHPP_PACKED_END
246 
247 // Encoding functions (CHRE --> CHPP)
248 
249 /**
250  * Converts from given CHRE structure to serialized CHPP type.
251  *
252  * @param in Fully-formed CHRE structure.
253  * @param out Upon success, will point to a buffer allocated with chppMalloc().
254  * It is the responsibility of the caller to set the values of the CHPP app
255  * layer header, and to free the buffer when it is no longer needed via
256  * chppFree() or CHPP_FREE_AND_NULLIFY().
257  * @param outSize Upon success, will be set to the size of the output buffer, in
258  * bytes.
259  *
260  * @return true on success, false if memory allocation failed.
261  */
262 bool chppWifiScanEventFromChre(const struct chreWifiScanEvent *in,
263                                struct ChppWifiScanEventWithHeader **out,
264                                size_t *outSize);
265 
266 /**
267  * Converts from given CHRE structure to serialized CHPP type.
268  *
269  * @param in Fully-formed CHRE structure.
270  * @param out Upon success, will point to a buffer allocated with chppMalloc().
271  * It is the responsibility of the caller to set the values of the CHPP app
272  * layer header, and to free the buffer when it is no longer needed via
273  * chppFree() or CHPP_FREE_AND_NULLIFY().
274  * @param outSize Upon success, will be set to the size of the output buffer, in
275  * bytes.
276  *
277  * @return true on success, false if memory allocation failed.
278  */
279 bool chppWifiScanParamsFromChre(const struct chreWifiScanParams *in,
280                                 struct ChppWifiScanParamsWithHeader **out,
281                                 size_t *outSize);
282 
283 /**
284  * Converts from given CHRE structure to serialized CHPP type.
285  *
286  * @param in Fully-formed CHRE structure.
287  * @param out Upon success, will point to a buffer allocated with chppMalloc().
288  * It is the responsibility of the caller to set the values of the CHPP app
289  * layer header, and to free the buffer when it is no longer needed via
290  * chppFree() or CHPP_FREE_AND_NULLIFY().
291  * @param outSize Upon success, will be set to the size of the output buffer, in
292  * bytes.
293  *
294  * @return true on success, false if memory allocation failed.
295  */
296 bool chppWifiRangingEventFromChre(const struct chreWifiRangingEvent *in,
297                                   struct ChppWifiRangingEventWithHeader **out,
298                                   size_t *outSize);
299 
300 /**
301  * Converts from given CHRE structure to serialized CHPP type.
302  *
303  * @param in Fully-formed CHRE structure.
304  * @param out Upon success, will point to a buffer allocated with chppMalloc().
305  * It is the responsibility of the caller to set the values of the CHPP app
306  * layer header, and to free the buffer when it is no longer needed via
307  * chppFree() or CHPP_FREE_AND_NULLIFY().
308  * @param outSize Upon success, will be set to the size of the output buffer, in
309  * bytes.
310  *
311  * @return true on success, false if memory allocation failed.
312  */
313 bool chppWifiRangingParamsFromChre(const struct chreWifiRangingParams *in,
314                                    struct ChppWifiRangingParamsWithHeader **out,
315                                    size_t *outSize);
316 
317 /**
318  * Converts from given CHRE structure to serialized CHPP type.
319  *
320  * @param in Fully-formed CHRE structure.
321  * @param out Upon success, will point to a buffer allocated with chppMalloc().
322  * It is the responsibility of the caller to set the values of the CHPP app
323  * layer header, and to free the buffer when it is no longer needed via
324  * chppFree() or CHPP_FREE_AND_NULLIFY().
325  * @param outSize Upon success, will be set to the size of the output buffer, in
326  * bytes.
327  *
328  * @return true on success, false if memory allocation failed.
329  */
330 bool chppWifiNanSubscribeConfigFromChre(
331     const struct chreWifiNanSubscribeConfig *in,
332     struct ChppWifiNanSubscribeConfigWithHeader **out, size_t *outSize);
333 
334 /**
335  * Converts from given CHRE structure to serialized CHPP type.
336  *
337  * @param in Fully-formed CHRE structure.
338  * @param out Upon success, will point to a buffer allocated with chppMalloc().
339  * It is the responsibility of the caller to set the values of the CHPP app
340  * layer header, and to free the buffer when it is no longer needed via
341  * chppFree() or CHPP_FREE_AND_NULLIFY().
342  * @param outSize Upon success, will be set to the size of the output buffer, in
343  * bytes.
344  *
345  * @return true on success, false if memory allocation failed.
346  */
347 bool chppWifiNanDiscoveryEventFromChre(
348     const struct chreWifiNanDiscoveryEvent *in,
349     struct ChppWifiNanDiscoveryEventWithHeader **out, size_t *outSize);
350 
351 /**
352  * Converts from given CHRE structure to serialized CHPP type.
353  *
354  * @param in Fully-formed CHRE structure.
355  * @param out Upon success, will point to a buffer allocated with chppMalloc().
356  * It is the responsibility of the caller to set the values of the CHPP app
357  * layer header, and to free the buffer when it is no longer needed via
358  * chppFree() or CHPP_FREE_AND_NULLIFY().
359  * @param outSize Upon success, will be set to the size of the output buffer, in
360  * bytes.
361  *
362  * @return true on success, false if memory allocation failed.
363  */
364 bool chppWifiNanSessionLostEventFromChre(
365     const struct chreWifiNanSessionLostEvent *in,
366     struct ChppWifiNanSessionLostEventWithHeader **out, size_t *outSize);
367 
368 /**
369  * Converts from given CHRE structure to serialized CHPP type.
370  *
371  * @param in Fully-formed CHRE structure.
372  * @param out Upon success, will point to a buffer allocated with chppMalloc().
373  * It is the responsibility of the caller to set the values of the CHPP app
374  * layer header, and to free the buffer when it is no longer needed via
375  * chppFree() or CHPP_FREE_AND_NULLIFY().
376  * @param outSize Upon success, will be set to the size of the output buffer, in
377  * bytes.
378  *
379  * @return true on success, false if memory allocation failed.
380  */
381 bool chppWifiNanSessionTerminatedEventFromChre(
382     const struct chreWifiNanSessionTerminatedEvent *in,
383     struct ChppWifiNanSessionTerminatedEventWithHeader **out, size_t *outSize);
384 
385 /**
386  * Converts from given CHRE structure to serialized CHPP type.
387  *
388  * @param in Fully-formed CHRE structure.
389  * @param out Upon success, will point to a buffer allocated with chppMalloc().
390  * It is the responsibility of the caller to set the values of the CHPP app
391  * layer header, and to free the buffer when it is no longer needed via
392  * chppFree() or CHPP_FREE_AND_NULLIFY().
393  * @param outSize Upon success, will be set to the size of the output buffer, in
394  * bytes.
395  *
396  * @return true on success, false if memory allocation failed.
397  */
398 bool chppWifiNanRangingParamsFromChre(
399     const struct chreWifiNanRangingParams *in,
400     struct ChppWifiNanRangingParamsWithHeader **out, size_t *outSize);
401 
402 // Decoding functions (CHPP --> CHRE)
403 
404 /**
405  * Converts from serialized CHPP structure to a CHRE type.
406  *
407  * @param in Fully-formed CHPP structure.
408  * @param in Size of the CHPP structure in bytes.
409  *
410  * @return If successful, a pointer to a CHRE structure allocated with
411  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
412  * to free the buffer when it is no longer needed via chppFree() or
413  * CHPP_FREE_AND_NULLIFY().
414  */
415 struct chreWifiScanEvent *chppWifiScanEventToChre(
416     const struct ChppWifiScanEvent *in, size_t inSize);
417 
418 /**
419  * Converts from serialized CHPP structure to a CHRE type.
420  *
421  * @param in Fully-formed CHPP structure.
422  * @param in Size of the CHPP structure in bytes.
423  *
424  * @return If successful, a pointer to a CHRE structure allocated with
425  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
426  * to free the buffer when it is no longer needed via chppFree() or
427  * CHPP_FREE_AND_NULLIFY().
428  */
429 struct chreWifiScanParams *chppWifiScanParamsToChre(
430     const struct ChppWifiScanParams *in, size_t inSize);
431 
432 /**
433  * Converts from serialized CHPP structure to a CHRE type.
434  *
435  * @param in Fully-formed CHPP structure.
436  * @param in Size of the CHPP structure in bytes.
437  *
438  * @return If successful, a pointer to a CHRE structure allocated with
439  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
440  * to free the buffer when it is no longer needed via chppFree() or
441  * CHPP_FREE_AND_NULLIFY().
442  */
443 struct chreWifiRangingEvent *chppWifiRangingEventToChre(
444     const struct ChppWifiRangingEvent *in, size_t inSize);
445 
446 /**
447  * Converts from serialized CHPP structure to a CHRE type.
448  *
449  * @param in Fully-formed CHPP structure.
450  * @param in Size of the CHPP structure in bytes.
451  *
452  * @return If successful, a pointer to a CHRE structure allocated with
453  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
454  * to free the buffer when it is no longer needed via chppFree() or
455  * CHPP_FREE_AND_NULLIFY().
456  */
457 struct chreWifiRangingParams *chppWifiRangingParamsToChre(
458     const struct ChppWifiRangingParams *in, size_t inSize);
459 
460 /**
461  * Converts from serialized CHPP structure to a CHRE type.
462  *
463  * @param in Fully-formed CHPP structure.
464  * @param in Size of the CHPP structure in bytes.
465  *
466  * @return If successful, a pointer to a CHRE structure allocated with
467  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
468  * to free the buffer when it is no longer needed via chppFree() or
469  * CHPP_FREE_AND_NULLIFY().
470  */
471 struct chreWifiNanSubscribeConfig *chppWifiNanSubscribeConfigToChre(
472     const struct ChppWifiNanSubscribeConfig *in, size_t inSize);
473 
474 /**
475  * Converts from serialized CHPP structure to a CHRE type.
476  *
477  * @param in Fully-formed CHPP structure.
478  * @param in Size of the CHPP structure in bytes.
479  *
480  * @return If successful, a pointer to a CHRE structure allocated with
481  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
482  * to free the buffer when it is no longer needed via chppFree() or
483  * CHPP_FREE_AND_NULLIFY().
484  */
485 struct chreWifiNanDiscoveryEvent *chppWifiNanDiscoveryEventToChre(
486     const struct ChppWifiNanDiscoveryEvent *in, size_t inSize);
487 
488 /**
489  * Converts from serialized CHPP structure to a CHRE type.
490  *
491  * @param in Fully-formed CHPP structure.
492  * @param in Size of the CHPP structure in bytes.
493  *
494  * @return If successful, a pointer to a CHRE structure allocated with
495  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
496  * to free the buffer when it is no longer needed via chppFree() or
497  * CHPP_FREE_AND_NULLIFY().
498  */
499 struct chreWifiNanSessionLostEvent *chppWifiNanSessionLostEventToChre(
500     const struct ChppWifiNanSessionLostEvent *in, size_t inSize);
501 
502 /**
503  * Converts from serialized CHPP structure to a CHRE type.
504  *
505  * @param in Fully-formed CHPP structure.
506  * @param in Size of the CHPP structure in bytes.
507  *
508  * @return If successful, a pointer to a CHRE structure allocated with
509  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
510  * to free the buffer when it is no longer needed via chppFree() or
511  * CHPP_FREE_AND_NULLIFY().
512  */
513 struct chreWifiNanSessionTerminatedEvent *
514 chppWifiNanSessionTerminatedEventToChre(
515     const struct ChppWifiNanSessionTerminatedEvent *in, size_t inSize);
516 
517 /**
518  * Converts from serialized CHPP structure to a CHRE type.
519  *
520  * @param in Fully-formed CHPP structure.
521  * @param in Size of the CHPP structure in bytes.
522  *
523  * @return If successful, a pointer to a CHRE structure allocated with
524  * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller
525  * to free the buffer when it is no longer needed via chppFree() or
526  * CHPP_FREE_AND_NULLIFY().
527  */
528 struct chreWifiNanRangingParams *chppWifiNanRangingParamsToChre(
529     const struct ChppWifiNanRangingParams *in, size_t inSize);
530 
531 #ifdef __cplusplus
532 }
533 #endif
534 
535 #endif  // CHPP_WIFI_TYPES_H_
536