common.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. /*
  2. * fota_supplicant/hostapd / common helper functions, etc.
  3. * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef COMMON_H
  9. #define COMMON_H
  10. #include "os.h"
  11. #if defined(__linux__) || defined(__GLIBC__)
  12. #include <endian.h>
  13. #include <byteswap.h>
  14. #endif /* __linux__ */
  15. #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
  16. defined(__OpenBSD__)
  17. #include <sys/types.h>
  18. #include <sys/endian.h>
  19. #define __BYTE_ORDER _BYTE_ORDER
  20. #define __LITTLE_ENDIAN _LITTLE_ENDIAN
  21. #define __BIG_ENDIAN _BIG_ENDIAN
  22. #ifdef __OpenBSD__
  23. #define bswap_16 swap16
  24. #define bswap_32 swap32
  25. #define bswap_64 swap64
  26. #else /* __OpenBSD__ */
  27. #define bswap_16 bswap16
  28. #define bswap_32 bswap32
  29. #define bswap_64 bswap64
  30. #endif /* __OpenBSD__ */
  31. #endif /* defined(__FreeBSD__) || defined(__NetBSD__) ||
  32. * defined(__DragonFly__) || defined(__OpenBSD__) */
  33. #ifdef __APPLE__
  34. #include <sys/types.h>
  35. #include <machine/endian.h>
  36. #define __BYTE_ORDER _BYTE_ORDER
  37. #define __LITTLE_ENDIAN _LITTLE_ENDIAN
  38. #define __BIG_ENDIAN _BIG_ENDIAN
  39. static inline unsigned short bswap_16(unsigned short v)
  40. {
  41. return ((v & 0xff) << 8) | (v >> 8);
  42. }
  43. static inline unsigned int bswap_32(unsigned int v)
  44. {
  45. return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
  46. ((v & 0xff0000) >> 8) | (v >> 24);
  47. }
  48. #endif /* __APPLE__ */
  49. #ifdef __rtems__
  50. #include <rtems/endian.h>
  51. #define __BYTE_ORDER BYTE_ORDER
  52. #define __LITTLE_ENDIAN LITTLE_ENDIAN
  53. #define __BIG_ENDIAN BIG_ENDIAN
  54. #define bswap_16 CPU_swap_u16
  55. #define bswap_32 CPU_swap_u32
  56. #endif /* __rtems__ */
  57. #ifdef CONFIG_NATIVE_WINDOWS
  58. #include <winsock.h>
  59. typedef int socklen_t;
  60. #ifndef MSG_DONTWAIT
  61. #define MSG_DONTWAIT 0 /* not supported */
  62. #endif
  63. #endif /* CONFIG_NATIVE_WINDOWS */
  64. #ifdef _MSC_VER
  65. #define inline __inline
  66. #undef vsnprintf
  67. #define vsnprintf _vsnprintf
  68. #undef close
  69. #define close closesocket
  70. #endif /* _MSC_VER */
  71. /* Define platform specific integer types */
  72. #ifdef _MSC_VER
  73. typedef UINT64 u64;
  74. typedef UINT32 u32;
  75. typedef UINT16 u16;
  76. typedef UINT8 u8;
  77. typedef INT64 s64;
  78. typedef INT32 s32;
  79. typedef INT16 s16;
  80. typedef INT8 s8;
  81. #define FOTA_TYPES_DEFINED
  82. #endif /* _MSC_VER */
  83. #ifdef __vxworks
  84. typedef unsigned long long u64;
  85. typedef UINT32 u32;
  86. typedef UINT16 u16;
  87. typedef UINT8 u8;
  88. typedef long long s64;
  89. typedef INT32 s32;
  90. typedef INT16 s16;
  91. typedef INT8 s8;
  92. #define FOTA_TYPES_DEFINED
  93. #endif /* __vxworks */
  94. #ifndef FOTA_TYPES_DEFINED
  95. #ifdef CONFIG_USE_INTTYPES_H
  96. #include <inttypes.h>
  97. #else
  98. #include <stdint.h>
  99. #endif
  100. typedef uint64_t u64;
  101. typedef uint32_t u32;
  102. typedef uint16_t u16;
  103. typedef uint8_t u8;
  104. typedef int64_t s64;
  105. typedef int32_t s32;
  106. typedef int16_t s16;
  107. typedef int8_t s8;
  108. #define FOTA_TYPES_DEFINED
  109. #endif /* !FOTA_TYPES_DEFINED */
  110. /* Define platform specific byte swapping macros */
  111. #if defined(__CYGWIN__) || defined(CONFIG_NATIVE_WINDOWS)
  112. static inline unsigned short fota_swap_16(unsigned short v)
  113. {
  114. return ((v & 0xff) << 8) | (v >> 8);
  115. }
  116. static inline unsigned int fota_swap_32(unsigned int v)
  117. {
  118. return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
  119. ((v & 0xff0000) >> 8) | (v >> 24);
  120. }
  121. #define le_to_host16(n) (n)
  122. #define host_to_le16(n) (n)
  123. #define be_to_host16(n) fota_swap_16(n)
  124. #define host_to_be16(n) fota_swap_16(n)
  125. #define le_to_host32(n) (n)
  126. #define host_to_le32(n) (n)
  127. #define be_to_host32(n) fota_swap_32(n)
  128. #define host_to_be32(n) fota_swap_32(n)
  129. #define host_to_le64(n) (n)
  130. #define FOTA_BYTE_SWAP_DEFINED
  131. #endif /* __CYGWIN__ || CONFIG_NATIVE_WINDOWS */
  132. #ifndef FOTA_BYTE_SWAP_DEFINED
  133. #ifndef __BYTE_ORDER
  134. #ifndef __LITTLE_ENDIAN
  135. #ifndef __BIG_ENDIAN
  136. #define __LITTLE_ENDIAN 1234
  137. #define __BIG_ENDIAN 4321
  138. #if defined(sparc)
  139. #define __BYTE_ORDER __BIG_ENDIAN
  140. #endif
  141. #endif /* __BIG_ENDIAN */
  142. #endif /* __LITTLE_ENDIAN */
  143. #endif /* __BYTE_ORDER */
  144. #if __BYTE_ORDER == __LITTLE_ENDIAN
  145. #define le_to_host16(n) ((__force u16) (le16) (n))
  146. #define host_to_le16(n) ((__force le16) (u16) (n))
  147. #define be_to_host16(n) bswap_16((__force u16) (be16) (n))
  148. #define host_to_be16(n) ((__force be16) bswap_16((n)))
  149. #define le_to_host32(n) ((__force u32) (le32) (n))
  150. #define host_to_le32(n) ((__force le32) (u32) (n))
  151. #define be_to_host32(n) bswap_32((__force u32) (be32) (n))
  152. #define host_to_be32(n) ((__force be32) bswap_32((n)))
  153. #define le_to_host64(n) ((__force u64) (le64) (n))
  154. #define host_to_le64(n) ((__force le64) (u64) (n))
  155. #define be_to_host64(n) bswap_64((__force u64) (be64) (n))
  156. #define host_to_be64(n) ((__force be64) bswap_64((n)))
  157. #elif __BYTE_ORDER == __BIG_ENDIAN
  158. #define le_to_host16(n) bswap_16(n)
  159. #define host_to_le16(n) bswap_16(n)
  160. #define be_to_host16(n) (n)
  161. #define host_to_be16(n) (n)
  162. #define le_to_host32(n) bswap_32(n)
  163. #define host_to_le32(n) bswap_32(n)
  164. #define be_to_host32(n) (n)
  165. #define host_to_be32(n) (n)
  166. #define le_to_host64(n) bswap_64(n)
  167. #define host_to_le64(n) bswap_64(n)
  168. #define be_to_host64(n) (n)
  169. #define host_to_be64(n) (n)
  170. #ifndef WORDS_BIGENDIAN
  171. #define WORDS_BIGENDIAN
  172. #endif
  173. #else
  174. #error Could not determine CPU byte order
  175. #endif
  176. #define FOTA_BYTE_SWAP_DEFINED
  177. #endif /* !FOTA_BYTE_SWAP_DEFINED */
  178. /* Macros for handling unaligned memory accesses */
  179. static inline u16 FOTA_GET_BE16(const u8 *a)
  180. {
  181. return (a[0] << 8) | a[1];
  182. }
  183. static inline void FOTA_PUT_BE16(u8 *a, u16 val)
  184. {
  185. a[0] = val >> 8;
  186. a[1] = val & 0xff;
  187. }
  188. static inline u16 FOTA_GET_LE16(const u8 *a)
  189. {
  190. return (a[1] << 8) | a[0];
  191. }
  192. static inline void FOTA_PUT_LE16(u8 *a, u16 val)
  193. {
  194. a[1] = val >> 8;
  195. a[0] = val & 0xff;
  196. }
  197. static inline u32 FOTA_GET_BE24(const u8 *a)
  198. {
  199. return (a[0] << 16) | (a[1] << 8) | a[2];
  200. }
  201. static inline void FOTA_PUT_BE24(u8 *a, u32 val)
  202. {
  203. a[0] = (val >> 16) & 0xff;
  204. a[1] = (val >> 8) & 0xff;
  205. a[2] = val & 0xff;
  206. }
  207. static inline u32 FOTA_GET_BE32(const u8 *a)
  208. {
  209. return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  210. }
  211. static inline void FOTA_PUT_BE32(u8 *a, u32 val)
  212. {
  213. a[0] = (val >> 24) & 0xff;
  214. a[1] = (val >> 16) & 0xff;
  215. a[2] = (val >> 8) & 0xff;
  216. a[3] = val & 0xff;
  217. }
  218. static inline u32 FOTA_GET_LE32(const u8 *a)
  219. {
  220. return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
  221. }
  222. static inline void FOTA_PUT_LE32(u8 *a, u32 val)
  223. {
  224. a[3] = (val >> 24) & 0xff;
  225. a[2] = (val >> 16) & 0xff;
  226. a[1] = (val >> 8) & 0xff;
  227. a[0] = val & 0xff;
  228. }
  229. static inline u64 FOTA_GET_BE64(const u8 *a)
  230. {
  231. return (((u64) a[0]) << 56) | (((u64) a[1]) << 48) |
  232. (((u64) a[2]) << 40) | (((u64) a[3]) << 32) |
  233. (((u64) a[4]) << 24) | (((u64) a[5]) << 16) |
  234. (((u64) a[6]) << 8) | ((u64) a[7]);
  235. }
  236. static inline void FOTA_PUT_BE64(u8 *a, u64 val)
  237. {
  238. a[0] = val >> 56;
  239. a[1] = val >> 48;
  240. a[2] = val >> 40;
  241. a[3] = val >> 32;
  242. a[4] = val >> 24;
  243. a[5] = val >> 16;
  244. a[6] = val >> 8;
  245. a[7] = val & 0xff;
  246. }
  247. static inline u64 FOTA_GET_LE64(const u8 *a)
  248. {
  249. return (((u64) a[7]) << 56) | (((u64) a[6]) << 48) |
  250. (((u64) a[5]) << 40) | (((u64) a[4]) << 32) |
  251. (((u64) a[3]) << 24) | (((u64) a[2]) << 16) |
  252. (((u64) a[1]) << 8) | ((u64) a[0]);
  253. }
  254. static inline void FOTA_PUT_LE64(u8 *a, u64 val)
  255. {
  256. a[7] = val >> 56;
  257. a[6] = val >> 48;
  258. a[5] = val >> 40;
  259. a[4] = val >> 32;
  260. a[3] = val >> 24;
  261. a[2] = val >> 16;
  262. a[1] = val >> 8;
  263. a[0] = val & 0xff;
  264. }
  265. #ifndef ETH_ALEN
  266. #define ETH_ALEN 6
  267. #endif
  268. #ifndef ETH_HLEN
  269. #define ETH_HLEN 14
  270. #endif
  271. #ifndef IFNAMSIZ
  272. #define IFNAMSIZ 16
  273. #endif
  274. #ifndef ETH_P_ALL
  275. #define ETH_P_ALL 0x0003
  276. #endif
  277. #ifndef ETH_P_IP
  278. #define ETH_P_IP 0x0800
  279. #endif
  280. #ifndef ETH_P_80211_ENCAP
  281. #define ETH_P_80211_ENCAP 0x890d /* TDLS comes under this category */
  282. #endif
  283. #ifndef ETH_P_PAE
  284. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  285. #endif /* ETH_P_PAE */
  286. #ifndef ETH_P_EAPOL
  287. #define ETH_P_EAPOL ETH_P_PAE
  288. #endif /* ETH_P_EAPOL */
  289. #ifndef ETH_P_RSN_PREAUTH
  290. #define ETH_P_RSN_PREAUTH 0x88c7
  291. #endif /* ETH_P_RSN_PREAUTH */
  292. #ifndef ETH_P_RRB
  293. #define ETH_P_RRB 0x890D
  294. #endif /* ETH_P_RRB */
  295. #ifndef ETH_P_OUI
  296. #define ETH_P_OUI 0x88B7
  297. #endif /* ETH_P_OUI */
  298. #ifdef __GNUC__
  299. #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
  300. #define STRUCT_PACKED __attribute__ ((packed))
  301. #else
  302. #define PRINTF_FORMAT(a,b)
  303. #define STRUCT_PACKED
  304. #endif
  305. #ifdef CONFIG_ANSI_C_EXTRA
  306. #if !defined(_MSC_VER) || _MSC_VER < 1400
  307. /* snprintf - used in number of places; sprintf() is _not_ a good replacement
  308. * due to possible buffer overflow; see, e.g.,
  309. * http://www.ijs.si/software/snprintf/ for portable implementation of
  310. * snprintf. */
  311. int snprintf(char *str, size_t size, const char *format, ...);
  312. /* vsnprintf - only used for fota_msg() in fota_supplicant.c */
  313. int vsnprintf(char *str, size_t size, const char *format, va_list ap);
  314. #endif /* !defined(_MSC_VER) || _MSC_VER < 1400 */
  315. /* getopt - only used in main.c */
  316. int getopt(int argc, char *const argv[], const char *optstring);
  317. extern char *optarg;
  318. extern int optind;
  319. #ifndef CONFIG_NO_SOCKLEN_T_TYPEDEF
  320. #ifndef __socklen_t_defined
  321. typedef int socklen_t;
  322. #endif
  323. #endif
  324. /* inline - define as __inline or just define it to be empty, if needed */
  325. #ifdef CONFIG_NO_INLINE
  326. #define inline
  327. #else
  328. #define inline __inline
  329. #endif
  330. #ifndef __func__
  331. #define __func__ "__func__ not defined"
  332. #endif
  333. #ifndef bswap_16
  334. #define bswap_16(a) ((((u16) (a) << 8) & 0xff00) | (((u16) (a) >> 8) & 0xff))
  335. #endif
  336. #ifndef bswap_32
  337. #define bswap_32(a) ((((u32) (a) << 24) & 0xff000000) | \
  338. (((u32) (a) << 8) & 0xff0000) | \
  339. (((u32) (a) >> 8) & 0xff00) | \
  340. (((u32) (a) >> 24) & 0xff))
  341. #endif
  342. #ifndef MSG_DONTWAIT
  343. #define MSG_DONTWAIT 0
  344. #endif
  345. #ifdef _WIN32_WCE
  346. void perror(const char *s);
  347. #endif /* _WIN32_WCE */
  348. #endif /* CONFIG_ANSI_C_EXTRA */
  349. #ifndef MAC2STR
  350. #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  351. #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  352. /*
  353. * Compact form for string representation of MAC address
  354. * To be used, e.g., for constructing dbus paths for P2P Devices
  355. */
  356. #define COMPACT_MACSTR "%02x%02x%02x%02x%02x%02x"
  357. #endif
  358. #ifndef BIT
  359. #define BIT(x) (1U << (x))
  360. #endif
  361. /*
  362. * Definitions for sparse validation
  363. * (http://kernel.org/pub/linux/kernel/people/josh/sparse/)
  364. */
  365. #ifdef __CHECKER__
  366. #define __force __attribute__((force))
  367. #undef __bitwise
  368. #define __bitwise __attribute__((bitwise))
  369. #else
  370. #define __force
  371. #undef __bitwise
  372. #define __bitwise
  373. #endif
  374. typedef u16 __bitwise be16;
  375. typedef u16 __bitwise le16;
  376. typedef u32 __bitwise be32;
  377. typedef u32 __bitwise le32;
  378. typedef u64 __bitwise be64;
  379. typedef u64 __bitwise le64;
  380. #ifndef __must_check
  381. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
  382. #define __must_check __attribute__((__warn_unused_result__))
  383. #else
  384. #define __must_check
  385. #endif /* __GNUC__ */
  386. #endif /* __must_check */
  387. #ifndef __maybe_unused
  388. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
  389. #define __maybe_unused __attribute__((unused))
  390. #else
  391. #define __maybe_unused
  392. #endif /* __GNUC__ */
  393. #endif /* __must_check */
  394. #define SSID_MAX_LEN 32
  395. struct fota_ssid_value {
  396. u8 ssid[SSID_MAX_LEN];
  397. size_t ssid_len;
  398. };
  399. int hwaddr_aton(const char *txt, u8 *addr);
  400. int hwaddr_masked_aton(const char *txt, u8 *addr, u8 *mask, u8 maskable);
  401. int hwaddr_compact_aton(const char *txt, u8 *addr);
  402. int hwaddr_aton2(const char *txt, u8 *addr);
  403. int hex2byte(const char *hex);
  404. int hexstr2bin(const char *hex, u8 *buf, size_t len);
  405. void inc_byte_array(u8 *counter, size_t len);
  406. void buf_shift_right(u8 *buf, size_t len, size_t bits);
  407. void fota_get_ntp_timestamp(u8 *buf);
  408. int fota_scnprintf(char *buf, size_t size, const char *fmt, ...);
  409. int fota_snprintf_hex_sep(char *buf, size_t buf_size, const u8 *data, size_t len,
  410. char sep);
  411. int fota_snprintf_hex(char *buf, size_t buf_size, const u8 *data, size_t len);
  412. int fota_snprintf_hex_uppercase(char *buf, size_t buf_size, const u8 *data,
  413. size_t len);
  414. int hwaddr_mask_txt(char *buf, size_t len, const u8 *addr, const u8 *mask);
  415. int ssid_parse(const char *buf, struct fota_ssid_value *ssid);
  416. #ifdef CONFIG_NATIVE_WINDOWS
  417. void fota_unicode2ascii_inplace(TCHAR *str);
  418. TCHAR *fota_strdup_tchar(const char *str);
  419. #else /* CONFIG_NATIVE_WINDOWS */
  420. #define fota_unicode2ascii_inplace(s) do { } while (0)
  421. #define fota_strdup_tchar(s) strdup((s))
  422. #endif /* CONFIG_NATIVE_WINDOWS */
  423. void printf_encode(char *txt, size_t maxlen, const u8 *data, size_t len);
  424. size_t printf_decode(u8 *buf, size_t maxlen, const char *str);
  425. const char *fota_ssid_txt(const u8 *ssid, size_t ssid_len);
  426. char *fota_config_parse_string(const char *value, size_t *len);
  427. int is_hex(const u8 *data, size_t len);
  428. int has_ctrl_char(const u8 *data, size_t len);
  429. int has_newline(const char *str);
  430. size_t merge_byte_arrays(u8 *res, size_t res_len,
  431. const u8 *src1, size_t src1_len,
  432. const u8 *src2, size_t src2_len);
  433. char *dup_binstr(const void *src, size_t len);
  434. static inline int is_zero_ether_addr(const u8 *a)
  435. {
  436. return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
  437. }
  438. static inline int is_broadcast_ether_addr(const u8 *a)
  439. {
  440. return (a[0] & a[1] & a[2] & a[3] & a[4] & a[5]) == 0xff;
  441. }
  442. static inline int is_multicast_ether_addr(const u8 *a)
  443. {
  444. return a[0] & 0x01;
  445. }
  446. #define broadcast_ether_addr (const u8 *) "\xff\xff\xff\xff\xff\xff"
  447. #include "fota_debug.h"
  448. struct fota_freq_range_list {
  449. struct fota_freq_range {
  450. unsigned int min;
  451. unsigned int max;
  452. } *range;
  453. unsigned int num;
  454. };
  455. int freq_range_list_parse(struct fota_freq_range_list *res, const char *value);
  456. int freq_range_list_includes(const struct fota_freq_range_list *list,
  457. unsigned int freq);
  458. char *freq_range_list_str(const struct fota_freq_range_list *list);
  459. int int_array_len(const int *a);
  460. void int_array_concat(int **res, const int *a);
  461. void int_array_sort_unique(int *a);
  462. void int_array_add_unique(int **res, int a);
  463. #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
  464. void str_clear_free(char *str);
  465. void bin_clear_free(void *bin, size_t len);
  466. int random_mac_addr(u8 *addr);
  467. int random_mac_addr_keep_oui(u8 *addr);
  468. const char *cstr_token(const char *str, const char *delim, const char **last);
  469. char *str_token(char *str, const char *delim, char **context);
  470. size_t utf8_escape(const char *inp, size_t in_size,
  471. char *outp, size_t out_size);
  472. size_t utf8_unescape(const char *inp, size_t in_size,
  473. char *outp, size_t out_size);
  474. int is_ctrl_char(char c);
  475. int str_starts(const char *str, const char *start);
  476. u8 rssi_to_rcpi(int rssi);
  477. char *get_param(const char *cmd, const char *param);
  478. void forced_memzero(void *ptr, size_t len);
  479. /*
  480. * gcc 4.4 ends up generating strict-aliasing warnings about some very common
  481. * networking socket uses that do not really result in a real problem and
  482. * cannot be easily avoided with union-based type-punning due to struct
  483. * definitions including another struct in system header files. To avoid having
  484. * to fully disable strict-aliasing warnings, provide a mechanism to hide the
  485. * typecast from aliasing for now. A cleaner solution will hopefully be found
  486. * in the future to handle these cases.
  487. */
  488. void *__hide_aliasing_typecast(void *foo);
  489. #define aliasing_hide_typecast(a,t) (t *) __hide_aliasing_typecast((a))
  490. #ifdef CONFIG_VALGRIND
  491. #include <valgrind/memcheck.h>
  492. #define FOTA_MEM_DEFINED(ptr, len) VALGRIND_MAKE_MEM_DEFINED((ptr), (len))
  493. #else /* CONFIG_VALGRIND */
  494. #define FOTA_MEM_DEFINED(ptr, len) do { } while (0)
  495. #endif /* CONFIG_VALGRIND */
  496. #endif /* COMMON_H */