99 lines
3.9 KiB
C
99 lines
3.9 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only */
|
|
#pragma once
|
|
#include <assert.h>
|
|
#include <arpa/inet.h>
|
|
#include <errno.h>
|
|
#include <netdb.h>
|
|
#include <net/if.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/time.h>
|
|
#include <unistd.h>
|
|
|
|
#define CONFIG_LWIP_IPV6 1
|
|
#define CONFIG_LWIP_DNS_MAX_HOST_IP 1
|
|
#define ESP_IDF_VERSION_VAL(a,b,c) (((a)<<16)|((b)<<8)|(c))
|
|
#define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(5,5,0)
|
|
typedef int esp_err_t;
|
|
#define ESP_OK 0
|
|
#define MALLOC_CAP_SPIRAM 1
|
|
#define MALLOC_CAP_8BIT 2
|
|
#define pdTRUE 1
|
|
#define portMAX_DELAY UINT32_MAX
|
|
#define pdMS_TO_TICKS(x) (x)
|
|
typedef uint32_t TickType_t;
|
|
typedef uint16_t u16_t;
|
|
typedef struct { int unused; } StaticQueue_t;
|
|
typedef void *QueueHandle_t;
|
|
typedef struct { struct in6_addr addr; uint8_t zone; } ip6_addr_t;
|
|
typedef struct in_addr ip4_addr_t;
|
|
typedef struct { int family; union { ip4_addr_t v4; ip6_addr_t v6; }; } ip_addr_t;
|
|
#define inet_addr_to_ip4addr(d,s) (*(d)=*(s))
|
|
#define inet6_addr_to_ip6addr(d,s) ((d)->addr=*(s))
|
|
#define ip6_addr_set_zone(d,z) ((d)->zone=(z))
|
|
#define ip_addr_copy_from_ip4(d,s) ((d).family=AF_INET,(d).v4=(s))
|
|
#define ip_addr_copy_from_ip6(d,s) ((d).family=AF_INET6,(d).v6=(s))
|
|
#define IP_IS_V4(d) ((d)->family==AF_INET)
|
|
#define lwip_htons htons
|
|
#define ICMP_ECHO 8
|
|
#define ICMP_ER 0
|
|
#define ICMP_TE 11
|
|
#define ICMP_DUR 3
|
|
struct icmp_echo_hdr { uint8_t type, code; uint16_t chksum, id, seqno; };
|
|
typedef void *esp_ping_handle_t;
|
|
typedef struct { uint32_t count, interface, interval_ms, timeout_ms; ip_addr_t target_addr; } esp_ping_config_t;
|
|
#define ESP_PING_DEFAULT_CONFIG() ((esp_ping_config_t){0})
|
|
typedef struct {
|
|
void *cb_args;
|
|
void (*on_ping_success)(esp_ping_handle_t,void *);
|
|
void (*on_ping_timeout)(esp_ping_handle_t,void *);
|
|
void (*on_ping_end)(esp_ping_handle_t,void *);
|
|
} esp_ping_callbacks_t;
|
|
enum { ESP_PING_PROF_SEQNO, ESP_PING_PROF_SIZE, ESP_PING_PROF_TIMEGAP,
|
|
ESP_PING_PROF_IPADDR, ESP_PING_PROF_TTL, ESP_PING_PROF_REQUEST,
|
|
ESP_PING_PROF_REPLY, ESP_PING_PROF_DURATION };
|
|
typedef struct { const char *command, *help, *hint; int (*func)(int,char **); void *argtable; } esp_console_cmd_t;
|
|
typedef int esp_netif_t;
|
|
|
|
int fake_getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
|
|
void fake_freeaddrinfo(struct addrinfo *);
|
|
int fake_socket(int,int,int);
|
|
int fake_setsockopt(int,int,int,const void *,socklen_t);
|
|
ssize_t fake_sendto(int,const void *,size_t,int,const struct sockaddr *,socklen_t);
|
|
ssize_t fake_recvfrom(int,void *,size_t,int,struct sockaddr *,socklen_t *);
|
|
int fake_close(int);
|
|
unsigned int fake_if_nametoindex(const char *);
|
|
char *fake_if_indextoname(unsigned int,char *);
|
|
#define getaddrinfo fake_getaddrinfo
|
|
#define freeaddrinfo fake_freeaddrinfo
|
|
#define socket fake_socket
|
|
#define setsockopt fake_setsockopt
|
|
#define sendto fake_sendto
|
|
#define recvfrom fake_recvfrom
|
|
#define close fake_close
|
|
#define if_nametoindex fake_if_nametoindex
|
|
#define if_indextoname fake_if_indextoname
|
|
|
|
size_t strlcpy(char *,const char *,size_t);
|
|
const char *esp_err_to_name(esp_err_t);
|
|
void *heap_caps_malloc(size_t,int);
|
|
QueueHandle_t xQueueCreateStatic(unsigned int,unsigned int,uint8_t *,StaticQueue_t *);
|
|
int xQueueReset(QueueHandle_t);
|
|
int xQueueSend(QueueHandle_t,const void *,unsigned int);
|
|
int xQueueReceive(QueueHandle_t,void *,unsigned int);
|
|
const char *ipaddr_ntoa_r(const ip_addr_t *,char *,int);
|
|
esp_err_t esp_ping_get_profile(esp_ping_handle_t,int,void *,size_t);
|
|
esp_err_t esp_ping_new_session(const esp_ping_config_t *,const esp_ping_callbacks_t *,esp_ping_handle_t *);
|
|
esp_err_t esp_ping_start(esp_ping_handle_t);
|
|
esp_err_t esp_ping_delete_session(esp_ping_handle_t);
|
|
esp_err_t esp_ping_stop(esp_ping_handle_t);
|
|
int64_t esp_timer_get_time(void);
|
|
uint16_t inet_chksum(const void *,u16_t);
|
|
esp_netif_t *esp_netif_get_handle_from_ifkey(const char *);
|
|
int esp_netif_get_netif_impl_index(esp_netif_t *);
|
|
esp_err_t esp_console_cmd_register(const esp_console_cmd_t *);
|