mirror of
				https://github.com/0xFEEDC0DE64/arduino-esp32.git
				synced 2025-11-04 16:11:38 +01:00 
			
		
		
		
	v2.0.0 Add support for ESP32S2 and update ESP-IDF to 4.4 (#4996)
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
This commit is contained in:
		@@ -0,0 +1,73 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2010 Espressif System
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef BYTESWAP_H
 | 
			
		||||
#define BYTESWAP_H
 | 
			
		||||
 | 
			
		||||
#include <machine/endian.h>
 | 
			
		||||
 | 
			
		||||
/* Swap bytes in 16 bit value.  */
 | 
			
		||||
#ifndef __bswap_16
 | 
			
		||||
#ifdef __GNUC__
 | 
			
		||||
# define __bswap_16(x) \
 | 
			
		||||
    (__extension__							      \
 | 
			
		||||
     ({ unsigned short int __bsx = (x);					      \
 | 
			
		||||
        ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }))
 | 
			
		||||
#else
 | 
			
		||||
static INLINE unsigned short int
 | 
			
		||||
__bswap_16 (unsigned short int __bsx)
 | 
			
		||||
{
 | 
			
		||||
  return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif // __bswap_16
 | 
			
		||||
 | 
			
		||||
/* Swap bytes in 32 bit value.  */
 | 
			
		||||
#ifndef __bswap_32
 | 
			
		||||
#ifdef __GNUC__
 | 
			
		||||
# define __bswap_32(x) \
 | 
			
		||||
    (__extension__							      \
 | 
			
		||||
     ({ unsigned int __bsx = (x);					      \
 | 
			
		||||
        ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |    \
 | 
			
		||||
	 (((__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24)); }))
 | 
			
		||||
#else
 | 
			
		||||
static INLINE unsigned int
 | 
			
		||||
__bswap_32 (unsigned int __bsx)
 | 
			
		||||
{
 | 
			
		||||
  return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |
 | 
			
		||||
	  (((__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24));
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif // __bswap_32
 | 
			
		||||
 | 
			
		||||
#ifndef __bswap_64
 | 
			
		||||
#if defined __GNUC__ && __GNUC__ >= 2
 | 
			
		||||
/* Swap bytes in 64 bit value.  */
 | 
			
		||||
# define __bswap_constant_64(x) \
 | 
			
		||||
     ((((x) & 0xff00000000000000ull) >> 56)				      \
 | 
			
		||||
      | (((x) & 0x00ff000000000000ull) >> 40)				      \
 | 
			
		||||
      | (((x) & 0x0000ff0000000000ull) >> 24)				      \
 | 
			
		||||
      | (((x) & 0x000000ff00000000ull) >> 8)				      \
 | 
			
		||||
      | (((x) & 0x00000000ff000000ull) << 8)				      \
 | 
			
		||||
      | (((x) & 0x0000000000ff0000ull) << 24)				      \
 | 
			
		||||
      | (((x) & 0x000000000000ff00ull) << 40)				      \
 | 
			
		||||
      | (((x) & 0x00000000000000ffull) << 56))
 | 
			
		||||
 | 
			
		||||
# define __bswap_64(x) \
 | 
			
		||||
     (__extension__							      \
 | 
			
		||||
      ({ union { __extension__ unsigned long long int __ll;		      \
 | 
			
		||||
		 unsigned int __l[2]; } __w, __r;			      \
 | 
			
		||||
         if (__builtin_constant_p (x))					      \
 | 
			
		||||
	   __r.__ll = __bswap_constant_64 (x);				      \
 | 
			
		||||
	 else								      \
 | 
			
		||||
	   {								      \
 | 
			
		||||
	     __w.__ll = (x);						      \
 | 
			
		||||
	     __r.__l[0] = __bswap_32 (__w.__l[1]);			      \
 | 
			
		||||
	     __r.__l[1] = __bswap_32 (__w.__l[0]);			      \
 | 
			
		||||
	   }								      \
 | 
			
		||||
	 __r.__ll; }))
 | 
			
		||||
#endif
 | 
			
		||||
#endif // __bswap_64
 | 
			
		||||
 | 
			
		||||
#endif /* BYTESWAP_H */
 | 
			
		||||
							
								
								
									
										226
									
								
								tools/sdk/esp32s2/include/wpa_supplicant/port/include/endian.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								tools/sdk/esp32s2/include/wpa_supplicant/port/include/endian.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,226 @@
 | 
			
		||||
/*-
 | 
			
		||||
 * Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in the
 | 
			
		||||
 *    documentation and/or other materials provided with the distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 | 
			
		||||
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 | 
			
		||||
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 | 
			
		||||
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
			
		||||
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 | 
			
		||||
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 | 
			
		||||
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 *
 | 
			
		||||
 * $FreeBSD$
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ENDIAN_H_
 | 
			
		||||
#define _ENDIAN_H_
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include "byteswap.h"
 | 
			
		||||
 | 
			
		||||
#ifndef BIG_ENDIAN
 | 
			
		||||
#define BIG_ENDIAN 4321
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef LITTLE_ENDIAN
 | 
			
		||||
#define LITTLE_ENDIAN 1234
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef BYTE_ORDER
 | 
			
		||||
#ifdef __IEEE_LITTLE_ENDIAN
 | 
			
		||||
#define BYTE_ORDER LITTLE_ENDIAN
 | 
			
		||||
#else
 | 
			
		||||
#define BYTE_ORDER BIG_ENDIAN
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define _UINT8_T_DECLARED
 | 
			
		||||
#ifndef _UINT8_T_DECLARED
 | 
			
		||||
typedef	__uint8_t	uint8_t;
 | 
			
		||||
#define	_UINT8_T_DECLARED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define _UINT16_T_DECLARED
 | 
			
		||||
#ifndef _UINT16_T_DECLARED
 | 
			
		||||
typedef	__uint16_t	uint16_t;
 | 
			
		||||
#define	_UINT16_T_DECLARED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define _UINT32_T_DECLARED
 | 
			
		||||
#ifndef _UINT32_T_DECLARED
 | 
			
		||||
typedef	__uint32_t	uint32_t;
 | 
			
		||||
#define	_UINT32_T_DECLARED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define _UINT64_T_DECLARED
 | 
			
		||||
#ifndef _UINT64_T_DECLARED
 | 
			
		||||
typedef	__uint64_t	uint64_t;
 | 
			
		||||
#define	_UINT64_T_DECLARED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * General byte order swapping functions.
 | 
			
		||||
 */
 | 
			
		||||
#define	bswap16(x)	__bswap16(x)
 | 
			
		||||
#define	bswap32(x)	__bswap32(x)
 | 
			
		||||
#define	bswap64(x)	__bswap64(x)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Host to big endian, host to little endian, big endian to host, and little
 | 
			
		||||
 * endian to host byte order functions as detailed in byteorder(9).
 | 
			
		||||
 */
 | 
			
		||||
#if BYTE_ORDER == _LITTLE_ENDIAN
 | 
			
		||||
#define	htobe16(x)	bswap16((x))
 | 
			
		||||
#define	htobe32(x)	bswap32((x))
 | 
			
		||||
#define	htobe64(x)	bswap64((x))
 | 
			
		||||
#define	htole16(x)	((uint16_t)(x))
 | 
			
		||||
#define	htole32(x)	((uint32_t)(x))
 | 
			
		||||
#define	htole64(x)	((uint64_t)(x))
 | 
			
		||||
 | 
			
		||||
#define	be16toh(x)	bswap16((x))
 | 
			
		||||
#define	be32toh(x)	bswap32((x))
 | 
			
		||||
#define	be64toh(x)	bswap64((x))
 | 
			
		||||
#define	le16toh(x)	((uint16_t)(x))
 | 
			
		||||
#define	le32toh(x)	((uint32_t)(x))
 | 
			
		||||
#define	le64toh(x)	((uint64_t)(x))
 | 
			
		||||
 | 
			
		||||
#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
 | 
			
		||||
#define	htobe16(x)	((uint16_t)(x))
 | 
			
		||||
#define	htobe32(x)	((uint32_t)(x))
 | 
			
		||||
#define	htobe64(x)	((uint64_t)(x))
 | 
			
		||||
#define	htole16(x)	bswap16((x))
 | 
			
		||||
#define	htole32(x)	bswap32((x))
 | 
			
		||||
#define	htole64(x)	bswap64((x))
 | 
			
		||||
 | 
			
		||||
#define	be16toh(x)	((uint16_t)(x))
 | 
			
		||||
#define	be32toh(x)	((uint32_t)(x))
 | 
			
		||||
#define	be64toh(x)	((uint64_t)(x))
 | 
			
		||||
#define	le16toh(x)	bswap16((x))
 | 
			
		||||
#define	le32toh(x)	bswap32((x))
 | 
			
		||||
#define	le64toh(x)	bswap64((x))
 | 
			
		||||
#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
 | 
			
		||||
 | 
			
		||||
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
 | 
			
		||||
#define INLINE                  __inline__
 | 
			
		||||
 | 
			
		||||
static INLINE uint16_t
 | 
			
		||||
be16dec(const void *pp)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t const *p = (uint8_t const *)pp;
 | 
			
		||||
 | 
			
		||||
	return ((p[0] << 8) | p[1]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE uint32_t
 | 
			
		||||
be32dec(const void *pp)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t const *p = (uint8_t const *)pp;
 | 
			
		||||
 | 
			
		||||
	return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE uint64_t
 | 
			
		||||
be64dec(const void *pp)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t const *p = (uint8_t const *)pp;
 | 
			
		||||
 | 
			
		||||
	return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE uint16_t
 | 
			
		||||
le16dec(const void *pp)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t const *p = (uint8_t const *)pp;
 | 
			
		||||
 | 
			
		||||
	return ((p[1] << 8) | p[0]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE uint32_t
 | 
			
		||||
le32dec(const void *pp)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t const *p = (uint8_t const *)pp;
 | 
			
		||||
 | 
			
		||||
	return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE uint64_t
 | 
			
		||||
le64dec(const void *pp)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t const *p = (uint8_t const *)pp;
 | 
			
		||||
 | 
			
		||||
	return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE void
 | 
			
		||||
be16enc(void *pp, uint16_t u)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *p = (uint8_t *)pp;
 | 
			
		||||
 | 
			
		||||
	p[0] = (u >> 8) & 0xff;
 | 
			
		||||
	p[1] = u & 0xff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE void
 | 
			
		||||
be32enc(void *pp, uint32_t u)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *p = (uint8_t *)pp;
 | 
			
		||||
 | 
			
		||||
	p[0] = (u >> 24) & 0xff;
 | 
			
		||||
	p[1] = (u >> 16) & 0xff;
 | 
			
		||||
	p[2] = (u >> 8) & 0xff;
 | 
			
		||||
	p[3] = u & 0xff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE void
 | 
			
		||||
be64enc(void *pp, uint64_t u)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *p = (uint8_t *)pp;
 | 
			
		||||
 | 
			
		||||
	be32enc(p, (uint32_t)(u >> 32));
 | 
			
		||||
	be32enc(p + 4, (uint32_t)(u & 0xffffffffU));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE void
 | 
			
		||||
le16enc(void *pp, uint16_t u)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *p = (uint8_t *)pp;
 | 
			
		||||
 | 
			
		||||
	p[0] = u & 0xff;
 | 
			
		||||
	p[1] = (u >> 8) & 0xff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE void
 | 
			
		||||
le32enc(void *pp, uint32_t u)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *p = (uint8_t *)pp;
 | 
			
		||||
 | 
			
		||||
	p[0] = u & 0xff;
 | 
			
		||||
	p[1] = (u >> 8) & 0xff;
 | 
			
		||||
	p[2] = (u >> 16) & 0xff;
 | 
			
		||||
	p[3] = (u >> 24) & 0xff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static INLINE void
 | 
			
		||||
le64enc(void *pp, uint64_t u)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *p = (uint8_t *)pp;
 | 
			
		||||
 | 
			
		||||
	le32enc(p, (uint32_t)(u & 0xffffffffU));
 | 
			
		||||
	le32enc(p + 4, (uint32_t)(u >> 32));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif	/* _ENDIAN_H_ */
 | 
			
		||||
							
								
								
									
										311
									
								
								tools/sdk/esp32s2/include/wpa_supplicant/port/include/os.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										311
									
								
								tools/sdk/esp32s2/include/wpa_supplicant/port/include/os.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,311 @@
 | 
			
		||||
/*
 | 
			
		||||
 * OS specific functions
 | 
			
		||||
 * Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License version 2 as
 | 
			
		||||
 * published by the Free Software Foundation.
 | 
			
		||||
 *
 | 
			
		||||
 * Alternatively, this software may be distributed under the terms of BSD
 | 
			
		||||
 * license.
 | 
			
		||||
 *
 | 
			
		||||
 * See README and COPYING for more details.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef OS_H
 | 
			
		||||
#define OS_H
 | 
			
		||||
#include "esp_types.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include "esp_err.h"
 | 
			
		||||
 | 
			
		||||
typedef time_t os_time_t;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_sleep - Sleep (sec, usec)
 | 
			
		||||
 * @sec: Number of seconds to sleep
 | 
			
		||||
 * @usec: Number of microseconds to sleep
 | 
			
		||||
 */
 | 
			
		||||
void os_sleep(os_time_t sec, os_time_t usec);
 | 
			
		||||
 | 
			
		||||
struct os_time {
 | 
			
		||||
	os_time_t sec;
 | 
			
		||||
	suseconds_t usec;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define os_reltime os_time
 | 
			
		||||
 | 
			
		||||
struct os_tm {
 | 
			
		||||
    int sec; /* 0..59 or 60 for leap seconds */
 | 
			
		||||
    int min; /* 0..59 */
 | 
			
		||||
    int hour; /* 0..23 */
 | 
			
		||||
    int day; /* 1..31 */
 | 
			
		||||
    int month; /* 1..12 */
 | 
			
		||||
    int year; /* Four digit year */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_get_time - Get current time (sec, usec)
 | 
			
		||||
 * @t: Pointer to buffer for the time
 | 
			
		||||
 * Returns: 0 on success, -1 on failure
 | 
			
		||||
 */
 | 
			
		||||
int os_get_time(struct os_time *t);
 | 
			
		||||
#define os_get_reltime os_get_time
 | 
			
		||||
 | 
			
		||||
/* Helper macros for handling struct os_time */
 | 
			
		||||
 | 
			
		||||
#define os_time_before(a, b) \
 | 
			
		||||
	((a)->sec < (b)->sec || \
 | 
			
		||||
	 ((a)->sec == (b)->sec && (a)->usec < (b)->usec))
 | 
			
		||||
 | 
			
		||||
#define os_reltime_before os_time_before
 | 
			
		||||
#define os_time_sub(a, b, res) do { \
 | 
			
		||||
	(res)->sec = (a)->sec - (b)->sec; \
 | 
			
		||||
	(res)->usec = (a)->usec - (b)->usec; \
 | 
			
		||||
	if ((res)->usec < 0) { \
 | 
			
		||||
		(res)->sec--; \
 | 
			
		||||
		(res)->usec += 1000000; \
 | 
			
		||||
	} \
 | 
			
		||||
} while (0)
 | 
			
		||||
#define os_reltime_sub os_time_sub
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_mktime - Convert broken-down time into seconds since 1970-01-01
 | 
			
		||||
 * @year: Four digit year
 | 
			
		||||
 * @month: Month (1 .. 12)
 | 
			
		||||
 * @day: Day of month (1 .. 31)
 | 
			
		||||
 * @hour: Hour (0 .. 23)
 | 
			
		||||
 * @min: Minute (0 .. 59)
 | 
			
		||||
 * @sec: Second (0 .. 60)
 | 
			
		||||
 * @t: Buffer for returning calendar time representation (seconds since
 | 
			
		||||
 * 1970-01-01 00:00:00)
 | 
			
		||||
 * Returns: 0 on success, -1 on failure
 | 
			
		||||
 *
 | 
			
		||||
 * Note: The result is in seconds from Epoch, i.e., in UTC, not in local time
 | 
			
		||||
 * which is used by POSIX mktime().
 | 
			
		||||
 */
 | 
			
		||||
int os_mktime(int year, int month, int day, int hour, int min, int sec,
 | 
			
		||||
	      os_time_t *t);
 | 
			
		||||
 | 
			
		||||
int os_gmtime(os_time_t t, struct os_tm *tm);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_daemonize - Run in the background (detach from the controlling terminal)
 | 
			
		||||
 * @pid_file: File name to write the process ID to or %NULL to skip this
 | 
			
		||||
 * Returns: 0 on success, -1 on failure
 | 
			
		||||
 */
 | 
			
		||||
int os_daemonize(const char *pid_file);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_daemonize_terminate - Stop running in the background (remove pid file)
 | 
			
		||||
 * @pid_file: File name to write the process ID to or %NULL to skip this
 | 
			
		||||
 */
 | 
			
		||||
void os_daemonize_terminate(const char *pid_file);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_get_random - Get cryptographically strong pseudo random data
 | 
			
		||||
 * @buf: Buffer for pseudo random data
 | 
			
		||||
 * @len: Length of the buffer
 | 
			
		||||
 * Returns: 0 on success, -1 on failure
 | 
			
		||||
 */
 | 
			
		||||
int os_get_random(unsigned char *buf, size_t len);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_random - Get pseudo random value (not necessarily very strong)
 | 
			
		||||
 * Returns: Pseudo random value
 | 
			
		||||
 */
 | 
			
		||||
unsigned long os_random(void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_rel2abs_path - Get an absolute path for a file
 | 
			
		||||
 * @rel_path: Relative path to a file
 | 
			
		||||
 * Returns: Absolute path for the file or %NULL on failure
 | 
			
		||||
 *
 | 
			
		||||
 * This function tries to convert a relative path of a file to an absolute path
 | 
			
		||||
 * in order for the file to be found even if current working directory has
 | 
			
		||||
 * changed. The returned value is allocated and caller is responsible for
 | 
			
		||||
 * freeing it. It is acceptable to just return the same path in an allocated
 | 
			
		||||
 * buffer, e.g., return strdup(rel_path). This function is only used to find
 | 
			
		||||
 * configuration files when os_daemonize() may have changed the current working
 | 
			
		||||
 * directory and relative path would be pointing to a different location.
 | 
			
		||||
 */
 | 
			
		||||
char * os_rel2abs_path(const char *rel_path);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_program_init - Program initialization (called at start)
 | 
			
		||||
 * Returns: 0 on success, -1 on failure
 | 
			
		||||
 *
 | 
			
		||||
 * This function is called when a programs starts. If there are any OS specific
 | 
			
		||||
 * processing that is needed, it can be placed here. It is also acceptable to
 | 
			
		||||
 * just return 0 if not special processing is needed.
 | 
			
		||||
 */
 | 
			
		||||
int os_program_init(void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_program_deinit - Program deinitialization (called just before exit)
 | 
			
		||||
 *
 | 
			
		||||
 * This function is called just before a program exists. If there are any OS
 | 
			
		||||
 * specific processing, e.g., freeing resourced allocated in os_program_init(),
 | 
			
		||||
 * it should be done here. It is also acceptable for this function to do
 | 
			
		||||
 * nothing.
 | 
			
		||||
 */
 | 
			
		||||
void os_program_deinit(void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_setenv - Set environment variable
 | 
			
		||||
 * @name: Name of the variable
 | 
			
		||||
 * @value: Value to set to the variable
 | 
			
		||||
 * @overwrite: Whether existing variable should be overwritten
 | 
			
		||||
 * Returns: 0 on success, -1 on error
 | 
			
		||||
 *
 | 
			
		||||
 * This function is only used for wpa_cli action scripts. OS wrapper does not
 | 
			
		||||
 * need to implement this if such functionality is not needed.
 | 
			
		||||
 */
 | 
			
		||||
int os_setenv(const char *name, const char *value, int overwrite);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_unsetenv - Delete environent variable
 | 
			
		||||
 * @name: Name of the variable
 | 
			
		||||
 * Returns: 0 on success, -1 on error
 | 
			
		||||
 *
 | 
			
		||||
 * This function is only used for wpa_cli action scripts. OS wrapper does not
 | 
			
		||||
 * need to implement this if such functionality is not needed.
 | 
			
		||||
 */
 | 
			
		||||
int os_unsetenv(const char *name);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * os_readfile - Read a file to an allocated memory buffer
 | 
			
		||||
 * @name: Name of the file to read
 | 
			
		||||
 * @len: For returning the length of the allocated buffer
 | 
			
		||||
 * Returns: Pointer to the allocated buffer or %NULL on failure
 | 
			
		||||
 *
 | 
			
		||||
 * This function allocates memory and reads the given file to this buffer. Both
 | 
			
		||||
 * binary and text files can be read with this function. The caller is
 | 
			
		||||
 * responsible for freeing the returned buffer with os_free().
 | 
			
		||||
 */
 | 
			
		||||
char * os_readfile(const char *name, size_t *len);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The following functions are wrapper for standard ANSI C or POSIX functions.
 | 
			
		||||
 * By default, they are just defined to use the standard function name and no
 | 
			
		||||
 * os_*.c implementation is needed for them. This avoids extra function calls
 | 
			
		||||
 * by allowing the C pre-processor take care of the function name mapping.
 | 
			
		||||
 *
 | 
			
		||||
 * If the target system uses a C library that does not provide these functions,
 | 
			
		||||
 * build_config.h can be used to define the wrappers to use a different
 | 
			
		||||
 * function name. This can be done on function-by-function basis since the
 | 
			
		||||
 * defines here are only used if build_config.h does not define the os_* name.
 | 
			
		||||
 * If needed, os_*.c file can be used to implement the functions that are not
 | 
			
		||||
 * included in the C library on the target system. Alternatively,
 | 
			
		||||
 * OS_NO_C_LIB_DEFINES can be defined to skip all defines here in which case
 | 
			
		||||
 * these functions need to be implemented in os_*.c file for the target system.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef os_malloc
 | 
			
		||||
#define os_malloc(s) malloc((s))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_realloc
 | 
			
		||||
#define os_realloc(p, s) realloc((p), (s))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_zalloc
 | 
			
		||||
#define os_zalloc(s) calloc(1, (s))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_calloc
 | 
			
		||||
#define os_calloc(p, s) calloc((p), (s))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef os_free
 | 
			
		||||
#define os_free(p) free((p))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef os_bzero
 | 
			
		||||
#define os_bzero(s, n) bzero(s, n)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef os_strdup
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#define os_strdup(s) _strdup(s)
 | 
			
		||||
#else
 | 
			
		||||
#define os_strdup(s) strdup(s)
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
char * ets_strdup(const char *s);
 | 
			
		||||
 | 
			
		||||
#ifndef os_memcpy
 | 
			
		||||
#define os_memcpy(d, s, n) memcpy((d), (s), (n))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_memmove
 | 
			
		||||
#define os_memmove(d, s, n) memmove((d), (s), (n))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_memset
 | 
			
		||||
#define os_memset(s, c, n) memset(s, c, n)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_memcmp
 | 
			
		||||
#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_memcmp_const
 | 
			
		||||
#define os_memcmp_const(s1, s2, n) memcmp((s1), (s2), (n))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef os_strlen
 | 
			
		||||
#define os_strlen(s) strlen(s)
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strcasecmp
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#define os_strcasecmp(s1, s2) _stricmp((s1), (s2))
 | 
			
		||||
#else
 | 
			
		||||
#define os_strcasecmp(s1, s2) strcasecmp((s1), (s2))
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strncasecmp
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#define os_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
 | 
			
		||||
#else
 | 
			
		||||
#define os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n))
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strchr
 | 
			
		||||
#define os_strchr(s, c) strchr((s), (c))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strcmp
 | 
			
		||||
#define os_strcmp(s1, s2) strcmp((s1), (s2))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strncmp
 | 
			
		||||
#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strncpy
 | 
			
		||||
#define os_strncpy(d, s, n) strncpy((d), (s), (n))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strrchr
 | 
			
		||||
#define os_strrchr(s, c)  strrchr((s), (c))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strstr
 | 
			
		||||
#define os_strstr(h, n) strstr((h), (n))
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef os_strlcpy
 | 
			
		||||
#define os_strlcpy(d, s, n) strlcpy((d), (s), (n))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef os_snprintf
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#define os_snprintf _snprintf
 | 
			
		||||
#else
 | 
			
		||||
#define os_snprintf snprintf
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static inline int os_snprintf_error(size_t size, int res)
 | 
			
		||||
{
 | 
			
		||||
        return res < 0 || (unsigned int) res >= size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
 | 
			
		||||
{
 | 
			
		||||
	if (size && nmemb > (~(size_t) 0) / size)
 | 
			
		||||
		return NULL;
 | 
			
		||||
	return os_realloc(ptr, nmemb * size);
 | 
			
		||||
}
 | 
			
		||||
#endif /* OS_H */
 | 
			
		||||
@@ -0,0 +1,39 @@
 | 
			
		||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
 | 
			
		||||
//
 | 
			
		||||
// 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 _SUPPLICANT_OPT_H
 | 
			
		||||
#define _SUPPLICANT_OPT_H
 | 
			
		||||
 | 
			
		||||
#include "sdkconfig.h"
 | 
			
		||||
 | 
			
		||||
#if CONFIG_WPA_MBEDTLS_CRYPTO
 | 
			
		||||
#define USE_MBEDTLS_CRYPTO 1
 | 
			
		||||
#else
 | 
			
		||||
#define CONFIG_TLS_INTERNAL_CLIENT
 | 
			
		||||
#define CONFIG_TLSV12
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if CONFIG_WPA_DEBUG_PRINT
 | 
			
		||||
#define DEBUG_PRINT
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if CONFIG_WPA_11KV_SUPPORT
 | 
			
		||||
#define ROAMING_SUPPORT 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if CONFIG_WPA_SCAN_CACHE
 | 
			
		||||
#define SCAN_CACHE_SUPPORTED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* _SUPPLICANT_OPT_H */
 | 
			
		||||
		Reference in New Issue
	
	Block a user