mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 04:50:58 +02:00
Update IDF to 3.2-3276a13 and esptool.py to 2.5.0 (#1878)
* TX Flow Control and Code cleanup * Use semaphore instead of delay TX functionality is done. * Use single buffer and empty queue on exit * Fix compile issues because of LwIP code relocation * Add temporary header to fix Azure not compiling * Fix AsyncUDP early init * AsyncUDP Multicast fixes * Add source mac address and rework multicast * Allow redefinition of default pins for Serials 1 and 2 * Update IDF to 3276a13 * Update esptool.py to 2.5.0 * Fix sketches * Fix log level in BluetoothSetial
This commit is contained in:
@ -1,52 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SYS_ARCH_H__
|
||||
#define __SYS_ARCH_H__
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SYS_ARCH_H__
|
||||
#define __SYS_ARCH_H__
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "arch/vfs_lwip.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef xSemaphoreHandle sys_sem_t;
|
||||
typedef xSemaphoreHandle sys_mutex_t;
|
||||
typedef xTaskHandle sys_thread_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef xSemaphoreHandle sys_sem_t;
|
||||
typedef xSemaphoreHandle sys_mutex_t;
|
||||
typedef xTaskHandle sys_thread_t;
|
||||
|
||||
typedef struct sys_mbox_s {
|
||||
xQueueHandle os_mbox;
|
||||
@ -54,28 +54,28 @@ typedef struct sys_mbox_s {
|
||||
uint8_t alive;
|
||||
}* sys_mbox_t;
|
||||
|
||||
|
||||
#define LWIP_COMPAT_MUTEX 0
|
||||
|
||||
#if !LWIP_COMPAT_MUTEX
|
||||
#define sys_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_mutex_set_invalid( x ) ( ( *x ) = NULL )
|
||||
#endif
|
||||
|
||||
#define sys_mbox_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_mbox_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
#define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_sem_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
#define LWIP_COMPAT_MUTEX 0
|
||||
|
||||
#if !LWIP_COMPAT_MUTEX
|
||||
#define sys_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_mutex_set_invalid( x ) ( ( *x ) = NULL )
|
||||
#endif
|
||||
|
||||
#define sys_mbox_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_mbox_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
#define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_sem_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
void sys_delay_ms(uint32_t ms);
|
||||
sys_sem_t* sys_thread_sem_init(void);
|
||||
void sys_thread_sem_deinit(void);
|
||||
sys_sem_t* sys_thread_sem_get(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
sys_sem_t* sys_thread_sem_get(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SYS_ARCH_H__ */
|
||||
|
||||
#endif /* __SYS_ARCH_H__ */
|
||||
|
||||
|
@ -15,6 +15,6 @@
|
||||
#ifndef INET_H_
|
||||
#define INET_H_
|
||||
|
||||
#include "lwip/inet.h"
|
||||
#include "../../../lwip/src/include/lwip/inet.h"
|
||||
|
||||
#endif /* INET_H_ */
|
||||
|
94
tools/sdk/include/lwip/cc.h
Normal file
94
tools/sdk/include/lwip/cc.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_CC_H__
|
||||
#define __ARCH_CC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "arch/sys_arch.h"
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
typedef uint8_t u8_t;
|
||||
typedef int8_t s8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef int16_t s16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef int32_t s32_t;
|
||||
|
||||
typedef unsigned long mem_ptr_t;
|
||||
typedef int sys_prot_t;
|
||||
|
||||
#define S16_F "d"
|
||||
#define U16_F "d"
|
||||
#define X16_F "x"
|
||||
|
||||
#define S32_F "d"
|
||||
#define U32_F "d"
|
||||
#define X32_F "x"
|
||||
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
||||
// __assert_func is the assertion failure handler from newlib, defined in assert.h
|
||||
#define LWIP_PLATFORM_ASSERT(message) __assert_func(__FILE__, __LINE__, __ASSERT_FUNC, message)
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define LWIP_NOASSERT
|
||||
#else // Assertions enabled
|
||||
|
||||
// If assertions are on, the default LWIP_ERROR handler behaviour is to
|
||||
// abort w/ an assertion failure. Don't do this, instead just print the error (if LWIP_DEBUG is set)
|
||||
// and run the handler (same as the LWIP_ERROR behaviour if LWIP_NOASSERT is set).
|
||||
#ifdef LWIP_DEBUG
|
||||
#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
|
||||
puts(message); handler;}} while(0)
|
||||
#else
|
||||
// If LWIP_DEBUG is not set, return the error silently (default LWIP behaviour, also.)
|
||||
#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
|
||||
handler;}} while(0)
|
||||
#endif // LWIP_DEBUG
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* netconn API (to be used from non-TCPIP threads)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -38,8 +43,7 @@
|
||||
/* Note: Netconn API is always available when sockets are enabled -
|
||||
* sockets are implemented on top of them */
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/netbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
@ -65,9 +69,11 @@ extern "C" {
|
||||
#define NETCONN_FLAG_NON_BLOCKING 0x02
|
||||
/** Was the last connect action a non-blocking one? */
|
||||
#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
|
||||
#if ESP_AUTO_RECV
|
||||
/** If this is set, a TCP netconn must call netconn_recved() to update
|
||||
the TCP receive window (done automatically if not set). */
|
||||
#define NETCONN_FLAG_NO_AUTO_RECVED 0x08
|
||||
#endif
|
||||
/** If a nonblocking write has been rejected before, poll_tcp needs to
|
||||
check if the netconn is writable again */
|
||||
#define NETCONN_FLAG_CHECK_WRITESPACE 0x10
|
||||
@ -79,7 +85,7 @@ extern "C" {
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
|
||||
/* Helpers to process several netconn_types by the same code */
|
||||
/* Helpers to process several netconn_types by the same code */
|
||||
#define NETCONNTYPE_GROUP(t) ((t)&0xF0)
|
||||
#define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0)
|
||||
#if LWIP_IPV6
|
||||
@ -88,32 +94,42 @@ extern "C" {
|
||||
#define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF3) == NETCONN_UDPLITE)
|
||||
#define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF3) == NETCONN_UDPNOCHKSUM)
|
||||
#else /* LWIP_IPV6 */
|
||||
#define NETCONNTYPE_ISIPV6(t) (0)
|
||||
#define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE)
|
||||
#define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM)
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/** Protocol family and type of the netconn */
|
||||
/** @ingroup netconn_common
|
||||
* Protocol family and type of the netconn
|
||||
*/
|
||||
enum netconn_type {
|
||||
NETCONN_INVALID = 0,
|
||||
/* NETCONN_TCP Group */
|
||||
/** TCP IPv4 */
|
||||
NETCONN_TCP = 0x10,
|
||||
#if LWIP_IPV6
|
||||
/** TCP IPv6 */
|
||||
NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 /* 0x18 */,
|
||||
#endif /* LWIP_IPV6 */
|
||||
/* NETCONN_UDP Group */
|
||||
/** UDP IPv4 */
|
||||
NETCONN_UDP = 0x20,
|
||||
/** UDP IPv4 lite */
|
||||
NETCONN_UDPLITE = 0x21,
|
||||
/** UDP IPv4 no checksum */
|
||||
NETCONN_UDPNOCHKSUM = 0x22,
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** UDP IPv6 (dual-stack by default, unless you call @ref netconn_set_ipv6only) */
|
||||
NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 /* 0x28 */,
|
||||
/** UDP IPv6 lite (dual-stack by default, unless you call @ref netconn_set_ipv6only) */
|
||||
NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 /* 0x29 */,
|
||||
/** UDP IPv6 no checksum (dual-stack by default, unless you call @ref netconn_set_ipv6only) */
|
||||
NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 /* 0x2a */,
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/* NETCONN_RAW Group */
|
||||
/** Raw connection IPv4 */
|
||||
NETCONN_RAW = 0x40
|
||||
#if LWIP_IPV6
|
||||
/** Raw connection IPv6 (dual-stack by default, unless you call @ref netconn_set_ipv6only) */
|
||||
, NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6 /* 0x48 */
|
||||
#endif /* LWIP_IPV6 */
|
||||
};
|
||||
@ -128,7 +144,32 @@ enum netconn_state {
|
||||
NETCONN_CLOSE
|
||||
};
|
||||
|
||||
/** Use to inform the callback function about changes */
|
||||
/** Used to inform the callback function about changes
|
||||
*
|
||||
* Event explanation:
|
||||
*
|
||||
* In the netconn implementation, there are three ways to block a client:
|
||||
*
|
||||
* - accept mbox (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, 0); in netconn_accept())
|
||||
* - receive mbox (sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0); in netconn_recv_data())
|
||||
* - send queue is full (sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0); in lwip_netconn_do_write())
|
||||
*
|
||||
* The events have to be seen as events signaling the state of these mboxes/semaphores. For non-blocking
|
||||
* connections, you need to know in advance whether a call to a netconn function call would block or not,
|
||||
* and these events tell you about that.
|
||||
*
|
||||
* RCVPLUS events say: Safe to perform a potentially blocking call call once more.
|
||||
* They are counted in sockets - three RCVPLUS events for accept mbox means you are safe
|
||||
* to call netconn_accept 3 times without being blocked.
|
||||
* Same thing for receive mbox.
|
||||
*
|
||||
* RCVMINUS events say: Your call to to a possibly blocking function is "acknowledged".
|
||||
* Socket implementation decrements the counter.
|
||||
*
|
||||
* For TX, there is no need to count, its merely a flag. SENDPLUS means you may send something.
|
||||
* SENDPLUS occurs when enough data was delivered to peer so netconn_send() can be called again.
|
||||
* A SENDMINUS event occurs when the next call to a netconn_send() would be blocking.
|
||||
*/
|
||||
enum netconn_evt {
|
||||
NETCONN_EVT_RCVPLUS,
|
||||
NETCONN_EVT_RCVMINUS,
|
||||
@ -160,7 +201,7 @@ struct tcp_pcb;
|
||||
struct udp_pcb;
|
||||
struct raw_pcb;
|
||||
struct netconn;
|
||||
struct api_msg_msg;
|
||||
struct api_msg;
|
||||
|
||||
/** A callback prototype to inform about events for a netconn */
|
||||
typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
|
||||
@ -180,13 +221,10 @@ struct netconn {
|
||||
} pcb;
|
||||
/** the last error this netconn had */
|
||||
err_t last_err;
|
||||
|
||||
#if !LWIP_NETCONN_SEM_PER_THREAD
|
||||
/** sem that is used to synchronously execute functions in the core context */
|
||||
sys_sem_t op_completed;
|
||||
|
||||
#endif
|
||||
|
||||
/** mbox where received packets are stored until they are fetched
|
||||
by the netconn application thread (can grow quite big) */
|
||||
sys_mbox_t recvmbox;
|
||||
@ -231,7 +269,7 @@ struct netconn {
|
||||
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
||||
this temporarily stores the message.
|
||||
Also used during connect and close. */
|
||||
struct api_msg_msg *current_msg;
|
||||
struct api_msg *current_msg;
|
||||
#endif /* LWIP_TCP */
|
||||
/** A callback function that is informed about events for this netconn */
|
||||
netconn_callback callback;
|
||||
@ -253,6 +291,10 @@ struct netconn {
|
||||
}} while(0);
|
||||
|
||||
/* Network connection functions: */
|
||||
|
||||
/** @ingroup netconn_common
|
||||
* Create new netconn connection
|
||||
* @param t @ref netconn_type */
|
||||
#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL)
|
||||
#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
|
||||
struct netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
|
||||
@ -263,23 +305,29 @@ err_t netconn_delete(struct netconn *conn);
|
||||
|
||||
err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr,
|
||||
u16_t *port, u8_t local);
|
||||
/** @ingroup netconn_common */
|
||||
#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
|
||||
/** @ingroup netconn_common */
|
||||
#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
|
||||
|
||||
err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port);
|
||||
err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port);
|
||||
err_t netconn_disconnect (struct netconn *conn);
|
||||
err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
|
||||
/** @ingroup netconn_tcp */
|
||||
#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
|
||||
err_t netconn_accept(struct netconn *conn, struct netconn **new_conn);
|
||||
err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf);
|
||||
err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf);
|
||||
#if ESP_AUTO_RECV
|
||||
void netconn_recved(struct netconn *conn, u32_t length);
|
||||
#endif
|
||||
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
|
||||
const ip_addr_t *addr, u16_t port);
|
||||
err_t netconn_send(struct netconn *conn, struct netbuf *buf);
|
||||
err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
|
||||
u8_t apiflags, size_t *bytes_written);
|
||||
/** @ingroup netconn_tcp */
|
||||
#define netconn_write(conn, dataptr, size, apiflags) \
|
||||
netconn_write_partly(conn, dataptr, size, apiflags, NULL)
|
||||
err_t netconn_close(struct netconn *conn);
|
||||
@ -310,6 +358,7 @@ err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
|
||||
/** Get the blocking status of netconn calls (@todo: write/send is missing) */
|
||||
#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
|
||||
|
||||
#if ESP_AUTO_RECV
|
||||
/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
|
||||
#define netconn_set_noautorecved(conn, val) do { if(val) { \
|
||||
(conn)->flags |= NETCONN_FLAG_NO_AUTO_RECVED; \
|
||||
@ -317,14 +366,19 @@ err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
|
||||
(conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0)
|
||||
/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
|
||||
#define netconn_get_noautorecved(conn) (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0)
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY) */
|
||||
/** @ingroup netconn_common
|
||||
* TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)
|
||||
*/
|
||||
#define netconn_set_ipv6only(conn, val) do { if(val) { \
|
||||
(conn)->flags |= NETCONN_FLAG_IPV6_V6ONLY; \
|
||||
} else { \
|
||||
(conn)->flags &= ~ NETCONN_FLAG_IPV6_V6ONLY; }} while(0)
|
||||
/** TCP: Get the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY) */
|
||||
/** @ingroup netconn_common
|
||||
* TCP: Get the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)
|
||||
*/
|
||||
#define netconn_get_ipv6only(conn) (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0)
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
|
2
tools/sdk/include/lwip/lwip/apps/FILES
Normal file
2
tools/sdk/include/lwip/lwip/apps/FILES
Normal file
@ -0,0 +1,2 @@
|
||||
This directory contains application headers.
|
||||
Every application shall provide one api file APP.h and optionally one options file APP_opts.h
|
103
tools/sdk/include/lwip/lwip/apps/fs.h
Normal file
103
tools/sdk/include/lwip/lwip/apps/fs.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_FS_H
|
||||
#define LWIP_HDR_APPS_FS_H
|
||||
|
||||
#include "httpd_opts.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FS_READ_EOF -1
|
||||
#define FS_READ_DELAYED -2
|
||||
|
||||
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||
struct fsdata_chksum {
|
||||
u32_t offset;
|
||||
u16_t chksum;
|
||||
u16_t len;
|
||||
};
|
||||
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||
|
||||
#define FS_FILE_FLAGS_HEADER_INCLUDED 0x01
|
||||
#define FS_FILE_FLAGS_HEADER_PERSISTENT 0x02
|
||||
|
||||
struct fs_file {
|
||||
const char *data;
|
||||
int len;
|
||||
int index;
|
||||
void *pextension;
|
||||
#if HTTPD_PRECALCULATED_CHECKSUM
|
||||
const struct fsdata_chksum *chksum;
|
||||
u16_t chksum_count;
|
||||
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||
u8_t flags;
|
||||
#if LWIP_HTTPD_CUSTOM_FILES
|
||||
u8_t is_custom_file;
|
||||
#endif /* LWIP_HTTPD_CUSTOM_FILES */
|
||||
#if LWIP_HTTPD_FILE_STATE
|
||||
void *state;
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
};
|
||||
|
||||
#if LWIP_HTTPD_FS_ASYNC_READ
|
||||
typedef void (*fs_wait_cb)(void *arg);
|
||||
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
|
||||
err_t fs_open(struct fs_file *file, const char *name);
|
||||
void fs_close(struct fs_file *file);
|
||||
#if LWIP_HTTPD_DYNAMIC_FILE_READ
|
||||
#if LWIP_HTTPD_FS_ASYNC_READ
|
||||
int fs_read_async(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg);
|
||||
#else /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
int fs_read(struct fs_file *file, char *buffer, int count);
|
||||
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
#endif /* LWIP_HTTPD_DYNAMIC_FILE_READ */
|
||||
#if LWIP_HTTPD_FS_ASYNC_READ
|
||||
int fs_is_file_ready(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg);
|
||||
#endif /* LWIP_HTTPD_FS_ASYNC_READ */
|
||||
int fs_bytes_left(struct fs_file *file);
|
||||
|
||||
#if LWIP_HTTPD_FILE_STATE
|
||||
/** This user-defined function is called when a file is opened. */
|
||||
void *fs_state_init(struct fs_file *file, const char *name);
|
||||
/** This user-defined function is called when a file is closed. */
|
||||
void fs_state_free(struct fs_file *file, void *state);
|
||||
#endif /* #if LWIP_HTTPD_FILE_STATE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_FS_H */
|
236
tools/sdk/include/lwip/lwip/apps/httpd.h
Normal file
236
tools/sdk/include/lwip/lwip/apps/httpd.h
Normal file
@ -0,0 +1,236 @@
|
||||
/**
|
||||
* @file
|
||||
* HTTP server
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* This version of the file has been modified by Texas Instruments to offer
|
||||
* simple server-side-include (SSI) and Common Gateway Interface (CGI)
|
||||
* capability.
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_HTTPD_H
|
||||
#define LWIP_HDR_APPS_HTTPD_H
|
||||
|
||||
#include "httpd_opts.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_HTTPD_CGI
|
||||
|
||||
/*
|
||||
* Function pointer for a CGI script handler.
|
||||
*
|
||||
* This function is called each time the HTTPD server is asked for a file
|
||||
* whose name was previously registered as a CGI function using a call to
|
||||
* http_set_cgi_handler. The iIndex parameter provides the index of the
|
||||
* CGI within the ppcURLs array passed to http_set_cgi_handler. Parameters
|
||||
* pcParam and pcValue provide access to the parameters provided along with
|
||||
* the URI. iNumParams provides a count of the entries in the pcParam and
|
||||
* pcValue arrays. Each entry in the pcParam array contains the name of a
|
||||
* parameter with the corresponding entry in the pcValue array containing the
|
||||
* value for that parameter. Note that pcParam may contain multiple elements
|
||||
* with the same name if, for example, a multi-selection list control is used
|
||||
* in the form generating the data.
|
||||
*
|
||||
* The function should return a pointer to a character string which is the
|
||||
* path and filename of the response that is to be sent to the connected
|
||||
* browser, for example "/thanks.htm" or "/response/error.ssi".
|
||||
*
|
||||
* The maximum number of parameters that will be passed to this function via
|
||||
* iNumParams is defined by LWIP_HTTPD_MAX_CGI_PARAMETERS. Any parameters in the incoming
|
||||
* HTTP request above this number will be discarded.
|
||||
*
|
||||
* Requests intended for use by this CGI mechanism must be sent using the GET
|
||||
* method (which encodes all parameters within the URI rather than in a block
|
||||
* later in the request). Attempts to use the POST method will result in the
|
||||
* request being ignored.
|
||||
*
|
||||
*/
|
||||
typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[],
|
||||
char *pcValue[]);
|
||||
|
||||
/*
|
||||
* Structure defining the base filename (URL) of a CGI and the associated
|
||||
* function which is to be called when that URL is requested.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *pcCGIName;
|
||||
tCGIHandler pfnCGIHandler;
|
||||
} tCGI;
|
||||
|
||||
void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers);
|
||||
|
||||
#endif /* LWIP_HTTPD_CGI */
|
||||
|
||||
#if LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI
|
||||
|
||||
#if LWIP_HTTPD_CGI_SSI
|
||||
/** Define this generic CGI handler in your application.
|
||||
* It is called once for every URI with parameters.
|
||||
* The parameters can be stored to
|
||||
*/
|
||||
extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue
|
||||
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
|
||||
, void *connection_state
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
);
|
||||
#endif /* LWIP_HTTPD_CGI_SSI */
|
||||
|
||||
#endif /* LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI */
|
||||
|
||||
#if LWIP_HTTPD_SSI
|
||||
|
||||
/*
|
||||
* Function pointer for the SSI tag handler callback.
|
||||
*
|
||||
* This function will be called each time the HTTPD server detects a tag of the
|
||||
* form <!--#name--> in a .shtml, .ssi or .shtm file where "name" appears as
|
||||
* one of the tags supplied to http_set_ssi_handler in the ppcTags array. The
|
||||
* returned insert string, which will be appended after the the string
|
||||
* "<!--#name-->" in file sent back to the client,should be written to pointer
|
||||
* pcInsert. iInsertLen contains the size of the buffer pointed to by
|
||||
* pcInsert. The iIndex parameter provides the zero-based index of the tag as
|
||||
* found in the ppcTags array and identifies the tag that is to be processed.
|
||||
*
|
||||
* The handler returns the number of characters written to pcInsert excluding
|
||||
* any terminating NULL or a negative number to indicate a failure (tag not
|
||||
* recognized, for example).
|
||||
*
|
||||
* Note that the behavior of this SSI mechanism is somewhat different from the
|
||||
* "normal" SSI processing as found in, for example, the Apache web server. In
|
||||
* this case, the inserted text is appended following the SSI tag rather than
|
||||
* replacing the tag entirely. This allows for an implementation that does not
|
||||
* require significant additional buffering of output data yet which will still
|
||||
* offer usable SSI functionality. One downside to this approach is when
|
||||
* attempting to use SSI within JavaScript. The SSI tag is structured to
|
||||
* resemble an HTML comment but this syntax does not constitute a comment
|
||||
* within JavaScript and, hence, leaving the tag in place will result in
|
||||
* problems in these cases. To work around this, any SSI tag which needs to
|
||||
* output JavaScript code must do so in an encapsulated way, sending the whole
|
||||
* HTML <script>...</script> section as a single include.
|
||||
*/
|
||||
typedef u16_t (*tSSIHandler)(
|
||||
#if LWIP_HTTPD_SSI_RAW
|
||||
const char* ssi_tag_name,
|
||||
#else /* LWIP_HTTPD_SSI_RAW */
|
||||
int iIndex,
|
||||
#endif /* LWIP_HTTPD_SSI_RAW */
|
||||
char *pcInsert, int iInsertLen
|
||||
#if LWIP_HTTPD_SSI_MULTIPART
|
||||
, u16_t current_tag_part, u16_t *next_tag_part
|
||||
#endif /* LWIP_HTTPD_SSI_MULTIPART */
|
||||
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
|
||||
, void *connection_state
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
);
|
||||
|
||||
/** Set the SSI handler function
|
||||
* (if LWIP_HTTPD_SSI_RAW==1, only the first argument is used)
|
||||
*/
|
||||
void http_set_ssi_handler(tSSIHandler pfnSSIHandler,
|
||||
const char **ppcTags, int iNumTags);
|
||||
|
||||
/** For LWIP_HTTPD_SSI_RAW==1, return this to indicate the tag is unknown.
|
||||
* In this case, the webserver writes a warning into the page.
|
||||
* You can also just return 0 to write nothing for unknown tags.
|
||||
*/
|
||||
#define HTTPD_SSI_TAG_UNKNOWN 0xFFFF
|
||||
|
||||
#endif /* LWIP_HTTPD_SSI */
|
||||
|
||||
#if LWIP_HTTPD_SUPPORT_POST
|
||||
|
||||
/* These functions must be implemented by the application */
|
||||
|
||||
/** Called when a POST request has been received. The application can decide
|
||||
* whether to accept it or not.
|
||||
*
|
||||
* @param connection Unique connection identifier, valid until httpd_post_end
|
||||
* is called.
|
||||
* @param uri The HTTP header URI receiving the POST request.
|
||||
* @param http_request The raw HTTP request (the first packet, normally).
|
||||
* @param http_request_len Size of 'http_request'.
|
||||
* @param content_len Content-Length from HTTP header.
|
||||
* @param response_uri Filename of response file, to be filled when denying the
|
||||
* request
|
||||
* @param response_uri_len Size of the 'response_uri' buffer.
|
||||
* @param post_auto_wnd Set this to 0 to let the callback code handle window
|
||||
* updates by calling 'httpd_post_data_recved' (to throttle rx speed)
|
||||
* default is 1 (httpd handles window updates automatically)
|
||||
* @return ERR_OK: Accept the POST request, data may be passed in
|
||||
* another err_t: Deny the POST request, send back 'bad request'.
|
||||
*/
|
||||
err_t httpd_post_begin(void *connection, const char *uri, const char *http_request,
|
||||
u16_t http_request_len, int content_len, char *response_uri,
|
||||
u16_t response_uri_len, u8_t *post_auto_wnd);
|
||||
|
||||
/** Called for each pbuf of data that has been received for a POST.
|
||||
* ATTENTION: The application is responsible for freeing the pbufs passed in!
|
||||
*
|
||||
* @param connection Unique connection identifier.
|
||||
* @param p Received data.
|
||||
* @return ERR_OK: Data accepted.
|
||||
* another err_t: Data denied, http_post_get_response_uri will be called.
|
||||
*/
|
||||
err_t httpd_post_receive_data(void *connection, struct pbuf *p);
|
||||
|
||||
/** Called when all data is received or when the connection is closed.
|
||||
* The application must return the filename/URI of a file to send in response
|
||||
* to this POST request. If the response_uri buffer is untouched, a 404
|
||||
* response is returned.
|
||||
*
|
||||
* @param connection Unique connection identifier.
|
||||
* @param response_uri Filename of response file, to be filled when denying the request
|
||||
* @param response_uri_len Size of the 'response_uri' buffer.
|
||||
*/
|
||||
void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len);
|
||||
|
||||
#if LWIP_HTTPD_POST_MANUAL_WND
|
||||
void httpd_post_data_recved(void *connection, u16_t recved_len);
|
||||
#endif /* LWIP_HTTPD_POST_MANUAL_WND */
|
||||
|
||||
#endif /* LWIP_HTTPD_SUPPORT_POST */
|
||||
|
||||
void httpd_init(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HTTPD_H */
|
323
tools/sdk/include/lwip/lwip/apps/httpd_opts.h
Normal file
323
tools/sdk/include/lwip/lwip/apps/httpd_opts.h
Normal file
@ -0,0 +1,323 @@
|
||||
/**
|
||||
* @file
|
||||
* HTTP server options list
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* This version of the file has been modified by Texas Instruments to offer
|
||||
* simple server-side-include (SSI) and Common Gateway Interface (CGI)
|
||||
* capability.
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_HTTPD_OPTS_H
|
||||
#define LWIP_HDR_APPS_HTTPD_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup httpd_opts Options
|
||||
* @ingroup httpd
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Set this to 1 to support CGI (old style) */
|
||||
#if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_CGI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support CGI (new style) */
|
||||
#if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_CGI_SSI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support SSI (Server-Side-Includes) */
|
||||
#if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to implement an SSI tag handler callback that gets a const char*
|
||||
* to the tag (instead of an index into a pre-registered array of known tags) */
|
||||
#if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI_RAW 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support HTTP POST */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_POST 0
|
||||
#endif
|
||||
|
||||
/* The maximum number of parameters that the CGI handler can be sent. */
|
||||
#if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16
|
||||
#endif
|
||||
|
||||
/** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more
|
||||
* arguments indicating a counter for insert string that are too long to be
|
||||
* inserted at once: the SSI handler function must then set 'next_tag_part'
|
||||
* which will be passed back to it in the next call. */
|
||||
#if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI_MULTIPART 0
|
||||
#endif
|
||||
|
||||
/* The maximum length of the string comprising the tag name */
|
||||
#if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8
|
||||
#endif
|
||||
|
||||
/* The maximum length of string that can be returned to replace any given tag */
|
||||
#if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192
|
||||
#endif
|
||||
|
||||
#if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_POST_MANUAL_WND 0
|
||||
#endif
|
||||
|
||||
/** This string is passed in the HTTP header as "Server: " */
|
||||
#if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__
|
||||
#define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)"
|
||||
#endif
|
||||
|
||||
/** Set this to 1 if you want to include code that creates HTTP headers
|
||||
* at runtime. Default is off: HTTP headers are then created statically
|
||||
* by the makefsdata tool. Static headers mean smaller code size, but
|
||||
* the (readonly) fsdata will grow a bit as every file includes the HTTP
|
||||
* header. */
|
||||
#if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_DYNAMIC_HEADERS 0
|
||||
#endif
|
||||
|
||||
#if !defined HTTPD_DEBUG || defined __DOXYGEN__
|
||||
#define HTTPD_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to use a memp pool for allocating
|
||||
* struct http_state instead of the heap.
|
||||
*/
|
||||
#if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__
|
||||
#define HTTPD_USE_MEM_POOL 0
|
||||
#endif
|
||||
|
||||
/** The server port for HTTPD to use */
|
||||
#if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__
|
||||
#define HTTPD_SERVER_PORT 80
|
||||
#endif
|
||||
|
||||
/** Maximum retries before the connection is aborted/closed.
|
||||
* - number of times pcb->poll is called -> default is 4*500ms = 2s;
|
||||
* - reset when pcb->sent is called
|
||||
*/
|
||||
#if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__
|
||||
#define HTTPD_MAX_RETRIES 4
|
||||
#endif
|
||||
|
||||
/** The poll delay is X*500ms */
|
||||
#if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__
|
||||
#define HTTPD_POLL_INTERVAL 4
|
||||
#endif
|
||||
|
||||
/** Priority for tcp pcbs created by HTTPD (very low by default).
|
||||
* Lower priorities get killed first when running out of memory.
|
||||
*/
|
||||
#if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__
|
||||
#define HTTPD_TCP_PRIO TCP_PRIO_MIN
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to enable timing each file sent */
|
||||
#if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_TIMING 0
|
||||
#endif
|
||||
/** Set this to 1 to enable timing each file sent */
|
||||
#if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__
|
||||
#define HTTPD_DEBUG_TIMING LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** Set this to one to show error pages when parsing a request fails instead
|
||||
of simply closing the connection. */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_EXTSTATUS 0
|
||||
#endif
|
||||
|
||||
/** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_V09 1
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to enable HTTP/1.1 persistent connections.
|
||||
* ATTENTION: If the generated file system includes HTTP headers, these must
|
||||
* include the "Connection: keep-alive" header (pass argument "-11" to makefsdata).
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */
|
||||
#if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SUPPORT_REQUESTLIST 1
|
||||
#endif
|
||||
|
||||
#if LWIP_HTTPD_SUPPORT_REQUESTLIST
|
||||
/** Number of rx pbufs to enqueue to parse an incoming request (up to the first
|
||||
newline) */
|
||||
#if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_REQ_QUEUELEN 5
|
||||
#endif
|
||||
|
||||
/** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming
|
||||
request (up to the first double-newline) */
|
||||
#if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH
|
||||
#endif
|
||||
|
||||
/** Defines the maximum length of a HTTP request line (up to the first CRLF,
|
||||
copied from pbuf into this a global buffer when pbuf- or packet-queues
|
||||
are received - otherwise the input pbuf is used directly) */
|
||||
#if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE))
|
||||
#endif
|
||||
#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */
|
||||
|
||||
/** This is the size of a static buffer used when URIs end with '/'.
|
||||
* In this buffer, the directory requested is concatenated with all the
|
||||
* configured default file names.
|
||||
* Set to 0 to disable checking default filenames on non-root directories.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63
|
||||
#endif
|
||||
|
||||
/** Maximum length of the filename to send as response to a POST request,
|
||||
* filled in by the application when a POST is finished.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63
|
||||
#endif
|
||||
|
||||
/** Set this to 0 to not send the SSI tag (default is on, so the tag will
|
||||
* be sent in the HTML page */
|
||||
#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_SSI_INCLUDE_TAG 1
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to call tcp_abort when tcp_close fails with memory error.
|
||||
* This can be used to prevent consuming all memory in situations where the
|
||||
* HTTP server has low priority compared to other communication. */
|
||||
#if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to kill the oldest connection when running out of
|
||||
* memory for 'struct http_state' or 'struct http_ssi_state'.
|
||||
* ATTENTION: This puts all connections on a linked list, so may be kind of slow.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to send URIs without extension without headers
|
||||
* (who uses this at all??) */
|
||||
#if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0
|
||||
#endif
|
||||
|
||||
/** Default: Tags are sent from struct http_state and are therefore volatile */
|
||||
#if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__
|
||||
#define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY
|
||||
#endif
|
||||
|
||||
/* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low
|
||||
when http is not an important protocol in the device. */
|
||||
#if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__
|
||||
#define HTTPD_LIMIT_SENDING_TO_2MSS 1
|
||||
#endif
|
||||
|
||||
/* Define this to a function that returns the maximum amount of data to enqueue.
|
||||
The function have this signature: u16_t fn(struct tcp_pcb* pcb); */
|
||||
#if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__
|
||||
#if HTTPD_LIMIT_SENDING_TO_2MSS
|
||||
#define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*------------------- FS OPTIONS -------------------*/
|
||||
|
||||
/** Set this to 1 and provide the functions:
|
||||
* - "int fs_open_custom(struct fs_file *file, const char *name)"
|
||||
* Called first for every opened file to allow opening files
|
||||
* that are not included in fsdata(_custom).c
|
||||
* - "void fs_close_custom(struct fs_file *file)"
|
||||
* Called to free resources allocated by fs_open_custom().
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_CUSTOM_FILES 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support fs_read() to dynamically read file data.
|
||||
* Without this (default=off), only one-block files are supported,
|
||||
* and the contents must be ready after fs_open().
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_DYNAMIC_FILE_READ 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to include an application state argument per file
|
||||
* that is opened. This allows to keep a state per connection/file.
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_FILE_STATE 0
|
||||
#endif
|
||||
|
||||
/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for
|
||||
* predefined (MSS-sized) chunks of the files to prevent having to calculate
|
||||
* the checksums at runtime. */
|
||||
#if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__
|
||||
#define HTTPD_PRECALCULATED_CHECKSUM 0
|
||||
#endif
|
||||
|
||||
/** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations
|
||||
* (fs_read_async returns FS_READ_DELAYED and calls a callback when finished).
|
||||
*/
|
||||
#if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__
|
||||
#define LWIP_HTTPD_FS_ASYNC_READ 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the
|
||||
* file system (to prevent changing the file included in CVS) */
|
||||
#if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__
|
||||
#define HTTPD_USE_CUSTOM_FSDATA 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */
|
84
tools/sdk/include/lwip/lwip/apps/lwiperf.h
Normal file
84
tools/sdk/include/lwip/lwip/apps/lwiperf.h
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file
|
||||
* lwIP iPerf server implementation
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014 Simon Goldschmidt
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_LWIPERF_H
|
||||
#define LWIP_HDR_APPS_LWIPERF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LWIPERF_TCP_PORT_DEFAULT 5001
|
||||
|
||||
/** lwIPerf test results */
|
||||
enum lwiperf_report_type
|
||||
{
|
||||
/** The server side test is done */
|
||||
LWIPERF_TCP_DONE_SERVER,
|
||||
/** The client side test is done */
|
||||
LWIPERF_TCP_DONE_CLIENT,
|
||||
/** Local error lead to test abort */
|
||||
LWIPERF_TCP_ABORTED_LOCAL,
|
||||
/** Data check error lead to test abort */
|
||||
LWIPERF_TCP_ABORTED_LOCAL_DATAERROR,
|
||||
/** Transmit error lead to test abort */
|
||||
LWIPERF_TCP_ABORTED_LOCAL_TXERROR,
|
||||
/** Remote side aborted the test */
|
||||
LWIPERF_TCP_ABORTED_REMOTE
|
||||
};
|
||||
|
||||
/** Prototype of a report function that is called when a session is finished.
|
||||
This report function can show the test results.
|
||||
@param report_type contains the test result */
|
||||
typedef void (*lwiperf_report_fn)(void *arg, enum lwiperf_report_type report_type,
|
||||
const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port,
|
||||
u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec);
|
||||
|
||||
|
||||
void* lwiperf_start_tcp_server(const ip_addr_t* local_addr, u16_t local_port,
|
||||
lwiperf_report_fn report_fn, void* report_arg);
|
||||
void* lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void* report_arg);
|
||||
void lwiperf_abort(void* lwiperf_session);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_LWIPERF_H */
|
69
tools/sdk/include/lwip/lwip/apps/mdns.h
Normal file
69
tools/sdk/include/lwip/lwip/apps/mdns.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @file
|
||||
* MDNS responder
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Verisure Innovation AB
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Ekman <erik@kryo.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_MDNS_H
|
||||
#define LWIP_HDR_MDNS_H
|
||||
|
||||
#include "lwip/apps/mdns_opts.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#if LWIP_MDNS_RESPONDER
|
||||
|
||||
enum mdns_sd_proto {
|
||||
DNSSD_PROTO_UDP = 0,
|
||||
DNSSD_PROTO_TCP = 1
|
||||
};
|
||||
|
||||
#define MDNS_LABEL_MAXLEN 63
|
||||
|
||||
struct mdns_host;
|
||||
struct mdns_service;
|
||||
|
||||
/** Callback function to add text to a reply, called when generating the reply */
|
||||
typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata);
|
||||
|
||||
void mdns_resp_init(void);
|
||||
|
||||
err_t mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl);
|
||||
err_t mdns_resp_remove_netif(struct netif *netif);
|
||||
|
||||
err_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata);
|
||||
err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len);
|
||||
void mdns_resp_netif_settings_changed(struct netif *netif);
|
||||
|
||||
#endif /* LWIP_MDNS_RESPONDER */
|
||||
|
||||
#endif /* LWIP_HDR_MDNS_H */
|
74
tools/sdk/include/lwip/lwip/apps/mdns_opts.h
Normal file
74
tools/sdk/include/lwip/lwip/apps/mdns_opts.h
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @file
|
||||
* MDNS responder
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Verisure Innovation AB
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Ekman <erik@kryo.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_MDNS_OPTS_H
|
||||
#define LWIP_HDR_APPS_MDNS_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup mdns_opts Options
|
||||
* @ingroup mdns
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_MDNS_RESPONDER==1: Turn on multicast DNS module. UDP must be available for MDNS
|
||||
* transport. IGMP is needed for IPv4 multicast.
|
||||
*/
|
||||
#ifndef LWIP_MDNS_RESPONDER
|
||||
#define LWIP_MDNS_RESPONDER 0
|
||||
#endif /* LWIP_MDNS_RESPONDER */
|
||||
|
||||
/** The maximum number of services per netif */
|
||||
#ifndef MDNS_MAX_SERVICES
|
||||
#define MDNS_MAX_SERVICES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MDNS_DEBUG: Enable debugging for multicast DNS.
|
||||
*/
|
||||
#ifndef MDNS_DEBUG
|
||||
#define MDNS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_MDNS_OPTS_H */
|
||||
|
66
tools/sdk/include/lwip/lwip/apps/mdns_priv.h
Normal file
66
tools/sdk/include/lwip/lwip/apps/mdns_priv.h
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file
|
||||
* MDNS responder private definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Verisure Innovation AB
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Ekman <erik@kryo.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_MDNS_PRIV_H
|
||||
#define LWIP_HDR_MDNS_PRIV_H
|
||||
|
||||
#include "lwip/apps/mdns_opts.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#if LWIP_MDNS_RESPONDER
|
||||
|
||||
/* Domain struct and methods - visible for unit tests */
|
||||
|
||||
#define MDNS_DOMAIN_MAXLEN 256
|
||||
#define MDNS_READNAME_ERROR 0xFFFF
|
||||
|
||||
struct mdns_domain {
|
||||
/* Encoded domain name */
|
||||
u8_t name[MDNS_DOMAIN_MAXLEN];
|
||||
/* Total length of domain name, including zero */
|
||||
u16_t length;
|
||||
/* Set if compression of this domain is not allowed */
|
||||
u8_t skip_compression;
|
||||
};
|
||||
|
||||
err_t mdns_domain_add_label(struct mdns_domain *domain, const char *label, u8_t len);
|
||||
u16_t mdns_readname(struct pbuf *p, u16_t offset, struct mdns_domain *domain);
|
||||
int mdns_domain_eq(struct mdns_domain *a, struct mdns_domain *b);
|
||||
u16_t mdns_compress_domain(struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain);
|
||||
|
||||
#endif /* LWIP_MDNS_RESPONDER */
|
||||
|
||||
#endif /* LWIP_HDR_MDNS_PRIV_H */
|
244
tools/sdk/include/lwip/lwip/apps/mqtt.h
Normal file
244
tools/sdk/include/lwip/lwip/apps/mqtt.h
Normal file
@ -0,0 +1,244 @@
|
||||
/**
|
||||
* @file
|
||||
* MQTT client
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Erik Andersson
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Andersson
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_MQTT_CLIENT_H
|
||||
#define LWIP_HDR_APPS_MQTT_CLIENT_H
|
||||
|
||||
#include "lwip/apps/mqtt_opts.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct mqtt_client_t mqtt_client_t;
|
||||
|
||||
/** @ingroup mqtt
|
||||
* Default MQTT port */
|
||||
#define MQTT_PORT 1883
|
||||
|
||||
/*---------------------------------------------------------------------------------------------- */
|
||||
/* Connection with server */
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Client information and connection parameters */
|
||||
struct mqtt_connect_client_info_t {
|
||||
/** Client identifier, must be set by caller */
|
||||
const char *client_id;
|
||||
/** User name and password, set to NULL if not used */
|
||||
const char* client_user;
|
||||
const char* client_pass;
|
||||
/** keep alive time in seconds, 0 to disable keep alive functionality*/
|
||||
u16_t keep_alive;
|
||||
/** will topic, set to NULL if will is not to be used,
|
||||
will_msg, will_qos and will retain are then ignored */
|
||||
const char* will_topic;
|
||||
const char* will_msg;
|
||||
u8_t will_qos;
|
||||
u8_t will_retain;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Connection status codes */
|
||||
typedef enum
|
||||
{
|
||||
MQTT_CONNECT_ACCEPTED = 0,
|
||||
MQTT_CONNECT_REFUSED_PROTOCOL_VERSION = 1,
|
||||
MQTT_CONNECT_REFUSED_IDENTIFIER = 2,
|
||||
MQTT_CONNECT_REFUSED_SERVER = 3,
|
||||
MQTT_CONNECT_REFUSED_USERNAME_PASS = 4,
|
||||
MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ = 5,
|
||||
MQTT_CONNECT_DISCONNECTED = 256,
|
||||
MQTT_CONNECT_TIMEOUT = 257
|
||||
} mqtt_connection_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for mqtt connection status callback. Called when
|
||||
* client has connected to the server after initiating a mqtt connection attempt by
|
||||
* calling mqtt_connect() or when connection is closed by server or an error
|
||||
*
|
||||
* @param client MQTT client itself
|
||||
* @param arg Additional argument to pass to the callback function
|
||||
* @param status Connect result code or disconnection notification @see mqtt_connection_status_t
|
||||
*
|
||||
*/
|
||||
typedef void (*mqtt_connection_cb_t)(mqtt_client_t *client, void *arg, mqtt_connection_status_t status);
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Data callback flags */
|
||||
enum {
|
||||
/** Flag set when last fragment of data arrives in data callback */
|
||||
MQTT_DATA_FLAG_LAST = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for MQTT incoming publish data callback function. Called when data
|
||||
* arrives to a subscribed topic @see mqtt_subscribe
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function
|
||||
* @param data User data, pointed object, data may not be referenced after callback return,
|
||||
NULL is passed when all publish data are delivered
|
||||
* @param len Length of publish data fragment
|
||||
* @param flags MQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message
|
||||
*
|
||||
*/
|
||||
typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags);
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for MQTT incoming publish function. Called when an incoming publish
|
||||
* arrives to a subscribed topic @see mqtt_subscribe
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function
|
||||
* @param topic Zero terminated Topic text string, topic may not be referenced after callback return
|
||||
* @param tot_len Total length of publish data, if set to 0 (no publish payload) data callback will not be invoked
|
||||
*/
|
||||
typedef void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t tot_len);
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup mqtt
|
||||
* Function prototype for mqtt request callback. Called when a subscribe, unsubscribe
|
||||
* or publish request has completed
|
||||
* @param arg Pointer to user data supplied when invoking request
|
||||
* @param err ERR_OK on success
|
||||
* ERR_TIMEOUT if no response was received within timeout,
|
||||
* ERR_ABRT if (un)subscribe was denied
|
||||
*/
|
||||
typedef void (*mqtt_request_cb_t)(void *arg, err_t err);
|
||||
|
||||
|
||||
/**
|
||||
* Pending request item, binds application callback to pending server requests
|
||||
*/
|
||||
struct mqtt_request_t
|
||||
{
|
||||
/** Next item in list, NULL means this is the last in chain,
|
||||
next pointing at itself means request is unallocated */
|
||||
struct mqtt_request_t *next;
|
||||
/** Callback to upper layer */
|
||||
mqtt_request_cb_t cb;
|
||||
void *arg;
|
||||
/** MQTT packet identifier */
|
||||
u16_t pkt_id;
|
||||
/** Expire time relative to element before this */
|
||||
u16_t timeout_diff;
|
||||
};
|
||||
|
||||
/** Ring buffer */
|
||||
struct mqtt_ringbuf_t {
|
||||
u16_t put;
|
||||
u16_t get;
|
||||
u8_t buf[MQTT_OUTPUT_RINGBUF_SIZE];
|
||||
};
|
||||
|
||||
/** MQTT client */
|
||||
struct mqtt_client_t
|
||||
{
|
||||
/** Timers and timeouts */
|
||||
u16_t cyclic_tick;
|
||||
u16_t keep_alive;
|
||||
u16_t server_watchdog;
|
||||
/** Packet identifier generator*/
|
||||
u16_t pkt_id_seq;
|
||||
/** Packet identifier of pending incoming publish */
|
||||
u16_t inpub_pkt_id;
|
||||
/** Connection state */
|
||||
u8_t conn_state;
|
||||
struct tcp_pcb *conn;
|
||||
/** Connection callback */
|
||||
void *connect_arg;
|
||||
mqtt_connection_cb_t connect_cb;
|
||||
/** Pending requests to server */
|
||||
struct mqtt_request_t *pend_req_queue;
|
||||
struct mqtt_request_t req_list[MQTT_REQ_MAX_IN_FLIGHT];
|
||||
void *inpub_arg;
|
||||
/** Incoming data callback */
|
||||
mqtt_incoming_data_cb_t data_cb;
|
||||
mqtt_incoming_publish_cb_t pub_cb;
|
||||
/** Input */
|
||||
u32_t msg_idx;
|
||||
u8_t rx_buffer[MQTT_VAR_HEADER_BUFFER_LEN];
|
||||
/** Output ring-buffer */
|
||||
struct mqtt_ringbuf_t output;
|
||||
};
|
||||
|
||||
|
||||
/** Connect to server */
|
||||
err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg,
|
||||
const struct mqtt_connect_client_info_t *client_info);
|
||||
|
||||
/** Disconnect from server */
|
||||
void mqtt_disconnect(mqtt_client_t *client);
|
||||
|
||||
/** Create new client */
|
||||
mqtt_client_t *mqtt_client_new(void);
|
||||
|
||||
/** Check connection status */
|
||||
u8_t mqtt_client_is_connected(mqtt_client_t *client);
|
||||
|
||||
/** Set callback to call for incoming publish */
|
||||
void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t,
|
||||
mqtt_incoming_data_cb_t data_cb, void *arg);
|
||||
|
||||
/** Common function for subscribe and unsubscribe */
|
||||
err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub);
|
||||
|
||||
/** @ingroup mqtt
|
||||
*Subscribe to topic */
|
||||
#define mqtt_subscribe(client, topic, qos, cb, arg) mqtt_sub_unsub(client, topic, qos, cb, arg, 1)
|
||||
/** @ingroup mqtt
|
||||
* Unsubscribe to topic */
|
||||
#define mqtt_unsubscribe(client, topic, cb, arg) mqtt_sub_unsub(client, topic, 0, cb, arg, 0)
|
||||
|
||||
|
||||
/** Publish data to topic */
|
||||
err_t mqtt_publish(mqtt_client_t *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain,
|
||||
mqtt_request_cb_t cb, void *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_MQTT_CLIENT_H */
|
103
tools/sdk/include/lwip/lwip/apps/mqtt_opts.h
Normal file
103
tools/sdk/include/lwip/lwip/apps/mqtt_opts.h
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @file
|
||||
* MQTT client options
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Erik Andersson
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Andersson
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_MQTT_OPTS_H
|
||||
#define LWIP_HDR_APPS_MQTT_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup mqtt_opts Options
|
||||
* @ingroup mqtt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads
|
||||
*/
|
||||
#ifndef MQTT_OUTPUT_RINGBUF_SIZE
|
||||
#define MQTT_OUTPUT_RINGBUF_SIZE 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8
|
||||
* If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8
|
||||
*/
|
||||
#ifndef MQTT_VAR_HEADER_BUFFER_LEN
|
||||
#define MQTT_VAR_HEADER_BUFFER_LEN 128
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Maximum number of pending subscribe, unsubscribe and publish requests to server .
|
||||
*/
|
||||
#ifndef MQTT_REQ_MAX_IN_FLIGHT
|
||||
#define MQTT_REQ_MAX_IN_FLIGHT 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Seconds between each cyclic timer call.
|
||||
*/
|
||||
#ifndef MQTT_CYCLIC_TIMER_INTERVAL
|
||||
#define MQTT_CYCLIC_TIMER_INTERVAL 5
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Publish, subscribe and unsubscribe request timeout in seconds.
|
||||
*/
|
||||
#ifndef MQTT_REQ_TIMEOUT
|
||||
#define MQTT_REQ_TIMEOUT 30
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Seconds for MQTT connect response timeout after sending connect request
|
||||
*/
|
||||
#ifndef MQTT_CONNECT_TIMOUT
|
||||
#define MQTT_CONNECT_TIMOUT 100
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_MQTT_OPTS_H */
|
43
tools/sdk/include/lwip/lwip/apps/netbiosns.h
Normal file
43
tools/sdk/include/lwip/lwip/apps/netbiosns.h
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file
|
||||
* NETBIOS name service responder
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_NETBIOS_H
|
||||
#define LWIP_HDR_APPS_NETBIOS_H
|
||||
|
||||
#include "lwip/apps/netbiosns_opts.h"
|
||||
|
||||
void netbiosns_init(void);
|
||||
#ifndef NETBIOS_LWIP_NAME
|
||||
void netbiosns_set_name(const char* hostname);
|
||||
#endif
|
||||
void netbiosns_stop(void);
|
||||
|
||||
#endif /* LWIP_HDR_APPS_NETBIOS_H */
|
59
tools/sdk/include/lwip/lwip/apps/netbiosns_opts.h
Normal file
59
tools/sdk/include/lwip/lwip/apps/netbiosns_opts.h
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @file
|
||||
* NETBIOS name service responder options
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_NETBIOS_OPTS_H
|
||||
#define LWIP_HDR_APPS_NETBIOS_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup netbiosns_opts Options
|
||||
* @ingroup netbiosns
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** NetBIOS name of lwip device
|
||||
* This must be uppercase until NETBIOS_STRCMP() is defined to a string
|
||||
* comparision function that is case insensitive.
|
||||
* If you want to use the netif's hostname, use this (with LWIP_NETIF_HOSTNAME):
|
||||
* (ip_current_netif() != NULL ? ip_current_netif()->hostname != NULL ? ip_current_netif()->hostname : "" : "")
|
||||
*
|
||||
* If this is not defined, netbiosns_set_name() can be called at runtime to change the name.
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define NETBIOS_LWIP_NAME "NETBIOSLWIPDEV"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_NETBIOS_OPTS_H */
|
128
tools/sdk/include/lwip/lwip/apps/snmp.h
Normal file
128
tools/sdk/include/lwip/lwip/apps/snmp.h
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server main API - start and basic configuration
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Martin Hentschel <info@cl-soft.de>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNMP_H
|
||||
#define LWIP_HDR_APPS_SNMP_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
/** SNMP variable binding descriptor (publically needed for traps) */
|
||||
struct snmp_varbind
|
||||
{
|
||||
/** pointer to next varbind, NULL for last in list */
|
||||
struct snmp_varbind *next;
|
||||
/** pointer to previous varbind, NULL for first in list */
|
||||
struct snmp_varbind *prev;
|
||||
|
||||
/** object identifier */
|
||||
struct snmp_obj_id oid;
|
||||
|
||||
/** value ASN1 type */
|
||||
u8_t type;
|
||||
/** object value length */
|
||||
u16_t value_len;
|
||||
/** object value */
|
||||
void *value;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup snmp_core
|
||||
* Agent setup, start listening to port 161.
|
||||
*/
|
||||
void snmp_init(void);
|
||||
void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs);
|
||||
|
||||
void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_oid);
|
||||
const struct snmp_obj_id* snmp_get_device_enterprise_oid(void);
|
||||
|
||||
void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable);
|
||||
void snmp_trap_dst_ip_set(u8_t dst_idx, const ip_addr_t *dst);
|
||||
|
||||
/** Generic trap: cold start */
|
||||
#define SNMP_GENTRAP_COLDSTART 0
|
||||
/** Generic trap: warm start */
|
||||
#define SNMP_GENTRAP_WARMSTART 1
|
||||
/** Generic trap: link down */
|
||||
#define SNMP_GENTRAP_LINKDOWN 2
|
||||
/** Generic trap: link up */
|
||||
#define SNMP_GENTRAP_LINKUP 3
|
||||
/** Generic trap: authentication failure */
|
||||
#define SNMP_GENTRAP_AUTH_FAILURE 4
|
||||
/** Generic trap: EGP neighbor lost */
|
||||
#define SNMP_GENTRAP_EGP_NEIGHBOR_LOSS 5
|
||||
/** Generic trap: enterprise specific */
|
||||
#define SNMP_GENTRAP_ENTERPRISE_SPECIFIC 6
|
||||
|
||||
err_t snmp_send_trap_generic(s32_t generic_trap);
|
||||
err_t snmp_send_trap_specific(s32_t specific_trap, struct snmp_varbind *varbinds);
|
||||
err_t snmp_send_trap(const struct snmp_obj_id* oid, s32_t generic_trap, s32_t specific_trap, struct snmp_varbind *varbinds);
|
||||
|
||||
#define SNMP_AUTH_TRAPS_DISABLED 0
|
||||
#define SNMP_AUTH_TRAPS_ENABLED 1
|
||||
void snmp_set_auth_traps_enabled(u8_t enable);
|
||||
u8_t snmp_get_auth_traps_enabled(void);
|
||||
|
||||
const char * snmp_get_community(void);
|
||||
const char * snmp_get_community_write(void);
|
||||
const char * snmp_get_community_trap(void);
|
||||
void snmp_set_community(const char * const community);
|
||||
void snmp_set_community_write(const char * const community);
|
||||
void snmp_set_community_trap(const char * const community);
|
||||
|
||||
void snmp_coldstart_trap(void);
|
||||
void snmp_authfail_trap(void);
|
||||
|
||||
typedef void (*snmp_write_callback_fct)(const u32_t* oid, u8_t oid_len, void* callback_arg);
|
||||
void snmp_set_write_callback(snmp_write_callback_fct write_callback, void* callback_arg);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_H */
|
364
tools/sdk/include/lwip/lwip/apps/snmp_core.h
Normal file
364
tools/sdk/include/lwip/lwip/apps/snmp_core.h
Normal file
@ -0,0 +1,364 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP core API for implementing MIBs
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
* Martin Hentschel <info@cl-soft.de>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_CORE_H
|
||||
#define LWIP_HDR_APPS_SNMP_CORE_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* basic ASN1 defines */
|
||||
#define SNMP_ASN1_CLASS_UNIVERSAL 0x00
|
||||
#define SNMP_ASN1_CLASS_APPLICATION 0x40
|
||||
#define SNMP_ASN1_CLASS_CONTEXT 0x80
|
||||
#define SNMP_ASN1_CLASS_PRIVATE 0xC0
|
||||
|
||||
#define SNMP_ASN1_CONTENTTYPE_PRIMITIVE 0x00
|
||||
#define SNMP_ASN1_CONTENTTYPE_CONSTRUCTED 0x20
|
||||
|
||||
/* universal tags (from ASN.1 spec.) */
|
||||
#define SNMP_ASN1_UNIVERSAL_END_OF_CONTENT 0
|
||||
#define SNMP_ASN1_UNIVERSAL_INTEGER 2
|
||||
#define SNMP_ASN1_UNIVERSAL_OCTET_STRING 4
|
||||
#define SNMP_ASN1_UNIVERSAL_NULL 5
|
||||
#define SNMP_ASN1_UNIVERSAL_OBJECT_ID 6
|
||||
#define SNMP_ASN1_UNIVERSAL_SEQUENCE_OF 16
|
||||
|
||||
/* application specific (SNMP) tags (from SNMPv2-SMI) */
|
||||
#define SNMP_ASN1_APPLICATION_IPADDR 0 /* [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4)) */
|
||||
#define SNMP_ASN1_APPLICATION_COUNTER 1 /* [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) => u32_t */
|
||||
#define SNMP_ASN1_APPLICATION_GAUGE 2 /* [APPLICATION 2] IMPLICIT INTEGER (0..4294967295) => u32_t */
|
||||
#define SNMP_ASN1_APPLICATION_TIMETICKS 3 /* [APPLICATION 3] IMPLICIT INTEGER (0..4294967295) => u32_t */
|
||||
#define SNMP_ASN1_APPLICATION_OPAQUE 4 /* [APPLICATION 4] IMPLICIT OCTET STRING */
|
||||
#define SNMP_ASN1_APPLICATION_COUNTER64 6 /* [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615) */
|
||||
|
||||
/* context specific (SNMP) tags (from RFC 1905) */
|
||||
#define SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE 1
|
||||
|
||||
/* full ASN1 type defines */
|
||||
#define SNMP_ASN1_TYPE_END_OF_CONTENT (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_END_OF_CONTENT)
|
||||
#define SNMP_ASN1_TYPE_INTEGER (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_INTEGER)
|
||||
#define SNMP_ASN1_TYPE_OCTET_STRING (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OCTET_STRING)
|
||||
#define SNMP_ASN1_TYPE_NULL (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_NULL)
|
||||
#define SNMP_ASN1_TYPE_OBJECT_ID (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OBJECT_ID)
|
||||
#define SNMP_ASN1_TYPE_SEQUENCE (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_CONSTRUCTED | SNMP_ASN1_UNIVERSAL_SEQUENCE_OF)
|
||||
#define SNMP_ASN1_TYPE_IPADDR (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_IPADDR)
|
||||
#define SNMP_ASN1_TYPE_IPADDRESS SNMP_ASN1_TYPE_IPADDR
|
||||
#define SNMP_ASN1_TYPE_COUNTER (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER)
|
||||
#define SNMP_ASN1_TYPE_COUNTER32 SNMP_ASN1_TYPE_COUNTER
|
||||
#define SNMP_ASN1_TYPE_GAUGE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_GAUGE)
|
||||
#define SNMP_ASN1_TYPE_GAUGE32 SNMP_ASN1_TYPE_GAUGE
|
||||
#define SNMP_ASN1_TYPE_UNSIGNED32 SNMP_ASN1_TYPE_GAUGE
|
||||
#define SNMP_ASN1_TYPE_TIMETICKS (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_TIMETICKS)
|
||||
#define SNMP_ASN1_TYPE_OPAQUE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_OPAQUE)
|
||||
#define SNMP_ASN1_TYPE_COUNTER64 (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER64)
|
||||
|
||||
#define SNMP_VARBIND_EXCEPTION_OFFSET 0xF0
|
||||
#define SNMP_VARBIND_EXCEPTION_MASK 0x0F
|
||||
|
||||
/** error codes predefined by SNMP prot. */
|
||||
typedef enum {
|
||||
SNMP_ERR_NOERROR = 0,
|
||||
/*
|
||||
outdated v1 error codes. do not use anmore!
|
||||
#define SNMP_ERR_NOSUCHNAME 2 use SNMP_ERR_NOSUCHINSTANCE instead
|
||||
#define SNMP_ERR_BADVALUE 3 use SNMP_ERR_WRONGTYPE,SNMP_ERR_WRONGLENGTH,SNMP_ERR_WRONGENCODING or SNMP_ERR_WRONGVALUE instead
|
||||
#define SNMP_ERR_READONLY 4 use SNMP_ERR_NOTWRITABLE instead
|
||||
*/
|
||||
SNMP_ERR_GENERROR = 5,
|
||||
SNMP_ERR_NOACCESS = 6,
|
||||
SNMP_ERR_WRONGTYPE = 7,
|
||||
SNMP_ERR_WRONGLENGTH = 8,
|
||||
SNMP_ERR_WRONGENCODING = 9,
|
||||
SNMP_ERR_WRONGVALUE = 10,
|
||||
SNMP_ERR_NOCREATION = 11,
|
||||
SNMP_ERR_INCONSISTENTVALUE = 12,
|
||||
SNMP_ERR_RESOURCEUNAVAILABLE = 13,
|
||||
SNMP_ERR_COMMITFAILED = 14,
|
||||
SNMP_ERR_UNDOFAILED = 15,
|
||||
SNMP_ERR_NOTWRITABLE = 17,
|
||||
SNMP_ERR_INCONSISTENTNAME = 18,
|
||||
|
||||
SNMP_ERR_NOSUCHINSTANCE = SNMP_VARBIND_EXCEPTION_OFFSET + SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE
|
||||
} snmp_err_t;
|
||||
|
||||
/** internal object identifier representation */
|
||||
struct snmp_obj_id
|
||||
{
|
||||
u8_t len;
|
||||
u32_t id[SNMP_MAX_OBJ_ID_LEN];
|
||||
};
|
||||
|
||||
struct snmp_obj_id_const_ref
|
||||
{
|
||||
u8_t len;
|
||||
const u32_t* id;
|
||||
};
|
||||
|
||||
extern const struct snmp_obj_id_const_ref snmp_zero_dot_zero; /* administrative identifier from SNMPv2-SMI */
|
||||
|
||||
/** SNMP variant value, used as reference in struct snmp_node_instance and table implementation */
|
||||
union snmp_variant_value
|
||||
{
|
||||
void* ptr;
|
||||
const void* const_ptr;
|
||||
u32_t u32;
|
||||
s32_t s32;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
SNMP MIB node types
|
||||
tree node is the only node the stack can process in order to walk the tree,
|
||||
all other nodes are assumed to be leaf nodes.
|
||||
This cannot be an enum because users may want to define their own node types.
|
||||
*/
|
||||
#define SNMP_NODE_TREE 0x00
|
||||
/* predefined leaf node types */
|
||||
#define SNMP_NODE_SCALAR 0x01
|
||||
#define SNMP_NODE_SCALAR_ARRAY 0x02
|
||||
#define SNMP_NODE_TABLE 0x03
|
||||
#define SNMP_NODE_THREADSYNC 0x04
|
||||
|
||||
/** node "base class" layout, the mandatory fields for a node */
|
||||
struct snmp_node
|
||||
{
|
||||
/** one out of SNMP_NODE_TREE or any leaf node type (like SNMP_NODE_SCALAR) */
|
||||
u8_t node_type;
|
||||
/** the number assigned to this node which used as part of the full OID */
|
||||
u32_t oid;
|
||||
};
|
||||
|
||||
/** SNMP node instance access types */
|
||||
typedef enum {
|
||||
SNMP_NODE_INSTANCE_ACCESS_READ = 1,
|
||||
SNMP_NODE_INSTANCE_ACCESS_WRITE = 2,
|
||||
SNMP_NODE_INSTANCE_READ_ONLY = SNMP_NODE_INSTANCE_ACCESS_READ,
|
||||
SNMP_NODE_INSTANCE_READ_WRITE = (SNMP_NODE_INSTANCE_ACCESS_READ | SNMP_NODE_INSTANCE_ACCESS_WRITE),
|
||||
SNMP_NODE_INSTANCE_WRITE_ONLY = SNMP_NODE_INSTANCE_ACCESS_WRITE,
|
||||
SNMP_NODE_INSTANCE_NOT_ACCESSIBLE = 0
|
||||
} snmp_access_t;
|
||||
|
||||
struct snmp_node_instance;
|
||||
|
||||
typedef s16_t (*node_instance_get_value_method)(struct snmp_node_instance*, void*);
|
||||
typedef snmp_err_t (*node_instance_set_test_method)(struct snmp_node_instance*, u16_t, void*);
|
||||
typedef snmp_err_t (*node_instance_set_value_method)(struct snmp_node_instance*, u16_t, void*);
|
||||
typedef void (*node_instance_release_method)(struct snmp_node_instance*);
|
||||
|
||||
#define SNMP_GET_VALUE_RAW_DATA 0x8000
|
||||
|
||||
/** SNMP node instance */
|
||||
struct snmp_node_instance
|
||||
{
|
||||
/** prefilled with the node, get_instance() is called on; may be changed by user to any value to pass an arbitrary node between calls to get_instance() and get_value/test_value/set_value */
|
||||
const struct snmp_node* node;
|
||||
/** prefilled with the instance id requested; for get_instance() this is the exact oid requested; for get_next_instance() this is the relative starting point, stack expects relative oid of next node here */
|
||||
struct snmp_obj_id instance_oid;
|
||||
|
||||
/** ASN type for this object (see snmp_asn1.h for definitions) */
|
||||
u8_t asn1_type;
|
||||
/** one out of instance access types defined above (SNMP_NODE_INSTANCE_READ_ONLY,...) */
|
||||
snmp_access_t access;
|
||||
|
||||
/** returns object value for the given object identifier. Return values <0 to indicate an error */
|
||||
node_instance_get_value_method get_value;
|
||||
/** tests length and/or range BEFORE setting */
|
||||
node_instance_set_test_method set_test;
|
||||
/** sets object value, only called when set_test() was successful */
|
||||
node_instance_set_value_method set_value;
|
||||
/** called in any case when the instance is not required anymore by stack (useful for freeing memory allocated in get_instance/get_next_instance methods) */
|
||||
node_instance_release_method release_instance;
|
||||
|
||||
/** reference to pass arbitrary value between calls to get_instance() and get_value/test_value/set_value */
|
||||
union snmp_variant_value reference;
|
||||
/** see reference (if reference is a pointer, the length of underlying data may be stored here or anything else) */
|
||||
u32_t reference_len;
|
||||
};
|
||||
|
||||
|
||||
/** SNMP tree node */
|
||||
struct snmp_tree_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_node node;
|
||||
u16_t subnode_count;
|
||||
const struct snmp_node* const *subnodes;
|
||||
};
|
||||
|
||||
#define SNMP_CREATE_TREE_NODE(oid, subnodes) \
|
||||
{{ SNMP_NODE_TREE, (oid) }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(subnodes), (subnodes) }
|
||||
|
||||
#define SNMP_CREATE_EMPTY_TREE_NODE(oid) \
|
||||
{{ SNMP_NODE_TREE, (oid) }, \
|
||||
0, NULL }
|
||||
|
||||
/** SNMP leaf node */
|
||||
struct snmp_leaf_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_node node;
|
||||
snmp_err_t (*get_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t (*get_next_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
};
|
||||
|
||||
/** represents a single mib with its base oid and root node */
|
||||
struct snmp_mib
|
||||
{
|
||||
const u32_t *base_oid;
|
||||
u8_t base_oid_len;
|
||||
const struct snmp_node *root_node;
|
||||
};
|
||||
|
||||
#define SNMP_MIB_CREATE(oid_list, root_node) { (oid_list), (u8_t)LWIP_ARRAYSIZE(oid_list), root_node }
|
||||
|
||||
/** OID range structure */
|
||||
struct snmp_oid_range
|
||||
{
|
||||
u32_t min;
|
||||
u32_t max;
|
||||
};
|
||||
|
||||
/** checks if incoming OID length and values are in allowed ranges */
|
||||
u8_t snmp_oid_in_range(const u32_t *oid_in, u8_t oid_len, const struct snmp_oid_range *oid_ranges, u8_t oid_ranges_len);
|
||||
|
||||
typedef enum {
|
||||
SNMP_NEXT_OID_STATUS_SUCCESS,
|
||||
SNMP_NEXT_OID_STATUS_NO_MATCH,
|
||||
SNMP_NEXT_OID_STATUS_BUF_TO_SMALL
|
||||
} snmp_next_oid_status_t;
|
||||
|
||||
/** state for next_oid_init / next_oid_check functions */
|
||||
struct snmp_next_oid_state
|
||||
{
|
||||
const u32_t* start_oid;
|
||||
u8_t start_oid_len;
|
||||
|
||||
u32_t* next_oid;
|
||||
u8_t next_oid_len;
|
||||
u8_t next_oid_max_len;
|
||||
|
||||
snmp_next_oid_status_t status;
|
||||
void* reference;
|
||||
};
|
||||
|
||||
void snmp_next_oid_init(struct snmp_next_oid_state *state,
|
||||
const u32_t *start_oid, u8_t start_oid_len,
|
||||
u32_t *next_oid_buf, u8_t next_oid_max_len);
|
||||
u8_t snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len);
|
||||
u8_t snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference);
|
||||
|
||||
void snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
void snmp_oid_combine(struct snmp_obj_id* target, const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len);
|
||||
void snmp_oid_prefix(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
void snmp_oid_append(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
u8_t snmp_oid_equal(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len);
|
||||
s8_t snmp_oid_compare(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len);
|
||||
|
||||
#if LWIP_IPV4
|
||||
u8_t snmp_oid_to_ip4(const u32_t *oid, ip4_addr_t *ip);
|
||||
void snmp_ip4_to_oid(const ip4_addr_t *ip, u32_t *oid);
|
||||
#endif /* LWIP_IPV4 */
|
||||
#if LWIP_IPV6
|
||||
u8_t snmp_oid_to_ip6(const u32_t *oid, ip6_addr_t *ip);
|
||||
void snmp_ip6_to_oid(const ip6_addr_t *ip, u32_t *oid);
|
||||
#endif /* LWIP_IPV6 */
|
||||
#if LWIP_IPV4 || LWIP_IPV6
|
||||
u8_t snmp_ip_to_oid(const ip_addr_t *ip, u32_t *oid);
|
||||
u8_t snmp_ip_port_to_oid(const ip_addr_t *ip, u16_t port, u32_t *oid);
|
||||
|
||||
u8_t snmp_oid_to_ip(const u32_t *oid, u8_t oid_len, ip_addr_t *ip);
|
||||
u8_t snmp_oid_to_ip_port(const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port);
|
||||
#endif /* LWIP_IPV4 || LWIP_IPV6 */
|
||||
|
||||
struct netif;
|
||||
u8_t netif_to_num(const struct netif *netif);
|
||||
|
||||
snmp_err_t snmp_set_test_ok(struct snmp_node_instance* instance, u16_t value_len, void* value); /* generic function which can be used if test is always successful */
|
||||
|
||||
err_t snmp_decode_bits(const u8_t *buf, u32_t buf_len, u32_t *bit_value);
|
||||
err_t snmp_decode_truthvalue(const s32_t *asn1_value, u8_t *bool_value);
|
||||
u8_t snmp_encode_bits(u8_t *buf, u32_t buf_len, u32_t bit_value, u8_t bit_count);
|
||||
u8_t snmp_encode_truthvalue(s32_t *asn1_value, u32_t bool_value);
|
||||
|
||||
struct snmp_statistics
|
||||
{
|
||||
u32_t inpkts;
|
||||
u32_t outpkts;
|
||||
u32_t inbadversions;
|
||||
u32_t inbadcommunitynames;
|
||||
u32_t inbadcommunityuses;
|
||||
u32_t inasnparseerrs;
|
||||
u32_t intoobigs;
|
||||
u32_t innosuchnames;
|
||||
u32_t inbadvalues;
|
||||
u32_t inreadonlys;
|
||||
u32_t ingenerrs;
|
||||
u32_t intotalreqvars;
|
||||
u32_t intotalsetvars;
|
||||
u32_t ingetrequests;
|
||||
u32_t ingetnexts;
|
||||
u32_t insetrequests;
|
||||
u32_t ingetresponses;
|
||||
u32_t intraps;
|
||||
u32_t outtoobigs;
|
||||
u32_t outnosuchnames;
|
||||
u32_t outbadvalues;
|
||||
u32_t outgenerrs;
|
||||
u32_t outgetrequests;
|
||||
u32_t outgetnexts;
|
||||
u32_t outsetrequests;
|
||||
u32_t outgetresponses;
|
||||
u32_t outtraps;
|
||||
};
|
||||
|
||||
extern struct snmp_statistics snmp_stats;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_CORE_H */
|
78
tools/sdk/include/lwip/lwip/apps/snmp_mib2.h
Normal file
78
tools/sdk/include/lwip/lwip/apps/snmp_mib2.h
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP MIB2 API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier <dziegel@gmx.de>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNMP_MIB2_H
|
||||
#define LWIP_HDR_APPS_SNMP_MIB2_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
#if SNMP_LWIP_MIB2
|
||||
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
extern const struct snmp_mib mib2;
|
||||
|
||||
#if SNMP_USE_NETCONN
|
||||
#include "lwip/apps/snmp_threadsync.h"
|
||||
void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg);
|
||||
extern struct snmp_threadsync_instance snmp_mib2_lwip_locks;
|
||||
#endif
|
||||
|
||||
#ifndef SNMP_SYSSERVICES
|
||||
#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
|
||||
#endif
|
||||
|
||||
void snmp_mib2_set_sysdescr(const u8_t* str, const u16_t* len); /* read-only be defintion */
|
||||
void snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize);
|
||||
void snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen);
|
||||
void snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize);
|
||||
void snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen);
|
||||
void snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize);
|
||||
void snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen);
|
||||
|
||||
#endif /* SNMP_LWIP_MIB2 */
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_MIB2_H */
|
293
tools/sdk/include/lwip/lwip/apps/snmp_opts.h
Normal file
293
tools/sdk/include/lwip/lwip/apps/snmp_opts.h
Normal file
@ -0,0 +1,293 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server options list
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Dirk Ziegelmeier
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_SNMP_OPTS_H
|
||||
#define LWIP_HDR_SNMP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup snmp_opts Options
|
||||
* @ingroup snmp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available
|
||||
* for SNMP transport.
|
||||
* If you want to use your own SNMP agent, leave this disabled.
|
||||
* To integrate MIB2 of an external agent, you need to enable
|
||||
* LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks
|
||||
* and statistics counters you need to get MIB2 working.
|
||||
*/
|
||||
#if !defined LWIP_SNMP || defined __DOXYGEN__
|
||||
#define LWIP_SNMP 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_USE_NETCONN: Use netconn API instead of raw API.
|
||||
* Makes SNMP agent run in a worker thread, so blocking operations
|
||||
* can be done in MIB calls.
|
||||
*/
|
||||
#if !defined SNMP_USE_NETCONN || defined __DOXYGEN__
|
||||
#define SNMP_USE_NETCONN 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_USE_RAW: Use raw API.
|
||||
* SNMP agent does not run in a worker thread, so blocking operations
|
||||
* should not be done in MIB calls.
|
||||
*/
|
||||
#if !defined SNMP_USE_RAW || defined __DOXYGEN__
|
||||
#define SNMP_USE_RAW 1
|
||||
#endif
|
||||
|
||||
#if SNMP_USE_NETCONN && SNMP_USE_RAW
|
||||
#error SNMP stack can use only one of the APIs {raw, netconn}
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP && !SNMP_USE_NETCONN && !SNMP_USE_RAW
|
||||
#error SNMP stack needs a receive API and UDP {raw, netconn}
|
||||
#endif
|
||||
|
||||
#if SNMP_USE_NETCONN
|
||||
/**
|
||||
* SNMP_STACK_SIZE: Stack size of SNMP netconn worker thread
|
||||
*/
|
||||
#if !defined SNMP_STACK_SIZE || defined __DOXYGEN__
|
||||
#define SNMP_STACK_SIZE DEFAULT_THREAD_STACKSIZE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_THREAD_PRIO: SNMP netconn worker thread priority
|
||||
*/
|
||||
#if !defined SNMP_THREAD_PRIO || defined __DOXYGEN__
|
||||
#define SNMP_THREAD_PRIO DEFAULT_THREAD_PRIO
|
||||
#endif
|
||||
#endif /* SNMP_USE_NETCONN */
|
||||
|
||||
/**
|
||||
* SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap
|
||||
* destination is required
|
||||
*/
|
||||
#if !defined SNMP_TRAP_DESTINATIONS || defined __DOXYGEN__
|
||||
#define SNMP_TRAP_DESTINATIONS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Only allow SNMP write actions that are 'safe' (e.g. disabling netifs is not
|
||||
* a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
|
||||
* Unsafe requests are disabled by default!
|
||||
*/
|
||||
#if !defined SNMP_SAFE_REQUESTS || defined __DOXYGEN__
|
||||
#define SNMP_SAFE_REQUESTS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of strings used.
|
||||
*/
|
||||
#if !defined SNMP_MAX_OCTET_STRING_LEN || defined __DOXYGEN__
|
||||
#define SNMP_MAX_OCTET_STRING_LEN 127
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum number of Sub ID's inside an object identifier.
|
||||
* Indirectly this also limits the maximum depth of SNMP tree.
|
||||
*/
|
||||
#if !defined SNMP_MAX_OBJ_ID_LEN || defined __DOXYGEN__
|
||||
#define SNMP_MAX_OBJ_ID_LEN 50
|
||||
#endif
|
||||
|
||||
#if !defined SNMP_MAX_VALUE_SIZE || defined __DOXYGEN__
|
||||
/**
|
||||
* The maximum size of a value.
|
||||
*/
|
||||
#define SNMP_MIN_VALUE_SIZE (2 * sizeof(u32_t*)) /* size required to store the basic types (8 bytes for counter64) */
|
||||
/**
|
||||
* The minimum size of a value.
|
||||
*/
|
||||
#define SNMP_MAX_VALUE_SIZE LWIP_MAX(LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN), sizeof(u32_t)*(SNMP_MAX_OBJ_ID_LEN)), SNMP_MIN_VALUE_SIZE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp read-access community. Used for write-access and traps, too
|
||||
* unless SNMP_COMMUNITY_WRITE or SNMP_COMMUNITY_TRAP are enabled, respectively.
|
||||
*/
|
||||
#if !defined SNMP_COMMUNITY || defined __DOXYGEN__
|
||||
#define SNMP_COMMUNITY "public"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp write-access community.
|
||||
* Set this community to "" in order to disallow any write access.
|
||||
*/
|
||||
#if !defined SNMP_COMMUNITY_WRITE || defined __DOXYGEN__
|
||||
#define SNMP_COMMUNITY_WRITE "private"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp community used for sending traps.
|
||||
*/
|
||||
#if !defined SNMP_COMMUNITY_TRAP || defined __DOXYGEN__
|
||||
#define SNMP_COMMUNITY_TRAP "public"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of community string.
|
||||
* If community names shall be adjusted at runtime via snmp_set_community() calls,
|
||||
* enter here the possible maximum length (+1 for terminating null character).
|
||||
*/
|
||||
#if !defined SNMP_MAX_COMMUNITY_STR_LEN || defined __DOXYGEN__
|
||||
#define SNMP_MAX_COMMUNITY_STR_LEN LWIP_MAX(LWIP_MAX(sizeof(SNMP_COMMUNITY), sizeof(SNMP_COMMUNITY_WRITE)), sizeof(SNMP_COMMUNITY_TRAP))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The OID identifiying the device. This may be the enterprise OID itself or any OID located below it in tree.
|
||||
*/
|
||||
#if !defined SNMP_DEVICE_ENTERPRISE_OID || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_ENTERPRISE_OID 26381
|
||||
/**
|
||||
* IANA assigned enterprise ID for lwIP is 26381
|
||||
* @see http://www.iana.org/assignments/enterprise-numbers
|
||||
*
|
||||
* @note this enterprise ID is assigned to the lwIP project,
|
||||
* all object identifiers living under this ID are assigned
|
||||
* by the lwIP maintainers!
|
||||
* @note don't change this define, use snmp_set_device_enterprise_oid()
|
||||
*
|
||||
* If you need to create your own private MIB you'll need
|
||||
* to apply for your own enterprise ID with IANA:
|
||||
* http://www.iana.org/numbers.html
|
||||
*/
|
||||
#define SNMP_DEVICE_ENTERPRISE_OID {1, 3, 6, 1, 4, 1, SNMP_LWIP_ENTERPRISE_OID}
|
||||
/**
|
||||
* Length of SNMP_DEVICE_ENTERPRISE_OID
|
||||
*/
|
||||
#define SNMP_DEVICE_ENTERPRISE_OID_LEN 7
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_DEBUG: Enable debugging for SNMP messages.
|
||||
*/
|
||||
#if !defined SNMP_DEBUG || defined __DOXYGEN__
|
||||
#define SNMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs.
|
||||
*/
|
||||
#if !defined SNMP_MIB_DEBUG || defined __DOXYGEN__
|
||||
#define SNMP_MIB_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Indicates if the MIB2 implementation of LWIP SNMP stack is used.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2 || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2 LWIP_SNMP
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysDesc field of MIB2.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSDESC || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSDESC "lwIP"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysName field of MIB2.
|
||||
* To make sysName field settable, call snmp_mib2_set_sysname() to provide the necessary buffers.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSNAME || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSNAME "FQDN-unk"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysContact field of MIB2.
|
||||
* To make sysContact field settable, call snmp_mib2_set_syscontact() to provide the necessary buffers.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSCONTACT || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSCONTACT ""
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Value return for sysLocation field of MIB2.
|
||||
* To make sysLocation field settable, call snmp_mib2_set_syslocation() to provide the necessary buffers.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_MIB2_SYSLOCATION || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_MIB2_SYSLOCATION ""
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This value is used to limit the repetitions processed in GetBulk requests (value == 0 means no limitation).
|
||||
* This may be useful to limit the load for a single request.
|
||||
* According to SNMP RFC 1905 it is allowed to not return all requested variables from a GetBulk request if system load would be too high.
|
||||
* so the effect is that the client will do more requests to gather all data.
|
||||
* For the stack this could be useful in case that SNMP processing is done in TCP/IP thread. In this situation a request with many
|
||||
* repetitions could block the thread for a longer time. Setting limit here will keep the stack more responsive.
|
||||
*/
|
||||
#if !defined SNMP_LWIP_GETBULK_MAX_REPETITIONS || defined __DOXYGEN__
|
||||
#define SNMP_LWIP_GETBULK_MAX_REPETITIONS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- SNMPv3 options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_SNMP_V3==1: This enables EXPERIMENTAL SNMPv3 support. LWIP_SNMP must
|
||||
* also be enabled.
|
||||
* THIS IS UNDER DEVELOPMENT AND SHOULD NOT BE ENABLED IN PRODUCTS.
|
||||
*/
|
||||
#ifndef LWIP_SNMP_V3
|
||||
#define LWIP_SNMP_V3 0
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_SNMP_V3_CRYPTO
|
||||
#define LWIP_SNMP_V3_CRYPTO LWIP_SNMP_V3
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_SNMP_V3_MBEDTLS
|
||||
#define LWIP_SNMP_V3_MBEDTLS LWIP_SNMP_V3
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_SNMP_OPTS_H */
|
113
tools/sdk/include/lwip/lwip/apps/snmp_scalar.h
Normal file
113
tools/sdk/include/lwip/lwip/apps/snmp_scalar.h
Normal file
@ -0,0 +1,113 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server MIB API to implement scalar nodes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Martin Hentschel <info@cl-soft.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_SCALAR_H
|
||||
#define LWIP_HDR_APPS_SNMP_SCALAR_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/** basic scalar node */
|
||||
struct snmp_scalar_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u8_t asn1_type;
|
||||
snmp_access_t access;
|
||||
node_instance_get_value_method get_value;
|
||||
node_instance_set_test_method set_test;
|
||||
node_instance_set_value_method set_value;
|
||||
};
|
||||
|
||||
|
||||
snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_SCALAR_CREATE_NODE(oid, access, asn1_type, get_value_method, set_test_method, set_value_method) \
|
||||
{{{ SNMP_NODE_SCALAR, (oid) }, \
|
||||
snmp_scalar_get_instance, \
|
||||
snmp_scalar_get_next_instance }, \
|
||||
(asn1_type), (access), (get_value_method), (set_test_method), (set_value_method) }
|
||||
|
||||
#define SNMP_SCALAR_CREATE_NODE_READONLY(oid, asn1_type, get_value_method) SNMP_SCALAR_CREATE_NODE(oid, SNMP_NODE_INSTANCE_READ_ONLY, asn1_type, get_value_method, NULL, NULL)
|
||||
|
||||
/** scalar array node - a tree node which contains scalars only as children */
|
||||
struct snmp_scalar_array_node_def
|
||||
{
|
||||
u32_t oid;
|
||||
u8_t asn1_type;
|
||||
snmp_access_t access;
|
||||
};
|
||||
|
||||
typedef s16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_array_node_def*, void*);
|
||||
typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
|
||||
typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
|
||||
|
||||
/** basic scalar array node */
|
||||
struct snmp_scalar_array_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t array_node_count;
|
||||
const struct snmp_scalar_array_node_def* array_nodes;
|
||||
snmp_scalar_array_get_value_method get_value;
|
||||
snmp_scalar_array_set_test_method set_test;
|
||||
snmp_scalar_array_set_value_method set_value;
|
||||
};
|
||||
|
||||
snmp_err_t snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_SCALAR_CREATE_ARRAY_NODE(oid, array_nodes, get_value_method, set_test_method, set_value_method) \
|
||||
{{{ SNMP_NODE_SCALAR_ARRAY, (oid) }, \
|
||||
snmp_scalar_array_get_instance, \
|
||||
snmp_scalar_array_get_next_instance }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(array_nodes), (array_nodes), (get_value_method), (set_test_method), (set_value_method) }
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_SCALAR_H */
|
134
tools/sdk/include/lwip/lwip/apps/snmp_table.h
Normal file
134
tools/sdk/include/lwip/lwip/apps/snmp_table.h
Normal file
@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server MIB API to implement table nodes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Martin Hentschel <info@cl-soft.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_TABLE_H
|
||||
#define LWIP_HDR_APPS_SNMP_TABLE_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/** default (customizable) read/write table */
|
||||
struct snmp_table_col_def
|
||||
{
|
||||
u32_t index;
|
||||
u8_t asn1_type;
|
||||
snmp_access_t access;
|
||||
};
|
||||
|
||||
/** table node */
|
||||
struct snmp_table_node
|
||||
{
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t column_count;
|
||||
const struct snmp_table_col_def* columns;
|
||||
snmp_err_t (*get_cell_instance)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, struct snmp_node_instance* cell_instance);
|
||||
snmp_err_t (*get_next_cell_instance)(const u32_t* column, struct snmp_obj_id* row_oid, struct snmp_node_instance* cell_instance);
|
||||
/** returns object value for the given object identifier */
|
||||
node_instance_get_value_method get_value;
|
||||
/** tests length and/or range BEFORE setting */
|
||||
node_instance_set_test_method set_test;
|
||||
/** sets object value, only called when set_test() was successful */
|
||||
node_instance_set_value_method set_value;
|
||||
};
|
||||
|
||||
snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_TABLE_CREATE(oid, columns, get_cell_instance_method, get_next_cell_instance_method, get_value_method, set_test_method, set_value_method) \
|
||||
{{{ SNMP_NODE_TABLE, (oid) }, \
|
||||
snmp_table_get_instance, \
|
||||
snmp_table_get_next_instance }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(columns), (columns), \
|
||||
(get_cell_instance_method), (get_next_cell_instance_method), \
|
||||
(get_value_method), (set_test_method), (set_value_method)}
|
||||
|
||||
#define SNMP_TABLE_GET_COLUMN_FROM_OID(oid) ((oid)[1]) /* first array value is (fixed) row entry (fixed to 1) and 2nd value is column, follow3ed by instance */
|
||||
|
||||
|
||||
/** simple read-only table */
|
||||
typedef enum {
|
||||
SNMP_VARIANT_VALUE_TYPE_U32,
|
||||
SNMP_VARIANT_VALUE_TYPE_S32,
|
||||
SNMP_VARIANT_VALUE_TYPE_PTR,
|
||||
SNMP_VARIANT_VALUE_TYPE_CONST_PTR
|
||||
} snmp_table_column_data_type_t;
|
||||
|
||||
struct snmp_table_simple_col_def
|
||||
{
|
||||
u32_t index;
|
||||
u8_t asn1_type;
|
||||
snmp_table_column_data_type_t data_type; /* depending of what union member is used to store the value*/
|
||||
};
|
||||
|
||||
/** simple read-only table node */
|
||||
struct snmp_table_simple_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t column_count;
|
||||
const struct snmp_table_simple_col_def* columns;
|
||||
snmp_err_t (*get_cell_value)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len);
|
||||
snmp_err_t (*get_next_cell_instance_and_value)(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len);
|
||||
};
|
||||
|
||||
snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_table_simple_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
#define SNMP_TABLE_CREATE_SIMPLE(oid, columns, get_cell_value_method, get_next_cell_instance_and_value_method) \
|
||||
{{{ SNMP_NODE_TABLE, (oid) }, \
|
||||
snmp_table_simple_get_instance, \
|
||||
snmp_table_simple_get_next_instance }, \
|
||||
(u16_t)LWIP_ARRAYSIZE(columns), (columns), (get_cell_value_method), (get_next_cell_instance_and_value_method) }
|
||||
|
||||
s16_t snmp_table_extract_value_from_s32ref(struct snmp_node_instance* instance, void* value);
|
||||
s16_t snmp_table_extract_value_from_u32ref(struct snmp_node_instance* instance, void* value);
|
||||
s16_t snmp_table_extract_value_from_refconstptr(struct snmp_node_instance* instance, void* value);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_TABLE_H */
|
114
tools/sdk/include/lwip/lwip/apps/snmp_threadsync.h
Normal file
114
tools/sdk/include/lwip/lwip/apps/snmp_threadsync.h
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @file
|
||||
* SNMP server MIB API to implement thread synchronization
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier <dziegel@gmx.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_THREADSYNC_H
|
||||
#define LWIP_HDR_APPS_SNMP_THREADSYNC_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/apps/snmp_core.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
typedef void (*snmp_threadsync_called_fn)(void* arg);
|
||||
typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg);
|
||||
|
||||
|
||||
/** Thread sync runtime data. For internal usage only. */
|
||||
struct threadsync_data
|
||||
{
|
||||
union {
|
||||
snmp_err_t err;
|
||||
s16_t s16;
|
||||
} retval;
|
||||
union {
|
||||
const u32_t *root_oid;
|
||||
void *value;
|
||||
} arg1;
|
||||
union {
|
||||
u8_t root_oid_len;
|
||||
u16_t len;
|
||||
} arg2;
|
||||
const struct snmp_threadsync_node *threadsync_node;
|
||||
struct snmp_node_instance proxy_instance;
|
||||
};
|
||||
|
||||
/** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */
|
||||
struct snmp_threadsync_instance
|
||||
{
|
||||
sys_sem_t sem;
|
||||
sys_mutex_t sem_usage_mutex;
|
||||
snmp_threadsync_synchronizer_fn sync_fn;
|
||||
struct threadsync_data data;
|
||||
};
|
||||
|
||||
/** SNMP thread sync proxy leaf node */
|
||||
struct snmp_threadsync_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
|
||||
const struct snmp_leaf_node *target;
|
||||
struct snmp_threadsync_instance *instance;
|
||||
};
|
||||
|
||||
snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
/** Create thread sync proxy node */
|
||||
#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \
|
||||
{{{ SNMP_NODE_THREADSYNC, (oid) }, \
|
||||
snmp_threadsync_get_instance, \
|
||||
snmp_threadsync_get_next_instance }, \
|
||||
(target_leaf_node), \
|
||||
(threadsync_instance) }
|
||||
|
||||
/** Create thread sync instance data */
|
||||
void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_THREADSYNC_H */
|
90
tools/sdk/include/lwip/lwip/apps/snmpv3.h
Normal file
90
tools/sdk/include/lwip/lwip/apps/snmpv3.h
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file
|
||||
* Additional SNMPv3 functionality RFC3414 and RFC3826.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Elias Oenal.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* Author: Elias Oenal <lwip@eliasoenal.com>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_SNMP_V3_H
|
||||
#define LWIP_HDR_APPS_SNMP_V3_H
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#if LWIP_SNMP && LWIP_SNMP_V3
|
||||
|
||||
#define SNMP_V3_AUTH_ALGO_INVAL 0
|
||||
#define SNMP_V3_AUTH_ALGO_MD5 1
|
||||
#define SNMP_V3_AUTH_ALGO_SHA 2
|
||||
|
||||
#define SNMP_V3_PRIV_ALGO_INVAL 0
|
||||
#define SNMP_V3_PRIV_ALGO_DES 1
|
||||
#define SNMP_V3_PRIV_ALGO_AES 2
|
||||
|
||||
#define SNMP_V3_PRIV_MODE_DECRYPT 0
|
||||
#define SNMP_V3_PRIV_MODE_ENCRYPT 1
|
||||
|
||||
/*
|
||||
* The following callback functions must be implemented by the application.
|
||||
* There is a dummy implementation in snmpv3_dummy.c.
|
||||
*/
|
||||
|
||||
void snmpv3_get_engine_id(const char **id, u8_t *len);
|
||||
err_t snmpv3_set_engine_id(const char* id, u8_t len);
|
||||
|
||||
u32_t snmpv3_get_engine_boots(void);
|
||||
void snmpv3_set_engine_boots(u32_t boots);
|
||||
|
||||
u32_t snmpv3_get_engine_time(void);
|
||||
void snmpv3_reset_engine_time(void);
|
||||
|
||||
err_t snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *priv_algo, u8_t *priv_key);
|
||||
|
||||
/* The following functions are provided by the SNMPv3 agent */
|
||||
|
||||
void snmpv3_engine_id_changed(void);
|
||||
|
||||
void snmpv3_password_to_key_md5(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength, /* IN - length of snmpEngineID */
|
||||
u8_t *key); /* OUT - pointer to caller 16-octet buffer */
|
||||
|
||||
void snmpv3_password_to_key_sha(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength, /* IN - length of snmpEngineID */
|
||||
u8_t *key); /* OUT - pointer to caller 20-octet buffer */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNMP_V3_H */
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* SNTP client API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt
|
||||
* All rights reserved.
|
||||
@ -32,7 +37,7 @@
|
||||
#ifndef LWIP_HDR_APPS_SNTP_H
|
||||
#define LWIP_HDR_APPS_SNTP_H
|
||||
|
||||
#include "apps/sntp/sntp_opts.h"
|
||||
#include "lwip/apps/sntp_opts.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -51,7 +56,7 @@ void sntp_stop(void);
|
||||
u8_t sntp_enabled(void);
|
||||
|
||||
void sntp_setserver(u8_t idx, const ip_addr_t *addr);
|
||||
ip_addr_t sntp_getserver(u8_t idx);
|
||||
const ip_addr_t* sntp_getserver(u8_t idx);
|
||||
|
||||
#if SNTP_SERVER_DNS
|
||||
void sntp_setservername(u8_t idx, char *server);
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* SNTP client options list
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt
|
||||
* All rights reserved.
|
||||
@ -34,48 +39,53 @@
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup sntp_opts Options
|
||||
* @ingroup sntp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** SNTP macro to change system time in seconds
|
||||
* Define SNTP_SET_SYSTEM_TIME_US(sec, us) to set the time in microseconds instead of this one
|
||||
* if you need the additional precision.
|
||||
*/
|
||||
#ifndef SNTP_SET_SYSTEM_TIME
|
||||
#if !defined SNTP_SET_SYSTEM_TIME || defined __DOXYGEN__
|
||||
#define SNTP_SET_SYSTEM_TIME(sec) LWIP_UNUSED_ARG(sec)
|
||||
#endif
|
||||
|
||||
/** The maximum number of SNTP servers that can be set */
|
||||
#ifndef SNTP_MAX_SERVERS
|
||||
#if !defined SNTP_MAX_SERVERS || defined __DOXYGEN__
|
||||
#define SNTP_MAX_SERVERS LWIP_DHCP_MAX_NTP_SERVERS
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to implement the callback function called by dhcp when
|
||||
* NTP servers are received. */
|
||||
#ifndef SNTP_GET_SERVERS_FROM_DHCP
|
||||
#if !defined SNTP_GET_SERVERS_FROM_DHCP || defined __DOXYGEN__
|
||||
#define SNTP_GET_SERVERS_FROM_DHCP LWIP_DHCP_GET_NTP_SRV
|
||||
#endif
|
||||
|
||||
/* Set this to 1 to support DNS names (or IP address strings) to set sntp servers */
|
||||
#ifndef SNTP_SERVER_DNS
|
||||
/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers
|
||||
* One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
|
||||
* \#define SNTP_SERVER_ADDRESS "pool.ntp.org"
|
||||
*/
|
||||
#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__
|
||||
#define SNTP_SERVER_DNS 1
|
||||
#endif
|
||||
|
||||
/** One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
|
||||
* #define SNTP_SERVER_ADDRESS "pool.ntp.org"
|
||||
*/
|
||||
|
||||
/**
|
||||
* SNTP_DEBUG: Enable debugging for SNTP.
|
||||
*/
|
||||
#ifndef SNTP_DEBUG
|
||||
#if !defined SNTP_DEBUG || defined __DOXYGEN__
|
||||
#define SNTP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** SNTP server port */
|
||||
#ifndef SNTP_PORT
|
||||
#if !defined SNTP_PORT || defined __DOXYGEN__
|
||||
#define SNTP_PORT 123
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to allow config of SNTP server(s) by DNS name */
|
||||
#ifndef SNTP_SERVER_DNS
|
||||
#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__
|
||||
#define SNTP_SERVER_DNS 0
|
||||
#endif
|
||||
|
||||
@ -93,7 +103,7 @@
|
||||
* currently a cozy number like one second. This check avoids using a
|
||||
* server whose synchronization source has expired for a very long time.
|
||||
*/
|
||||
#ifndef SNTP_CHECK_RESPONSE
|
||||
#if !defined SNTP_CHECK_RESPONSE || defined __DOXYGEN__
|
||||
#define SNTP_CHECK_RESPONSE 0
|
||||
#endif
|
||||
|
||||
@ -103,14 +113,14 @@
|
||||
* which must return the delay in milliseconds as u32_t.
|
||||
* Turned off by default.
|
||||
*/
|
||||
#ifndef SNTP_STARTUP_DELAY
|
||||
#if !defined SNTP_STARTUP_DELAY || defined __DOXYGEN__
|
||||
#define SNTP_STARTUP_DELAY 0
|
||||
#endif
|
||||
|
||||
/** If you want the startup delay to be a function, define this
|
||||
* to a function (including the brackets) and define SNTP_STARTUP_DELAY to 1.
|
||||
*/
|
||||
#ifndef SNTP_STARTUP_DELAY_FUNC
|
||||
#if !defined SNTP_STARTUP_DELAY_FUNC || defined __DOXYGEN__
|
||||
#define SNTP_STARTUP_DELAY_FUNC SNTP_STARTUP_DELAY
|
||||
#endif
|
||||
|
||||
@ -118,21 +128,21 @@
|
||||
* Also used as retry timeout - this shouldn't be too low.
|
||||
* Default is 3 seconds.
|
||||
*/
|
||||
#ifndef SNTP_RECV_TIMEOUT
|
||||
#if !defined SNTP_RECV_TIMEOUT || defined __DOXYGEN__
|
||||
#define SNTP_RECV_TIMEOUT 3000
|
||||
#endif
|
||||
|
||||
/** SNTP update delay - in milliseconds
|
||||
* Default is 1 hour. Must not be beolw 15 seconds by specification (i.e. 15000)
|
||||
*/
|
||||
#ifndef SNTP_UPDATE_DELAY
|
||||
#if !defined SNTP_UPDATE_DELAY || defined __DOXYGEN__
|
||||
#define SNTP_UPDATE_DELAY 3600000
|
||||
#endif
|
||||
|
||||
/** SNTP macro to get system time, used with SNTP_CHECK_RESPONSE >= 2
|
||||
* to send in request and compare in response.
|
||||
*/
|
||||
#ifndef SNTP_GET_SYSTEM_TIME
|
||||
#if !defined SNTP_GET_SYSTEM_TIME || defined __DOXYGEN__
|
||||
#define SNTP_GET_SYSTEM_TIME(sec, us) do { (sec) = 0; (us) = 0; } while(0)
|
||||
#endif
|
||||
|
||||
@ -140,20 +150,24 @@
|
||||
* received is invalid.
|
||||
* This is doubled with each retry until SNTP_RETRY_TIMEOUT_MAX is reached.
|
||||
*/
|
||||
#ifndef SNTP_RETRY_TIMEOUT
|
||||
#if !defined SNTP_RETRY_TIMEOUT || defined __DOXYGEN__
|
||||
#define SNTP_RETRY_TIMEOUT SNTP_RECV_TIMEOUT
|
||||
#endif
|
||||
|
||||
/** Maximum retry timeout (in milliseconds). */
|
||||
#ifndef SNTP_RETRY_TIMEOUT_MAX
|
||||
#if !defined SNTP_RETRY_TIMEOUT_MAX || defined __DOXYGEN__
|
||||
#define SNTP_RETRY_TIMEOUT_MAX (SNTP_RETRY_TIMEOUT * 10)
|
||||
#endif
|
||||
|
||||
/** Increase retry timeout with every retry sent
|
||||
* Default is on to conform to RFC.
|
||||
*/
|
||||
#ifndef SNTP_RETRY_TIMEOUT_EXP
|
||||
#if !defined SNTP_RETRY_TIMEOUT_EXP || defined __DOXYGEN__
|
||||
#define SNTP_RETRY_TIMEOUT_EXP 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNTP_OPTS_H */
|
105
tools/sdk/include/lwip/lwip/apps/tftp_opts.h
Normal file
105
tools/sdk/include/lwip/lwip/apps/tftp_opts.h
Normal file
@ -0,0 +1,105 @@
|
||||
/****************************************************************//**
|
||||
*
|
||||
* @file tftp_opts.h
|
||||
*
|
||||
* @author Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
* @brief Trivial File Transfer Protocol (RFC 1350) implementation options
|
||||
*
|
||||
* Copyright (c) Deltatee Enterprises Ltd. 2013
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* Author: Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_TFTP_OPTS_H
|
||||
#define LWIP_HDR_APPS_TFTP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* @defgroup tftp_opts Options
|
||||
* @ingroup tftp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable TFTP debug messages
|
||||
*/
|
||||
#if !defined TFTP_DEBUG || defined __DOXYGEN__
|
||||
#define TFTP_DEBUG LWIP_DBG_ON
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TFTP server port
|
||||
*/
|
||||
#if !defined TFTP_PORT || defined __DOXYGEN__
|
||||
#define TFTP_PORT 69
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TFTP timeout
|
||||
*/
|
||||
#if !defined TFTP_TIMEOUT_MSECS || defined __DOXYGEN__
|
||||
#define TFTP_TIMEOUT_MSECS 10000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Max. number of retries when a file is read from server
|
||||
*/
|
||||
#if !defined TFTP_MAX_RETRIES || defined __DOXYGEN__
|
||||
#define TFTP_MAX_RETRIES 5
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TFTP timer cyclic interval
|
||||
*/
|
||||
#if !defined TFTP_TIMER_MSECS || defined __DOXYGEN__
|
||||
#define TFTP_TIMER_MSECS 50
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Max. length of TFTP filename
|
||||
*/
|
||||
#if !defined TFTP_MAX_FILENAME_LEN || defined __DOXYGEN__
|
||||
#define TFTP_MAX_FILENAME_LEN 20
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Max. length of TFTP mode
|
||||
*/
|
||||
#if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__
|
||||
#define TFTP_MAX_MODE_LEN 7
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_TFTP_OPTS_H */
|
94
tools/sdk/include/lwip/lwip/apps/tftp_server.h
Normal file
94
tools/sdk/include/lwip/lwip/apps/tftp_server.h
Normal file
@ -0,0 +1,94 @@
|
||||
/****************************************************************//**
|
||||
*
|
||||
* @file tftp_server.h
|
||||
*
|
||||
* @author Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
* @brief Trivial File Transfer Protocol (RFC 1350)
|
||||
*
|
||||
* Copyright (c) Deltatee Enterprises Ltd. 2013
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* Author: Logan Gunthorpe <logang@deltatee.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_TFTP_SERVER_H
|
||||
#define LWIP_HDR_APPS_TFTP_SERVER_H
|
||||
|
||||
#include "lwip/apps/tftp_opts.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @ingroup tftp
|
||||
* TFTP context containing callback functions for TFTP transfers
|
||||
*/
|
||||
struct tftp_context {
|
||||
/**
|
||||
* Open file for read/write.
|
||||
* @param fname Filename
|
||||
* @param mode Mode string from TFTP RFC 1350 (netascii, octet, mail)
|
||||
* @param write Flag indicating read (0) or write (!= 0) access
|
||||
* @returns File handle supplied to other functions
|
||||
*/
|
||||
void* (*open)(const char* fname, const char* mode, u8_t write);
|
||||
/**
|
||||
* Close file handle
|
||||
* @param handle File handle returned by open()
|
||||
*/
|
||||
void (*close)(void* handle);
|
||||
/**
|
||||
* Read from file
|
||||
* @param handle File handle returned by open()
|
||||
* @param buf Target buffer to copy read data to
|
||||
* @param bytes Number of bytes to copy to buf
|
||||
* @returns >= 0: Success; < 0: Error
|
||||
*/
|
||||
int (*read)(void* handle, void* buf, int bytes);
|
||||
/**
|
||||
* Write to file
|
||||
* @param handle File handle returned by open()
|
||||
* @param pbuf PBUF adjusted such that payload pointer points
|
||||
* to the beginning of write data. In other words,
|
||||
* TFTP headers are stripped off.
|
||||
* @returns >= 0: Success; < 0: Error
|
||||
*/
|
||||
int (*write)(void* handle, struct pbuf* p);
|
||||
};
|
||||
|
||||
err_t tftp_init(const struct tftp_context* ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_TFTP_SERVER_H */
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Support for different processor and compiler architectures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -42,189 +47,269 @@
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
/** Temporary: define format string for size_t if not defined in cc.h */
|
||||
#ifndef SZT_F
|
||||
#define SZT_F U32_F
|
||||
#endif /* SZT_F */
|
||||
/** Temporary upgrade helper: define format string for u8_t as hex if not
|
||||
defined in cc.h */
|
||||
/**
|
||||
* @defgroup compiler_abstraction Compiler/platform abstraction
|
||||
* @ingroup sys_layer
|
||||
* All defines related to this section must not be placed in lwipopts.h,
|
||||
* but in arch/cc.h!
|
||||
* These options cannot be \#defined in lwipopts.h since they are not options
|
||||
* of lwIP itself, but options of the lwIP port to your system.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Define the byte order of the system.
|
||||
* Needed for conversion of network data to host byte order.
|
||||
* Allowed values: LITTLE_ENDIAN and BIG_ENDIAN
|
||||
*/
|
||||
#ifndef BYTE_ORDER
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
/** Define random number generator function of your system */
|
||||
#ifdef __DOXYGEN__
|
||||
#define LWIP_RAND() ((u32_t)rand())
|
||||
#endif
|
||||
|
||||
/** Platform specific diagnostic output.\n
|
||||
* Note the default implementation pulls in printf, which may
|
||||
* in turn pull in a lot of standard libary code. In resource-constrained
|
||||
* systems, this should be defined to something less resource-consuming.
|
||||
*/
|
||||
#ifndef LWIP_PLATFORM_DIAG
|
||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/** Platform specific assertion handling.\n
|
||||
* Note the default implementation pulls in printf, fflush and abort, which may
|
||||
* in turn pull in a lot of standard libary code. In resource-constrained
|
||||
* systems, this should be defined to something less resource-consuming.
|
||||
*/
|
||||
#ifndef LWIP_PLATFORM_ASSERT
|
||||
#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \
|
||||
x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/** Define this to 1 in arch/cc.h of your port if you do not want to
|
||||
* include stddef.h header to get size_t. You need to typedef size_t
|
||||
* by yourself in this case.
|
||||
*/
|
||||
#ifndef LWIP_NO_STDDEF_H
|
||||
#define LWIP_NO_STDDEF_H 0
|
||||
#endif
|
||||
|
||||
#if !LWIP_NO_STDDEF_H
|
||||
#include <stddef.h> /* for size_t */
|
||||
#endif
|
||||
|
||||
/** Define this to 1 in arch/cc.h of your port if your compiler does not provide
|
||||
* the stdint.h header. You need to typedef the generic types listed in
|
||||
* lwip/arch.h yourself in this case (u8_t, u16_t...).
|
||||
*/
|
||||
#ifndef LWIP_NO_STDINT_H
|
||||
#define LWIP_NO_STDINT_H 0
|
||||
#endif
|
||||
|
||||
/* Define generic types used in lwIP */
|
||||
#if !LWIP_NO_STDINT_H
|
||||
#include <stdint.h>
|
||||
typedef uint8_t u8_t;
|
||||
typedef int8_t s8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef int16_t s16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef int32_t s32_t;
|
||||
#endif
|
||||
|
||||
/** Define this to 1 in arch/cc.h of your port if your compiler does not provide
|
||||
* the inttypes.h header. You need to define the format strings listed in
|
||||
* lwip/arch.h yourself in this case (X8_F, U16_F...).
|
||||
*/
|
||||
#ifndef LWIP_NO_INTTYPES_H
|
||||
#define LWIP_NO_INTTYPES_H 0
|
||||
#endif
|
||||
|
||||
/* Define (sn)printf formatters for these lwIP types */
|
||||
#if !LWIP_NO_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#ifndef X8_F
|
||||
#define X8_F "02x"
|
||||
#endif /* X8_F */
|
||||
#define X8_F "02" PRIx8
|
||||
#endif
|
||||
#ifndef U16_F
|
||||
#define U16_F PRIu16
|
||||
#endif
|
||||
#ifndef S16_F
|
||||
#define S16_F PRId16
|
||||
#endif
|
||||
#ifndef X16_F
|
||||
#define X16_F PRIx16
|
||||
#endif
|
||||
#ifndef U32_F
|
||||
#define U32_F PRIu32
|
||||
#endif
|
||||
#ifndef S32_F
|
||||
#define S32_F PRId32
|
||||
#endif
|
||||
#ifndef X32_F
|
||||
#define X32_F PRIx32
|
||||
#endif
|
||||
#ifndef SZT_F
|
||||
#define SZT_F PRIuPTR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Define this to 1 in arch/cc.h of your port if your compiler does not provide
|
||||
* the limits.h header. You need to define the type limits yourself in this case
|
||||
* (e.g. INT_MAX).
|
||||
*/
|
||||
#ifndef LWIP_NO_LIMITS_H
|
||||
#define LWIP_NO_LIMITS_H 0
|
||||
#endif
|
||||
|
||||
/* Include limits.h? */
|
||||
#if !LWIP_NO_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/** C++ const_cast<target_type>(val) equivalent to remove constness from a value (GCC -Wcast-qual) */
|
||||
#ifndef LWIP_CONST_CAST
|
||||
#define LWIP_CONST_CAST(target_type, val) ((target_type)((ptrdiff_t)val))
|
||||
#endif
|
||||
|
||||
/** Get rid of alignment cast warnings (GCC -Wcast-align) */
|
||||
#ifndef LWIP_ALIGNMENT_CAST
|
||||
#define LWIP_ALIGNMENT_CAST(target_type, val) LWIP_CONST_CAST(target_type, val)
|
||||
#endif
|
||||
|
||||
/** Get rid of warnings related to pointer-to-numeric and vice-versa casts,
|
||||
* e.g. "conversion from 'u8_t' to 'void *' of greater size"
|
||||
*/
|
||||
#ifndef LWIP_PTR_NUMERIC_CAST
|
||||
#define LWIP_PTR_NUMERIC_CAST(target_type, val) LWIP_CONST_CAST(target_type, val)
|
||||
#endif
|
||||
|
||||
/** Allocates a memory buffer of specified size that is of sufficient size to align
|
||||
* its start address using LWIP_MEM_ALIGN.
|
||||
* You can declare your own version here e.g. to enforce alignment without adding
|
||||
* trailing padding bytes (see LWIP_MEM_ALIGN_BUFFER) or your own section placement
|
||||
* requirements.\n
|
||||
* e.g. if you use gcc and need 32 bit alignment:\n
|
||||
* \#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[size] \_\_attribute\_\_((aligned(4)))\n
|
||||
* or more portable:\n
|
||||
* \#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u32_t variable_name[(size + sizeof(u32_t) - 1) / sizeof(u32_t)]
|
||||
*/
|
||||
#ifndef LWIP_DECLARE_MEMORY_ALIGNED
|
||||
#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)]
|
||||
#endif
|
||||
|
||||
/** Calculate memory size for an aligned buffer - returns the next highest
|
||||
* multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and
|
||||
* LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4).
|
||||
*/
|
||||
#ifndef LWIP_MEM_ALIGN_SIZE
|
||||
#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1U) & ~(MEM_ALIGNMENT-1U))
|
||||
#endif
|
||||
|
||||
/** Calculate safe memory size for an aligned buffer when using an unaligned
|
||||
* type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the
|
||||
* start (e.g. if buffer is u8_t[] and actual data will be u32_t*)
|
||||
*/
|
||||
#ifndef LWIP_MEM_ALIGN_BUFFER
|
||||
#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1U))
|
||||
#endif
|
||||
|
||||
/** Align a memory pointer to the alignment defined by MEM_ALIGNMENT
|
||||
* so that ADDR % MEM_ALIGNMENT == 0
|
||||
*/
|
||||
#ifndef LWIP_MEM_ALIGN
|
||||
#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Packed structs support.
|
||||
* Placed BEFORE declaration of a packed struct.\n
|
||||
* For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n
|
||||
* A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.
|
||||
*/
|
||||
#ifndef PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#endif /* PACK_STRUCT_BEGIN */
|
||||
|
||||
/** Packed structs support.
|
||||
* Placed AFTER declaration of a packed struct.\n
|
||||
* For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n
|
||||
* A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.
|
||||
*/
|
||||
#ifndef PACK_STRUCT_END
|
||||
#define PACK_STRUCT_END
|
||||
#endif /* PACK_STRUCT_END */
|
||||
|
||||
/** Packed structs support.
|
||||
* Placed between end of declaration of a packed struct and trailing semicolon.\n
|
||||
* For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n
|
||||
* A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.
|
||||
*/
|
||||
#ifndef PACK_STRUCT_STRUCT
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
#else
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#endif
|
||||
#endif /* PACK_STRUCT_STRUCT */
|
||||
|
||||
/** Packed structs support.
|
||||
* Wraps u32_t and u16_t members.\n
|
||||
* For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n
|
||||
* A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.
|
||||
*/
|
||||
#ifndef PACK_STRUCT_FIELD
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#endif /* PACK_STRUCT_FIELD */
|
||||
|
||||
/* Used for struct fields of u8_t,
|
||||
* where some compilers warn that packing is not necessary */
|
||||
/** Packed structs support.
|
||||
* Wraps u8_t members, where some compilers warn that packing is not necessary.\n
|
||||
* For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n
|
||||
* A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.
|
||||
*/
|
||||
#ifndef PACK_STRUCT_FLD_8
|
||||
#define PACK_STRUCT_FLD_8(x) PACK_STRUCT_FIELD(x)
|
||||
#endif /* PACK_STRUCT_FLD_8 */
|
||||
|
||||
/* Used for struct fields of that are packed structs themself,
|
||||
* where some compilers warn that packing is not necessary */
|
||||
/** Packed structs support.
|
||||
* Wraps members that are packed structs themselves, where some compilers warn that packing is not necessary.\n
|
||||
* For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n
|
||||
* A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.
|
||||
*/
|
||||
#ifndef PACK_STRUCT_FLD_S
|
||||
#define PACK_STRUCT_FLD_S(x) PACK_STRUCT_FIELD(x)
|
||||
#endif /* PACK_STRUCT_FLD_S */
|
||||
|
||||
/** Packed structs support using \#include files before and after struct to be packed.\n
|
||||
* The file included BEFORE the struct is "arch/bpstruct.h".\n
|
||||
* The file included AFTER the struct is "arch/epstruct.h".\n
|
||||
* This can be used to implement struct packing on MS Visual C compilers, see
|
||||
* the Win32 port in the lwIP contrib repository for reference.
|
||||
* For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n
|
||||
* A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here.
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define PACK_STRUCT_USE_INCLUDES
|
||||
#endif
|
||||
|
||||
/** Eliminates compiler warning about unused arguments (GCC -Wextra -Wunused). */
|
||||
#ifndef LWIP_UNUSED_ARG
|
||||
#define LWIP_UNUSED_ARG(x) (void)x
|
||||
#endif /* LWIP_UNUSED_ARG */
|
||||
|
||||
|
||||
#ifdef LWIP_PROVIDE_ERRNO
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_PROVIDE_ERRNO */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -36,9 +36,6 @@
|
||||
* This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
|
||||
* with RFC 3927.
|
||||
*
|
||||
*
|
||||
* Please coordinate changes and requests with Dominik Spies
|
||||
* <kontakt@dspies.de>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_AUTOIP_H
|
||||
@ -50,16 +47,17 @@
|
||||
|
||||
#include "lwip/netif.h"
|
||||
/* #include "lwip/udp.h" */
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/etharp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* AutoIP Timing */
|
||||
/** AutoIP Timing */
|
||||
#define AUTOIP_TMR_INTERVAL 100
|
||||
#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
|
||||
|
||||
#if ESP_LWIP
|
||||
/* RFC 3927 Constants */
|
||||
#define PROBE_WAIT 1 /* second (initial random delay) */
|
||||
#define PROBE_MIN 1 /* second (minimum delay till repeated probe) */
|
||||
@ -77,43 +75,40 @@ extern "C" {
|
||||
#define AUTOIP_STATE_PROBING 1
|
||||
#define AUTOIP_STATE_ANNOUNCING 2
|
||||
#define AUTOIP_STATE_BOUND 3
|
||||
#endif
|
||||
|
||||
/** AutoIP state information per netif */
|
||||
struct autoip
|
||||
{
|
||||
ip4_addr_t llipaddr; /* the currently selected, probed, announced or used LL IP-Address */
|
||||
u8_t state; /* current AutoIP state machine state */
|
||||
u8_t sent_num; /* sent number of probes or announces, dependent on state */
|
||||
u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
|
||||
u8_t lastconflict; /* ticks until a conflict can be solved by defending */
|
||||
u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */
|
||||
/** the currently selected, probed, announced or used LL IP-Address */
|
||||
ip4_addr_t llipaddr;
|
||||
/** current AutoIP state machine state */
|
||||
u8_t state;
|
||||
/** sent number of probes or announces, dependent on state */
|
||||
u8_t sent_num;
|
||||
/** ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
|
||||
u16_t ttw;
|
||||
/** ticks until a conflict can be solved by defending */
|
||||
u8_t lastconflict;
|
||||
/** total number of probed/used Link Local IP-Addresses */
|
||||
u8_t tried_llipaddr;
|
||||
};
|
||||
|
||||
|
||||
#define autoip_init() /* Compatibility define, no init needed. */
|
||||
|
||||
/** Set a struct autoip allocated by the application to work with */
|
||||
void autoip_set_struct(struct netif *netif, struct autoip *autoip);
|
||||
|
||||
/** Remove a struct autoip previously set to the netif using autoip_set_struct() */
|
||||
#define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0)
|
||||
|
||||
/** Start AutoIP client */
|
||||
err_t autoip_start(struct netif *netif);
|
||||
|
||||
/** Stop AutoIP client */
|
||||
err_t autoip_stop(struct netif *netif);
|
||||
|
||||
/** Handles every incoming ARP Packet, called by etharp_arp_input */
|
||||
void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
|
||||
|
||||
/** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
|
||||
void autoip_tmr(void);
|
||||
|
||||
/** Handle a possible change in the network configuration */
|
||||
void autoip_network_changed(struct netif *netif);
|
||||
u8_t autoip_supplied_address(const struct netif *netif);
|
||||
|
||||
/** check if AutoIP supplied netif->ip_addr */
|
||||
u8_t autoip_supplied_address(struct netif *netif);
|
||||
/* for lwIP internal use by ip4.c */
|
||||
u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr);
|
||||
|
||||
#define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Debug messages infrastructure
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -35,24 +40,45 @@
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/** lower two bits indicate debug level
|
||||
* - 0 all
|
||||
* - 1 warning
|
||||
* - 2 serious
|
||||
* - 3 severe
|
||||
/**
|
||||
* @defgroup debugging_levels LWIP_DBG_MIN_LEVEL and LWIP_DBG_TYPES_ON values
|
||||
* @ingroup lwip_opts_debugmsg
|
||||
* @{
|
||||
*/
|
||||
#define LWIP_DBG_LEVEL_ALL 0x00
|
||||
#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */
|
||||
#define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
|
||||
#define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
|
||||
#define LWIP_DBG_LEVEL_SEVERE 0x03
|
||||
#define LWIP_DBG_MASK_LEVEL 0x03
|
||||
|
||||
/** @name Debug level (LWIP_DBG_MIN_LEVEL)
|
||||
* @{
|
||||
*/
|
||||
/** Debug level: ALL messages*/
|
||||
#define LWIP_DBG_LEVEL_ALL 0x00
|
||||
/** Debug level: Warnings. bad checksums, dropped packets, ... */
|
||||
#define LWIP_DBG_LEVEL_WARNING 0x01
|
||||
/** Debug level: Serious. memory allocation failures, ... */
|
||||
#define LWIP_DBG_LEVEL_SERIOUS 0x02
|
||||
/** Debug level: Severe */
|
||||
#define LWIP_DBG_LEVEL_SEVERE 0x03
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define LWIP_DBG_MASK_LEVEL 0x03
|
||||
/* compatibility define only */
|
||||
#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL
|
||||
|
||||
/** @name Enable/disable debug messages completely (LWIP_DBG_TYPES_ON)
|
||||
* @{
|
||||
*/
|
||||
/** flag for LWIP_DEBUGF to enable that debug message */
|
||||
#define LWIP_DBG_ON 0x80U
|
||||
/** flag for LWIP_DEBUGF to disable that debug message */
|
||||
#define LWIP_DBG_OFF 0x00U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @name Debug message types (LWIP_DBG_TYPES_ON)
|
||||
* @{
|
||||
*/
|
||||
/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
|
||||
#define LWIP_DBG_TRACE 0x40U
|
||||
/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
|
||||
@ -61,14 +87,34 @@
|
||||
#define LWIP_DBG_FRESH 0x10U
|
||||
/** flag for LWIP_DEBUGF to halt after printing this debug message */
|
||||
#define LWIP_DBG_HALT 0x08U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_NOASSERT: Disable LWIP_ASSERT checks.
|
||||
* -- To disable assertions define LWIP_NOASSERT in arch/cc.h.
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lwip_assertions Assertion handling
|
||||
* @ingroup lwip_opts_debug
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* LWIP_NOASSERT: Disable LWIP_ASSERT checks:
|
||||
* To disable assertions define LWIP_NOASSERT in arch/cc.h.
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define LWIP_NOASSERT
|
||||
#undef LWIP_NOASSERT
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef LWIP_NOASSERT
|
||||
#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \
|
||||
LWIP_PLATFORM_ASSERT(message); } while(0)
|
||||
#define LWIP_ASSERT(message, assertion) do { if (!(assertion)) { \
|
||||
LWIP_PLATFORM_ASSERT(message); }} while(0)
|
||||
#ifndef LWIP_PLATFORM_ASSERT
|
||||
#error "If you want to use LWIP_ASSERT, LWIP_PLATFORM_ASSERT(message) needs to be defined in your arch/cc.h"
|
||||
#endif
|
||||
@ -76,7 +122,6 @@
|
||||
#define LWIP_ASSERT(message, assertion)
|
||||
#endif /* LWIP_NOASSERT */
|
||||
|
||||
/** if "expression" isn't true, then print "message" and execute "handler" expression */
|
||||
#ifndef LWIP_ERROR
|
||||
#ifndef LWIP_NOASSERT
|
||||
#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_ASSERT(message)
|
||||
@ -86,17 +131,23 @@
|
||||
#define LWIP_PLATFORM_ERROR(message)
|
||||
#endif
|
||||
|
||||
/* if "expression" isn't true, then print "message" and execute "handler" expression */
|
||||
#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
|
||||
LWIP_PLATFORM_ERROR(message); handler;}} while(0)
|
||||
#endif /* LWIP_ERROR */
|
||||
|
||||
/** Enable debug message printing, but only if debug message type is enabled
|
||||
* AND is of correct type AND is at least LWIP_DBG_LEVEL.
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define LWIP_DEBUG
|
||||
#undef LWIP_DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
#ifndef LWIP_PLATFORM_DIAG
|
||||
#error "If you want to use LWIP_DEBUG, LWIP_PLATFORM_DIAG(message) needs to be defined in your arch/cc.h"
|
||||
#endif
|
||||
/** print debug message only if debug message type is enabled...
|
||||
* AND is of correct type AND is at least LWIP_DBG_LEVEL
|
||||
*/
|
||||
#define LWIP_DEBUGF(debug, message) do { \
|
||||
if ( \
|
||||
((debug) & LWIP_DBG_ON) && \
|
||||
@ -114,4 +165,3 @@
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
#endif /* LWIP_HDR_DEBUG_H */
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* various utility macros
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -52,43 +57,20 @@ extern "C" {
|
||||
/* Get the number of entries in an array ('x' must NOT be a pointer!) */
|
||||
#define LWIP_ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
/** Create u32_t value from bytes */
|
||||
#define LWIP_MAKEU32(a,b,c,d) (((u32_t)((a) & 0xff) << 24) | \
|
||||
((u32_t)((b) & 0xff) << 16) | \
|
||||
((u32_t)((c) & 0xff) << 8) | \
|
||||
(u32_t)((d) & 0xff))
|
||||
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
/* Endianess-optimized shifting of two u8_t to create one u16_t */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define LWIP_MAKE_U16(a, b) ((a << 8) | b)
|
||||
#else
|
||||
#define LWIP_MAKE_U16(a, b) ((b << 8) | a)
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_PLATFORM_BYTESWAP
|
||||
#define LWIP_PLATFORM_BYTESWAP 0
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_PREFIX_BYTEORDER_FUNCS
|
||||
/* workaround for naming collisions on some platforms */
|
||||
|
||||
#ifdef htons
|
||||
#undef htons
|
||||
#endif /* htons */
|
||||
#ifdef htonl
|
||||
#undef htonl
|
||||
#endif /* htonl */
|
||||
#ifdef ntohs
|
||||
#undef ntohs
|
||||
#endif /* ntohs */
|
||||
#ifdef ntohl
|
||||
#undef ntohl
|
||||
#endif /* ntohl */
|
||||
|
||||
#define htons(x) lwip_htons(x)
|
||||
#define ntohs(x) lwip_ntohs(x)
|
||||
#define htonl(x) lwip_htonl(x)
|
||||
#define ntohl(x) lwip_ntohl(x)
|
||||
#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define lwip_htons(x) (x)
|
||||
#define lwip_ntohs(x) (x)
|
||||
@ -99,34 +81,61 @@ extern "C" {
|
||||
#define PP_HTONL(x) (x)
|
||||
#define PP_NTOHL(x) (x)
|
||||
#else /* BYTE_ORDER != BIG_ENDIAN */
|
||||
#if LWIP_PLATFORM_BYTESWAP
|
||||
#define lwip_htons(x) LWIP_PLATFORM_HTONS(x)
|
||||
#define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x)
|
||||
#define lwip_htonl(x) LWIP_PLATFORM_HTONL(x)
|
||||
#define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x)
|
||||
#else /* LWIP_PLATFORM_BYTESWAP */
|
||||
#ifndef lwip_htons
|
||||
u16_t lwip_htons(u16_t x);
|
||||
u16_t lwip_ntohs(u16_t x);
|
||||
#endif
|
||||
#define lwip_ntohs(x) lwip_htons(x)
|
||||
|
||||
#ifndef lwip_htonl
|
||||
u32_t lwip_htonl(u32_t x);
|
||||
u32_t lwip_ntohl(u32_t x);
|
||||
#endif /* LWIP_PLATFORM_BYTESWAP */
|
||||
#endif
|
||||
#define lwip_ntohl(x) lwip_htonl(x)
|
||||
|
||||
/* These macros should be calculated by the preprocessor and are used
|
||||
with compile-time constants only (so that there is no little-endian
|
||||
overhead at runtime). */
|
||||
#define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
|
||||
#define PP_HTONS(x) ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8))
|
||||
#define PP_NTOHS(x) PP_HTONS(x)
|
||||
#define PP_HTONL(x) ((((x) & 0xff) << 24) | \
|
||||
(((x) & 0xff00) << 8) | \
|
||||
(((x) & 0xff0000UL) >> 8) | \
|
||||
#define PP_HTONL(x) ((((x) & 0x000000ffUL) << 24) | \
|
||||
(((x) & 0x0000ff00UL) << 8) | \
|
||||
(((x) & 0x00ff0000UL) >> 8) | \
|
||||
(((x) & 0xff000000UL) >> 24))
|
||||
#define PP_NTOHL(x) PP_HTONL(x)
|
||||
|
||||
#endif /* BYTE_ORDER == BIG_ENDIAN */
|
||||
|
||||
/* Provide usual function names as macros for users, but this can be turned off */
|
||||
#ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
|
||||
#define htons(x) lwip_htons(x)
|
||||
#define ntohs(x) lwip_ntohs(x)
|
||||
#define htonl(x) lwip_htonl(x)
|
||||
#define ntohl(x) lwip_ntohl(x)
|
||||
#endif
|
||||
|
||||
/* Functions that are not available as standard implementations.
|
||||
* In cc.h, you can #define these to implementations available on
|
||||
* your platform to save some code bytes if you use these functions
|
||||
* in your application, too.
|
||||
*/
|
||||
|
||||
#ifndef lwip_itoa
|
||||
/* This can be #defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform */
|
||||
void lwip_itoa(char* result, size_t bufsize, int number);
|
||||
#endif
|
||||
#ifndef lwip_strnicmp
|
||||
/* This can be #defined to strnicmp() or strncasecmp() depending on your platform */
|
||||
int lwip_strnicmp(const char* str1, const char* str2, size_t len);
|
||||
#endif
|
||||
#ifndef lwip_stricmp
|
||||
/* This can be #defined to stricmp() or strcasecmp() depending on your platform */
|
||||
int lwip_stricmp(const char* str1, const char* str2);
|
||||
#endif
|
||||
#ifndef lwip_strnstr
|
||||
/* This can be #defined to strnstr() depending on your platform */
|
||||
char* lwip_strnstr(const char* buffer, const char* token, size_t n);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_DEF_H */
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* DHCP client API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Leon Woestenberg <leon.woestenberg@gmx.net>
|
||||
* Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands.
|
||||
@ -45,15 +50,23 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** period (in seconds) of the application calling dhcp_coarse_tmr() */
|
||||
#if ESP_DHCP
|
||||
#define DHCP_COARSE_TIMER_SECS 1
|
||||
#else
|
||||
#define DHCP_COARSE_TIMER_SECS 60
|
||||
#endif
|
||||
/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */
|
||||
#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL)
|
||||
/** period (in milliseconds) of the application calling dhcp_fine_tmr() */
|
||||
#define DHCP_FINE_TIMER_MSECS 500
|
||||
#define DHCP_FINE_TIMER_MSECS 500
|
||||
|
||||
#define DHCP_CHADDR_LEN 16U
|
||||
#define DHCP_SNAME_LEN 64U
|
||||
#define DHCP_FILE_LEN 128U
|
||||
#define DHCP_BOOT_FILE_LEN 128U
|
||||
|
||||
/* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */
|
||||
typedef enum {
|
||||
DHCP_AUTOIP_COOP_STATE_OFF = 0,
|
||||
DHCP_AUTOIP_COOP_STATE_ON = 1
|
||||
} dhcp_autoip_coop_state_enum_t;
|
||||
|
||||
struct dhcp
|
||||
{
|
||||
@ -76,12 +89,12 @@ struct dhcp
|
||||
struct dhcp_msg *msg_out; /* outgoing msg */
|
||||
u16_t options_out_len; /* outgoing msg options length */
|
||||
u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
|
||||
u32_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
|
||||
u32_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
|
||||
u32_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */
|
||||
u32_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */
|
||||
u32_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */
|
||||
u32_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */
|
||||
u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
|
||||
u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
|
||||
u16_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */
|
||||
u16_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */
|
||||
u16_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */
|
||||
u16_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */
|
||||
ip_addr_t server_ip_addr; /* dhcp server address that offered this lease (ip_addr_t because passed to UDP) */
|
||||
ip4_addr_t offered_ip_addr;
|
||||
ip4_addr_t offered_sn_mask;
|
||||
@ -91,12 +104,12 @@ struct dhcp
|
||||
u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
|
||||
u32_t offered_t2_rebind; /* recommended rebind time (usually 87.5 of lease period) */
|
||||
#if LWIP_DHCP_BOOTP_FILE
|
||||
ip_addr_t offered_si_addr;
|
||||
char boot_file_name[DHCP_FILE_LEN];
|
||||
ip4_addr_t offered_si_addr;
|
||||
char boot_file_name[DHCP_BOOT_FILE_LEN];
|
||||
#endif /* LWIP_DHCP_BOOTPFILE */
|
||||
|
||||
/* Espressif add start. */
|
||||
#ifdef ESP_LWIP
|
||||
#ifdef ESP_DHCP
|
||||
void (*cb)(struct netif*); /* callback for dhcp, add a parameter to show dhcp status if needed */
|
||||
#else
|
||||
void (*cb)(void); /* callback for dhcp, add a parameter to show dhcp status if needed */
|
||||
@ -104,200 +117,36 @@ struct dhcp
|
||||
/* Espressif add end. */
|
||||
};
|
||||
|
||||
/* MUST be compiled with "pack structs" or equivalent! */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** minimum set of fields of any DHCP message */
|
||||
struct dhcp_msg
|
||||
{
|
||||
PACK_STRUCT_FLD_8(u8_t op);
|
||||
PACK_STRUCT_FLD_8(u8_t htype);
|
||||
PACK_STRUCT_FLD_8(u8_t hlen);
|
||||
PACK_STRUCT_FLD_8(u8_t hops);
|
||||
PACK_STRUCT_FIELD(u32_t xid);
|
||||
PACK_STRUCT_FIELD(u16_t secs);
|
||||
PACK_STRUCT_FIELD(u16_t flags);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t ciaddr);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t yiaddr);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t siaddr);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t giaddr);
|
||||
PACK_STRUCT_FLD_8(u8_t chaddr[DHCP_CHADDR_LEN]);
|
||||
PACK_STRUCT_FLD_8(u8_t sname[DHCP_SNAME_LEN]);
|
||||
PACK_STRUCT_FLD_8(u8_t file[DHCP_FILE_LEN]);
|
||||
PACK_STRUCT_FIELD(u32_t cookie);
|
||||
#define DHCP_MIN_OPTIONS_LEN 68U
|
||||
/** make sure user does not configure this too small */
|
||||
#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
|
||||
# undef DHCP_OPTIONS_LEN
|
||||
#endif
|
||||
/** allow this to be configured in lwipopts.h, but not too small */
|
||||
#if (!defined(DHCP_OPTIONS_LEN))
|
||||
/** set this to be sufficient for your options in outgoing DHCP msgs */
|
||||
# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
|
||||
#endif
|
||||
PACK_STRUCT_FLD_8(u8_t options[DHCP_OPTIONS_LEN]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp);
|
||||
/** Remove a struct dhcp previously set to the netif using dhcp_set_struct() */
|
||||
#define dhcp_remove_struct(netif) do { (netif)->dhcp = NULL; } while(0)
|
||||
#define dhcp_remove_struct(netif) netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, NULL)
|
||||
void dhcp_cleanup(struct netif *netif);
|
||||
err_t dhcp_start(struct netif *netif);
|
||||
err_t dhcp_renew(struct netif *netif);
|
||||
err_t dhcp_release(struct netif *netif);
|
||||
void dhcp_stop(struct netif *netif);
|
||||
void dhcp_inform(struct netif *netif);
|
||||
void dhcp_network_changed(struct netif *netif);
|
||||
|
||||
/* Espressif add start. */
|
||||
/** set callback for DHCP */
|
||||
#ifdef ESP_LWIP
|
||||
#ifdef ESP_DHCP
|
||||
void dhcp_set_cb(struct netif *netif, void (*cb)(struct netif*));
|
||||
#else
|
||||
void dhcp_set_cb(struct netif *netif, void (*cb)(void));
|
||||
#endif
|
||||
/* Espressif add end. */
|
||||
/** start DHCP configuration */
|
||||
err_t dhcp_start(struct netif *netif);
|
||||
/** enforce early lease renewal (not needed normally)*/
|
||||
err_t dhcp_renew(struct netif *netif);
|
||||
/** release the DHCP lease, usually called before dhcp_stop()*/
|
||||
err_t dhcp_release(struct netif *netif);
|
||||
/** stop DHCP configuration */
|
||||
void dhcp_stop(struct netif *netif);
|
||||
/** inform server of our manual IP address */
|
||||
void dhcp_inform(struct netif *netif);
|
||||
/** Handle a possible change in the network configuration */
|
||||
void dhcp_network_changed(struct netif *netif);
|
||||
|
||||
/** if enabled, check whether the offered IP address is not in use, using ARP */
|
||||
#if DHCP_DOES_ARP_CHECK
|
||||
void dhcp_arp_reply(struct netif *netif, const ip4_addr_t *addr);
|
||||
#endif
|
||||
|
||||
/** check if DHCP supplied netif->ip_addr */
|
||||
u8_t dhcp_supplied_address(struct netif *netif);
|
||||
|
||||
/** to be called every minute */
|
||||
u8_t dhcp_supplied_address(const struct netif *netif);
|
||||
/* to be called every minute */
|
||||
void dhcp_coarse_tmr(void);
|
||||
/** to be called every half second */
|
||||
/* to be called every half second */
|
||||
void dhcp_fine_tmr(void);
|
||||
|
||||
/** DHCP message item offsets and length */
|
||||
#define DHCP_OP_OFS 0
|
||||
#define DHCP_HTYPE_OFS 1
|
||||
#define DHCP_HLEN_OFS 2
|
||||
#define DHCP_HOPS_OFS 3
|
||||
#define DHCP_XID_OFS 4
|
||||
#define DHCP_SECS_OFS 8
|
||||
#define DHCP_FLAGS_OFS 10
|
||||
#define DHCP_CIADDR_OFS 12
|
||||
#define DHCP_YIADDR_OFS 16
|
||||
#define DHCP_SIADDR_OFS 20
|
||||
#define DHCP_GIADDR_OFS 24
|
||||
#define DHCP_CHADDR_OFS 28
|
||||
#define DHCP_SNAME_OFS 44
|
||||
#define DHCP_FILE_OFS 108
|
||||
#define DHCP_MSG_LEN 236
|
||||
|
||||
#define DHCP_COOKIE_OFS DHCP_MSG_LEN
|
||||
#define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4)
|
||||
|
||||
#define DHCP_CLIENT_PORT 68
|
||||
#define DHCP_SERVER_PORT 67
|
||||
|
||||
/** DHCP client states */
|
||||
#define DHCP_STATE_OFF 0
|
||||
#define DHCP_STATE_REQUESTING 1
|
||||
#define DHCP_STATE_INIT 2
|
||||
#define DHCP_STATE_REBOOTING 3
|
||||
#define DHCP_STATE_REBINDING 4
|
||||
#define DHCP_STATE_RENEWING 5
|
||||
#define DHCP_STATE_SELECTING 6
|
||||
#define DHCP_STATE_INFORMING 7
|
||||
#define DHCP_STATE_CHECKING 8
|
||||
/** not yet implemented #define DHCP_STATE_PERMANENT 9 */
|
||||
#define DHCP_STATE_BOUND 10
|
||||
/** not yet implemented #define DHCP_STATE_RELEASING 11 */
|
||||
#define DHCP_STATE_BACKING_OFF 12
|
||||
|
||||
/** AUTOIP cooperation flags */
|
||||
#define DHCP_AUTOIP_COOP_STATE_OFF 0
|
||||
#define DHCP_AUTOIP_COOP_STATE_ON 1
|
||||
|
||||
#define DHCP_BOOTREQUEST 1
|
||||
#define DHCP_BOOTREPLY 2
|
||||
|
||||
/** DHCP message types */
|
||||
#define DHCP_DISCOVER 1
|
||||
#define DHCP_OFFER 2
|
||||
#define DHCP_REQUEST 3
|
||||
#define DHCP_DECLINE 4
|
||||
#define DHCP_ACK 5
|
||||
#define DHCP_NAK 6
|
||||
#define DHCP_RELEASE 7
|
||||
#define DHCP_INFORM 8
|
||||
|
||||
/** DHCP hardware type, currently only ethernet is supported */
|
||||
#define DHCP_HTYPE_ETH 1
|
||||
|
||||
#define DHCP_MAGIC_COOKIE 0x63825363UL
|
||||
|
||||
/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */
|
||||
|
||||
/** BootP options */
|
||||
#define DHCP_OPTION_PAD 0
|
||||
#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */
|
||||
#define DHCP_OPTION_ROUTER 3
|
||||
#define DHCP_OPTION_DNS_SERVER 6
|
||||
#define DHCP_OPTION_HOSTNAME 12
|
||||
#define DHCP_OPTION_IP_TTL 23
|
||||
#define DHCP_OPTION_MTU 26
|
||||
#define DHCP_OPTION_BROADCAST 28
|
||||
#define DHCP_OPTION_TCP_TTL 37
|
||||
#define DHCP_OPTION_NTP 42
|
||||
#define DHCP_OPTION_END 255
|
||||
|
||||
#if ESP_LWIP
|
||||
/**add options for support more router by liuHan**/
|
||||
#define DHCP_OPTION_DOMAIN_NAME 15
|
||||
#define DHCP_OPTION_PRD 31
|
||||
#define DHCP_OPTION_STATIC_ROUTER 33
|
||||
#define DHCP_OPTION_VSN 43
|
||||
#define DHCP_OPTION_NB_TINS 44
|
||||
#define DHCP_OPTION_NB_TINT 46
|
||||
#define DHCP_OPTION_NB_TIS 47
|
||||
#define DHCP_OPTION_CLASSLESS_STATIC_ROUTER 121
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/** DHCP options */
|
||||
#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
|
||||
#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
|
||||
#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */
|
||||
|
||||
#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */
|
||||
#define DHCP_OPTION_MESSAGE_TYPE_LEN 1
|
||||
|
||||
#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */
|
||||
#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */
|
||||
|
||||
#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */
|
||||
#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
|
||||
|
||||
#define DHCP_OPTION_T1 58 /* T1 renewal time */
|
||||
#define DHCP_OPTION_T2 59 /* T2 rebinding time */
|
||||
#define DHCP_OPTION_US 60
|
||||
#define DHCP_OPTION_CLIENT_ID 61
|
||||
#define DHCP_OPTION_TFTP_SERVERNAME 66
|
||||
#define DHCP_OPTION_BOOTFILE 67
|
||||
|
||||
/** possible combinations of overloading the file and sname fields with options */
|
||||
#define DHCP_OVERLOAD_NONE 0
|
||||
#define DHCP_OVERLOAD_FILE 1
|
||||
#define DHCP_OVERLOAD_SNAME 2
|
||||
#define DHCP_OVERLOAD_SNAME_FILE 3
|
||||
|
||||
#if LWIP_DHCP_GET_NTP_SRV
|
||||
/** This function must exist, in other to add offered NTP servers to
|
||||
* the NTP (or SNTP) engine.
|
||||
@ -305,6 +154,8 @@ void dhcp_fine_tmr(void);
|
||||
extern void dhcp_set_ntp_servers(u8_t num_ntp_servers, const ip4_addr_t* ntp_server_addrs);
|
||||
#endif /* LWIP_DHCP_GET_NTP_SRV */
|
||||
|
||||
#define netif_dhcp_data(netif) ((struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
struct dhcp6
|
||||
{
|
||||
/*TODO: implement DHCP6*/
|
||||
/*@todo: implement DHCP6*/
|
||||
};
|
||||
|
||||
#endif /* LWIP_IPV6_DHCP6 */
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* DNS API
|
||||
*/
|
||||
|
||||
/**
|
||||
* lwip DNS resolver header file.
|
||||
|
||||
@ -36,14 +41,10 @@
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if ESP_DNS
|
||||
#include "lwip/err.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if LWIP_DNS
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -61,7 +62,7 @@ extern "C" {
|
||||
#ifndef LWIP_DNS_ADDRTYPE_DEFAULT
|
||||
#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4_IPV6
|
||||
#endif
|
||||
#elif defined(LWIP_IPV4)
|
||||
#elif LWIP_IPV4
|
||||
#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4
|
||||
#else
|
||||
#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV6
|
||||
@ -76,6 +77,7 @@ struct local_hostlist_entry {
|
||||
ip_addr_t addr;
|
||||
struct local_hostlist_entry *next;
|
||||
};
|
||||
#define DNS_LOCAL_HOSTLIST_ELEM(name, addr_init) {name, addr_init, NULL}
|
||||
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
|
||||
#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH
|
||||
@ -84,6 +86,13 @@ struct local_hostlist_entry {
|
||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
#endif /* DNS_LOCAL_HOSTLIST */
|
||||
|
||||
#if LWIP_IPV4
|
||||
extern const ip_addr_t dns_mquery_v4group;
|
||||
#endif /* LWIP_IPV4 */
|
||||
#if LWIP_IPV6
|
||||
extern const ip_addr_t dns_mquery_v6group;
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/** Callback which is invoked when a hostname is found.
|
||||
* A function of this type must be implemented by the application using the DNS resolver.
|
||||
* @param name pointer to the name that was looked up.
|
||||
@ -93,22 +102,32 @@ struct local_hostlist_entry {
|
||||
*/
|
||||
typedef void (*dns_found_callback)(const char *name, const ip_addr_t *ipaddr, void *callback_arg);
|
||||
|
||||
void dns_init(void);
|
||||
void dns_tmr(void);
|
||||
void dns_setserver(u8_t numdns, const ip_addr_t *dnsserver);
|
||||
void dns_clear_servers(bool keep_fallback);
|
||||
ip_addr_t dns_getserver(u8_t numdns);
|
||||
err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr,
|
||||
dns_found_callback found, void *callback_arg);
|
||||
err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr,
|
||||
dns_found_callback found, void *callback_arg,
|
||||
u8_t dns_addrtype);
|
||||
void dns_init(void);
|
||||
void dns_tmr(void);
|
||||
void dns_setserver(u8_t numdns, const ip_addr_t *dnsserver);
|
||||
#if ESP_DNS
|
||||
ip_addr_t dns_getserver(u8_t numdns);
|
||||
#else
|
||||
const ip_addr_t* dns_getserver(u8_t numdns);
|
||||
#endif
|
||||
err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr,
|
||||
dns_found_callback found, void *callback_arg);
|
||||
err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr,
|
||||
dns_found_callback found, void *callback_arg,
|
||||
u8_t dns_addrtype);
|
||||
#if ESP_DNS
|
||||
void dns_clear_servers(bool keep_fallback);
|
||||
#endif
|
||||
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
#if DNS_LOCAL_HOSTLIST
|
||||
size_t dns_local_iterate(dns_found_callback iterator_fn, void *iterator_arg);
|
||||
err_t dns_local_lookup(const char *hostname, ip_addr_t *addr, u8_t dns_addrtype);
|
||||
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
int dns_local_removehost(const char *hostname, const ip_addr_t *addr);
|
||||
err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr);
|
||||
#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
#endif /* DNS_LOCAL_HOSTLIST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @file
|
||||
* lwIP Error codes
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -39,6 +43,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup infrastructure_errors Error codes
|
||||
* @ingroup infrastructure
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Define LWIP_ERR_T in cc.h if you want to use
|
||||
* a different type for your platform (must be signed). */
|
||||
#ifdef LWIP_ERR_T
|
||||
@ -47,40 +57,50 @@ typedef LWIP_ERR_T err_t;
|
||||
typedef s8_t err_t;
|
||||
#endif /* LWIP_ERR_T*/
|
||||
|
||||
/* Definitions for error constants. */
|
||||
/** Definitions for error constants. */
|
||||
typedef enum {
|
||||
/** No error, everything OK. */
|
||||
ERR_OK = 0,
|
||||
/** Out of memory error. */
|
||||
ERR_MEM = -1,
|
||||
/** Buffer error. */
|
||||
ERR_BUF = -2,
|
||||
/** Timeout. */
|
||||
ERR_TIMEOUT = -3,
|
||||
/** Routing problem. */
|
||||
ERR_RTE = -4,
|
||||
/** Operation in progress */
|
||||
ERR_INPROGRESS = -5,
|
||||
/** Illegal value. */
|
||||
ERR_VAL = -6,
|
||||
/** Operation would block. */
|
||||
ERR_WOULDBLOCK = -7,
|
||||
/** Address in use. */
|
||||
ERR_USE = -8,
|
||||
/** Already connecting. */
|
||||
ERR_ALREADY = -9,
|
||||
/** Conn already established.*/
|
||||
ERR_ISCONN = -10,
|
||||
/** Not connected. */
|
||||
ERR_CONN = -11,
|
||||
/** Low-level netif error */
|
||||
ERR_IF = -12,
|
||||
|
||||
#define ERR_OK 0 /* No error, everything OK. */
|
||||
#define ERR_MEM -1 /* Out of memory error. */
|
||||
#define ERR_BUF -2 /* Buffer error. */
|
||||
#define ERR_TIMEOUT -3 /* Timeout. */
|
||||
#define ERR_RTE -4 /* Routing problem. */
|
||||
#define ERR_INPROGRESS -5 /* Operation in progress */
|
||||
#define ERR_VAL -6 /* Illegal value. */
|
||||
#define ERR_WOULDBLOCK -7 /* Operation would block. */
|
||||
#define ERR_USE -8 /* Address in use. */
|
||||
/** Connection aborted. */
|
||||
ERR_ABRT = -13,
|
||||
/** Connection reset. */
|
||||
ERR_RST = -14,
|
||||
/** Connection closed. */
|
||||
ERR_CLSD = -15,
|
||||
/** Illegal argument. */
|
||||
ERR_ARG = -16
|
||||
} err_enum_t;
|
||||
|
||||
|
||||
#if ESP_LWIP
|
||||
#define ERR_ALREADY -9 /* Already connected. */
|
||||
#define ERR_ISCONN -10 /* Conn already established.*/
|
||||
#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN)
|
||||
#define ERR_ABRT -11 /* Connection aborted. */
|
||||
#define ERR_RST -12 /* Connection reset. */
|
||||
#define ERR_CLSD -13 /* Connection closed. */
|
||||
#define ERR_CONN -14 /* Not connected. */
|
||||
#define ERR_ARG -15 /* Illegal argument. */
|
||||
#define ERR_IF -16 /* Low-level netif error */
|
||||
#else
|
||||
#define ERR_ALREADY -9 /* Already connecting. */
|
||||
#define ERR_ISCONN -10 /* Conn already established.*/
|
||||
#define ERR_CONN -11 /* Not connected. */
|
||||
#define ERR_IF -12 /* Low-level netif error */
|
||||
#define ERR_IS_FATAL(e) ((e) <= ERR_ABRT)
|
||||
#define ERR_ABRT -13 /* Connection aborted. */
|
||||
#define ERR_RST -14 /* Connection reset. */
|
||||
#define ERR_CLSD -15 /* Connection closed. */
|
||||
#define ERR_ARG -16 /* Illegal argument. */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
extern const char *lwip_strerr(err_t err);
|
||||
@ -88,6 +108,10 @@ extern const char *lwip_strerr(err_t err);
|
||||
#define lwip_strerr(x) ""
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
#if !NO_SYS
|
||||
int err_to_errno(err_t err);
|
||||
#endif /* !NO_SYS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
193
tools/sdk/include/lwip/lwip/errno.h
Normal file
193
tools/sdk/include/lwip/lwip/errno.h
Normal file
@ -0,0 +1,193 @@
|
||||
/**
|
||||
* @file
|
||||
* Posix Errno defines
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_ERRNO_H
|
||||
#define LWIP_HDR_ERRNO_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_PROVIDE_ERRNO
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#else /* LWIP_PROVIDE_ERRNO */
|
||||
|
||||
/* Define LWIP_ERRNO_INCLUDE to <errno.h> to include the error defines here */
|
||||
#ifdef LWIP_ERRNO_INCLUDE
|
||||
#include LWIP_ERRNO_INCLUDE
|
||||
#endif /* LWIP_ERRNO_INCLUDE */
|
||||
|
||||
#endif /* LWIP_PROVIDE_ERRNO */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_ERRNO_H */
|
116
tools/sdk/include/lwip/lwip/etharp.h
Normal file
116
tools/sdk/include/lwip/lwip/etharp.h
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @file
|
||||
* Ethernet output function - handles OUTGOING ethernet level traffic, implements
|
||||
* ARP resolving.
|
||||
* To be used in most low-level netif implementations
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_NETIF_ETHARP_H
|
||||
#define LWIP_HDR_NETIF_ETHARP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip4.h"
|
||||
#include "lwip/prot/ethernet.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/prot/etharp.h"
|
||||
|
||||
/** 1 seconds period */
|
||||
#define ARP_TMR_INTERVAL 1000
|
||||
|
||||
#if ARP_QUEUEING
|
||||
/** struct for queueing outgoing packets for unknown address
|
||||
* defined here to be accessed by memp.h
|
||||
*/
|
||||
struct etharp_q_entry {
|
||||
struct etharp_q_entry *next;
|
||||
struct pbuf *p;
|
||||
};
|
||||
#endif /* ARP_QUEUEING */
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
#ifdef CONFIG_GARP_TMR_INTERVAL
|
||||
#define GARP_TMR_INTERVAL (CONFIG_GARP_TMR_INTERVAL*1000UL)
|
||||
#else
|
||||
#define GARP_TMR_INTERVAL 60000
|
||||
#endif
|
||||
|
||||
void garp_tmr(void);
|
||||
#endif
|
||||
|
||||
#define etharp_init() /* Compatibility define, no init needed. */
|
||||
void etharp_tmr(void);
|
||||
s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
||||
struct eth_addr **eth_ret, const ip4_addr_t **ip_ret);
|
||||
u8_t etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_addr **eth_ret);
|
||||
err_t etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
|
||||
err_t etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q);
|
||||
err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr);
|
||||
/** For Ethernet network interfaces, we might want to send "gratuitous ARP";
|
||||
* this is an ARP packet sent by a node in order to spontaneously cause other
|
||||
* nodes to update an entry in their ARP cache.
|
||||
* From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
|
||||
#define etharp_gratuitous(netif) etharp_request((netif), netif_ip4_addr(netif))
|
||||
void etharp_cleanup_netif(struct netif *netif);
|
||||
|
||||
#if ETHARP_SUPPORT_STATIC_ENTRIES
|
||||
err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr);
|
||||
err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr);
|
||||
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
|
||||
|
||||
#endif /* LWIP_IPV4 && LWIP_ARP */
|
||||
|
||||
void etharp_input(struct pbuf *p, struct netif *netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_ARP || LWIP_ETHERNET */
|
||||
|
||||
#endif /* LWIP_HDR_NETIF_ETHARP_H */
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* ICMP API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -36,6 +41,7 @@
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/prot/icmp.h"
|
||||
|
||||
#if LWIP_IPV6 && LWIP_ICMP6
|
||||
#include "lwip/icmp6.h"
|
||||
@ -45,63 +51,30 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ICMP_ER 0 /* echo reply */
|
||||
#define ICMP_DUR 3 /* destination unreachable */
|
||||
#define ICMP_SQ 4 /* source quench */
|
||||
#define ICMP_RD 5 /* redirect */
|
||||
#define ICMP_ECHO 8 /* echo */
|
||||
#define ICMP_TE 11 /* time exceeded */
|
||||
#define ICMP_PP 12 /* parameter problem */
|
||||
#define ICMP_TS 13 /* timestamp */
|
||||
#define ICMP_TSR 14 /* timestamp reply */
|
||||
#define ICMP_IRQ 15 /* information request */
|
||||
#define ICMP_IR 16 /* information reply */
|
||||
#define ICMP_AM 17 /* address mask request */
|
||||
#define ICMP_AMR 18 /* address mask reply */
|
||||
|
||||
/** ICMP destination unreachable codes */
|
||||
enum icmp_dur_type {
|
||||
ICMP_DUR_NET = 0, /* net unreachable */
|
||||
ICMP_DUR_HOST = 1, /* host unreachable */
|
||||
ICMP_DUR_PROTO = 2, /* protocol unreachable */
|
||||
ICMP_DUR_PORT = 3, /* port unreachable */
|
||||
ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
|
||||
ICMP_DUR_SR = 5 /* source route failed */
|
||||
/** net unreachable */
|
||||
ICMP_DUR_NET = 0,
|
||||
/** host unreachable */
|
||||
ICMP_DUR_HOST = 1,
|
||||
/** protocol unreachable */
|
||||
ICMP_DUR_PROTO = 2,
|
||||
/** port unreachable */
|
||||
ICMP_DUR_PORT = 3,
|
||||
/** fragmentation needed and DF set */
|
||||
ICMP_DUR_FRAG = 4,
|
||||
/** source route failed */
|
||||
ICMP_DUR_SR = 5
|
||||
};
|
||||
|
||||
/** ICMP time exceeded codes */
|
||||
enum icmp_te_type {
|
||||
ICMP_TE_TTL = 0, /* time to live exceeded in transit */
|
||||
ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
|
||||
/** time to live exceeded in transit */
|
||||
ICMP_TE_TTL = 0,
|
||||
/** fragment reassembly time exceeded */
|
||||
ICMP_TE_FRAG = 1
|
||||
};
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
/** This is the standard ICMP header only that the u32_t data
|
||||
* is split to two u16_t like ICMP echo needs it.
|
||||
* This header is also used for other ICMP types that do not
|
||||
* use the data part.
|
||||
*/
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp_echo_hdr {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t id);
|
||||
PACK_STRUCT_FIELD(u16_t seqno);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define ICMPH_TYPE(hdr) ((hdr)->type)
|
||||
#define ICMPH_CODE(hdr) ((hdr)->code)
|
||||
|
||||
/** Combines type and code to an u16_t */
|
||||
#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t))
|
||||
#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c))
|
||||
|
||||
|
||||
#if LWIP_IPV4 && LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
void icmp_input(struct pbuf *p, struct netif *inp);
|
||||
|
@ -45,94 +45,12 @@
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#include "lwip/prot/icmp6.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum icmp6_type {
|
||||
ICMP6_TYPE_DUR = 1, /* Destination unreachable */
|
||||
ICMP6_TYPE_PTB = 2, /* Packet too big */
|
||||
ICMP6_TYPE_TE = 3, /* Time exceeded */
|
||||
ICMP6_TYPE_PP = 4, /* Parameter problem */
|
||||
ICMP6_TYPE_PE1 = 100, /* Private experimentation */
|
||||
ICMP6_TYPE_PE2 = 101, /* Private experimentation */
|
||||
ICMP6_TYPE_RSV_ERR = 127, /* Reserved for expansion of error messages */
|
||||
|
||||
ICMP6_TYPE_EREQ = 128, /* Echo request */
|
||||
ICMP6_TYPE_EREP = 129, /* Echo reply */
|
||||
ICMP6_TYPE_MLQ = 130, /* Multicast listener query */
|
||||
ICMP6_TYPE_MLR = 131, /* Multicast listener report */
|
||||
ICMP6_TYPE_MLD = 132, /* Multicast listener done */
|
||||
ICMP6_TYPE_RS = 133, /* Router solicitation */
|
||||
ICMP6_TYPE_RA = 134, /* Router advertisement */
|
||||
ICMP6_TYPE_NS = 135, /* Neighbor solicitation */
|
||||
ICMP6_TYPE_NA = 136, /* Neighbor advertisement */
|
||||
ICMP6_TYPE_RD = 137, /* Redirect */
|
||||
ICMP6_TYPE_MRA = 151, /* Multicast router advertisement */
|
||||
ICMP6_TYPE_MRS = 152, /* Multicast router solicitation */
|
||||
ICMP6_TYPE_MRT = 153, /* Multicast router termination */
|
||||
ICMP6_TYPE_PE3 = 200, /* Private experimentation */
|
||||
ICMP6_TYPE_PE4 = 201, /* Private experimentation */
|
||||
ICMP6_TYPE_RSV_INF = 255 /* Reserved for expansion of informational messages */
|
||||
};
|
||||
|
||||
enum icmp6_dur_code {
|
||||
ICMP6_DUR_NO_ROUTE = 0, /* No route to destination */
|
||||
ICMP6_DUR_PROHIBITED = 1, /* Communication with destination administratively prohibited */
|
||||
ICMP6_DUR_SCOPE = 2, /* Beyond scope of source address */
|
||||
ICMP6_DUR_ADDRESS = 3, /* Address unreachable */
|
||||
ICMP6_DUR_PORT = 4, /* Port unreachable */
|
||||
ICMP6_DUR_POLICY = 5, /* Source address failed ingress/egress policy */
|
||||
ICMP6_DUR_REJECT_ROUTE = 6 /* Reject route to destination */
|
||||
};
|
||||
|
||||
enum icmp6_te_code {
|
||||
ICMP6_TE_HL = 0, /* Hop limit exceeded in transit */
|
||||
ICMP6_TE_FRAG = 1 /* Fragment reassembly time exceeded */
|
||||
};
|
||||
|
||||
enum icmp6_pp_code {
|
||||
ICMP6_PP_FIELD = 0, /* Erroneous header field encountered */
|
||||
ICMP6_PP_HEADER = 1, /* Unrecognized next header type encountered */
|
||||
ICMP6_PP_OPTION = 2 /* Unrecognized IPv6 option encountered */
|
||||
};
|
||||
|
||||
/** This is the standard ICMP6 header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp6_hdr {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t data);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** This is the ICMP6 header adapted for echo req/resp. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp6_echo_hdr {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t id);
|
||||
PACK_STRUCT_FIELD(u16_t seqno);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
void icmp6_input(struct pbuf *p, struct netif *inp);
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* IGMP API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 CITEL Technologies Ltd.
|
||||
* All rights reserved.
|
||||
@ -46,17 +51,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* IGMP timer */
|
||||
#define IGMP_TMR_INTERVAL 100 /* Milliseconds */
|
||||
#define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL)
|
||||
#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
|
||||
|
||||
/* MAC Filter Actions, these are passed to a netif's
|
||||
* igmp_mac_filter callback function. */
|
||||
#define IGMP_DEL_MAC_FILTER 0
|
||||
#define IGMP_ADD_MAC_FILTER 1
|
||||
|
||||
/* Compatibility defines (don't use for new code) */
|
||||
#define IGMP_DEL_MAC_FILTER NETIF_DEL_MAC_FILTER
|
||||
#define IGMP_ADD_MAC_FILTER NETIF_ADD_MAC_FILTER
|
||||
|
||||
/**
|
||||
* igmp group structure - there is
|
||||
@ -70,10 +72,8 @@ extern "C" {
|
||||
* from all the other groups
|
||||
*/
|
||||
struct igmp_group {
|
||||
/** next link */
|
||||
/** next link */
|
||||
struct igmp_group *next;
|
||||
/** interface on which the group is active */
|
||||
struct netif *netif;
|
||||
/** multicast address */
|
||||
ip4_addr_t group_address;
|
||||
/** signifies we were the last person to report */
|
||||
@ -83,7 +83,7 @@ struct igmp_group {
|
||||
/** timer for reporting, negative is OFF */
|
||||
u16_t timer;
|
||||
/** counter of simultaneous uses */
|
||||
u8_t use;
|
||||
u8_t use;
|
||||
};
|
||||
|
||||
/* Prototypes */
|
||||
@ -99,6 +99,13 @@ err_t igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr);
|
||||
err_t igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr);
|
||||
void igmp_tmr(void);
|
||||
|
||||
/** @ingroup igmp
|
||||
* Get list head of IGMP groups for netif.
|
||||
* Note: The allsystems group IP is contained in the list as first entry.
|
||||
* @see @ref netif_set_igmp_mac_filter()
|
||||
*/
|
||||
#define netif_igmp_data(netif) ((struct igmp_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -132,10 +132,10 @@ extern const struct in6_addr in6addr_any;
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
|
||||
#define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
|
||||
/* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */
|
||||
#define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr))
|
||||
#define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
|
||||
#define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
|
||||
/* ATTENTION: the next define only works because both s_addr and ip4_addr_t are an u32_t effectively! */
|
||||
#define inet_addr_to_ip4addr_p(target_ip4addr_p, source_inaddr) ((target_ip4addr_p) = (ip4_addr_t*)&((source_inaddr)->s_addr))
|
||||
|
||||
/* directly map this to the lwip internal functions */
|
||||
#define inet_addr(cp) ipaddr_addr(cp)
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* IP checksum calculation functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -37,15 +42,9 @@
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
/** Swap the bytes in an u16_t: much like htons() for little-endian */
|
||||
/** Swap the bytes in an u16_t: much like lwip_htons() for little-endian */
|
||||
#ifndef SWAP_BYTES_IN_WORD
|
||||
#if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)
|
||||
/* little endian and PLATFORM_BYTESWAP defined */
|
||||
#define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w)
|
||||
#else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */
|
||||
/* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */
|
||||
#define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8)
|
||||
#endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/
|
||||
#endif /* SWAP_BYTES_IN_WORD */
|
||||
|
||||
/** Split an u32_t in two u16_ts and add them up */
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* lwIP initialization API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -38,29 +43,52 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup lwip_version Version
|
||||
* @ingroup lwip
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** X.x.x: Major version of the stack */
|
||||
#define LWIP_VERSION_MAJOR 1U
|
||||
#define LWIP_VERSION_MAJOR 2
|
||||
/** x.X.x: Minor version of the stack */
|
||||
#define LWIP_VERSION_MINOR 5U
|
||||
#define LWIP_VERSION_MINOR 0
|
||||
/** x.x.X: Revision of the stack */
|
||||
#define LWIP_VERSION_REVISION 0U
|
||||
#define LWIP_VERSION_REVISION 3
|
||||
/** For release candidates, this is set to 1..254
|
||||
* For official releases, this is set to 255 (LWIP_RC_RELEASE)
|
||||
* For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */
|
||||
#define LWIP_VERSION_RC 0U
|
||||
#define LWIP_VERSION_RC LWIP_RC_RELEASE
|
||||
|
||||
/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
|
||||
#define LWIP_RC_RELEASE 255U
|
||||
#define LWIP_RC_RELEASE 255
|
||||
/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions */
|
||||
#define LWIP_RC_DEVELOPMENT 0U
|
||||
#define LWIP_RC_DEVELOPMENT 0
|
||||
|
||||
#define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE)
|
||||
#define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT)
|
||||
#define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT))
|
||||
|
||||
/* Some helper defines to get a version string */
|
||||
#define LWIP_VERSTR2(x) #x
|
||||
#define LWIP_VERSTR(x) LWIP_VERSTR2(x)
|
||||
#if LWIP_VERSION_IS_RELEASE
|
||||
#define LWIP_VERSION_STRING_SUFFIX ""
|
||||
#elif LWIP_VERSION_IS_DEVELOPMENT
|
||||
#define LWIP_VERSION_STRING_SUFFIX "d"
|
||||
#else
|
||||
#define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC)
|
||||
#endif
|
||||
|
||||
/** Provides the version of the stack */
|
||||
#define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \
|
||||
LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC)
|
||||
#define LWIP_VERSION (((u32_t)LWIP_VERSION_MAJOR) << 24 | ((u32_t)LWIP_VERSION_MINOR) << 16 | \
|
||||
((u32_t)LWIP_VERSION_REVISION) << 8 | ((u32_t)LWIP_VERSION_RC))
|
||||
/** Provides the version of the stack as string */
|
||||
#define LWIP_VERSION_STRING LWIP_VERSTR(LWIP_VERSION_MAJOR) "." LWIP_VERSTR(LWIP_VERSION_MINOR) "." LWIP_VERSTR(LWIP_VERSION_REVISION) LWIP_VERSION_STRING_SUFFIX
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Modules initialization */
|
||||
void lwip_init(void);
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* IP API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -29,8 +34,8 @@
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_IP_H__
|
||||
#define LWIP_HDR_IP_H__
|
||||
#ifndef LWIP_HDR_IP_H
|
||||
#define LWIP_HDR_IP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
@ -41,27 +46,16 @@
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip4.h"
|
||||
#include "lwip/ip6.h"
|
||||
#include "lwip/prot/ip.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IP_PROTO_ICMP 1
|
||||
#define IP_PROTO_IGMP 2
|
||||
#define IP_PROTO_UDP 17
|
||||
#define IP_PROTO_UDPLITE 136
|
||||
#define IP_PROTO_TCP 6
|
||||
|
||||
/** This operates on a void* by loading the first byte */
|
||||
#define IP_HDR_GET_VERSION(ptr) ((*(u8_t*)(ptr)) >> 4)
|
||||
|
||||
/* This is passed as the destination address to ip_output_if (not
|
||||
to ip_output), meaning that an IP header already is constructed
|
||||
in the pbuf. This is used when TCP retransmits. */
|
||||
#ifdef IP_HDRINCL
|
||||
#undef IP_HDRINCL
|
||||
#endif /* IP_HDRINCL */
|
||||
#define IP_HDRINCL NULL
|
||||
#define LWIP_IP_HDRINCL NULL
|
||||
|
||||
/** pbufs passed to IP must have a ref-count of 1 as their payload pointer
|
||||
gets altered as the packet is passed down the stack */
|
||||
@ -75,7 +69,7 @@ extern "C" {
|
||||
#define IP_PCB_ADDRHINT
|
||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||
|
||||
/* This is the common part of all PCB types. It needs to be at the
|
||||
/** This is the common part of all PCB types. It needs to be at the
|
||||
beginning of a PCB type definition. It is located here so that
|
||||
changes to this common part are made in one location instead of
|
||||
having to change all PCB structs. */
|
||||
@ -107,7 +101,7 @@ struct ip_pcb {
|
||||
/* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */
|
||||
#define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE)
|
||||
|
||||
/* Global variables of this module, kept in a struct for efficient access using base+index. */
|
||||
/** Global variables of this module, kept in a struct for efficient access using base+index. */
|
||||
struct ip_globals
|
||||
{
|
||||
/** The interface that accepted the packet for the current callback invocation. */
|
||||
@ -225,26 +219,47 @@ extern struct ip_globals ip_data;
|
||||
#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt))
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/**
|
||||
* @ingroup ip
|
||||
* Output IP packet, netif is selected by source address
|
||||
*/
|
||||
#define ip_output(p, src, dest, ttl, tos, proto) \
|
||||
(IP_IS_V6(dest) ? \
|
||||
ip6_output(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto) : \
|
||||
ip4_output(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto))
|
||||
/**
|
||||
* @ingroup ip
|
||||
* Output IP packet to specified interface
|
||||
*/
|
||||
#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \
|
||||
(IP_IS_V6(dest) ? \
|
||||
ip6_output_if(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \
|
||||
ip4_output_if(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif))
|
||||
/**
|
||||
* @ingroup ip
|
||||
* Output IP packet to interface specifying source address
|
||||
*/
|
||||
#define ip_output_if_src(p, src, dest, ttl, tos, proto, netif) \
|
||||
(IP_IS_V6(dest) ? \
|
||||
ip6_output_if_src(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \
|
||||
ip4_output_if_src(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif))
|
||||
/** Output IP packet with addr_hint */
|
||||
#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \
|
||||
(IP_IS_V6(dest) ? \
|
||||
ip6_output_hinted(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, addr_hint) : \
|
||||
ip4_output_hinted(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, addr_hint))
|
||||
/**
|
||||
* @ingroup ip
|
||||
* Get netif for address combination. See \ref ip6_route and \ref ip4_route
|
||||
*/
|
||||
#define ip_route(src, dest) \
|
||||
(IP_IS_V6(dest) ? \
|
||||
ip6_route(ip_2_ip6(src), ip_2_ip6(dest)) : \
|
||||
ip4_route_src(ip_2_ip4(dest), ip_2_ip4(src)))
|
||||
/**
|
||||
* @ingroup ip
|
||||
* Get netif for IP.
|
||||
*/
|
||||
#define ip_netif_get_local_ip(netif, dest) (IP_IS_V6(dest) ? \
|
||||
ip6_netif_get_local_ip(netif, ip_2_ip6(dest)) : \
|
||||
ip4_netif_get_local_ip(netif))
|
||||
@ -299,6 +314,6 @@ err_t ip_input(struct pbuf *p, struct netif *inp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_IP_H__ */
|
||||
#endif /* LWIP_HDR_IP_H */
|
||||
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* IPv4 API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -41,6 +46,7 @@
|
||||
#include "lwip/ip4_addr.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/prot/ip4.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -55,62 +61,6 @@ extern "C" {
|
||||
/** Currently, the function ip_output_if_opt() is only used with IGMP */
|
||||
#define IP_OPTIONS_SEND (LWIP_IPV4 && LWIP_IGMP)
|
||||
|
||||
#define IP_HLEN 20
|
||||
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip_hdr {
|
||||
/* version / header length */
|
||||
PACK_STRUCT_FLD_8(u8_t _v_hl);
|
||||
/* type of service */
|
||||
PACK_STRUCT_FLD_8(u8_t _tos);
|
||||
/* total length */
|
||||
PACK_STRUCT_FIELD(u16_t _len);
|
||||
/* identification */
|
||||
PACK_STRUCT_FIELD(u16_t _id);
|
||||
/* fragment offset field */
|
||||
PACK_STRUCT_FIELD(u16_t _offset);
|
||||
#define IP_RF 0x8000U /* reserved fragment flag */
|
||||
#define IP_DF 0x4000U /* don't fragment flag */
|
||||
#define IP_MF 0x2000U /* more fragments flag */
|
||||
#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */
|
||||
/* time to live */
|
||||
PACK_STRUCT_FLD_8(u8_t _ttl);
|
||||
/* protocol*/
|
||||
PACK_STRUCT_FLD_8(u8_t _proto);
|
||||
/* checksum */
|
||||
PACK_STRUCT_FIELD(u16_t _chksum);
|
||||
/* source and destination IP addresses */
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t src);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t dest);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define IPH_V(hdr) ((hdr)->_v_hl >> 4)
|
||||
#define IPH_HL(hdr) ((hdr)->_v_hl & 0x0f)
|
||||
#define IPH_TOS(hdr) ((hdr)->_tos)
|
||||
#define IPH_LEN(hdr) ((hdr)->_len)
|
||||
#define IPH_ID(hdr) ((hdr)->_id)
|
||||
#define IPH_OFFSET(hdr) ((hdr)->_offset)
|
||||
#define IPH_TTL(hdr) ((hdr)->_ttl)
|
||||
#define IPH_PROTO(hdr) ((hdr)->_proto)
|
||||
#define IPH_CHKSUM(hdr) ((hdr)->_chksum)
|
||||
|
||||
#define IPH_VHL_SET(hdr, v, hl) (hdr)->_v_hl = (u8_t)((((v) << 4) | (hl)))
|
||||
#define IPH_TOS_SET(hdr, tos) (hdr)->_tos = (tos)
|
||||
#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
|
||||
#define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
|
||||
#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
|
||||
#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl)
|
||||
#define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto)
|
||||
#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
|
||||
|
||||
#define ip_init() /* Compatibility define, no init needed. */
|
||||
struct netif *ip4_route(const ip4_addr_t *dest);
|
||||
#if LWIP_IPV4_SRC_ROUTING
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* IPv4 address API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -41,32 +46,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is the aligned version of ip4_addr_t,
|
||||
/** This is the aligned version of ip4_addr_t,
|
||||
used as local variable, on the stack, etc. */
|
||||
struct ip4_addr {
|
||||
u32_t addr;
|
||||
};
|
||||
|
||||
/* This is the packed version of ip4_addr_t,
|
||||
used in network headers that are itself packed */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip4_addr_packed {
|
||||
PACK_STRUCT_FIELD(u32_t addr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** ip4_addr_t uses a struct for convenience only, so that the same defines can
|
||||
* operate both on ip4_addr_t as well as on ip4_addr_p_t. */
|
||||
typedef struct ip4_addr ip4_addr_t;
|
||||
typedef struct ip4_addr_packed ip4_addr_p_t;
|
||||
|
||||
/*
|
||||
/**
|
||||
* struct ipaddr2 is used in the definition of the ARP packet format in
|
||||
* order to support compilers that don't have structure packing.
|
||||
*/
|
||||
@ -126,23 +116,8 @@ struct netif;
|
||||
|
||||
#define IP_LOOPBACKNET 127 /* official! */
|
||||
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
/** Set an IP address given by the four byte-parts */
|
||||
#define IP4_ADDR(ipaddr, a,b,c,d) \
|
||||
(ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \
|
||||
((u32_t)((b) & 0xff) << 16) | \
|
||||
((u32_t)((c) & 0xff) << 8) | \
|
||||
(u32_t)((d) & 0xff)
|
||||
#else
|
||||
/** Set an IP address given by the four byte-parts.
|
||||
Little-endian version that prevents the use of htonl. */
|
||||
#define IP4_ADDR(ipaddr, a,b,c,d) \
|
||||
(ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \
|
||||
((u32_t)((c) & 0xff) << 16) | \
|
||||
((u32_t)((b) & 0xff) << 8) | \
|
||||
(u32_t)((a) & 0xff)
|
||||
#endif
|
||||
#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = PP_HTONL(LWIP_MAKEU32(a,b,c,d))
|
||||
|
||||
/** MEMCPY-like copying of IP addresses where addresses are known to be
|
||||
* 16-bit-aligned if the port is correctly configured (so a port could define
|
||||
@ -159,7 +134,7 @@ struct netif;
|
||||
(src)->addr))
|
||||
/** Set complete address to zero */
|
||||
#define ip4_addr_set_zero(ipaddr) ((ipaddr)->addr = 0)
|
||||
/** Set address to IPADDR_ANY (no need for htonl()) */
|
||||
/** Set address to IPADDR_ANY (no need for lwip_htonl()) */
|
||||
#define ip4_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY)
|
||||
/** Set address to loopback address */
|
||||
#define ip4_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK))
|
||||
@ -169,7 +144,7 @@ struct netif;
|
||||
* from host- to network-order. */
|
||||
#define ip4_addr_set_hton(dest, src) ((dest)->addr = \
|
||||
((src) == NULL ? 0:\
|
||||
htonl((src)->addr)))
|
||||
lwip_htonl((src)->addr)))
|
||||
/** IPv4 only: set the IP address given as an u32_t */
|
||||
#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32))
|
||||
/** IPv4 only: get the IP address as an u32_t */
|
||||
@ -209,10 +184,10 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
|
||||
LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d))
|
||||
#define ip4_addr_debug_print(debug, ipaddr) \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
(ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0)
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0))
|
||||
#define ip4_addr_debug_print_val(debug, ipaddr) \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
ip4_addr1_16(&(ipaddr)), \
|
||||
@ -233,7 +208,6 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
|
||||
#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
|
||||
|
||||
#define IP4ADDR_STRLEN_MAX 16
|
||||
#define IPADDR_STRLEN_MAX IP4ADDR_STRLEN_MAX
|
||||
|
||||
/** For backwards compatibility */
|
||||
#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr)
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* IP fragmentation/reassembly
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -30,8 +35,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_IP_FRAG_H
|
||||
#define LWIP_HDR_IP_FRAG_H
|
||||
#ifndef LWIP_HDR_IP4_FRAG_H
|
||||
#define LWIP_HDR_IP4_FRAG_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/err.h"
|
||||
@ -50,7 +55,7 @@ extern "C" {
|
||||
/* The IP reassembly timer interval in milliseconds. */
|
||||
#define IP_TMR_INTERVAL 1000
|
||||
|
||||
/* IP reassembly helper struct.
|
||||
/** IP reassembly helper struct.
|
||||
* This is exported because memp needs to know the size.
|
||||
*/
|
||||
struct ip_reassdata {
|
||||
@ -68,12 +73,12 @@ struct pbuf * ip4_reass(struct pbuf *p);
|
||||
#endif /* IP_REASSEMBLY */
|
||||
|
||||
#if IP_FRAG
|
||||
#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
|
||||
#if !LWIP_NETIF_TX_SINGLE_PBUF
|
||||
#ifndef LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
#define LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
/** A custom pbuf that holds a reference to another pbuf, which is freed
|
||||
* when this custom pbuf is freed. This is used to create a custom PBUF_REF
|
||||
* that points into the original pbuf. */
|
||||
#ifndef LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
#define LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
struct pbuf_custom_ref {
|
||||
/** 'base class' */
|
||||
struct pbuf_custom pc;
|
||||
@ -81,7 +86,7 @@ struct pbuf_custom_ref {
|
||||
struct pbuf *original;
|
||||
};
|
||||
#endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */
|
||||
#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
|
||||
#endif /* !LWIP_NETIF_TX_SINGLE_PBUF */
|
||||
|
||||
err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest);
|
||||
#endif /* IP_FRAG */
|
||||
@ -92,4 +97,4 @@ err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest);
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#endif /* LWIP_HDR_IP_FRAG_H */
|
||||
#endif /* LWIP_HDR_IP4_FRAG_H */
|
@ -46,6 +46,7 @@
|
||||
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/prot/ip6.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
@ -56,111 +57,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IP6_HLEN 40
|
||||
|
||||
#define IP6_NEXTH_HOPBYHOP 0
|
||||
#define IP6_NEXTH_TCP 6
|
||||
#define IP6_NEXTH_UDP 17
|
||||
#define IP6_NEXTH_ENCAPS 41
|
||||
#define IP6_NEXTH_ROUTING 43
|
||||
#define IP6_NEXTH_FRAGMENT 44
|
||||
#define IP6_NEXTH_ICMP6 58
|
||||
#define IP6_NEXTH_NONE 59
|
||||
#define IP6_NEXTH_DESTOPTS 60
|
||||
#define IP6_NEXTH_UDPLITE 136
|
||||
|
||||
|
||||
/* The IPv6 header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_hdr {
|
||||
/* version / traffic class / flow label */
|
||||
PACK_STRUCT_FIELD(u32_t _v_tc_fl);
|
||||
/* payload length */
|
||||
PACK_STRUCT_FIELD(u16_t _plen);
|
||||
/* next header */
|
||||
PACK_STRUCT_FLD_8(u8_t _nexth);
|
||||
/* hop limit */
|
||||
PACK_STRUCT_FLD_8(u8_t _hoplim);
|
||||
/* source and destination IP addresses */
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t src);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t dest);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* Hop-by-hop router alert option. */
|
||||
#define IP6_HBH_HLEN 8
|
||||
#define IP6_PAD1_OPTION 0
|
||||
#define IP6_PADN_ALERT_OPTION 1
|
||||
#define IP6_ROUTER_ALERT_OPTION 5
|
||||
#define IP6_ROUTER_ALERT_VALUE_MLD 0
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_hbh_hdr {
|
||||
/* next header */
|
||||
PACK_STRUCT_FLD_8(u8_t _nexth);
|
||||
/* header length */
|
||||
PACK_STRUCT_FLD_8(u8_t _hlen);
|
||||
/* router alert option type */
|
||||
PACK_STRUCT_FLD_8(u8_t _ra_opt_type);
|
||||
/* router alert option data len */
|
||||
PACK_STRUCT_FLD_8(u8_t _ra_opt_dlen);
|
||||
/* router alert option data */
|
||||
PACK_STRUCT_FIELD(u16_t _ra_opt_data);
|
||||
/* PadN option type */
|
||||
PACK_STRUCT_FLD_8(u8_t _padn_opt_type);
|
||||
/* PadN option data len */
|
||||
PACK_STRUCT_FLD_8(u8_t _padn_opt_dlen);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* Fragment header. */
|
||||
#define IP6_FRAG_HLEN 8
|
||||
#define IP6_FRAG_OFFSET_MASK 0xfff8
|
||||
#define IP6_FRAG_MORE_FLAG 0x0001
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_frag_hdr {
|
||||
/* next header */
|
||||
PACK_STRUCT_FLD_8(u8_t _nexth);
|
||||
/* reserved */
|
||||
PACK_STRUCT_FLD_8(u8_t reserved);
|
||||
/* fragment offset */
|
||||
PACK_STRUCT_FIELD(u16_t _fragment_offset);
|
||||
/* fragmented packet identification */
|
||||
PACK_STRUCT_FIELD(u32_t _identification);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define IP6H_V(hdr) ((ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f)
|
||||
#define IP6H_TC(hdr) ((ntohl((hdr)->_v_tc_fl) >> 20) & 0xff)
|
||||
#define IP6H_FL(hdr) (ntohl((hdr)->_v_tc_fl) & 0x000fffff)
|
||||
#define IP6H_PLEN(hdr) (ntohs((hdr)->_plen))
|
||||
#define IP6H_NEXTH(hdr) ((hdr)->_nexth)
|
||||
#define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6)
|
||||
#define IP6H_HOPLIM(hdr) ((hdr)->_hoplim)
|
||||
|
||||
#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))
|
||||
#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = htons(plen)
|
||||
#define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth)
|
||||
#define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl)
|
||||
|
||||
|
||||
struct netif *ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest);
|
||||
const ip_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest);
|
||||
err_t ip6_input(struct pbuf *p, struct netif *inp);
|
||||
|
@ -43,6 +43,7 @@
|
||||
#define LWIP_HDR_IP6_ADDR_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "def.h"
|
||||
|
||||
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
@ -52,46 +53,18 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* This is the aligned version of ip6_addr_t,
|
||||
used as local variable, on the stack, etc. */
|
||||
/** This is the aligned version of ip6_addr_t,
|
||||
used as local variable, on the stack, etc. */
|
||||
struct ip6_addr {
|
||||
u32_t addr[4];
|
||||
};
|
||||
|
||||
/* This is the packed version of ip6_addr_t,
|
||||
used in network headers that are itself packed */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_addr_packed {
|
||||
PACK_STRUCT_FIELD(u32_t addr[4]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** IPv6 address */
|
||||
typedef struct ip6_addr ip6_addr_t;
|
||||
typedef struct ip6_addr_packed ip6_addr_p_t;
|
||||
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
/** Set an IPv6 partial address given by byte-parts. */
|
||||
/** Set an IPv6 partial address given by byte-parts */
|
||||
#define IP6_ADDR_PART(ip6addr, index, a,b,c,d) \
|
||||
(ip6addr)->addr[index] = ((u32_t)((a) & 0xff) << 24) | \
|
||||
((u32_t)((b) & 0xff) << 16) | \
|
||||
((u32_t)((c) & 0xff) << 8) | \
|
||||
(u32_t)((d) & 0xff)
|
||||
#else
|
||||
/** Set an IPv6 partial address given by byte-parts.
|
||||
Little-endian version, stored in network order (no htonl). */
|
||||
#define IP6_ADDR_PART(ip6addr, index, a,b,c,d) \
|
||||
(ip6addr)->addr[index] = ((u32_t)((d) & 0xff) << 24) | \
|
||||
((u32_t)((c) & 0xff) << 16) | \
|
||||
((u32_t)((b) & 0xff) << 8) | \
|
||||
(u32_t)((a) & 0xff)
|
||||
#endif
|
||||
(ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a,b,c,d))
|
||||
|
||||
/** Set a full IPv6 address by passing the 4 u32_t indices in network byte order
|
||||
(use PP_HTONL() for constants) */
|
||||
@ -102,14 +75,21 @@ Little-endian version, stored in network order (no htonl). */
|
||||
(ip6addr)->addr[3] = idx3; } while(0)
|
||||
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0]) >> 16) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0])) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1]) >> 16) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1])) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2]) >> 16) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2])) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)(htonl((ip6addr)->addr[3]) >> 16) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)(htonl((ip6addr)->addr[3])) & 0xffff)
|
||||
#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff))
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0])) & 0xffff))
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff))
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1])) & 0xffff))
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff))
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2])) & 0xffff))
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff))
|
||||
/** Access address in 16-bit block */
|
||||
#define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3])) & 0xffff))
|
||||
|
||||
/** Copy IPv6 address - faster than ip6_addr_set: no NULL check */
|
||||
#define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \
|
||||
@ -128,7 +108,7 @@ Little-endian version, stored in network order (no htonl). */
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = 0;}while(0)
|
||||
|
||||
/** Set address to ipv6 'any' (no need for htonl()) */
|
||||
/** Set address to ipv6 'any' (no need for lwip_htonl()) */
|
||||
#define ip6_addr_set_any(ip6addr) ip6_addr_set_zero(ip6addr)
|
||||
/** Set address to ipv6 loopback address */
|
||||
#define ip6_addr_set_loopback(ip6addr) do{(ip6addr)->addr[0] = 0; \
|
||||
@ -137,10 +117,10 @@ Little-endian version, stored in network order (no htonl). */
|
||||
(ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0)
|
||||
/** Safely copy one IPv6 address to another and change byte order
|
||||
* from host- to network-order. */
|
||||
#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : htonl((src)->addr[0]); \
|
||||
(dest)->addr[1] = (src) == NULL ? 0 : htonl((src)->addr[1]); \
|
||||
(dest)->addr[2] = (src) == NULL ? 0 : htonl((src)->addr[2]); \
|
||||
(dest)->addr[3] = (src) == NULL ? 0 : htonl((src)->addr[3]);}while(0)
|
||||
#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : lwip_htonl((src)->addr[0]); \
|
||||
(dest)->addr[1] = (src) == NULL ? 0 : lwip_htonl((src)->addr[1]); \
|
||||
(dest)->addr[2] = (src) == NULL ? 0 : lwip_htonl((src)->addr[2]); \
|
||||
(dest)->addr[3] = (src) == NULL ? 0 : lwip_htonl((src)->addr[3]);}while(0)
|
||||
|
||||
|
||||
/**
|
||||
@ -158,7 +138,7 @@ Little-endian version, stored in network order (no htonl). */
|
||||
((addr1)->addr[2] == (addr2)->addr[2]) && \
|
||||
((addr1)->addr[3] == (addr2)->addr[3]))
|
||||
|
||||
#define ip6_get_subnet_id(ip6addr) (htonl((ip6addr)->addr[2]) & 0x0000ffffUL)
|
||||
#define ip6_get_subnet_id(ip6addr) (lwip_htonl((ip6addr)->addr[2]) & 0x0000ffffUL)
|
||||
|
||||
#define ip6_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \
|
||||
((ip6addr).addr[1] == 0) && \
|
||||
@ -179,11 +159,13 @@ Little-endian version, stored in network order (no htonl). */
|
||||
|
||||
#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL))
|
||||
|
||||
#define ip6_addr_isipv4mappedipv6(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL)))
|
||||
|
||||
#define ip6_addr_ismulticast(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL))
|
||||
#define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL))
|
||||
#define ip6_addr_multicast_prefix_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00200000UL))
|
||||
#define ip6_addr_multicast_rendezvous_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00400000UL))
|
||||
#define ip6_addr_multicast_scope(ip6addr) ((htonl((ip6addr)->addr[0]) >> 16) & 0xf)
|
||||
#define ip6_addr_multicast_scope(ip6addr) ((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xf)
|
||||
#define IP6_MULTICAST_SCOPE_RESERVED 0x0
|
||||
#define IP6_MULTICAST_SCOPE_RESERVED0 0x0
|
||||
#define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1
|
||||
@ -201,7 +183,7 @@ Little-endian version, stored in network order (no htonl). */
|
||||
#define ip6_addr_ismulticast_orglocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff080000UL))
|
||||
#define ip6_addr_ismulticast_global(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff0e0000UL))
|
||||
|
||||
/* TODO define get/set for well-know multicast addresses, e.g. ff02::1 */
|
||||
/* @todo define get/set for well-know multicast addresses, e.g. ff02::1 */
|
||||
#define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \
|
||||
((ip6addr)->addr[1] == 0UL) && \
|
||||
((ip6addr)->addr[2] == 0UL) && \
|
||||
@ -249,9 +231,11 @@ Little-endian version, stored in network order (no htonl). */
|
||||
#define IP6_ADDR_TENTATIVE_5 0x0d /* 5 probes sent */
|
||||
#define IP6_ADDR_TENTATIVE_6 0x0e /* 6 probes sent */
|
||||
#define IP6_ADDR_TENTATIVE_7 0x0f /* 7 probes sent */
|
||||
#define IP6_ADDR_VALID 0x10
|
||||
#define IP6_ADDR_VALID 0x10 /* This bit marks an address as valid (preferred or deprecated) */
|
||||
#define IP6_ADDR_PREFERRED 0x30
|
||||
#define IP6_ADDR_DEPRECATED 0x50
|
||||
#define IP6_ADDR_DEPRECATED 0x10 /* Same as VALID (valid but not preferred) */
|
||||
|
||||
#define IP6_ADDR_TENTATIVE_COUNT_MASK 0x07 /* 1-7 probes sent */
|
||||
|
||||
#define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID)
|
||||
#define ip6_addr_istentative(addr_state) (addr_state & IP6_ADDR_TENTATIVE)
|
||||
@ -264,14 +248,14 @@ Little-endian version, stored in network order (no htonl). */
|
||||
a, b, c, d, e, f, g, h))
|
||||
#define ip6_addr_debug_print(debug, ipaddr) \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0, \
|
||||
(ipaddr) != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0)
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0), \
|
||||
(u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0))
|
||||
#define ip6_addr_debug_print_val(debug, ipaddr) \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
IP6_ADDR_BLOCK1(&(ipaddr)), \
|
||||
|
@ -61,7 +61,7 @@ extern "C" {
|
||||
#define IPV6_FRAG_COPYHEADER 0
|
||||
#endif
|
||||
|
||||
/* The IPv6 reassembly timer interval in milliseconds. */
|
||||
/** The IPv6 reassembly timer interval in milliseconds. */
|
||||
#define IP6_REASS_TMR_INTERVAL 1000
|
||||
|
||||
/* Copy the complete header of the first fragment to struct ip6_reassdata
|
||||
@ -74,7 +74,7 @@ extern "C" {
|
||||
#define IPV6_FRAG_HDRREF(hdr) (hdr)
|
||||
#endif /* IPV6_FRAG_COPYHEADER */
|
||||
|
||||
/* IPv6 reassembly helper struct.
|
||||
/** IPv6 reassembly helper struct.
|
||||
* This is exported because memp needs to know the size.
|
||||
*/
|
||||
struct ip6_reassdata {
|
||||
@ -89,17 +89,17 @@ struct ip6_reassdata {
|
||||
|
||||
#define ip6_reass_init() /* Compatibility define */
|
||||
void ip6_reass_tmr(void);
|
||||
struct pbuf * ip6_reass(struct pbuf *p);
|
||||
struct pbuf *ip6_reass(struct pbuf *p);
|
||||
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
#define LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
/** A custom pbuf that holds a reference to another pbuf, which is freed
|
||||
* when this custom pbuf is freed. This is used to create a custom PBUF_REF
|
||||
* that points into the original pbuf. */
|
||||
#ifndef LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
#define LWIP_PBUF_CUSTOM_REF_DEFINED
|
||||
struct pbuf_custom_ref {
|
||||
/** 'base class' */
|
||||
struct pbuf_custom pc;
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* IP address API (common IPv4 and IPv6)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -29,8 +34,8 @@
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_IP_ADDR_H__
|
||||
#define LWIP_HDR_IP_ADDR_H__
|
||||
#ifndef LWIP_HDR_IP_ADDR_H
|
||||
#define LWIP_HDR_IP_ADDR_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
@ -42,36 +47,63 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** These are the values for ip_addr_t.type */
|
||||
#define IPADDR_TYPE_V4 0U
|
||||
#define IPADDR_TYPE_V6 6U
|
||||
#define IPADDR_TYPE_ANY 46U
|
||||
/** @ingroup ipaddr
|
||||
* IP address types for use in ip_addr_t.type member.
|
||||
* @see tcp_new_ip_type(), udp_new_ip_type(), raw_new_ip_type().
|
||||
*/
|
||||
enum lwip_ip_addr_type {
|
||||
/** IPv4 */
|
||||
IPADDR_TYPE_V4 = 0U,
|
||||
/** IPv6 */
|
||||
IPADDR_TYPE_V6 = 6U,
|
||||
/** IPv4+IPv6 ("dual-stack") */
|
||||
IPADDR_TYPE_ANY = 46U
|
||||
};
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/** A union struct for both IP version's addresses.
|
||||
/**
|
||||
* @ingroup ipaddr
|
||||
* A union struct for both IP version's addresses.
|
||||
* ATTENTION: watch out for its size when adding IPv6 address scope!
|
||||
*/
|
||||
typedef struct _ip_addr {
|
||||
typedef struct ip_addr {
|
||||
union {
|
||||
ip6_addr_t ip6;
|
||||
ip4_addr_t ip4;
|
||||
} u_addr;
|
||||
/** @ref lwip_ip_addr_type */
|
||||
u8_t type;
|
||||
} ip_addr_t;
|
||||
|
||||
extern const ip_addr_t ip_addr_any_type;
|
||||
|
||||
/** @ingroup ip4addr */
|
||||
#define IPADDR4_INIT(u32val) { { { { u32val, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_V4 }
|
||||
/** @ingroup ip4addr */
|
||||
#define IPADDR4_INIT_BYTES(a,b,c,d) IPADDR4_INIT(PP_HTONL(LWIP_MAKEU32(a,b,c,d)))
|
||||
/** @ingroup ip6addr */
|
||||
#define IPADDR6_INIT(a, b, c, d) { { { { a, b, c, d } } }, IPADDR_TYPE_V6 }
|
||||
/** @ingroup ip6addr */
|
||||
#define IPADDR6_INIT_HOST(a, b, c, d) { { { { PP_HTONL(a), PP_HTONL(b), PP_HTONL(c), PP_HTONL(d) } } }, IPADDR_TYPE_V6 }
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
#define IP_IS_ANY_TYPE_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_ANY)
|
||||
/** @ingroup ipaddr */
|
||||
#define IPADDR_ANY_TYPE_INIT { { { { 0ul, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_ANY }
|
||||
|
||||
/** @ingroup ip4addr */
|
||||
#define IP_IS_V4_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V4)
|
||||
/** @ingroup ip6addr */
|
||||
#define IP_IS_V6_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V6)
|
||||
/** @ingroup ip4addr */
|
||||
#define IP_IS_V4(ipaddr) (((ipaddr) == NULL) || IP_IS_V4_VAL(*(ipaddr)))
|
||||
/** @ingroup ip6addr */
|
||||
#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(*(ipaddr)))
|
||||
|
||||
#if ESP_LWIP
|
||||
#define IP_V6_EQ_PART(ipaddr, WORD, VAL) (ip_2_ip6(ipaddr)->addr[WORD] == htonl(VAL))
|
||||
#define IP_IS_V4MAPPEDV6(ipaddr) (IP_IS_V6(ipaddr) && IP_V6_EQ_PART(ipaddr, 0, 0) && IP_V6_EQ_PART(ipaddr, 1, 0) && IP_V6_EQ_PART(ipaddr, 2, 0x0000FFFF))
|
||||
#endif
|
||||
|
||||
#define IP_SET_TYPE_VAL(ipaddr, iptype) do { (ipaddr).type = (iptype); }while(0)
|
||||
#define IP_SET_TYPE(ipaddr, iptype) do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)
|
||||
@ -80,71 +112,100 @@ extern const ip_addr_t ip_addr_any_type;
|
||||
#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) (IP_GET_TYPE(&pcb->local_ip) == IP_GET_TYPE(ipaddr))
|
||||
#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (IP_IS_ANY_TYPE_VAL(pcb->local_ip) || IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr))
|
||||
|
||||
/* Convert generic ip address to specific protocol version */
|
||||
/** @ingroup ip6addr
|
||||
* Convert generic ip address to specific protocol version
|
||||
*/
|
||||
#define ip_2_ip6(ipaddr) (&((ipaddr)->u_addr.ip6))
|
||||
/** @ingroup ip4addr
|
||||
* Convert generic ip address to specific protocol version
|
||||
*/
|
||||
#define ip_2_ip4(ipaddr) (&((ipaddr)->u_addr.ip4))
|
||||
|
||||
/** @ingroup ip4addr */
|
||||
#define IP_ADDR4(ipaddr,a,b,c,d) do { IP4_ADDR(ip_2_ip4(ipaddr),a,b,c,d); \
|
||||
IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V4); } while(0)
|
||||
/** @ingroup ip6addr */
|
||||
#define IP_ADDR6(ipaddr,i0,i1,i2,i3) do { IP6_ADDR(ip_2_ip6(ipaddr),i0,i1,i2,i3); \
|
||||
IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V6); } while(0)
|
||||
/** @ingroup ip6addr */
|
||||
#define IP_ADDR6_HOST(ipaddr,i0,i1,i2,i3) IP_ADDR6(ipaddr,PP_HTONL(i0),PP_HTONL(i1),PP_HTONL(i2),PP_HTONL(i3))
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_copy(dest, src) do{ IP_SET_TYPE_VAL(dest, IP_GET_TYPE(&src)); if(IP_IS_V6_VAL(src)){ \
|
||||
ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); }else{ \
|
||||
ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); }}while(0)
|
||||
/** @ingroup ip6addr */
|
||||
#define ip_addr_copy_from_ip6(dest, src) do{ \
|
||||
ip6_addr_copy(*ip_2_ip6(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6); }while(0)
|
||||
/** @ingroup ip4addr */
|
||||
#define ip_addr_copy_from_ip4(dest, src) do{ \
|
||||
ip4_addr_copy(*ip_2_ip4(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4); }while(0)
|
||||
/** @ingroup ip4addr */
|
||||
#define ip_addr_set_ip4_u32(ipaddr, val) do{if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \
|
||||
IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0)
|
||||
#define ip_addr_get_ip4_u32(ipaddr) (((ipaddr) && !IP_IS_V6(ipaddr)) ? \
|
||||
/** @ingroup ip4addr */
|
||||
#define ip_addr_get_ip4_u32(ipaddr) (((ipaddr) && IP_IS_V4(ipaddr)) ? \
|
||||
ip4_addr_get_u32(ip_2_ip4(ipaddr)) : 0)
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set(dest, src) do{ IP_SET_TYPE(dest, IP_GET_TYPE(src)); if(IP_IS_V6(src)){ \
|
||||
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); }else{ \
|
||||
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); }}while(0)
|
||||
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_ipaddr(dest, src) ip_addr_set(dest, src)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_zero(ipaddr) do{ \
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, 0); }while(0)
|
||||
/** @ingroup ip5addr */
|
||||
#define ip_addr_set_zero_ip4(ipaddr) do{ \
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }while(0)
|
||||
/** @ingroup ip6addr */
|
||||
#define ip_addr_set_zero_ip6(ipaddr) do{ \
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_any(is_ipv6, ipaddr) do{if(is_ipv6){ \
|
||||
ip6_addr_set_any(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }else{ \
|
||||
ip4_addr_set_any(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_loopback(is_ipv6, ipaddr) do{if(is_ipv6){ \
|
||||
ip6_addr_set_loopback(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }else{ \
|
||||
ip4_addr_set_loopback(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_set_hton(dest, src) do{if(IP_IS_V6(src)){ \
|
||||
ip6_addr_set_hton(ip_2_ip6(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); }else{ \
|
||||
ip4_addr_set_hton(ip_2_ip4(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }}while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_get_network(target, host, netmask) do{if(IP_IS_V6(host)){ \
|
||||
ip4_addr_set_zero(ip_2_ip4(target)); IP_SET_TYPE(target, IPADDR_TYPE_V6); } else { \
|
||||
ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); IP_SET_TYPE(target, IPADDR_TYPE_V4); }}while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_netcmp(addr1, addr2, mask) ((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \
|
||||
0 : \
|
||||
ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_cmp(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \
|
||||
ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \
|
||||
ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2))))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_isany(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isany(ip_2_ip4(ipaddr)))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isany_val(ipaddr) ((IP_IS_V6_VAL(ipaddr)) ? \
|
||||
ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \
|
||||
ip4_addr_isany_val(*ip_2_ip4(&(ipaddr))))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isbroadcast(ipaddr, netif) ((IP_IS_V6(ipaddr)) ? \
|
||||
0 : \
|
||||
ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_ismulticast(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_ismulticast(ip_2_ip4(ipaddr)))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_isloopback(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isloopback(ip_2_ip4(ipaddr)))
|
||||
/** @ingroup ipaddr */
|
||||
#define ip_addr_islinklocal(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_islinklocal(ip_2_ip4(ipaddr)))
|
||||
@ -154,32 +215,29 @@ extern const ip_addr_t ip_addr_any_type;
|
||||
#define ip_addr_debug_print_val(debug, ipaddr) do { if(IP_IS_V6_VAL(ipaddr)) { \
|
||||
ip6_addr_debug_print_val(debug, *ip_2_ip6(&(ipaddr))); } else { \
|
||||
ip4_addr_debug_print_val(debug, *ip_2_ip4(&(ipaddr))); }}while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
|
||||
/** @ingroup ipaddr */
|
||||
#define ipaddr_ntoa_r(addr, buf, buflen) (((addr) == NULL) ? "NULL" : \
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen)))
|
||||
int ipaddr_aton(const char *cp, ip_addr_t *addr);
|
||||
|
||||
/* Map an IPv4 ip_addr into an IPV6 ip_addr, using format
|
||||
defined in RFC4291 2.5.5.2.
|
||||
/** @ingroup ipaddr */
|
||||
#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX
|
||||
|
||||
Safe to call when dest==src.
|
||||
*/
|
||||
#define ip_addr_make_ip4_mapped_ip6(dest, src) do { \
|
||||
u32_t tmp = ip_2_ip4(src)->addr; \
|
||||
IP_ADDR6((dest), 0x0, 0x0, htonl(0x0000FFFF), tmp); \
|
||||
} while(0)
|
||||
/** @ingroup ipaddr */
|
||||
#define ip4_2_ipv4_mapped_ipv6(ip6addr, ip4addr) do { \
|
||||
(ip6addr)->addr[3] = (ip4addr)->addr; \
|
||||
(ip6addr)->addr[2] = PP_HTONL(0x0000FFFFUL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[0] = 0; } while(0);
|
||||
|
||||
/* Convert an IPv4 mapped V6 address to an IPV4 address.
|
||||
/** @ingroup ipaddr */
|
||||
#define unmap_ipv4_mapped_ipv6(ip4addr, ip6addr) \
|
||||
(ip4addr)->addr = (ip6addr)->addr[3];
|
||||
|
||||
Check IP_IS_V4MAPPEDV6(src) before using this.
|
||||
|
||||
Safe to call when dest == src.
|
||||
*/
|
||||
#define ip_addr_ip4_from_mapped_ip6(dest, src) do { \
|
||||
ip_2_ip4(dest)->addr = ip_2_ip6(src)->addr[3]; \
|
||||
IP_SET_TYPE(dest, IPADDR_TYPE_V4); \
|
||||
} while(0)
|
||||
#define IP46_ADDR_ANY(type) (((type) == IPADDR_TYPE_V6)? IP6_ADDR_ANY : IP4_ADDR_ANY)
|
||||
|
||||
#else /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
@ -190,7 +248,10 @@ int ipaddr_aton(const char *cp, ip_addr_t *addr);
|
||||
|
||||
typedef ip4_addr_t ip_addr_t;
|
||||
#define IPADDR4_INIT(u32val) { u32val }
|
||||
#define IPADDR4_INIT_BYTES(a,b,c,d) IPADDR4_INIT(PP_HTONL(LWIP_MAKEU32(a,b,c,d)))
|
||||
#define IP_IS_V4_VAL(ipaddr) 1
|
||||
#define IP_IS_V6_VAL(ipaddr) 0
|
||||
#define IP_IS_V4(ipaddr) 1
|
||||
#define IP_IS_V6(ipaddr) 0
|
||||
#define IP_IS_ANY_TYPE_VAL(ipaddr) 0
|
||||
#define IP_SET_TYPE_VAL(ipaddr, iptype)
|
||||
@ -225,11 +286,18 @@ typedef ip4_addr_t ip_addr_t;
|
||||
#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip4addr_ntoa_r(ipaddr, buf, buflen)
|
||||
#define ipaddr_aton(cp, addr) ip4addr_aton(cp, addr)
|
||||
|
||||
#define IPADDR_STRLEN_MAX IP4ADDR_STRLEN_MAX
|
||||
|
||||
#define IP46_ADDR_ANY(type) (IP4_ADDR_ANY)
|
||||
|
||||
#else /* LWIP_IPV4 */
|
||||
|
||||
typedef ip6_addr_t ip_addr_t;
|
||||
#define IPADDR6_INIT(a, b, c, d) { { a, b, c, d } }
|
||||
#define IPADDR6_INIT_HOST(a, b, c, d) { { PP_HTONL(a), PP_HTONL(b), PP_HTONL(c), PP_HTONL(d) } }
|
||||
#define IP_IS_V4_VAL(ipaddr) 0
|
||||
#define IP_IS_V6_VAL(ipaddr) 1
|
||||
#define IP_IS_V4(ipaddr) 0
|
||||
#define IP_IS_V6(ipaddr) 1
|
||||
#define IP_IS_ANY_TYPE_VAL(ipaddr) 0
|
||||
#define IP_SET_TYPE_VAL(ipaddr, iptype)
|
||||
@ -237,6 +305,7 @@ typedef ip6_addr_t ip_addr_t;
|
||||
#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V6
|
||||
#define ip_2_ip6(ipaddr) (ipaddr)
|
||||
#define IP_ADDR6(ipaddr,i0,i1,i2,i3) IP6_ADDR(ipaddr,i0,i1,i2,i3)
|
||||
#define IP_ADDR6_HOST(ipaddr,i0,i1,i2,i3) IP_ADDR6(ipaddr,PP_HTONL(i0),PP_HTONL(i1),PP_HTONL(i2),PP_HTONL(i3))
|
||||
|
||||
#define ip_addr_copy(dest, src) ip6_addr_copy(dest, src)
|
||||
#define ip_addr_copy_from_ip6(dest, src) ip6_addr_copy(dest, src)
|
||||
@ -262,6 +331,10 @@ typedef ip6_addr_t ip_addr_t;
|
||||
#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip6addr_ntoa_r(ipaddr, buf, buflen)
|
||||
#define ipaddr_aton(cp, addr) ip6addr_aton(cp, addr)
|
||||
|
||||
#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX
|
||||
|
||||
#define IP46_ADDR_ANY(type) (IP6_ADDR_ANY)
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
@ -270,15 +343,33 @@ typedef ip6_addr_t ip_addr_t;
|
||||
extern const ip_addr_t ip_addr_any;
|
||||
extern const ip_addr_t ip_addr_broadcast;
|
||||
|
||||
/** IP_ADDR_ can be used as a fixed/const ip_addr_t
|
||||
* for the IPv4 wildcard and the broadcast address
|
||||
/**
|
||||
* @ingroup ip4addr
|
||||
* Can be used as a fixed/const ip_addr_t
|
||||
* for the IP wildcard.
|
||||
* Defined to @ref IP4_ADDR_ANY when IPv4 is enabled.
|
||||
* Defined to @ref IP6_ADDR_ANY in IPv6 only systems.
|
||||
* Use this if you can handle IPv4 _AND_ IPv6 addresses.
|
||||
* Use @ref IP4_ADDR_ANY or @ref IP6_ADDR_ANY when the IP
|
||||
* type matters.
|
||||
*/
|
||||
#define IP_ADDR_ANY (&ip_addr_any)
|
||||
#define IP_ADDR_ANY IP4_ADDR_ANY
|
||||
/**
|
||||
* @ingroup ip4addr
|
||||
* Can be used as a fixed/const ip_addr_t
|
||||
* for the IPv4 wildcard and the broadcast address
|
||||
*/
|
||||
#define IP4_ADDR_ANY (&ip_addr_any)
|
||||
/**
|
||||
* @ingroup ip4addr
|
||||
* Can be used as a fixed/const ip4_addr_t
|
||||
* for the wildcard and the broadcast address
|
||||
*/
|
||||
#define IP4_ADDR_ANY4 (ip_2_ip4(&ip_addr_any))
|
||||
|
||||
/** @ingroup ip4addr */
|
||||
#define IP_ADDR_BROADCAST (&ip_addr_broadcast)
|
||||
/** IP4_ADDR_ can be used as a fixed/const ip4_addr_t
|
||||
* for the wildcard and the broadcast address
|
||||
*/
|
||||
#define IP4_ADDR_ANY (ip_2_ip4(&ip_addr_any))
|
||||
/** @ingroup ip4addr */
|
||||
#define IP4_ADDR_BROADCAST (ip_2_ip4(&ip_addr_broadcast))
|
||||
|
||||
#endif /* LWIP_IPV4*/
|
||||
@ -287,23 +378,28 @@ extern const ip_addr_t ip_addr_broadcast;
|
||||
|
||||
extern const ip_addr_t ip6_addr_any;
|
||||
|
||||
/** IP6_ADDR_ANY can be used as a fixed ip_addr_t
|
||||
* for the IPv6 wildcard address
|
||||
/**
|
||||
* @ingroup ip6addr
|
||||
* IP6_ADDR_ANY can be used as a fixed ip_addr_t
|
||||
* for the IPv6 wildcard address
|
||||
*/
|
||||
#define IP6_ADDR_ANY (&ip6_addr_any)
|
||||
/** IP6_ADDR_ANY6 can be used as a fixed ip6_addr_t
|
||||
* for the IPv6 wildcard address
|
||||
/**
|
||||
* @ingroup ip6addr
|
||||
* IP6_ADDR_ANY6 can be used as a fixed ip6_addr_t
|
||||
* for the IPv6 wildcard address
|
||||
*/
|
||||
#define IP6_ADDR_ANY6 (ip_2_ip6(&ip6_addr_any))
|
||||
|
||||
#if !LWIP_IPV4
|
||||
/** Just a little upgrade-helper for IPv6-only configurations: */
|
||||
/** IPv6-only configurations */
|
||||
#define IP_ADDR_ANY IP6_ADDR_ANY
|
||||
#endif /* !LWIP_IPV4 */
|
||||
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/** @ingroup ipaddr */
|
||||
#define IP_ANY_TYPE (&ip_addr_any_type)
|
||||
#else
|
||||
#define IP_ANY_TYPE IP_ADDR_ANY
|
||||
@ -313,4 +409,4 @@ extern const ip_addr_t ip6_addr_any;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_IP_ADDR_H__ */
|
||||
#endif /* LWIP_HDR_IP_ADDR_H */
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Heap API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -40,20 +45,17 @@ extern "C" {
|
||||
|
||||
#if MEM_LIBC_MALLOC
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
#include "lwip/arch.h"
|
||||
|
||||
typedef size_t mem_size_t;
|
||||
#define MEM_SIZE_F SZT_F
|
||||
|
||||
/* aliases for C library malloc() */
|
||||
#define mem_init()
|
||||
/* in case C library malloc() needs extra protection,
|
||||
* allow these defines to be overridden.
|
||||
*/
|
||||
#elif MEM_USE_POOLS
|
||||
|
||||
#ifndef mem_free
|
||||
#define mem_free free
|
||||
#endif
|
||||
typedef u16_t mem_size_t;
|
||||
#define MEM_SIZE_F U16_F
|
||||
|
||||
#if ESP_LWIP
|
||||
/**
|
||||
* lwip_malloc: if CONFIG_ALLOC_MEMORY_IN_SPIRAM_FIRST is enabled, Try to
|
||||
* allocate memory for lwip in SPIRAM firstly. If failed, try to allocate
|
||||
@ -66,21 +68,10 @@ typedef size_t mem_size_t;
|
||||
#ifndef mem_calloc
|
||||
#define mem_calloc(n, size) heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#endif
|
||||
#else
|
||||
#ifndef mem_malloc
|
||||
#define mem_malloc malloc
|
||||
#endif
|
||||
#ifndef mem_calloc
|
||||
#define mem_calloc calloc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Since there is no C library allocation function to shrink memory without
|
||||
moving it, define this to nothing. */
|
||||
#ifndef mem_trim
|
||||
#define mem_trim(mem, size) (mem)
|
||||
#endif
|
||||
#else /* MEM_LIBC_MALLOC */
|
||||
#else
|
||||
|
||||
/* MEM_SIZE would have to be aligned, but using 64000 here instead of
|
||||
* 65535 leaves some room for alignment...
|
||||
@ -92,45 +83,13 @@ typedef u32_t mem_size_t;
|
||||
typedef u16_t mem_size_t;
|
||||
#define MEM_SIZE_F U16_F
|
||||
#endif /* MEM_SIZE > 64000 */
|
||||
#endif
|
||||
|
||||
#if MEM_USE_POOLS
|
||||
/** mem_init is not used when using pools instead of a heap */
|
||||
#define mem_init()
|
||||
/** mem_trim is not used when using pools instead of a heap:
|
||||
we can't free part of a pool element and don't want to copy the rest */
|
||||
#define mem_trim(mem, size) (mem)
|
||||
#else /* MEM_USE_POOLS */
|
||||
/* lwIP alternative malloc */
|
||||
void mem_init(void);
|
||||
void *mem_trim(void *mem, mem_size_t size);
|
||||
#endif /* MEM_USE_POOLS */
|
||||
void *mem_malloc(mem_size_t size);
|
||||
void *mem_calloc(mem_size_t count, mem_size_t size);
|
||||
void mem_free(void *mem);
|
||||
#endif /* MEM_LIBC_MALLOC */
|
||||
|
||||
/** Calculate memory size for an aligned buffer - returns the next highest
|
||||
* multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and
|
||||
* LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4).
|
||||
*/
|
||||
#ifndef LWIP_MEM_ALIGN_SIZE
|
||||
#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1U) & ~(MEM_ALIGNMENT-1U))
|
||||
#endif
|
||||
|
||||
/** Calculate safe memory size for an aligned buffer when using an unaligned
|
||||
* type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the
|
||||
* start (e.g. if buffer is u8_t[] and actual data will be u32_t*)
|
||||
*/
|
||||
#ifndef LWIP_MEM_ALIGN_BUFFER
|
||||
#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1U))
|
||||
#endif
|
||||
|
||||
/** Align a memory pointer to the alignment defined by MEM_ALIGNMENT
|
||||
* so that ADDR % MEM_ALIGNMENT == 0
|
||||
*/
|
||||
#ifndef LWIP_MEM_ALIGN
|
||||
#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Memory pool API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -33,6 +38,8 @@
|
||||
#ifndef LWIP_HDR_MEMP_H
|
||||
#define LWIP_HDR_MEMP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -41,7 +48,7 @@ extern "C" {
|
||||
#define LWIP_MEMPOOL(name,num,size,desc)
|
||||
#include "lwip/priv/memp_std.h"
|
||||
|
||||
/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
|
||||
/** Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
|
||||
typedef enum {
|
||||
#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
|
||||
#include "lwip/priv/memp_std.h"
|
||||
@ -49,8 +56,32 @@ typedef enum {
|
||||
} memp_t;
|
||||
|
||||
#include "lwip/priv/memp_priv.h"
|
||||
#include "lwip/stats.h"
|
||||
|
||||
/* Private mempools example:
|
||||
extern const struct memp_desc* const memp_pools[MEMP_MAX];
|
||||
|
||||
/**
|
||||
* @ingroup mempool
|
||||
* Declare prototype for private memory pool if it is used in multiple files
|
||||
*/
|
||||
#define LWIP_MEMPOOL_PROTOTYPE(name) extern const struct memp_desc memp_ ## name
|
||||
|
||||
#if MEMP_MEM_MALLOC
|
||||
|
||||
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
|
||||
LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \
|
||||
const struct memp_desc memp_ ## name = { \
|
||||
DECLARE_LWIP_MEMPOOL_DESC(desc) \
|
||||
LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \
|
||||
LWIP_MEM_ALIGN_SIZE(size) \
|
||||
};
|
||||
|
||||
#else /* MEMP_MEM_MALLOC */
|
||||
|
||||
/**
|
||||
* @ingroup mempool
|
||||
* Declare a private memory pool
|
||||
* Private mempools example:
|
||||
* .h: only when pool is used in multiple .c files: LWIP_MEMPOOL_PROTOTYPE(my_private_pool);
|
||||
* .c:
|
||||
* - in global variables section: LWIP_MEMPOOL_DECLARE(my_private_pool, 10, sizeof(foo), "Some description")
|
||||
@ -61,74 +92,50 @@ typedef enum {
|
||||
* To relocate a pool, declare it as extern in cc.h. Example for GCC:
|
||||
* extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_my_private_pool[];
|
||||
*/
|
||||
|
||||
extern const struct memp_desc* const memp_pools[MEMP_MAX];
|
||||
|
||||
#define LWIP_MEMPOOL_PROTOTYPE(name) extern const struct memp_desc memp_ ## name
|
||||
|
||||
#if MEMP_MEM_MALLOC
|
||||
|
||||
#include "lwip/mem.h"
|
||||
|
||||
#define memp_init()
|
||||
#if ESP_STATS_MEM
|
||||
static inline void* memp_malloc(int type)
|
||||
{
|
||||
ESP_CNT_MEM_MALLOC_INC(type);
|
||||
return mem_malloc(memp_pools[type]->size);
|
||||
}
|
||||
|
||||
static inline void memp_free(int type, void *mem)
|
||||
{
|
||||
ESP_CNT_MEM_FREE_INC(type);
|
||||
mem_free(mem);
|
||||
}
|
||||
|
||||
//#define memp_malloc(type) mem_malloc(memp_pools[type]->size); ESP_CNT_MEM_MALLOC_INC(type)
|
||||
//#define memp_free(type, mem) mem_free(mem); ESP_CNT_MEM_FREE_INC(type)
|
||||
#else
|
||||
#define memp_malloc(type) mem_malloc(memp_pools[type]->size)
|
||||
#define memp_free(type, mem) mem_free(mem)
|
||||
#endif
|
||||
|
||||
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
|
||||
const struct memp_desc memp_ ## name = { \
|
||||
LWIP_MEM_ALIGN_SIZE(size) \
|
||||
};
|
||||
|
||||
#define LWIP_MEMPOOL_INIT(name)
|
||||
#define LWIP_MEMPOOL_ALLOC(name) mem_malloc(memp_ ## name.size)
|
||||
#define LWIP_MEMPOOL_FREE(name, x) mem_free(x)
|
||||
|
||||
#else /* MEMP_MEM_MALLOC */
|
||||
|
||||
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) u8_t memp_memory_ ## name ## _base \
|
||||
[((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; \
|
||||
LWIP_DECLARE_MEMORY_ALIGNED(memp_memory_ ## name ## _base, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))); \
|
||||
\
|
||||
LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \
|
||||
\
|
||||
static struct memp *memp_tab_ ## name; \
|
||||
\
|
||||
const struct memp_desc memp_ ## name = { \
|
||||
DECLARE_LWIP_MEMPOOL_DESC(desc) \
|
||||
LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \
|
||||
LWIP_MEM_ALIGN_SIZE(size), \
|
||||
(num), \
|
||||
DECLARE_LWIP_MEMPOOL_DESC(desc) \
|
||||
memp_memory_ ## name ## _base, \
|
||||
&memp_tab_ ## name \
|
||||
};
|
||||
|
||||
#endif /* MEMP_MEM_MALLOC */
|
||||
|
||||
/**
|
||||
* @ingroup mempool
|
||||
* Initialize a private memory pool
|
||||
*/
|
||||
#define LWIP_MEMPOOL_INIT(name) memp_init_pool(&memp_ ## name)
|
||||
/**
|
||||
* @ingroup mempool
|
||||
* Allocate from a private memory pool
|
||||
*/
|
||||
#define LWIP_MEMPOOL_ALLOC(name) memp_malloc_pool(&memp_ ## name)
|
||||
/**
|
||||
* @ingroup mempool
|
||||
* Free element from a private memory pool
|
||||
*/
|
||||
#define LWIP_MEMPOOL_FREE(name, x) memp_free_pool(&memp_ ## name, (x))
|
||||
|
||||
#if MEM_USE_POOLS
|
||||
/** This structure is used to save the pool one element came from. */
|
||||
/** This structure is used to save the pool one element came from.
|
||||
* This has to be defined here as it is required for pool size calculation. */
|
||||
struct memp_malloc_helper
|
||||
{
|
||||
memp_t poolnr;
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
#if MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS)
|
||||
u16_t size;
|
||||
#endif /* MEMP_OVERFLOW_CHECK */
|
||||
#endif /* MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS) */
|
||||
};
|
||||
|
||||
#endif /* MEM_USE_POOLS */
|
||||
|
||||
void memp_init(void);
|
||||
@ -141,8 +148,6 @@ void *memp_malloc(memp_t type);
|
||||
#endif
|
||||
void memp_free(memp_t type, void *mem);
|
||||
|
||||
#endif /* MEMP_MEM_MALLOC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -50,16 +50,14 @@
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** MLD group */
|
||||
struct mld_group {
|
||||
/** next link */
|
||||
struct mld_group *next;
|
||||
/** interface on which the group is active */
|
||||
struct netif *netif;
|
||||
/** multicast address */
|
||||
ip6_addr_t group_address;
|
||||
/** signifies we were the last person to report */
|
||||
@ -72,33 +70,8 @@ struct mld_group {
|
||||
u8_t use;
|
||||
};
|
||||
|
||||
/** Multicast listener report/query/done message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct mld_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t max_resp_delay);
|
||||
PACK_STRUCT_FIELD(u16_t reserved);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define MLD6_TMR_INTERVAL 100 /* Milliseconds */
|
||||
|
||||
/* MAC Filter Actions, these are passed to a netif's
|
||||
* mld_mac_filter callback function. */
|
||||
#define MLD6_DEL_MAC_FILTER 0
|
||||
#define MLD6_ADD_MAC_FILTER 1
|
||||
|
||||
|
||||
err_t mld6_stop(struct netif *netif);
|
||||
void mld6_report_groups(struct netif *netif);
|
||||
void mld6_tmr(void);
|
||||
@ -109,6 +82,13 @@ err_t mld6_joingroup_netif(struct netif *netif, const ip6_addr_t *groupaddr);
|
||||
err_t mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr);
|
||||
err_t mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr);
|
||||
|
||||
/** @ingroup mld6
|
||||
* Get list head of MLD6 groups for netif.
|
||||
* Note: The allnodes group IP is NOT in the list, since it must always
|
||||
* be received for correct IPv6 operation.
|
||||
* @see @ref netif_set_mld_mac_filter()
|
||||
*/
|
||||
#define netif_mld6_data(netif) ((struct mld_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_MLD6))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -48,314 +48,38 @@
|
||||
|
||||
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip6.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Struct for tables. */
|
||||
struct nd6_neighbor_cache_entry {
|
||||
ip6_addr_t next_hop_address;
|
||||
struct netif * netif;
|
||||
u8_t lladdr[NETIF_MAX_HWADDR_LEN];
|
||||
/*u32_t pmtu;*/
|
||||
#if LWIP_ND6_QUEUEING
|
||||
/** Pointer to queue of pending outgoing packets on this entry. */
|
||||
struct nd6_q_entry *q;
|
||||
#else /* LWIP_ND6_QUEUEING */
|
||||
/** Pointer to a single pending outgoing packet on this entry. */
|
||||
struct pbuf *q;
|
||||
#endif /* LWIP_ND6_QUEUEING */
|
||||
u8_t state;
|
||||
u8_t isrouter;
|
||||
union {
|
||||
u32_t reachable_time;
|
||||
u32_t delay_time;
|
||||
u32_t probes_sent;
|
||||
u32_t stale_time;
|
||||
} counter;
|
||||
};
|
||||
|
||||
struct nd6_destination_cache_entry {
|
||||
ip6_addr_t destination_addr;
|
||||
ip6_addr_t next_hop_addr;
|
||||
u16_t pmtu;
|
||||
u32_t age;
|
||||
};
|
||||
|
||||
struct nd6_prefix_list_entry {
|
||||
ip6_addr_t prefix;
|
||||
struct netif * netif;
|
||||
u32_t invalidation_timer;
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
u8_t flags;
|
||||
#define ND6_PREFIX_AUTOCONFIG_AUTONOMOUS 0x01
|
||||
#define ND6_PREFIX_AUTOCONFIG_ADDRESS_GENERATED 0x02
|
||||
#define ND6_PREFIX_AUTOCONFIG_ADDRESS_DUPLICATE 0x04
|
||||
#endif /* LWIP_IPV6_AUTOCONFIG */
|
||||
};
|
||||
|
||||
struct nd6_router_list_entry {
|
||||
struct nd6_neighbor_cache_entry * neighbor_entry;
|
||||
u32_t invalidation_timer;
|
||||
u8_t flags;
|
||||
};
|
||||
|
||||
|
||||
enum nd6_neighbor_cache_entry_state {
|
||||
ND6_NO_ENTRY = 0,
|
||||
ND6_INCOMPLETE,
|
||||
ND6_REACHABLE,
|
||||
ND6_STALE,
|
||||
ND6_DELAY,
|
||||
ND6_PROBE
|
||||
};
|
||||
|
||||
#if LWIP_ND6_QUEUEING
|
||||
/** struct for queueing outgoing packets for unknown address
|
||||
* defined here to be accessed by memp.h
|
||||
*/
|
||||
struct nd6_q_entry {
|
||||
struct nd6_q_entry *next;
|
||||
struct pbuf *p;
|
||||
};
|
||||
#endif /* LWIP_ND6_QUEUEING */
|
||||
|
||||
/** Neighbor solicitation message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ns_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t reserved);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Neighbor advertisement message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct na_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FLD_8(u8_t flags);
|
||||
PACK_STRUCT_FLD_8(u8_t reserved[3]);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
#define ND6_FLAG_ROUTER (0x80)
|
||||
#define ND6_FLAG_SOLICITED (0x40)
|
||||
#define ND6_FLAG_OVERRIDE (0x20)
|
||||
|
||||
/** Router solicitation message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct rs_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t reserved);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Router advertisement message header. */
|
||||
#define ND6_RA_FLAG_MANAGED_ADDR_CONFIG (0x80)
|
||||
#define ND6_RA_FLAG_OTHER_CONFIG (0x40)
|
||||
#define ND6_RA_FLAG_HOME_AGENT (0x20)
|
||||
#define ND6_RA_PREFERENCE_MASK (0x18)
|
||||
#define ND6_RA_PREFERENCE_HIGH (0x08)
|
||||
#define ND6_RA_PREFERENCE_MEDIUM (0x00)
|
||||
#define ND6_RA_PREFERENCE_LOW (0x18)
|
||||
#define ND6_RA_PREFERENCE_DISABLED (0x10)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ra_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FLD_8(u8_t current_hop_limit);
|
||||
PACK_STRUCT_FLD_8(u8_t flags);
|
||||
PACK_STRUCT_FIELD(u16_t router_lifetime);
|
||||
PACK_STRUCT_FIELD(u32_t reachable_time);
|
||||
PACK_STRUCT_FIELD(u32_t retrans_timer);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Redirect message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct redirect_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t reserved);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t destination_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Link-layer address option. */
|
||||
#define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01)
|
||||
#define ND6_OPTION_TYPE_TARGET_LLADDR (0x02)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct lladdr_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t addr[NETIF_MAX_HWADDR_LEN]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Prefix information option. */
|
||||
#define ND6_OPTION_TYPE_PREFIX_INFO (0x03)
|
||||
#define ND6_PREFIX_FLAG_ON_LINK (0x80)
|
||||
#define ND6_PREFIX_FLAG_AUTONOMOUS (0x40)
|
||||
#define ND6_PREFIX_FLAG_ROUTER_ADDRESS (0x20)
|
||||
#define ND6_PREFIX_FLAG_SITE_PREFIX (0x10)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct prefix_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t prefix_length);
|
||||
PACK_STRUCT_FLD_8(u8_t flags);
|
||||
PACK_STRUCT_FIELD(u32_t valid_lifetime);
|
||||
PACK_STRUCT_FIELD(u32_t preferred_lifetime);
|
||||
PACK_STRUCT_FLD_8(u8_t reserved2[3]);
|
||||
PACK_STRUCT_FLD_8(u8_t site_prefix_length);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t prefix);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Redirected header option. */
|
||||
#define ND6_OPTION_TYPE_REDIR_HDR (0x04)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct redirected_header_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t reserved[6]);
|
||||
/* Portion of redirected packet follows. */
|
||||
/* PACK_STRUCT_FLD_8(u8_t redirected[8]); */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** MTU option. */
|
||||
#define ND6_OPTION_TYPE_MTU (0x05)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct mtu_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FIELD(u16_t reserved);
|
||||
PACK_STRUCT_FIELD(u32_t mtu);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Route information option. */
|
||||
#define ND6_OPTION_TYPE_ROUTE_INFO (24)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct route_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t prefix_length);
|
||||
PACK_STRUCT_FLD_8(u8_t preference);
|
||||
PACK_STRUCT_FIELD(u32_t route_lifetime);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t prefix);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** 1 second period */
|
||||
#define ND6_TMR_INTERVAL 1000
|
||||
|
||||
/* Router tables. */
|
||||
/* TODO make these static? and entries accessible through API? */
|
||||
extern struct nd6_neighbor_cache_entry neighbor_cache[];
|
||||
extern struct nd6_destination_cache_entry destination_cache[];
|
||||
extern struct nd6_prefix_list_entry prefix_list[];
|
||||
extern struct nd6_router_list_entry default_router_list[];
|
||||
|
||||
/* Default values, can be updated by a RA message. */
|
||||
extern u32_t reachable_time;
|
||||
extern u32_t retrans_timer;
|
||||
struct pbuf;
|
||||
struct netif;
|
||||
|
||||
void nd6_tmr(void);
|
||||
void nd6_input(struct pbuf *p, struct netif *inp);
|
||||
s8_t nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif);
|
||||
s8_t nd6_select_router(const ip6_addr_t * ip6addr, struct netif * netif);
|
||||
u16_t nd6_get_destination_mtu(const ip6_addr_t * ip6addr, struct netif * netif);
|
||||
err_t nd6_queue_packet(s8_t neighbor_index, struct pbuf * p);
|
||||
void nd6_clear_destination_cache(void);
|
||||
struct netif *nd6_find_route(const ip6_addr_t *ip6addr);
|
||||
err_t nd6_get_next_hop_addr_or_queue(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp);
|
||||
u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif);
|
||||
#if LWIP_ND6_TCP_REACHABILITY_HINTS
|
||||
void nd6_reachability_hint(const ip6_addr_t * ip6addr);
|
||||
void nd6_reachability_hint(const ip6_addr_t *ip6addr);
|
||||
#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */
|
||||
void nd6_cleanup_netif(struct netif *netif);
|
||||
#if LWIP_IPV6_MLD
|
||||
void nd6_adjust_mld_membership(struct netif *netif, s8_t addr_idx, u8_t new_state);
|
||||
#endif /* LWIP_IPV6_MLD */
|
||||
|
||||
#if ESP_LWIP
|
||||
/** set nd6 callback when ipv6 addr state pref*/
|
||||
void nd6_set_cb(struct netif *netif, void (*cb)(struct netif *netif, u8_t ip_index));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* netbuf API (for netconn API)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -51,6 +56,7 @@ extern "C" {
|
||||
/** This netbuf includes a checksum */
|
||||
#define NETBUF_FLAG_CHKSUM 0x02
|
||||
|
||||
/** "Network buffer" - contains data and addressing info */
|
||||
struct netbuf {
|
||||
struct pbuf *p, *ptr;
|
||||
ip_addr_t addr;
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* NETDB API (sockets)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@ -33,8 +38,7 @@
|
||||
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/sockets.h"
|
||||
|
||||
@ -125,12 +129,47 @@ int lwip_getaddrinfo(const char *nodename,
|
||||
struct addrinfo **res);
|
||||
|
||||
#if LWIP_COMPAT_SOCKETS
|
||||
#if ESP_LWIP
|
||||
#if LWIP_COMPAT_SOCKET_ADDR == 1
|
||||
/* Some libraries have problems with inet_... being macros, so please use this define
|
||||
to declare normal functions */
|
||||
static inline int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
|
||||
{ return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop); }
|
||||
static inline struct hostent *gethostbyname(const char *name)
|
||||
{ return lwip_gethostbyname(name); }
|
||||
static inline void freeaddrinfo(struct addrinfo *ai)
|
||||
{ lwip_freeaddrinfo(ai); }
|
||||
static inline int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
|
||||
{ return lwip_getaddrinfo(nodename, servname, hints, res); }
|
||||
#else
|
||||
/* By default fall back to original inet_... macros */
|
||||
|
||||
/** @ingroup netdbapi */
|
||||
#define gethostbyname(name) lwip_gethostbyname(name)
|
||||
/** @ingroup netdbapi */
|
||||
#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
|
||||
lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
|
||||
/** @ingroup netdbapi */
|
||||
#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo)
|
||||
/** @ingroup netdbapi */
|
||||
#define getaddrinfo(nodname, servname, hints, res) \
|
||||
lwip_getaddrinfo(nodname, servname, hints, res)
|
||||
#endif /* LWIP_COMPAT_SOCKET_ADDR == 1 */
|
||||
|
||||
#else /* ESP_LWIP */
|
||||
|
||||
/** @ingroup netdbapi */
|
||||
#define gethostbyname(name) lwip_gethostbyname(name)
|
||||
/** @ingroup netdbapi */
|
||||
#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
|
||||
lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
|
||||
/** @ingroup netdbapi */
|
||||
#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo)
|
||||
/** @ingroup netdbapi */
|
||||
#define getaddrinfo(nodname, servname, hints, res) \
|
||||
lwip_getaddrinfo(nodname, servname, hints, res)
|
||||
|
||||
#endif /* ESP_LWIP */
|
||||
#endif /* LWIP_COMPAT_SOCKETS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* netif API (to be used from TCPIP thread)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -44,16 +49,6 @@
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#if LWIP_DHCP
|
||||
struct dhcp;
|
||||
#endif
|
||||
#if LWIP_AUTOIP
|
||||
struct autoip;
|
||||
#endif
|
||||
#if LWIP_IPV6_DHCP6
|
||||
struct dhcp6;
|
||||
#endif /* LWIP_IPV6_DHCP6 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -68,6 +63,12 @@ extern "C" {
|
||||
#define NETIF_MAX_HWADDR_LEN 6U
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup netif_flags Flags
|
||||
* @ingroup netif
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Whether the network interface is 'up'. This is
|
||||
* a software flag used to control whether this network
|
||||
* interface is enabled and processes traffic.
|
||||
@ -99,6 +100,32 @@ extern "C" {
|
||||
* Set by the netif driver in its init function. */
|
||||
#define NETIF_FLAG_MLD6 0x40U
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
/** If set, the netif will send gratuitous ARP periodically */
|
||||
#define NETIF_FLAG_GARP 0x80U
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
enum lwip_internal_netif_client_data_index
|
||||
{
|
||||
#if LWIP_DHCP
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_DHCP,
|
||||
#endif
|
||||
#if LWIP_AUTOIP
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
|
||||
#endif
|
||||
#if LWIP_IGMP
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
|
||||
#endif
|
||||
#if LWIP_IPV6_MLD
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
|
||||
#endif
|
||||
LWIP_NETIF_CLIENT_DATA_INDEX_MAX
|
||||
};
|
||||
|
||||
#if LWIP_CHECKSUM_CTRL_PER_NETIF
|
||||
#define NETIF_CHECKSUM_GEN_IP 0x0001
|
||||
#define NETIF_CHECKSUM_GEN_UDP 0x0002
|
||||
@ -116,6 +143,15 @@ extern "C" {
|
||||
|
||||
struct netif;
|
||||
|
||||
/** MAC Filter Actions, these are passed to a netif's igmp_mac_filter or
|
||||
* mld_mac_filter callback function. */
|
||||
enum netif_mac_filter_action {
|
||||
/** Delete a filter entry */
|
||||
NETIF_DEL_MAC_FILTER = 0,
|
||||
/** Add a filter entry */
|
||||
NETIF_ADD_MAC_FILTER = 1
|
||||
};
|
||||
|
||||
/** Function prototype for netif init functions. Set up flags and output/linkoutput
|
||||
* callback functions in this function.
|
||||
*
|
||||
@ -168,21 +204,31 @@ typedef void (*netif_status_callback_fn)(struct netif *netif);
|
||||
#if LWIP_IPV4 && LWIP_IGMP
|
||||
/** Function prototype for netif igmp_mac_filter functions */
|
||||
typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif,
|
||||
const ip4_addr_t *group, u8_t action);
|
||||
const ip4_addr_t *group, enum netif_mac_filter_action action);
|
||||
#endif /* LWIP_IPV4 && LWIP_IGMP */
|
||||
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
||||
/** Function prototype for netif mld_mac_filter functions */
|
||||
typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif,
|
||||
const ip6_addr_t *group, u8_t action);
|
||||
const ip6_addr_t *group, enum netif_mac_filter_action action);
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
|
||||
#if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || (LWIP_NUM_NETIF_CLIENT_DATA > 0)
|
||||
u8_t netif_alloc_client_data_id(void);
|
||||
/** @ingroup netif_cd
|
||||
* Set client data. Obtain ID from netif_alloc_client_data_id().
|
||||
*/
|
||||
#define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data)
|
||||
/** @ingroup netif_cd
|
||||
* Get client data. Obtain ID from netif_alloc_client_data_id().
|
||||
*/
|
||||
#define netif_get_client_data(netif, id) (netif)->client_data[(id)]
|
||||
#endif /* LWIP_DHCP || LWIP_AUTOIP || (LWIP_NUM_NETIF_CLIENT_DATA > 0) */
|
||||
|
||||
#if ESP_DHCP
|
||||
/*add DHCP event processing by LiuHan*/
|
||||
typedef void (*dhcp_event_fn)(void);
|
||||
#endif
|
||||
|
||||
|
||||
/** Generic data structure used for all lwIP network interfaces.
|
||||
* The following fields should be filled in by the initialization
|
||||
* function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
|
||||
@ -213,17 +259,19 @@ struct netif {
|
||||
#if LWIP_IPV4
|
||||
/** This function is called by the IP module when it wants
|
||||
* to send a packet on the interface. This function typically
|
||||
* first resolves the hardware address, then sends the packet. */
|
||||
* first resolves the hardware address, then sends the packet.
|
||||
* For ethernet physical layer, this is usually etharp_output() */
|
||||
netif_output_fn output;
|
||||
#endif /* LWIP_IPV4 */
|
||||
/** This function is called by the ARP module when it wants
|
||||
/** This function is called by ethernet_output() when it wants
|
||||
* to send a packet on the interface. This function outputs
|
||||
* the pbuf as-is on the link medium. */
|
||||
netif_linkoutput_fn linkoutput;
|
||||
#if LWIP_IPV6
|
||||
/** This function is called by the IPv6 module when it wants
|
||||
* to send a packet on the interface. This function typically
|
||||
* first resolves the hardware address, then sends the packet. */
|
||||
* first resolves the hardware address, then sends the packet.
|
||||
* For ethernet physical layer, this is usually ethip6_output() */
|
||||
netif_output_ip6_fn output_ip6;
|
||||
#endif /* LWIP_IPV6 */
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
@ -243,59 +291,42 @@ struct netif {
|
||||
/** This field can be set by the device driver and could point
|
||||
* to state information for the device. */
|
||||
void *state;
|
||||
#if LWIP_DHCP
|
||||
/** the DHCP client state information for this netif */
|
||||
struct dhcp *dhcp;
|
||||
#ifdef netif_get_client_data
|
||||
void* client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX + LWIP_NUM_NETIF_CLIENT_DATA];
|
||||
#endif
|
||||
|
||||
#if ESP_LWIP
|
||||
#if ESP_DHCP
|
||||
struct udp_pcb *dhcps_pcb;
|
||||
dhcp_event_fn dhcp_event;
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_DHCP */
|
||||
|
||||
#if LWIP_AUTOIP
|
||||
/** the AutoIP client state information for this netif */
|
||||
struct autoip *autoip;
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
/** is this netif enabled for IPv6 autoconfiguration */
|
||||
u8_t ip6_autoconfig_enabled;
|
||||
#endif /* LWIP_IPV6_AUTOCONFIG */
|
||||
|
||||
#if LWIP_IPV6_SEND_ROUTER_SOLICIT
|
||||
/** Number of Router Solicitation messages that remain to be sent. */
|
||||
u8_t rs_count;
|
||||
#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */
|
||||
|
||||
#if LWIP_IPV6_DHCP6
|
||||
/** the DHCPv6 client state information for this netif */
|
||||
struct dhcp6 *dhcp6;
|
||||
#endif /* LWIP_IPV6_DHCP6 */
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
/* the hostname for this netif, NULL is a valid value */
|
||||
const char* hostname;
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
#if LWIP_CHECKSUM_CTRL_PER_NETIF
|
||||
u16_t chksum_flags;
|
||||
#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF*/
|
||||
|
||||
/** maximum transfer unit (in bytes) */
|
||||
u16_t mtu;
|
||||
/** number of bytes used in hwaddr */
|
||||
u8_t hwaddr_len;
|
||||
/** link level hardware address of this interface */
|
||||
u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
|
||||
/** flags (see NETIF_FLAG_ above) */
|
||||
/** flags (@see @ref netif_flags) */
|
||||
u8_t flags;
|
||||
/** descriptive abbreviation */
|
||||
char name[2];
|
||||
/** number of this interface */
|
||||
u8_t num;
|
||||
|
||||
#if MIB2_STATS
|
||||
/** link type (from "snmp_ifType" enum from snmp_mib2.h) */
|
||||
u8_t link_type;
|
||||
@ -306,19 +337,16 @@ struct netif {
|
||||
/** counters */
|
||||
struct stats_mib2_netif_ctrs mib2_counters;
|
||||
#endif /* MIB2_STATS */
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IGMP
|
||||
/** This function could be called to add or delete an entry in the multicast
|
||||
filter table of the ethernet MAC.*/
|
||||
netif_igmp_mac_filter_fn igmp_mac_filter;
|
||||
#endif /* LWIP_IPV4 && LWIP_IGMP */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
||||
/** This function could be called to add or delete an entry in the IPv6 multicast
|
||||
filter table of the ethernet MAC. */
|
||||
netif_mld_mac_filter_fn mld_mac_filter;
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
|
||||
#if LWIP_NETIF_HWADDRHINT
|
||||
u8_t *addr_hint;
|
||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||
@ -362,6 +390,11 @@ struct netif *netif_add(struct netif *netif,
|
||||
void netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask,
|
||||
const ip4_addr_t *gw);
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
void netif_set_garp_flag(struct netif *netif);
|
||||
#endif
|
||||
|
||||
void netif_remove(struct netif * netif);
|
||||
|
||||
/* Returns a network interface given its name. The name is of the form
|
||||
@ -376,17 +409,30 @@ void netif_set_default(struct netif *netif);
|
||||
void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr);
|
||||
void netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask);
|
||||
void netif_set_gw(struct netif *netif, const ip4_addr_t *gw);
|
||||
/** @ingroup netif_ip4 */
|
||||
#define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr)))
|
||||
/** @ingroup netif_ip4 */
|
||||
#define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask)))
|
||||
/** @ingroup netif_ip4 */
|
||||
#define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw)))
|
||||
/** @ingroup netif_ip4 */
|
||||
#define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr))
|
||||
/** @ingroup netif_ip4 */
|
||||
#define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask))
|
||||
/** @ingroup netif_ip4 */
|
||||
#define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw))
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
void netif_set_up(struct netif *netif);
|
||||
void netif_set_down(struct netif *netif);
|
||||
/** Ask if an interface is up */
|
||||
/** @ingroup netif
|
||||
* Ask if an interface is up
|
||||
*/
|
||||
#if ESP_LWIP
|
||||
#define netif_is_up(netif) ( ((netif) && ((netif)->flags & NETIF_FLAG_UP)) ? (u8_t)1 : (u8_t)0)
|
||||
#else
|
||||
#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
|
||||
#endif
|
||||
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback);
|
||||
@ -405,18 +451,23 @@ void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_
|
||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
/** @ingroup netif */
|
||||
#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
|
||||
/** @ingroup netif */
|
||||
#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
#if LWIP_IGMP
|
||||
/** @ingroup netif */
|
||||
#define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0)
|
||||
#define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL)
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
||||
/** @ingroup netif */
|
||||
#define netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0)
|
||||
#define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL)
|
||||
#define netif_mld_mac_filter(netif, addr, action) do { if((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); }}while(0)
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
|
||||
#if ENABLE_LOOPBACK
|
||||
@ -427,15 +478,21 @@ void netif_poll_all(void);
|
||||
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
||||
#endif /* ENABLE_LOOPBACK */
|
||||
|
||||
err_t netif_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** @ingroup netif_ip6 */
|
||||
#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
|
||||
/** @ingroup netif_ip6 */
|
||||
#define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i])))
|
||||
#define netif_ip6_addr_set(netif, i, addr6) do { ip6_addr_set(ip_2_ip6(&((netif)->ip6_addr[i])), addr6); IP_SET_TYPE_VAL((netif)->ip6_addr[i], IPADDR_TYPE_V6); } while(0)
|
||||
void netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6);
|
||||
void netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, u32_t i2, u32_t i3);
|
||||
#define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i])
|
||||
#define netif_ip6_addr_set_state(netif, i, state) ((netif)->ip6_addr_state[i] = (state))
|
||||
void netif_ip6_addr_set_state(struct netif* netif, s8_t addr_idx, u8_t state);
|
||||
s8_t netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr);
|
||||
void netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit);
|
||||
err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx);
|
||||
#define netif_set_ip6_autoconfig_enabled(netif, action) do { if(netif) { (netif)->ip6_autoconfig_enabled = (action); }}while(0)
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#if LWIP_NETIF_HWADDRHINT
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* netif API (to be used from non-TCPIP threads)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@ -51,7 +56,7 @@ typedef void (*netifapi_void_fn)(struct netif *netif);
|
||||
typedef err_t (*netifapi_errt_fn)(struct netif *netif);
|
||||
|
||||
struct netifapi_msg {
|
||||
struct tcpip_api_call call;
|
||||
struct tcpip_api_call_data call;
|
||||
struct netif *netif;
|
||||
union {
|
||||
struct {
|
||||
@ -87,16 +92,43 @@ err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
||||
err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
|
||||
netifapi_errt_fn errtfunc);
|
||||
|
||||
#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
|
||||
#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
|
||||
#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
|
||||
#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
|
||||
/** @ingroup netifapi_netif */
|
||||
#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
|
||||
/** @ingroup netifapi_netif */
|
||||
#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
|
||||
/** @ingroup netifapi_netif */
|
||||
#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
|
||||
/** @ingroup netifapi_netif */
|
||||
#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
|
||||
/** @ingroup netifapi_netif */
|
||||
#define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL)
|
||||
/** @ingroup netifapi_netif */
|
||||
#define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL)
|
||||
|
||||
/**
|
||||
* @defgroup netifapi_dhcp4 DHCPv4
|
||||
* @ingroup netifapi
|
||||
* To be called from non-TCPIP threads
|
||||
*/
|
||||
/** @ingroup netifapi_dhcp4 */
|
||||
#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
|
||||
/** @ingroup netifapi_dhcp4 */
|
||||
#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
|
||||
/** @ingroup netifapi_dhcp4 */
|
||||
#define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL)
|
||||
/** @ingroup netifapi_dhcp4 */
|
||||
#define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew)
|
||||
/** @ingroup netifapi_dhcp4 */
|
||||
#define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release)
|
||||
|
||||
/**
|
||||
* @defgroup netifapi_autoip AUTOIP
|
||||
* @ingroup netifapi
|
||||
* To be called from non-TCPIP threads
|
||||
*/
|
||||
/** @ingroup netifapi_autoip */
|
||||
#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
|
||||
/** @ingroup netifapi_autoip */
|
||||
#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* pbuf API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -47,7 +52,7 @@ extern "C" {
|
||||
* Currently, the pbuf_custom code is only needed for one specific configuration
|
||||
* of IP_FRAG, unless required by external driver/application code. */
|
||||
#ifndef LWIP_SUPPORT_CUSTOM_PBUF
|
||||
#define LWIP_SUPPORT_CUSTOM_PBUF ((IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG))
|
||||
#define LWIP_SUPPORT_CUSTOM_PBUF ((IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG))
|
||||
#endif
|
||||
|
||||
/* @todo: We need a mechanism to prevent wasting memory in every pbuf
|
||||
@ -60,20 +65,46 @@ extern "C" {
|
||||
#define PBUF_IP_HLEN 20
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup pbuf
|
||||
* Enumeration of pbuf layers
|
||||
*/
|
||||
typedef enum {
|
||||
/** Includes spare room for transport layer header, e.g. UDP header.
|
||||
* Use this if you intend to pass the pbuf to functions like udp_send().
|
||||
*/
|
||||
PBUF_TRANSPORT,
|
||||
/** Includes spare room for IP header.
|
||||
* Use this if you intend to pass the pbuf to functions like raw_send().
|
||||
*/
|
||||
PBUF_IP,
|
||||
/** Includes spare room for link layer header (ethernet header).
|
||||
* Use this if you intend to pass the pbuf to functions like ethernet_output().
|
||||
* @see PBUF_LINK_HLEN
|
||||
*/
|
||||
PBUF_LINK,
|
||||
/** Includes spare room for additional encapsulation header before ethernet
|
||||
* headers (e.g. 802.11).
|
||||
* Use this if you intend to pass the pbuf to functions like netif->linkoutput().
|
||||
* @see PBUF_LINK_ENCAPSULATION_HLEN
|
||||
*/
|
||||
PBUF_RAW_TX,
|
||||
/** Use this for input packets in a netif driver when calling netif->input()
|
||||
* in the most common case - ethernet-layer netif driver. */
|
||||
PBUF_RAW
|
||||
} pbuf_layer;
|
||||
|
||||
/**
|
||||
* @ingroup pbuf
|
||||
* Enumeration of pbuf types
|
||||
*/
|
||||
typedef enum {
|
||||
/** pbuf data is stored in RAM, used for TX mostly, struct pbuf and its payload
|
||||
are allocated in one piece of contiguous memory (so the first payload byte
|
||||
can be calculated from struct pbuf)
|
||||
can be calculated from struct pbuf).
|
||||
pbuf_alloc() allocates PBUF_RAM pbufs as unchained pbufs (although that might
|
||||
change in future versions) */
|
||||
change in future versions).
|
||||
This should be used for all OUTGOING packets (TX).*/
|
||||
PBUF_RAM,
|
||||
/** pbuf data is stored in ROM, i.e. struct pbuf and its payload are located in
|
||||
totally different memory areas. Since it points to ROM, payload does not
|
||||
@ -86,7 +117,9 @@ typedef enum {
|
||||
/** pbuf payload refers to RAM. This one comes from a pool and should be used
|
||||
for RX. Payload can be chained (scatter-gather RX) but like PBUF_RAM, struct
|
||||
pbuf and its payload are allocated in one piece of contiguous memory (so
|
||||
the first payload byte can be calculated from struct pbuf) */
|
||||
the first payload byte can be calculated from struct pbuf).
|
||||
Don't use this for TX, if the pool becomes empty e.g. because of TCP queuing,
|
||||
you are unable to receive TCP acks! */
|
||||
PBUF_POOL
|
||||
} pbuf_type;
|
||||
|
||||
@ -105,6 +138,7 @@ typedef enum {
|
||||
/** indicates this pbuf includes a TCP FIN flag */
|
||||
#define PBUF_FLAG_TCP_FIN 0x20U
|
||||
|
||||
/** Main packet buffer struct */
|
||||
struct pbuf {
|
||||
/** next pbuf in singly linked pbuf chain */
|
||||
struct pbuf *next;
|
||||
@ -169,12 +203,11 @@ struct pbuf_custom {
|
||||
};
|
||||
#endif /* LWIP_SUPPORT_CUSTOM_PBUF */
|
||||
|
||||
#if LWIP_TCP && TCP_QUEUE_OOSEQ
|
||||
/** Define this to 0 to prevent freeing ooseq pbufs when the PBUF_POOL is empty */
|
||||
#ifndef PBUF_POOL_FREE_OOSEQ
|
||||
#define PBUF_POOL_FREE_OOSEQ 1
|
||||
#endif /* PBUF_POOL_FREE_OOSEQ */
|
||||
#if NO_SYS && PBUF_POOL_FREE_OOSEQ
|
||||
#if LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ
|
||||
extern volatile u8_t pbuf_free_ooseq_pending;
|
||||
void pbuf_free_ooseq(void);
|
||||
/** When not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ()
|
||||
@ -184,8 +217,10 @@ void pbuf_free_ooseq(void);
|
||||
/* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \
|
||||
ooseq queued pbufs now */ \
|
||||
pbuf_free_ooseq(); }}while(0)
|
||||
#endif /* NO_SYS && PBUF_POOL_FREE_OOSEQ*/
|
||||
#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ */
|
||||
#else /* LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ */
|
||||
/* Otherwise declare an empty PBUF_CHECK_FREE_OOSEQ */
|
||||
#define PBUF_CHECK_FREE_OOSEQ()
|
||||
#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ*/
|
||||
|
||||
/* Initializes the pbuf module. This call is empty for now, but may not be in future. */
|
||||
#define pbuf_init()
|
||||
@ -201,12 +236,12 @@ u8_t pbuf_header(struct pbuf *p, s16_t header_size);
|
||||
u8_t pbuf_header_force(struct pbuf *p, s16_t header_size);
|
||||
void pbuf_ref(struct pbuf *p);
|
||||
u8_t pbuf_free(struct pbuf *p);
|
||||
u8_t pbuf_clen(struct pbuf *p);
|
||||
u16_t pbuf_clen(const struct pbuf *p);
|
||||
void pbuf_cat(struct pbuf *head, struct pbuf *tail);
|
||||
void pbuf_chain(struct pbuf *head, struct pbuf *tail);
|
||||
struct pbuf *pbuf_dechain(struct pbuf *p);
|
||||
err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
|
||||
u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
|
||||
err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from);
|
||||
u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
|
||||
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
|
||||
err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset);
|
||||
struct pbuf *pbuf_skip(struct pbuf* in, u16_t in_offset, u16_t* out_offset);
|
||||
@ -219,11 +254,12 @@ err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
|
||||
void pbuf_split_64k(struct pbuf *p, struct pbuf **rest);
|
||||
#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */
|
||||
|
||||
u8_t pbuf_get_at(struct pbuf* p, u16_t offset);
|
||||
u8_t pbuf_get_at(const struct pbuf* p, u16_t offset);
|
||||
int pbuf_try_get_at(const struct pbuf* p, u16_t offset);
|
||||
void pbuf_put_at(struct pbuf* p, u16_t offset, u8_t data);
|
||||
u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n);
|
||||
u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
|
||||
u16_t pbuf_strstr(struct pbuf* p, const char* substr);
|
||||
u16_t pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n);
|
||||
u16_t pbuf_memfind(const struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
|
||||
u16_t pbuf_strstr(const struct pbuf* p, const char* substr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* netconn API lwIP internal implementations (do not use in application code)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -38,29 +43,25 @@
|
||||
/* Note: Netconn API is always available when sockets are enabled -
|
||||
* sockets are implemented on top of them */
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
#define API_MSG_M_DEF(m) m
|
||||
#define API_MSG_M_DEF_C(t, m) t m
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
#define API_MSG_M_DEF_SEM(m) *m
|
||||
#else
|
||||
#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
|
||||
#endif
|
||||
#else /* LWIP_MPU_COMPATIBLE */
|
||||
#define API_MSG_M_DEF(m) *m
|
||||
#define API_MSG_M_DEF_C(t, m) const t * m
|
||||
#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
|
||||
@ -75,7 +76,7 @@ extern "C" {
|
||||
/** This struct includes everything that is necessary to execute a function
|
||||
for a netconn in another thread context (mainly used to process netconns
|
||||
in the tcpip_thread context to be thread safe). */
|
||||
struct api_msg_msg {
|
||||
struct api_msg {
|
||||
/** The netconn which to process - always needed: it includes the semaphore
|
||||
which is used to block the application thread until the function finished. */
|
||||
struct netconn *conn;
|
||||
@ -150,16 +151,6 @@ struct api_msg_msg {
|
||||
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
|
||||
|
||||
/** This struct contains a function to execute in another thread context and
|
||||
a struct api_msg_msg that serves as an argument for this function.
|
||||
This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
|
||||
struct api_msg {
|
||||
/** function to execute in tcpip_thread context */
|
||||
void (* function)(void *msg);
|
||||
/** arguments for this function */
|
||||
struct api_msg_msg msg;
|
||||
};
|
||||
|
||||
#if LWIP_DNS
|
||||
/** As lwip_netconn_do_gethostbyname requires more arguments but doesn't require a netconn,
|
||||
it has its own struct (to avoid struct api_msg getting bigger than necessary).
|
||||
@ -194,35 +185,9 @@ struct dns_api_msg {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
#ifdef LWIP_DEBUG
|
||||
#define TCIP_APIMSG_SET_ERR(m, e) (m)->msg.err = e /* catch functions that don't set err */
|
||||
#else
|
||||
#define TCIP_APIMSG_SET_ERR(m, e)
|
||||
#endif
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
#define TCPIP_APIMSG_SET_SEM(m) ((m)->msg.op_completed_sem = LWIP_NETCONN_THREAD_SEM_GET())
|
||||
#else
|
||||
#define TCPIP_APIMSG_SET_SEM(m)
|
||||
#endif
|
||||
#define TCPIP_APIMSG_NOERR(m,f) do { \
|
||||
TCIP_APIMSG_SET_ERR(m, ERR_VAL); \
|
||||
TCPIP_APIMSG_SET_SEM(m); \
|
||||
LOCK_TCPIP_CORE(); \
|
||||
f(&((m)->msg)); \
|
||||
UNLOCK_TCPIP_CORE(); \
|
||||
} while(0)
|
||||
#define TCPIP_APIMSG(m,f,e) do { \
|
||||
TCPIP_APIMSG_NOERR(m,f); \
|
||||
(e) = (m)->msg.err; \
|
||||
} while(0)
|
||||
#define TCPIP_APIMSG_ACK(m) NETCONN_SET_SAFE_ERR((m)->conn, (m)->err)
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#define TCPIP_APIMSG_NOERR(m,f) do { (m)->function = f; tcpip_apimsg(m); } while(0)
|
||||
#define TCPIP_APIMSG(m,f,e) do { (m)->function = f; (e) = tcpip_apimsg(m); } while(0)
|
||||
#define TCPIP_APIMSG_ACK(m) do { NETCONN_SET_SAFE_ERR((m)->conn, (m)->err); sys_sem_signal(LWIP_API_MSG_SEM(m)); } while(0)
|
||||
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#if LWIP_TCP
|
||||
extern u8_t netconn_aborted;
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
void lwip_netconn_do_newconn (void *m);
|
||||
void lwip_netconn_do_delconn (void *m);
|
||||
@ -232,6 +197,9 @@ void lwip_netconn_do_disconnect (void *m);
|
||||
void lwip_netconn_do_listen (void *m);
|
||||
void lwip_netconn_do_send (void *m);
|
||||
void lwip_netconn_do_recv (void *m);
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
void lwip_netconn_do_accepted (void *m);
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
void lwip_netconn_do_write (void *m);
|
||||
void lwip_netconn_do_getaddr (void *m);
|
||||
void lwip_netconn_do_close (void *m);
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* memory pools lwIP internal implementations (do not use in application code)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -38,7 +43,7 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "lwip/mem.h"
|
||||
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
@ -82,6 +87,7 @@ extern "C" {
|
||||
|
||||
#endif /* MEMP_OVERFLOW_CHECK */
|
||||
|
||||
#if !MEMP_MEM_MALLOC || MEMP_OVERFLOW_CHECK
|
||||
struct memp {
|
||||
struct memp *next;
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
@ -89,8 +95,9 @@ struct memp {
|
||||
int line;
|
||||
#endif /* MEMP_OVERFLOW_CHECK */
|
||||
};
|
||||
#endif /* !MEMP_MEM_MALLOC || MEMP_OVERFLOW_CHECK */
|
||||
|
||||
#if MEM_USE_POOLS
|
||||
#if MEM_USE_POOLS && MEMP_USE_CUSTOM_POOLS
|
||||
/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
|
||||
typedef enum {
|
||||
/* Get the first (via:
|
||||
@ -117,9 +124,19 @@ typedef enum {
|
||||
We use this helper type and these defines so we can avoid using const memp_t values */
|
||||
#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
|
||||
#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
|
||||
#endif /* MEM_USE_POOLS */
|
||||
#endif /* MEM_USE_POOLS && MEMP_USE_CUSTOM_POOLS */
|
||||
|
||||
/** Memory pool descriptor */
|
||||
struct memp_desc {
|
||||
#if defined(LWIP_DEBUG) || MEMP_OVERFLOW_CHECK || LWIP_STATS_DISPLAY
|
||||
/** Textual description */
|
||||
const char *desc;
|
||||
#endif /* LWIP_DEBUG || MEMP_OVERFLOW_CHECK || LWIP_STATS_DISPLAY */
|
||||
#if MEMP_STATS
|
||||
/** Statistics */
|
||||
struct stats_mem *stats;
|
||||
#endif
|
||||
|
||||
/** Element size */
|
||||
u16_t size;
|
||||
|
||||
@ -127,35 +144,28 @@ struct memp_desc {
|
||||
/** Number of elements */
|
||||
u16_t num;
|
||||
|
||||
#if defined(LWIP_DEBUG) || MEMP_OVERFLOW_CHECK
|
||||
/** Textual description */
|
||||
const char *desc;
|
||||
#endif /* LWIP_DEBUG || MEMP_OVERFLOW_CHECK */
|
||||
|
||||
/** Base */
|
||||
u8_t *base;
|
||||
/** Base address */
|
||||
u8_t *base;
|
||||
|
||||
/** First free element of each pool. Elements form a linked list. */
|
||||
struct memp **tab;
|
||||
#endif /* MEMP_MEM_MALLOC */
|
||||
};
|
||||
|
||||
#if (ESP_STATS_MEM == 1)
|
||||
extern uint32_t g_lwip_mem_cnt[MEMP_MAX][2];
|
||||
#define ESP_CNT_MEM_MALLOC_INC(type) g_lwip_mem_cnt[type][0]++
|
||||
#define ESP_CNT_MEM_FREE_INC(type) g_lwip_mem_cnt[type][1]++
|
||||
#else
|
||||
#define ESP_CNT_MEM_MALLOC_INC(type)
|
||||
#define ESP_CNT_MEM_FREE_INC(type)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
#if defined(LWIP_DEBUG) || MEMP_OVERFLOW_CHECK || LWIP_STATS_DISPLAY
|
||||
#define DECLARE_LWIP_MEMPOOL_DESC(desc) (desc),
|
||||
#else
|
||||
#define DECLARE_LWIP_MEMPOOL_DESC(desc)
|
||||
#endif
|
||||
|
||||
#if MEMP_STATS
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name) static struct stats_mem name;
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name) &name,
|
||||
#else
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name)
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name)
|
||||
#endif
|
||||
|
||||
void memp_init_pool(const struct memp_desc *desc);
|
||||
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
|
@ -1,3 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* lwIP internal memory pools (do not use in application code)
|
||||
* This file is deliberately included multiple times: once with empty
|
||||
* definition of LWIP_MEMPOOL() to handle all includes and multiple times
|
||||
* to build up various lists of mem pools.
|
||||
*/
|
||||
|
||||
/*
|
||||
* SETUP: Make sure we define everything we will need.
|
||||
*
|
||||
@ -47,9 +55,9 @@ LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg),
|
||||
#if LWIP_IPV4 && IP_REASSEMBLY
|
||||
LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
|
||||
#endif /* LWIP_IPV4 && IP_REASSEMBLY */
|
||||
#if (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)
|
||||
#if (IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)
|
||||
LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF")
|
||||
#endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
|
||||
#endif /* IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF || (LWIP_IPV6 && LWIP_IPV6_FRAG) */
|
||||
|
||||
#if LWIP_NETCONN || LWIP_SOCKET
|
||||
LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF")
|
||||
@ -83,9 +91,9 @@ LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_en
|
||||
LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP")
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
#if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */
|
||||
#if LWIP_TIMERS && !LWIP_TIMERS_CUSTOM
|
||||
LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT")
|
||||
#endif /* LWIP_TIMERS */
|
||||
#endif /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */
|
||||
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB")
|
||||
@ -94,19 +102,6 @@ LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE,
|
||||
LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST")
|
||||
#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
|
||||
#if PPP_SUPPORT
|
||||
LWIP_MEMPOOL(PPP_PCB, MEMP_NUM_PPP_PCB, sizeof(ppp_pcb), "PPP_PCB")
|
||||
#if PPPOS_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOS_PCB, MEMP_NUM_PPPOS_INTERFACES, sizeof(pppos_pcb), "PPPOS_PCB")
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
#if PPPOE_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOL2TP_PCB, MEMP_NUM_PPPOL2TP_INTERFACES, sizeof(pppol2tp_pcb), "PPPOL2TP_PCB")
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_ND6_QUEUEING
|
||||
LWIP_MEMPOOL(ND6_QUEUE, MEMP_NUM_ND6_QUEUE, sizeof(struct nd6_q_entry), "ND6_QUEUE")
|
||||
#endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */
|
||||
|
144
tools/sdk/include/lwip/lwip/priv/nd6_priv.h
Normal file
144
tools/sdk/include/lwip/lwip/priv/nd6_priv.h
Normal file
@ -0,0 +1,144 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Neighbor discovery and stateless address autoconfiguration for IPv6.
|
||||
* Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862
|
||||
* (Address autoconfiguration).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Inico Technologies Ltd.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Ivan Delamer <delamer@inicotech.com>
|
||||
*
|
||||
*
|
||||
* Please coordinate changes and requests with Ivan Delamer
|
||||
* <delamer@inicotech.com>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_ND6_PRIV_H
|
||||
#define LWIP_HDR_ND6_PRIV_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_ND6_QUEUEING
|
||||
/** struct for queueing outgoing packets for unknown address
|
||||
* defined here to be accessed by memp.h
|
||||
*/
|
||||
struct nd6_q_entry {
|
||||
struct nd6_q_entry *next;
|
||||
struct pbuf *p;
|
||||
};
|
||||
#endif /* LWIP_ND6_QUEUEING */
|
||||
|
||||
/** Struct for tables. */
|
||||
struct nd6_neighbor_cache_entry {
|
||||
ip6_addr_t next_hop_address;
|
||||
struct netif *netif;
|
||||
u8_t lladdr[NETIF_MAX_HWADDR_LEN];
|
||||
/*u32_t pmtu;*/
|
||||
#if LWIP_ND6_QUEUEING
|
||||
/** Pointer to queue of pending outgoing packets on this entry. */
|
||||
struct nd6_q_entry *q;
|
||||
#else /* LWIP_ND6_QUEUEING */
|
||||
/** Pointer to a single pending outgoing packet on this entry. */
|
||||
struct pbuf *q;
|
||||
#endif /* LWIP_ND6_QUEUEING */
|
||||
u8_t state;
|
||||
u8_t isrouter;
|
||||
union {
|
||||
u32_t reachable_time; /* in ms since value may originate from network packet */
|
||||
u32_t delay_time; /* ticks (ND6_TMR_INTERVAL) */
|
||||
u32_t probes_sent;
|
||||
u32_t stale_time; /* ticks (ND6_TMR_INTERVAL) */
|
||||
} counter;
|
||||
};
|
||||
|
||||
struct nd6_destination_cache_entry {
|
||||
ip6_addr_t destination_addr;
|
||||
ip6_addr_t next_hop_addr;
|
||||
u16_t pmtu;
|
||||
u32_t age;
|
||||
};
|
||||
|
||||
struct nd6_prefix_list_entry {
|
||||
ip6_addr_t prefix;
|
||||
struct netif *netif;
|
||||
u32_t invalidation_timer; /* in ms since value may originate from network packet */
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
u8_t flags;
|
||||
#define ND6_PREFIX_AUTOCONFIG_AUTONOMOUS 0x01
|
||||
#define ND6_PREFIX_AUTOCONFIG_ADDRESS_GENERATED 0x02
|
||||
#define ND6_PREFIX_AUTOCONFIG_ADDRESS_DUPLICATE 0x04
|
||||
#endif /* LWIP_IPV6_AUTOCONFIG */
|
||||
};
|
||||
|
||||
struct nd6_router_list_entry {
|
||||
struct nd6_neighbor_cache_entry *neighbor_entry;
|
||||
u32_t invalidation_timer; /* in ms since value may originate from network packet */
|
||||
u8_t flags;
|
||||
};
|
||||
|
||||
enum nd6_neighbor_cache_entry_state {
|
||||
ND6_NO_ENTRY = 0,
|
||||
ND6_INCOMPLETE,
|
||||
ND6_REACHABLE,
|
||||
ND6_STALE,
|
||||
ND6_DELAY,
|
||||
ND6_PROBE
|
||||
};
|
||||
|
||||
/* Router tables. */
|
||||
/* @todo make these static? and entries accessible through API? */
|
||||
extern struct nd6_neighbor_cache_entry neighbor_cache[];
|
||||
extern struct nd6_destination_cache_entry destination_cache[];
|
||||
extern struct nd6_prefix_list_entry prefix_list[];
|
||||
extern struct nd6_router_list_entry default_router_list[];
|
||||
|
||||
/* Default values, can be updated by a RA message. */
|
||||
extern u32_t reachable_time;
|
||||
extern u32_t retrans_timer;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#endif /* LWIP_HDR_ND6_PRIV_H */
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* TCP internal implementations (do not use in application code)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -29,8 +34,8 @@
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_TCP_IMPL_H
|
||||
#define LWIP_HDR_TCP_IMPL_H
|
||||
#ifndef LWIP_HDR_TCP_PRIV_H
|
||||
#define LWIP_HDR_TCP_PRIV_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
@ -44,6 +49,7 @@
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/ip6.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/prot/tcp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -92,7 +98,7 @@ err_t tcp_process_refused_data(struct tcp_pcb *pcb);
|
||||
((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \
|
||||
(((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \
|
||||
((tpcb)->unsent->len >= (tpcb)->mss))) || \
|
||||
((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN(tpcb))) \
|
||||
((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \
|
||||
) ? 1 : 0)
|
||||
#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK)
|
||||
|
||||
@ -106,19 +112,6 @@ err_t tcp_process_refused_data(struct tcp_pcb *pcb);
|
||||
#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b))
|
||||
#endif
|
||||
#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c))
|
||||
#define TCP_FIN 0x01U
|
||||
#define TCP_SYN 0x02U
|
||||
#define TCP_RST 0x04U
|
||||
#define TCP_PSH 0x08U
|
||||
#define TCP_ACK 0x10U
|
||||
#define TCP_URG 0x20U
|
||||
#define TCP_ECE 0x40U
|
||||
#define TCP_CWR 0x80U
|
||||
|
||||
#define TCP_FLAGS 0x3fU
|
||||
|
||||
/* Length of the TCP header, excluding options. */
|
||||
#define TCP_HLEN 20
|
||||
|
||||
#ifndef TCP_TMR_INTERVAL
|
||||
#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */
|
||||
@ -156,38 +149,6 @@ err_t tcp_process_refused_data(struct tcp_pcb *pcb);
|
||||
|
||||
#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */
|
||||
|
||||
/* Fields are (of course) in network byte order.
|
||||
* Some fields are converted to host byte order in tcp_input().
|
||||
*/
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct tcp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t src);
|
||||
PACK_STRUCT_FIELD(u16_t dest);
|
||||
PACK_STRUCT_FIELD(u32_t seqno);
|
||||
PACK_STRUCT_FIELD(u32_t ackno);
|
||||
PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags);
|
||||
PACK_STRUCT_FIELD(u16_t wnd);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t urgp);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)
|
||||
#define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)
|
||||
|
||||
#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr))
|
||||
#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | htons(flags))
|
||||
#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags))
|
||||
|
||||
#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags))
|
||||
#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~htons(flags))
|
||||
|
||||
#define TCP_TCPLEN(seg) ((seg)->len + (((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0) ? 1U : 0U))
|
||||
|
||||
/** Flags used on input processing, not on pcb->flags
|
||||
@ -199,7 +160,7 @@ PACK_STRUCT_END
|
||||
|
||||
#if LWIP_EVENT_API
|
||||
|
||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) ret = lwip_tcp_event(arg, (pcb),\
|
||||
LWIP_EVENT_ACCEPT, NULL, 0, err)
|
||||
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_SENT, NULL, space, ERR_OK)
|
||||
@ -209,17 +170,19 @@ PACK_STRUCT_END
|
||||
LWIP_EVENT_RECV, NULL, 0, ERR_OK)
|
||||
#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_CONNECTED, NULL, 0, (err))
|
||||
#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_POLL, NULL, 0, ERR_OK)
|
||||
#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \
|
||||
LWIP_EVENT_ERR, NULL, 0, (err))
|
||||
#define TCP_EVENT_POLL(pcb,ret) do { if ((pcb)->state != SYN_RCVD) { \
|
||||
ret = lwip_tcp_event((pcb)->callback_arg, (pcb), LWIP_EVENT_POLL, NULL, 0, ERR_OK); \
|
||||
} else { \
|
||||
ret = ERR_ARG; } } while(0)
|
||||
#define TCP_EVENT_ERR(last_state,errf,arg,err) do { if (last_state != SYN_RCVD) { \
|
||||
lwip_tcp_event((arg), NULL, LWIP_EVENT_ERR, NULL, 0, (err)); } } while(0)
|
||||
|
||||
#else /* LWIP_EVENT_API */
|
||||
|
||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) \
|
||||
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \
|
||||
do { \
|
||||
if((pcb)->accept != NULL) \
|
||||
(ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \
|
||||
if((lpcb)->accept != NULL) \
|
||||
(ret) = (lpcb)->accept((arg),(pcb),(err)); \
|
||||
else (ret) = ERR_ARG; \
|
||||
} while (0)
|
||||
|
||||
@ -262,8 +225,9 @@ PACK_STRUCT_END
|
||||
else (ret) = ERR_OK; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_EVENT_ERR(errf,arg,err) \
|
||||
#define TCP_EVENT_ERR(last_state,errf,arg,err) \
|
||||
do { \
|
||||
LWIP_UNUSED_ARG(last_state); \
|
||||
if((errf) != NULL) \
|
||||
(errf)((arg),(err)); \
|
||||
} while (0)
|
||||
@ -288,7 +252,7 @@ struct tcp_seg {
|
||||
#if TCP_OVERSIZE_DBGCHECK
|
||||
u16_t oversize_left; /* Extra bytes available at the end of the last
|
||||
pbuf in unsent (used for asserting vs.
|
||||
tcp_pcb.unsent_oversized only) */
|
||||
tcp_pcb.unsent_oversize only) */
|
||||
#endif /* TCP_OVERSIZE_DBGCHECK */
|
||||
#if TCP_CHECKSUM_ON_COPY
|
||||
u16_t chksum;
|
||||
@ -329,7 +293,7 @@ struct tcp_seg {
|
||||
(flags & TF_SEG_OPTS_WND_SCALE ? LWIP_TCP_OPT_LEN_WS_OUT : 0)
|
||||
|
||||
/** This returns a TCP header option for MSS in an u32_t */
|
||||
#define TCP_BUILD_MSS_OPTION(mss) htonl(0x02040000 | ((mss) & 0xFFFF))
|
||||
#define TCP_BUILD_MSS_OPTION(mss) lwip_htonl(0x02040000 | ((mss) & 0xFFFF))
|
||||
|
||||
#if LWIP_WND_SCALE
|
||||
#define TCPWNDSIZE_F U32_F
|
||||
@ -491,7 +455,7 @@ void tcp_rst(u32_t seqno, u32_t ackno,
|
||||
const ip_addr_t *local_ip, const ip_addr_t *remote_ip,
|
||||
u16_t local_port, u16_t remote_port);
|
||||
|
||||
u32_t tcp_next_iss(void);
|
||||
u32_t tcp_next_iss(struct tcp_pcb *pcb);
|
||||
|
||||
err_t tcp_keepalive(struct tcp_pcb *pcb);
|
||||
err_t tcp_zero_window_probe(struct tcp_pcb *pcb);
|
||||
@ -532,9 +496,7 @@ s16_t tcp_pcbs_sane(void);
|
||||
* that a timer is needed (i.e. active- or time-wait-pcb found). */
|
||||
void tcp_timer_needed(void);
|
||||
|
||||
#if LWIP_IPV4
|
||||
void tcp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* new_addr);
|
||||
#endif /* LWIP_IPV4 */
|
||||
void tcp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@ -542,4 +504,4 @@ void tcp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* n
|
||||
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#endif /* LWIP_HDR_TCP_H */
|
||||
#endif /* LWIP_HDR_TCP_PRIV_H */
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* TCPIP API internal implementations (do not use in application code)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -38,91 +43,79 @@
|
||||
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/timers.h"
|
||||
#include "lwip/timeouts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct pbuf;
|
||||
struct netif;
|
||||
|
||||
/** Define this to something that triggers a watchdog. This is called from
|
||||
* tcpip_thread after processing a message. */
|
||||
#ifndef LWIP_TCPIP_THREAD_ALIVE
|
||||
#define LWIP_TCPIP_THREAD_ALIVE()
|
||||
#endif
|
||||
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
/** The global semaphore to lock the stack. */
|
||||
extern sys_mutex_t lock_tcpip_core;
|
||||
#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
|
||||
#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#define LOCK_TCPIP_CORE()
|
||||
#define UNLOCK_TCPIP_CORE()
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
#define API_VAR_REF(name) (*(name))
|
||||
#define API_VAR_DECLARE(type, name) type * name
|
||||
#define API_VAR_ALLOC(type, pool, name) do { \
|
||||
#define API_VAR_ALLOC(type, pool, name, errorval) do { \
|
||||
name = (type *)memp_malloc(pool); \
|
||||
if (name == NULL) { \
|
||||
return ERR_MEM; \
|
||||
return errorval; \
|
||||
} \
|
||||
} while(0)
|
||||
#define API_VAR_ALLOC_DONTFAIL(type, pool, name) do { \
|
||||
name = (type *)memp_malloc(pool); \
|
||||
LWIP_ASSERT("pool empty", name != NULL); \
|
||||
#define API_VAR_ALLOC_POOL(type, pool, name, errorval) do { \
|
||||
name = (type *)LWIP_MEMPOOL_ALLOC(pool); \
|
||||
if (name == NULL) { \
|
||||
return errorval; \
|
||||
} \
|
||||
} while(0)
|
||||
#define API_VAR_FREE(pool, name) memp_free(pool, name)
|
||||
#define API_EXPR_REF(expr) &(expr)
|
||||
#define API_VAR_FREE_POOL(pool, name) LWIP_MEMPOOL_FREE(pool, name)
|
||||
#define API_EXPR_REF(expr) (&(expr))
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
#define API_EXPR_REF_SEM(expr) (expr)
|
||||
#else
|
||||
#define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr)
|
||||
#endif
|
||||
#define API_EXPR_DEREF(expr) expr
|
||||
#define API_MSG_M_DEF(m) m
|
||||
#define API_MSG_M_DEF_C(t, m) t m
|
||||
#else /* LWIP_MPU_COMPATIBLE */
|
||||
#define API_VAR_REF(name) name
|
||||
#define API_VAR_DECLARE(type, name) type name
|
||||
#define API_VAR_ALLOC(type, pool, name)
|
||||
#define API_VAR_ALLOC_DONTFAIL(type, pool, name)
|
||||
#define API_VAR_ALLOC(type, pool, name, errorval)
|
||||
#define API_VAR_ALLOC_POOL(type, pool, name, errorval)
|
||||
#define API_VAR_FREE(pool, name)
|
||||
#define API_VAR_FREE_POOL(pool, name)
|
||||
#define API_EXPR_REF(expr) expr
|
||||
#define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr)
|
||||
#define API_EXPR_DEREF(expr) *(expr)
|
||||
#define API_EXPR_DEREF(expr) (*(expr))
|
||||
#define API_MSG_M_DEF(m) *m
|
||||
#define API_MSG_M_DEF_C(t, m) const t * m
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
err_t tcpip_send_api_msg(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem);
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem);
|
||||
|
||||
struct tcpip_api_call;
|
||||
typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call* call);
|
||||
struct tcpip_api_call
|
||||
struct tcpip_api_call_data
|
||||
{
|
||||
tcpip_api_call_fn function;
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
sys_sem_t *sem;
|
||||
#else /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
err_t err;
|
||||
#if !LWIP_NETCONN_SEM_PER_THREAD
|
||||
sys_sem_t sem;
|
||||
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
err_t err;
|
||||
#else /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
u8_t dummy; /* avoid empty struct :-( */
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
};
|
||||
err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call *call);
|
||||
typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call_data* call);
|
||||
err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call);
|
||||
|
||||
enum tcpip_msg_type {
|
||||
TCPIP_MSG_API,
|
||||
TCPIP_MSG_API_CALL,
|
||||
TCPIP_MSG_INPKT,
|
||||
#if LWIP_TCPIP_TIMEOUT
|
||||
#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
|
||||
TCPIP_MSG_TIMEOUT,
|
||||
TCPIP_MSG_UNTIMEOUT,
|
||||
#endif /* LWIP_TCPIP_TIMEOUT */
|
||||
#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
|
||||
TCPIP_MSG_CALLBACK,
|
||||
TCPIP_MSG_CALLBACK_STATIC
|
||||
};
|
||||
@ -133,8 +126,12 @@ struct tcpip_msg {
|
||||
struct {
|
||||
tcpip_callback_fn function;
|
||||
void* msg;
|
||||
} api;
|
||||
struct tcpip_api_call *api_call;
|
||||
} api_msg;
|
||||
struct {
|
||||
tcpip_api_call_fn function;
|
||||
struct tcpip_api_call_data *arg;
|
||||
sys_sem_t *sem;
|
||||
} api_call;
|
||||
struct {
|
||||
struct pbuf *p;
|
||||
struct netif *netif;
|
||||
@ -144,13 +141,13 @@ struct tcpip_msg {
|
||||
tcpip_callback_fn function;
|
||||
void *ctx;
|
||||
} cb;
|
||||
#if LWIP_TCPIP_TIMEOUT
|
||||
#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
|
||||
struct {
|
||||
u32_t msecs;
|
||||
sys_timeout_handler h;
|
||||
void *arg;
|
||||
} tmo;
|
||||
#endif /* LWIP_TCPIP_TIMEOUT */
|
||||
#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
|
||||
} msg;
|
||||
};
|
||||
|
||||
|
83
tools/sdk/include/lwip/lwip/prot/autoip.h
Normal file
83
tools/sdk/include/lwip/lwip/prot/autoip.h
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file
|
||||
* AutoIP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* Author: Dominik Spies <kontakt@dspies.de>
|
||||
*
|
||||
* This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
|
||||
* with RFC 3927.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_PROT_AUTOIP_H
|
||||
#define LWIP_HDR_PROT_AUTOIP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 169.254.0.0 */
|
||||
#define AUTOIP_NET 0xA9FE0000
|
||||
/* 169.254.1.0 */
|
||||
#define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100)
|
||||
/* 169.254.254.255 */
|
||||
#define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF)
|
||||
|
||||
/* RFC 3927 Constants */
|
||||
#define PROBE_WAIT 1 /* second (initial random delay) */
|
||||
#define PROBE_MIN 1 /* second (minimum delay till repeated probe) */
|
||||
#define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */
|
||||
#define PROBE_NUM 3 /* (number of probe packets) */
|
||||
#define ANNOUNCE_NUM 2 /* (number of announcement packets) */
|
||||
#define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */
|
||||
#define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */
|
||||
#if ESP_LWIP
|
||||
#define MAX_CONFLICTS LWIP_AUTOIP_MAX_CONFLICTS /* (max conflicts before rate limiting) */
|
||||
#define RATE_LIMIT_INTERVAL LWIP_AUTOIP_RATE_LIMIT_INTERVAL /* seconds (delay between successive attempts) */
|
||||
#else
|
||||
#define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */
|
||||
#define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */
|
||||
#endif
|
||||
#define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */
|
||||
|
||||
/* AutoIP client states */
|
||||
typedef enum {
|
||||
AUTOIP_STATE_OFF = 0,
|
||||
AUTOIP_STATE_PROBING = 1,
|
||||
AUTOIP_STATE_ANNOUNCING = 2,
|
||||
AUTOIP_STATE_BOUND = 3
|
||||
} autoip_state_enum_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_AUTOIP_H */
|
195
tools/sdk/include/lwip/lwip/prot/dhcp.h
Normal file
195
tools/sdk/include/lwip/lwip/prot/dhcp.h
Normal file
@ -0,0 +1,195 @@
|
||||
/**
|
||||
* @file
|
||||
* DHCP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Leon Woestenberg <leon.woestenberg@gmx.net>
|
||||
* Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Leon Woestenberg <leon.woestenberg@gmx.net>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_DHCP_H
|
||||
#define LWIP_HDR_PROT_DHCP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DHCP_CLIENT_PORT 68
|
||||
#define DHCP_SERVER_PORT 67
|
||||
|
||||
|
||||
/* DHCP message item offsets and length */
|
||||
#define DHCP_CHADDR_LEN 16U
|
||||
#define DHCP_SNAME_OFS 44U
|
||||
#define DHCP_SNAME_LEN 64U
|
||||
#define DHCP_FILE_OFS 108U
|
||||
#define DHCP_FILE_LEN 128U
|
||||
#define DHCP_MSG_LEN 236U
|
||||
#define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4U) /* 4 byte: cookie */
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** minimum set of fields of any DHCP message */
|
||||
struct dhcp_msg
|
||||
{
|
||||
PACK_STRUCT_FLD_8(u8_t op);
|
||||
PACK_STRUCT_FLD_8(u8_t htype);
|
||||
PACK_STRUCT_FLD_8(u8_t hlen);
|
||||
PACK_STRUCT_FLD_8(u8_t hops);
|
||||
PACK_STRUCT_FIELD(u32_t xid);
|
||||
PACK_STRUCT_FIELD(u16_t secs);
|
||||
PACK_STRUCT_FIELD(u16_t flags);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t ciaddr);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t yiaddr);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t siaddr);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t giaddr);
|
||||
PACK_STRUCT_FLD_8(u8_t chaddr[DHCP_CHADDR_LEN]);
|
||||
PACK_STRUCT_FLD_8(u8_t sname[DHCP_SNAME_LEN]);
|
||||
PACK_STRUCT_FLD_8(u8_t file[DHCP_FILE_LEN]);
|
||||
PACK_STRUCT_FIELD(u32_t cookie);
|
||||
#define DHCP_MIN_OPTIONS_LEN 68U
|
||||
/** make sure user does not configure this too small */
|
||||
#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
|
||||
# undef DHCP_OPTIONS_LEN
|
||||
#endif
|
||||
/** allow this to be configured in lwipopts.h, but not too small */
|
||||
#if (!defined(DHCP_OPTIONS_LEN))
|
||||
/** set this to be sufficient for your options in outgoing DHCP msgs */
|
||||
# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
|
||||
#endif
|
||||
PACK_STRUCT_FLD_8(u8_t options[DHCP_OPTIONS_LEN]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* DHCP client states */
|
||||
typedef enum {
|
||||
DHCP_STATE_OFF = 0,
|
||||
DHCP_STATE_REQUESTING = 1,
|
||||
DHCP_STATE_INIT = 2,
|
||||
DHCP_STATE_REBOOTING = 3,
|
||||
DHCP_STATE_REBINDING = 4,
|
||||
DHCP_STATE_RENEWING = 5,
|
||||
DHCP_STATE_SELECTING = 6,
|
||||
DHCP_STATE_INFORMING = 7,
|
||||
DHCP_STATE_CHECKING = 8,
|
||||
DHCP_STATE_PERMANENT = 9, /* not yet implemented */
|
||||
DHCP_STATE_BOUND = 10,
|
||||
DHCP_STATE_RELEASING = 11, /* not yet implemented */
|
||||
DHCP_STATE_BACKING_OFF = 12
|
||||
} dhcp_state_enum_t;
|
||||
|
||||
/* DHCP op codes */
|
||||
#define DHCP_BOOTREQUEST 1
|
||||
#define DHCP_BOOTREPLY 2
|
||||
|
||||
/* DHCP message types */
|
||||
#define DHCP_DISCOVER 1
|
||||
#define DHCP_OFFER 2
|
||||
#define DHCP_REQUEST 3
|
||||
#define DHCP_DECLINE 4
|
||||
#define DHCP_ACK 5
|
||||
#define DHCP_NAK 6
|
||||
#define DHCP_RELEASE 7
|
||||
#define DHCP_INFORM 8
|
||||
|
||||
/** DHCP hardware type, currently only ethernet is supported */
|
||||
#define DHCP_HTYPE_ETH 1
|
||||
|
||||
#define DHCP_MAGIC_COOKIE 0x63825363UL
|
||||
|
||||
/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */
|
||||
|
||||
/* BootP options */
|
||||
#define DHCP_OPTION_PAD 0
|
||||
#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */
|
||||
#define DHCP_OPTION_ROUTER 3
|
||||
#define DHCP_OPTION_DNS_SERVER 6
|
||||
#define DHCP_OPTION_HOSTNAME 12
|
||||
#define DHCP_OPTION_IP_TTL 23
|
||||
#define DHCP_OPTION_MTU 26
|
||||
#define DHCP_OPTION_BROADCAST 28
|
||||
#define DHCP_OPTION_TCP_TTL 37
|
||||
#define DHCP_OPTION_NTP 42
|
||||
#define DHCP_OPTION_END 255
|
||||
|
||||
#if ESP_LWIP
|
||||
/**add options for support more router by liuHan**/
|
||||
#define DHCP_OPTION_DOMAIN_NAME 15
|
||||
#define DHCP_OPTION_PRD 31
|
||||
#define DHCP_OPTION_STATIC_ROUTER 33
|
||||
#define DHCP_OPTION_VSN 43
|
||||
#define DHCP_OPTION_NB_TINS 44
|
||||
#define DHCP_OPTION_NB_TINT 46
|
||||
#define DHCP_OPTION_NB_TIS 47
|
||||
#define DHCP_OPTION_CLASSLESS_STATIC_ROUTER 121
|
||||
#endif
|
||||
|
||||
/* DHCP options */
|
||||
#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
|
||||
#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
|
||||
#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */
|
||||
|
||||
#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */
|
||||
#define DHCP_OPTION_MESSAGE_TYPE_LEN 1
|
||||
|
||||
#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */
|
||||
#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */
|
||||
|
||||
#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */
|
||||
#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
|
||||
|
||||
#define DHCP_OPTION_T1 58 /* T1 renewal time */
|
||||
#define DHCP_OPTION_T2 59 /* T2 rebinding time */
|
||||
#define DHCP_OPTION_US 60
|
||||
#define DHCP_OPTION_CLIENT_ID 61
|
||||
#define DHCP_OPTION_TFTP_SERVERNAME 66
|
||||
#define DHCP_OPTION_BOOTFILE 67
|
||||
|
||||
/* possible combinations of overloading the file and sname fields with options */
|
||||
#define DHCP_OVERLOAD_NONE 0
|
||||
#define DHCP_OVERLOAD_FILE 1
|
||||
#define DHCP_OVERLOAD_SNAME 2
|
||||
#define DHCP_OVERLOAD_SNAME_FILE 3
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*LWIP_HDR_PROT_DHCP_H*/
|
140
tools/sdk/include/lwip/lwip/prot/dns.h
Normal file
140
tools/sdk/include/lwip/lwip/prot/dns.h
Normal file
@ -0,0 +1,140 @@
|
||||
/**
|
||||
* @file
|
||||
* DNS - host name to IP address resolver.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Port to lwIP from uIP
|
||||
* by Jim Pettinato April 2007
|
||||
*
|
||||
* security fixes and more by Simon Goldschmidt
|
||||
*
|
||||
* uIP version Copyright (c) 2002-2003, Adam Dunkels.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_PROT_DNS_H
|
||||
#define LWIP_HDR_PROT_DNS_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** DNS server port address */
|
||||
#ifndef DNS_SERVER_PORT
|
||||
#define DNS_SERVER_PORT 53
|
||||
#endif
|
||||
|
||||
/* DNS field TYPE used for "Resource Records" */
|
||||
#define DNS_RRTYPE_A 1 /* a host address */
|
||||
#define DNS_RRTYPE_NS 2 /* an authoritative name server */
|
||||
#define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */
|
||||
#define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */
|
||||
#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */
|
||||
#define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */
|
||||
#define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */
|
||||
#define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */
|
||||
#define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */
|
||||
#define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */
|
||||
#define DNS_RRTYPE_WKS 11 /* a well known service description */
|
||||
#define DNS_RRTYPE_PTR 12 /* a domain name pointer */
|
||||
#define DNS_RRTYPE_HINFO 13 /* host information */
|
||||
#define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */
|
||||
#define DNS_RRTYPE_MX 15 /* mail exchange */
|
||||
#define DNS_RRTYPE_TXT 16 /* text strings */
|
||||
#define DNS_RRTYPE_AAAA 28 /* IPv6 address */
|
||||
#define DNS_RRTYPE_SRV 33 /* service location */
|
||||
#define DNS_RRTYPE_ANY 255 /* any type */
|
||||
|
||||
/* DNS field CLASS used for "Resource Records" */
|
||||
#define DNS_RRCLASS_IN 1 /* the Internet */
|
||||
#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
|
||||
#define DNS_RRCLASS_CH 3 /* the CHAOS class */
|
||||
#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */
|
||||
#define DNS_RRCLASS_ANY 255 /* any class */
|
||||
#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */
|
||||
|
||||
/* DNS protocol flags */
|
||||
#define DNS_FLAG1_RESPONSE 0x80
|
||||
#define DNS_FLAG1_OPCODE_STATUS 0x10
|
||||
#define DNS_FLAG1_OPCODE_INVERSE 0x08
|
||||
#define DNS_FLAG1_OPCODE_STANDARD 0x00
|
||||
#define DNS_FLAG1_AUTHORATIVE 0x04
|
||||
#define DNS_FLAG1_TRUNC 0x02
|
||||
#define DNS_FLAG1_RD 0x01
|
||||
#define DNS_FLAG2_RA 0x80
|
||||
#define DNS_FLAG2_ERR_MASK 0x0f
|
||||
#define DNS_FLAG2_ERR_NONE 0x00
|
||||
#define DNS_FLAG2_ERR_NAME 0x03
|
||||
|
||||
#define DNS_HDR_GET_OPCODE(hdr) ((((hdr)->flags1) >> 3) & 0xF)
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** DNS message header */
|
||||
struct dns_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t id);
|
||||
PACK_STRUCT_FLD_8(u8_t flags1);
|
||||
PACK_STRUCT_FLD_8(u8_t flags2);
|
||||
PACK_STRUCT_FIELD(u16_t numquestions);
|
||||
PACK_STRUCT_FIELD(u16_t numanswers);
|
||||
PACK_STRUCT_FIELD(u16_t numauthrr);
|
||||
PACK_STRUCT_FIELD(u16_t numextrarr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
#define SIZEOF_DNS_HDR 12
|
||||
|
||||
|
||||
/* Multicast DNS definitions */
|
||||
|
||||
/** UDP port for multicast DNS queries */
|
||||
#ifndef DNS_MQUERY_PORT
|
||||
#define DNS_MQUERY_PORT 5353
|
||||
#endif
|
||||
|
||||
/* IPv4 group for multicast DNS queries: 224.0.0.251 */
|
||||
#ifndef DNS_MQUERY_IPV4_GROUP_INIT
|
||||
#define DNS_MQUERY_IPV4_GROUP_INIT IPADDR4_INIT_BYTES(224,0,0,251)
|
||||
#endif
|
||||
|
||||
/* IPv6 group for multicast DNS queries: FF02::FB */
|
||||
#ifndef DNS_MQUERY_IPV6_GROUP_INIT
|
||||
#define DNS_MQUERY_IPV6_GROUP_INIT IPADDR6_INIT_HOST(0xFF020000,0,0,0xFB)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_DNS_H */
|
91
tools/sdk/include/lwip/lwip/prot/etharp.h
Normal file
91
tools/sdk/include/lwip/lwip/prot/etharp.h
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file
|
||||
* ARP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_ETHARP_H
|
||||
#define LWIP_HDR_PROT_ETHARP_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/prot/ethernet.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef ETHARP_HWADDR_LEN
|
||||
#define ETHARP_HWADDR_LEN ETH_HWADDR_LEN
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** the ARP message, see RFC 826 ("Packet format") */
|
||||
struct etharp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t hwtype);
|
||||
PACK_STRUCT_FIELD(u16_t proto);
|
||||
PACK_STRUCT_FLD_8(u8_t hwlen);
|
||||
PACK_STRUCT_FLD_8(u8_t protolen);
|
||||
PACK_STRUCT_FIELD(u16_t opcode);
|
||||
PACK_STRUCT_FLD_S(struct eth_addr shwaddr);
|
||||
PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr);
|
||||
PACK_STRUCT_FLD_S(struct eth_addr dhwaddr);
|
||||
PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define SIZEOF_ETHARP_HDR 28
|
||||
|
||||
/* ARP hwtype values */
|
||||
enum etharp_hwtype {
|
||||
HWTYPE_ETHERNET = 1
|
||||
/* others not used */
|
||||
};
|
||||
|
||||
/* ARP message types (opcodes) */
|
||||
enum etharp_opcode {
|
||||
ARP_REQUEST = 1,
|
||||
ARP_REPLY = 2
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_ETHARP_H */
|
170
tools/sdk/include/lwip/lwip/prot/ethernet.h
Normal file
170
tools/sdk/include/lwip/lwip/prot/ethernet.h
Normal file
@ -0,0 +1,170 @@
|
||||
/**
|
||||
* @file
|
||||
* Ethernet protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_ETHERNET_H
|
||||
#define LWIP_HDR_PROT_ETHERNET_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef ETH_HWADDR_LEN
|
||||
#ifdef ETHARP_HWADDR_LEN
|
||||
#define ETH_HWADDR_LEN ETHARP_HWADDR_LEN /* compatibility mode */
|
||||
#else
|
||||
#define ETH_HWADDR_LEN 6
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct eth_addr {
|
||||
PACK_STRUCT_FLD_8(u8_t addr[ETH_HWADDR_LEN]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** Ethernet header */
|
||||
struct eth_hdr {
|
||||
#if ETH_PAD_SIZE
|
||||
PACK_STRUCT_FLD_8(u8_t padding[ETH_PAD_SIZE]);
|
||||
#endif
|
||||
PACK_STRUCT_FLD_S(struct eth_addr dest);
|
||||
PACK_STRUCT_FLD_S(struct eth_addr src);
|
||||
PACK_STRUCT_FIELD(u16_t type);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** VLAN header inserted between ethernet header and payload
|
||||
* if 'type' in ethernet header is ETHTYPE_VLAN.
|
||||
* See IEEE802.Q */
|
||||
struct eth_vlan_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t prio_vid);
|
||||
PACK_STRUCT_FIELD(u16_t tpid);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define SIZEOF_VLAN_HDR 4
|
||||
#define VLAN_ID(vlan_hdr) (lwip_htons((vlan_hdr)->prio_vid) & 0xFFF)
|
||||
|
||||
/**
|
||||
* @ingroup ethernet
|
||||
* A list of often ethtypes (although lwIP does not use all of them): */
|
||||
enum eth_type {
|
||||
/** Internet protocol v4 */
|
||||
ETHTYPE_IP = 0x0800U,
|
||||
/** Address resolution protocol */
|
||||
ETHTYPE_ARP = 0x0806U,
|
||||
/** Wake on lan */
|
||||
ETHTYPE_WOL = 0x0842U,
|
||||
/** RARP */
|
||||
ETHTYPE_RARP = 0x8035U,
|
||||
/** Virtual local area network */
|
||||
ETHTYPE_VLAN = 0x8100U,
|
||||
/** Internet protocol v6 */
|
||||
ETHTYPE_IPV6 = 0x86DDU,
|
||||
/** PPP Over Ethernet Discovery Stage */
|
||||
ETHTYPE_PPPOEDISC = 0x8863U,
|
||||
/** PPP Over Ethernet Session Stage */
|
||||
ETHTYPE_PPPOE = 0x8864U,
|
||||
/** Jumbo Frames */
|
||||
ETHTYPE_JUMBO = 0x8870U,
|
||||
/** Process field network */
|
||||
ETHTYPE_PROFINET = 0x8892U,
|
||||
/** Ethernet for control automation technology */
|
||||
ETHTYPE_ETHERCAT = 0x88A4U,
|
||||
/** Link layer discovery protocol */
|
||||
ETHTYPE_LLDP = 0x88CCU,
|
||||
/** Serial real-time communication system */
|
||||
ETHTYPE_SERCOS = 0x88CDU,
|
||||
/** Media redundancy protocol */
|
||||
ETHTYPE_MRP = 0x88E3U,
|
||||
/** Precision time protocol */
|
||||
ETHTYPE_PTP = 0x88F7U,
|
||||
/** Q-in-Q, 802.1ad */
|
||||
ETHTYPE_QINQ = 0x9100U
|
||||
};
|
||||
|
||||
/** The 24-bit IANA IPv4-multicast OUI is 01-00-5e: */
|
||||
#define LL_IP4_MULTICAST_ADDR_0 0x01
|
||||
#define LL_IP4_MULTICAST_ADDR_1 0x00
|
||||
#define LL_IP4_MULTICAST_ADDR_2 0x5e
|
||||
|
||||
/** IPv6 multicast uses this prefix */
|
||||
#define LL_IP6_MULTICAST_ADDR_0 0x33
|
||||
#define LL_IP6_MULTICAST_ADDR_1 0x33
|
||||
|
||||
/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
|
||||
* or known to be 32-bit aligned within the protocol header. */
|
||||
#ifndef ETHADDR32_COPY
|
||||
#define ETHADDR32_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN)
|
||||
#endif
|
||||
|
||||
/** MEMCPY-like macro to copy to/from struct eth_addr's that are no local
|
||||
* variables and known to be 16-bit aligned within the protocol header. */
|
||||
#ifndef ETHADDR16_COPY
|
||||
#define ETHADDR16_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN)
|
||||
#endif
|
||||
|
||||
#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_ETHERNET_H */
|
91
tools/sdk/include/lwip/lwip/prot/icmp.h
Normal file
91
tools/sdk/include/lwip/lwip/prot/icmp.h
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file
|
||||
* ICMP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_ICMP_H
|
||||
#define LWIP_HDR_PROT_ICMP_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ICMP_ER 0 /* echo reply */
|
||||
#define ICMP_DUR 3 /* destination unreachable */
|
||||
#define ICMP_SQ 4 /* source quench */
|
||||
#define ICMP_RD 5 /* redirect */
|
||||
#define ICMP_ECHO 8 /* echo */
|
||||
#define ICMP_TE 11 /* time exceeded */
|
||||
#define ICMP_PP 12 /* parameter problem */
|
||||
#define ICMP_TS 13 /* timestamp */
|
||||
#define ICMP_TSR 14 /* timestamp reply */
|
||||
#define ICMP_IRQ 15 /* information request */
|
||||
#define ICMP_IR 16 /* information reply */
|
||||
#define ICMP_AM 17 /* address mask request */
|
||||
#define ICMP_AMR 18 /* address mask reply */
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
/** This is the standard ICMP header only that the u32_t data
|
||||
* is split to two u16_t like ICMP echo needs it.
|
||||
* This header is also used for other ICMP types that do not
|
||||
* use the data part.
|
||||
*/
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp_echo_hdr {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t id);
|
||||
PACK_STRUCT_FIELD(u16_t seqno);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* Compatibility defines, old versions used to combine type and code to an u16_t */
|
||||
#define ICMPH_TYPE(hdr) ((hdr)->type)
|
||||
#define ICMPH_CODE(hdr) ((hdr)->code)
|
||||
#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t))
|
||||
#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_ICMP_H */
|
170
tools/sdk/include/lwip/lwip/prot/icmp6.h
Normal file
170
tools/sdk/include/lwip/lwip/prot/icmp6.h
Normal file
@ -0,0 +1,170 @@
|
||||
/**
|
||||
* @file
|
||||
* ICMP6 protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_ICMP6_H
|
||||
#define LWIP_HDR_PROT_ICMP6_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** ICMP type */
|
||||
enum icmp6_type {
|
||||
/** Destination unreachable */
|
||||
ICMP6_TYPE_DUR = 1,
|
||||
/** Packet too big */
|
||||
ICMP6_TYPE_PTB = 2,
|
||||
/** Time exceeded */
|
||||
ICMP6_TYPE_TE = 3,
|
||||
/** Parameter problem */
|
||||
ICMP6_TYPE_PP = 4,
|
||||
/** Private experimentation */
|
||||
ICMP6_TYPE_PE1 = 100,
|
||||
/** Private experimentation */
|
||||
ICMP6_TYPE_PE2 = 101,
|
||||
/** Reserved for expansion of error messages */
|
||||
ICMP6_TYPE_RSV_ERR = 127,
|
||||
|
||||
/** Echo request */
|
||||
ICMP6_TYPE_EREQ = 128,
|
||||
/** Echo reply */
|
||||
ICMP6_TYPE_EREP = 129,
|
||||
/** Multicast listener query */
|
||||
ICMP6_TYPE_MLQ = 130,
|
||||
/** Multicast listener report */
|
||||
ICMP6_TYPE_MLR = 131,
|
||||
/** Multicast listener done */
|
||||
ICMP6_TYPE_MLD = 132,
|
||||
/** Router solicitation */
|
||||
ICMP6_TYPE_RS = 133,
|
||||
/** Router advertisement */
|
||||
ICMP6_TYPE_RA = 134,
|
||||
/** Neighbor solicitation */
|
||||
ICMP6_TYPE_NS = 135,
|
||||
/** Neighbor advertisement */
|
||||
ICMP6_TYPE_NA = 136,
|
||||
/** Redirect */
|
||||
ICMP6_TYPE_RD = 137,
|
||||
/** Multicast router advertisement */
|
||||
ICMP6_TYPE_MRA = 151,
|
||||
/** Multicast router solicitation */
|
||||
ICMP6_TYPE_MRS = 152,
|
||||
/** Multicast router termination */
|
||||
ICMP6_TYPE_MRT = 153,
|
||||
/** Private experimentation */
|
||||
ICMP6_TYPE_PE3 = 200,
|
||||
/** Private experimentation */
|
||||
ICMP6_TYPE_PE4 = 201,
|
||||
/** Reserved for expansion of informational messages */
|
||||
ICMP6_TYPE_RSV_INF = 255
|
||||
};
|
||||
|
||||
/** ICMP destination unreachable codes */
|
||||
enum icmp6_dur_code {
|
||||
/** No route to destination */
|
||||
ICMP6_DUR_NO_ROUTE = 0,
|
||||
/** Communication with destination administratively prohibited */
|
||||
ICMP6_DUR_PROHIBITED = 1,
|
||||
/** Beyond scope of source address */
|
||||
ICMP6_DUR_SCOPE = 2,
|
||||
/** Address unreachable */
|
||||
ICMP6_DUR_ADDRESS = 3,
|
||||
/** Port unreachable */
|
||||
ICMP6_DUR_PORT = 4,
|
||||
/** Source address failed ingress/egress policy */
|
||||
ICMP6_DUR_POLICY = 5,
|
||||
/** Reject route to destination */
|
||||
ICMP6_DUR_REJECT_ROUTE = 6
|
||||
};
|
||||
|
||||
/** ICMP time exceeded codes */
|
||||
enum icmp6_te_code {
|
||||
/** Hop limit exceeded in transit */
|
||||
ICMP6_TE_HL = 0,
|
||||
/** Fragment reassembly time exceeded */
|
||||
ICMP6_TE_FRAG = 1
|
||||
};
|
||||
|
||||
/** ICMP parameter code */
|
||||
enum icmp6_pp_code {
|
||||
/** Erroneous header field encountered */
|
||||
ICMP6_PP_FIELD = 0,
|
||||
/** Unrecognized next header type encountered */
|
||||
ICMP6_PP_HEADER = 1,
|
||||
/** Unrecognized IPv6 option encountered */
|
||||
ICMP6_PP_OPTION = 2
|
||||
};
|
||||
|
||||
/** This is the standard ICMP6 header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp6_hdr {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t data);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** This is the ICMP6 header adapted for echo req/resp. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp6_echo_hdr {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t id);
|
||||
PACK_STRUCT_FIELD(u16_t seqno);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_ICMP6_H */
|
90
tools/sdk/include/lwip/lwip/prot/igmp.h
Normal file
90
tools/sdk/include/lwip/lwip/prot/igmp.h
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file
|
||||
* IGMP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_IGMP_H
|
||||
#define LWIP_HDR_PROT_IGMP_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* IGMP constants
|
||||
*/
|
||||
#define IGMP_TTL 1
|
||||
#define IGMP_MINLEN 8
|
||||
#define ROUTER_ALERT 0x9404U
|
||||
#define ROUTER_ALERTLEN 4
|
||||
|
||||
/*
|
||||
* IGMP message types, including version number.
|
||||
*/
|
||||
#define IGMP_MEMB_QUERY 0x11 /* Membership query */
|
||||
#define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */
|
||||
#define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */
|
||||
#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
|
||||
|
||||
/* Group membership states */
|
||||
#define IGMP_GROUP_NON_MEMBER 0
|
||||
#define IGMP_GROUP_DELAYING_MEMBER 1
|
||||
#define IGMP_GROUP_IDLE_MEMBER 2
|
||||
|
||||
/**
|
||||
* IGMP packet format.
|
||||
*/
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct igmp_msg {
|
||||
PACK_STRUCT_FLD_8(u8_t igmp_msgtype);
|
||||
PACK_STRUCT_FLD_8(u8_t igmp_maxresp);
|
||||
PACK_STRUCT_FIELD(u16_t igmp_checksum);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t igmp_group_address);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_IGMP_H */
|
51
tools/sdk/include/lwip/lwip/prot/ip.h
Normal file
51
tools/sdk/include/lwip/lwip/prot/ip.h
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file
|
||||
* IP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_IP_H
|
||||
#define LWIP_HDR_PROT_IP_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#define IP_PROTO_ICMP 1
|
||||
#define IP_PROTO_IGMP 2
|
||||
#define IP_PROTO_UDP 17
|
||||
#define IP_PROTO_UDPLITE 136
|
||||
#define IP_PROTO_TCP 6
|
||||
|
||||
/** This operates on a void* by loading the first byte */
|
||||
#define IP_HDR_GET_VERSION(ptr) ((*(u8_t*)(ptr)) >> 4)
|
||||
|
||||
#endif /* LWIP_HDR_PROT_IP_H */
|
127
tools/sdk/include/lwip/lwip/prot/ip4.h
Normal file
127
tools/sdk/include/lwip/lwip/prot/ip4.h
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @file
|
||||
* IPv4 protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_IP4_H
|
||||
#define LWIP_HDR_PROT_IP4_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** This is the packed version of ip4_addr_t,
|
||||
used in network headers that are itself packed */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip4_addr_packed {
|
||||
PACK_STRUCT_FIELD(u32_t addr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
typedef struct ip4_addr_packed ip4_addr_p_t;
|
||||
|
||||
/* Size of the IPv4 header. Same as 'sizeof(struct ip_hdr)'. */
|
||||
#define IP_HLEN 20
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/* The IPv4 header */
|
||||
struct ip_hdr {
|
||||
/* version / header length */
|
||||
PACK_STRUCT_FLD_8(u8_t _v_hl);
|
||||
/* type of service */
|
||||
PACK_STRUCT_FLD_8(u8_t _tos);
|
||||
/* total length */
|
||||
PACK_STRUCT_FIELD(u16_t _len);
|
||||
/* identification */
|
||||
PACK_STRUCT_FIELD(u16_t _id);
|
||||
/* fragment offset field */
|
||||
PACK_STRUCT_FIELD(u16_t _offset);
|
||||
#define IP_RF 0x8000U /* reserved fragment flag */
|
||||
#define IP_DF 0x4000U /* don't fragment flag */
|
||||
#define IP_MF 0x2000U /* more fragments flag */
|
||||
#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */
|
||||
/* time to live */
|
||||
PACK_STRUCT_FLD_8(u8_t _ttl);
|
||||
/* protocol*/
|
||||
PACK_STRUCT_FLD_8(u8_t _proto);
|
||||
/* checksum */
|
||||
PACK_STRUCT_FIELD(u16_t _chksum);
|
||||
/* source and destination IP addresses */
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t src);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t dest);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* Macros to get struct ip_hdr fields: */
|
||||
#define IPH_V(hdr) ((hdr)->_v_hl >> 4)
|
||||
#define IPH_HL(hdr) ((hdr)->_v_hl & 0x0f)
|
||||
#define IPH_TOS(hdr) ((hdr)->_tos)
|
||||
#define IPH_LEN(hdr) ((hdr)->_len)
|
||||
#define IPH_ID(hdr) ((hdr)->_id)
|
||||
#define IPH_OFFSET(hdr) ((hdr)->_offset)
|
||||
#define IPH_TTL(hdr) ((hdr)->_ttl)
|
||||
#define IPH_PROTO(hdr) ((hdr)->_proto)
|
||||
#define IPH_CHKSUM(hdr) ((hdr)->_chksum)
|
||||
|
||||
/* Macros to set struct ip_hdr fields: */
|
||||
#define IPH_VHL_SET(hdr, v, hl) (hdr)->_v_hl = (u8_t)((((v) << 4) | (hl)))
|
||||
#define IPH_TOS_SET(hdr, tos) (hdr)->_tos = (tos)
|
||||
#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
|
||||
#define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
|
||||
#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
|
||||
#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl)
|
||||
#define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto)
|
||||
#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_IP4_H */
|
169
tools/sdk/include/lwip/lwip/prot/ip6.h
Normal file
169
tools/sdk/include/lwip/lwip/prot/ip6.h
Normal file
@ -0,0 +1,169 @@
|
||||
/**
|
||||
* @file
|
||||
* IPv6 protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_IP6_H
|
||||
#define LWIP_HDR_PROT_IP6_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** This is the packed version of ip6_addr_t,
|
||||
used in network headers that are itself packed */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_addr_packed {
|
||||
PACK_STRUCT_FIELD(u32_t addr[4]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
typedef struct ip6_addr_packed ip6_addr_p_t;
|
||||
|
||||
#define IP6_HLEN 40
|
||||
|
||||
#define IP6_NEXTH_HOPBYHOP 0
|
||||
#define IP6_NEXTH_TCP 6
|
||||
#define IP6_NEXTH_UDP 17
|
||||
#define IP6_NEXTH_ENCAPS 41
|
||||
#define IP6_NEXTH_ROUTING 43
|
||||
#define IP6_NEXTH_FRAGMENT 44
|
||||
#define IP6_NEXTH_ICMP6 58
|
||||
#define IP6_NEXTH_NONE 59
|
||||
#define IP6_NEXTH_DESTOPTS 60
|
||||
#define IP6_NEXTH_UDPLITE 136
|
||||
|
||||
/** The IPv6 header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_hdr {
|
||||
/** version / traffic class / flow label */
|
||||
PACK_STRUCT_FIELD(u32_t _v_tc_fl);
|
||||
/** payload length */
|
||||
PACK_STRUCT_FIELD(u16_t _plen);
|
||||
/** next header */
|
||||
PACK_STRUCT_FLD_8(u8_t _nexth);
|
||||
/** hop limit */
|
||||
PACK_STRUCT_FLD_8(u8_t _hoplim);
|
||||
/** source and destination IP addresses */
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t src);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t dest);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* Hop-by-hop router alert option. */
|
||||
#define IP6_HBH_HLEN 8
|
||||
#define IP6_PAD1_OPTION 0
|
||||
#define IP6_PADN_ALERT_OPTION 1
|
||||
#define IP6_ROUTER_ALERT_OPTION 5
|
||||
#define IP6_ROUTER_ALERT_VALUE_MLD 0
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_hbh_hdr {
|
||||
/* next header */
|
||||
PACK_STRUCT_FLD_8(u8_t _nexth);
|
||||
/* header length */
|
||||
PACK_STRUCT_FLD_8(u8_t _hlen);
|
||||
/* router alert option type */
|
||||
PACK_STRUCT_FLD_8(u8_t _ra_opt_type);
|
||||
/* router alert option data len */
|
||||
PACK_STRUCT_FLD_8(u8_t _ra_opt_dlen);
|
||||
/* router alert option data */
|
||||
PACK_STRUCT_FIELD(u16_t _ra_opt_data);
|
||||
/* PadN option type */
|
||||
PACK_STRUCT_FLD_8(u8_t _padn_opt_type);
|
||||
/* PadN option data len */
|
||||
PACK_STRUCT_FLD_8(u8_t _padn_opt_dlen);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* Fragment header. */
|
||||
#define IP6_FRAG_HLEN 8
|
||||
#define IP6_FRAG_OFFSET_MASK 0xfff8
|
||||
#define IP6_FRAG_MORE_FLAG 0x0001
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip6_frag_hdr {
|
||||
/* next header */
|
||||
PACK_STRUCT_FLD_8(u8_t _nexth);
|
||||
/* reserved */
|
||||
PACK_STRUCT_FLD_8(u8_t reserved);
|
||||
/* fragment offset */
|
||||
PACK_STRUCT_FIELD(u16_t _fragment_offset);
|
||||
/* fragmented packet identification */
|
||||
PACK_STRUCT_FIELD(u32_t _identification);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f)
|
||||
#define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff)
|
||||
#define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff)
|
||||
#define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen))
|
||||
#define IP6H_NEXTH(hdr) ((hdr)->_nexth)
|
||||
#define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6)
|
||||
#define IP6H_HOPLIM(hdr) ((hdr)->_hoplim)
|
||||
|
||||
#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))
|
||||
#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen)
|
||||
#define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth)
|
||||
#define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_IP6_H */
|
70
tools/sdk/include/lwip/lwip/prot/mld6.h
Normal file
70
tools/sdk/include/lwip/lwip/prot/mld6.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @file
|
||||
* MLD6 protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_MLD6_H
|
||||
#define LWIP_HDR_PROT_MLD6_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/prot/ip6.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Multicast listener report/query/done message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct mld_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t max_resp_delay);
|
||||
PACK_STRUCT_FIELD(u16_t reserved);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_MLD6_H */
|
277
tools/sdk/include/lwip/lwip/prot/nd6.h
Normal file
277
tools/sdk/include/lwip/lwip/prot/nd6.h
Normal file
@ -0,0 +1,277 @@
|
||||
/**
|
||||
* @file
|
||||
* ND6 protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_ND6_H
|
||||
#define LWIP_HDR_PROT_ND6_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/prot/ip6.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Neighbor solicitation message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ns_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t reserved);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Neighbor advertisement message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct na_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FLD_8(u8_t flags);
|
||||
PACK_STRUCT_FLD_8(u8_t reserved[3]);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
#define ND6_FLAG_ROUTER (0x80)
|
||||
#define ND6_FLAG_SOLICITED (0x40)
|
||||
#define ND6_FLAG_OVERRIDE (0x20)
|
||||
|
||||
/** Router solicitation message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct rs_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t reserved);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Router advertisement message header. */
|
||||
#define ND6_RA_FLAG_MANAGED_ADDR_CONFIG (0x80)
|
||||
#define ND6_RA_FLAG_OTHER_CONFIG (0x40)
|
||||
#define ND6_RA_FLAG_HOME_AGENT (0x20)
|
||||
#define ND6_RA_PREFERENCE_MASK (0x18)
|
||||
#define ND6_RA_PREFERENCE_HIGH (0x08)
|
||||
#define ND6_RA_PREFERENCE_MEDIUM (0x00)
|
||||
#define ND6_RA_PREFERENCE_LOW (0x18)
|
||||
#define ND6_RA_PREFERENCE_DISABLED (0x10)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ra_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FLD_8(u8_t current_hop_limit);
|
||||
PACK_STRUCT_FLD_8(u8_t flags);
|
||||
PACK_STRUCT_FIELD(u16_t router_lifetime);
|
||||
PACK_STRUCT_FIELD(u32_t reachable_time);
|
||||
PACK_STRUCT_FIELD(u32_t retrans_timer);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Redirect message header. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct redirect_header {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t reserved);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t target_address);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t destination_address);
|
||||
/* Options follow. */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Link-layer address option. */
|
||||
#define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01)
|
||||
#define ND6_OPTION_TYPE_TARGET_LLADDR (0x02)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct lladdr_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t addr[NETIF_MAX_HWADDR_LEN]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Prefix information option. */
|
||||
#define ND6_OPTION_TYPE_PREFIX_INFO (0x03)
|
||||
#define ND6_PREFIX_FLAG_ON_LINK (0x80)
|
||||
#define ND6_PREFIX_FLAG_AUTONOMOUS (0x40)
|
||||
#define ND6_PREFIX_FLAG_ROUTER_ADDRESS (0x20)
|
||||
#define ND6_PREFIX_FLAG_SITE_PREFIX (0x10)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct prefix_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t prefix_length);
|
||||
PACK_STRUCT_FLD_8(u8_t flags);
|
||||
PACK_STRUCT_FIELD(u32_t valid_lifetime);
|
||||
PACK_STRUCT_FIELD(u32_t preferred_lifetime);
|
||||
PACK_STRUCT_FLD_8(u8_t reserved2[3]);
|
||||
PACK_STRUCT_FLD_8(u8_t site_prefix_length);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t prefix);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Redirected header option. */
|
||||
#define ND6_OPTION_TYPE_REDIR_HDR (0x04)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct redirected_header_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t reserved[6]);
|
||||
/* Portion of redirected packet follows. */
|
||||
/* PACK_STRUCT_FLD_8(u8_t redirected[8]); */
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** MTU option. */
|
||||
#define ND6_OPTION_TYPE_MTU (0x05)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct mtu_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FIELD(u16_t reserved);
|
||||
PACK_STRUCT_FIELD(u32_t mtu);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Route information option. */
|
||||
#define ND6_OPTION_TYPE_ROUTE_INFO (24)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct route_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FLD_8(u8_t prefix_length);
|
||||
PACK_STRUCT_FLD_8(u8_t preference);
|
||||
PACK_STRUCT_FIELD(u32_t route_lifetime);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t prefix);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** Recursive DNS Server Option. */
|
||||
#if LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
#define LWIP_RDNSS_OPTION_MAX_SERVERS LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
#else
|
||||
#define LWIP_RDNSS_OPTION_MAX_SERVERS 1
|
||||
#endif
|
||||
#define ND6_OPTION_TYPE_RDNSS (25)
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct rdnss_option {
|
||||
PACK_STRUCT_FLD_8(u8_t type);
|
||||
PACK_STRUCT_FLD_8(u8_t length);
|
||||
PACK_STRUCT_FIELD(u16_t reserved);
|
||||
PACK_STRUCT_FIELD(u32_t lifetime);
|
||||
PACK_STRUCT_FLD_S(ip6_addr_p_t rdnss_address[LWIP_RDNSS_OPTION_MAX_SERVERS]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_ND6_H */
|
97
tools/sdk/include/lwip/lwip/prot/tcp.h
Normal file
97
tools/sdk/include/lwip/lwip/prot/tcp.h
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file
|
||||
* TCP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_TCP_H
|
||||
#define LWIP_HDR_PROT_TCP_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Length of the TCP header, excluding options. */
|
||||
#define TCP_HLEN 20
|
||||
|
||||
/* Fields are (of course) in network byte order.
|
||||
* Some fields are converted to host byte order in tcp_input().
|
||||
*/
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct tcp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t src);
|
||||
PACK_STRUCT_FIELD(u16_t dest);
|
||||
PACK_STRUCT_FIELD(u32_t seqno);
|
||||
PACK_STRUCT_FIELD(u32_t ackno);
|
||||
PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags);
|
||||
PACK_STRUCT_FIELD(u16_t wnd);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t urgp);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* TCP header flags bits */
|
||||
#define TCP_FIN 0x01U
|
||||
#define TCP_SYN 0x02U
|
||||
#define TCP_RST 0x04U
|
||||
#define TCP_PSH 0x08U
|
||||
#define TCP_ACK 0x10U
|
||||
#define TCP_URG 0x20U
|
||||
#define TCP_ECE 0x40U
|
||||
#define TCP_CWR 0x80U
|
||||
/* Valid TCP header flags */
|
||||
#define TCP_FLAGS 0x3fU
|
||||
|
||||
#define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12))
|
||||
#define TCPH_FLAGS(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS))
|
||||
|
||||
#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | TCPH_FLAGS(phdr))
|
||||
#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | lwip_htons(flags))
|
||||
#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = (u16_t)(lwip_htons((u16_t)((len) << 12) | (flags)))
|
||||
|
||||
#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | lwip_htons(flags))
|
||||
#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~lwip_htons(flags))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_TCP_H */
|
68
tools/sdk/include/lwip/lwip/prot/udp.h
Normal file
68
tools/sdk/include/lwip/lwip/prot/udp.h
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file
|
||||
* UDP protocol definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_PROT_UDP_H
|
||||
#define LWIP_HDR_PROT_UDP_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UDP_HLEN 8
|
||||
|
||||
/* Fields are (of course) in network byte order. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct udp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t src);
|
||||
PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */
|
||||
PACK_STRUCT_FIELD(u16_t len);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PROT_UDP_H */
|
@ -1,3 +1,9 @@
|
||||
/**
|
||||
* @file
|
||||
* raw API (to be used from TCPIP thread)\n
|
||||
* See also @ref raw_raw
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -61,6 +67,7 @@ struct raw_pcb;
|
||||
typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *addr);
|
||||
|
||||
/** the RAW protocol control block */
|
||||
struct raw_pcb {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
@ -97,6 +104,8 @@ void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *re
|
||||
u8_t raw_input (struct pbuf *p, struct netif *inp);
|
||||
#define raw_init() /* Compatibility define, no init needed. */
|
||||
|
||||
void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr);
|
||||
|
||||
/* for compatibility with older implementation */
|
||||
#define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto)
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define SIO_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* MIB2 callback functions called from throughout the stack to integrate a MIB2
|
||||
* into lwIP (together with MIB2_STATS).
|
||||
* SNMP support API for implementing netifs and statitics for MIB2
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -48,9 +47,15 @@ extern "C" {
|
||||
struct udp_pcb;
|
||||
struct netif;
|
||||
|
||||
/**
|
||||
* @defgroup netif_mib2 MIB2 statistics
|
||||
* @ingroup netif
|
||||
*/
|
||||
|
||||
/* MIB2 statistics functions */
|
||||
#if MIB2_STATS /* don't build if not configured for use in lwipopts.h */
|
||||
/**
|
||||
* @ingroup netif_mib2
|
||||
* @see RFC1213, "MIB-II, 6. Definitions"
|
||||
*/
|
||||
enum snmp_ifType {
|
||||
@ -88,18 +93,31 @@ enum snmp_ifType {
|
||||
snmp_ifType_frame_relay
|
||||
};
|
||||
|
||||
/* This macro has a precision of ~49 days because sys_now returns u32_t. #define your own if you want ~490 days. */
|
||||
/** This macro has a precision of ~49 days because sys_now returns u32_t. \#define your own if you want ~490 days. */
|
||||
#ifndef MIB2_COPY_SYSUPTIME_TO
|
||||
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup netif_mib2
|
||||
* Increment stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs)
|
||||
*/
|
||||
#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0)
|
||||
/**
|
||||
* @ingroup netif_mib2
|
||||
* Add value to stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs)
|
||||
*/
|
||||
#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0)
|
||||
|
||||
/**
|
||||
* @ingroup netif_mib2
|
||||
* Init MIB2 statistic counters in netif
|
||||
* @param netif Netif to init
|
||||
* @param type one of enum @ref snmp_ifType
|
||||
* @param speed your link speed here (units: bits per second)
|
||||
*/
|
||||
#define MIB2_INIT_NETIF(netif, type, speed) do { \
|
||||
/* use "snmp_ifType" enum from snmp_mib2.h for "type", snmp_ifType_ethernet_csmacd by example */ \
|
||||
(netif)->link_type = (type); \
|
||||
/* your link speed here (units: bits per second) */ \
|
||||
(netif)->link_speed = (speed);\
|
||||
(netif)->ts = 0; \
|
||||
(netif)->mib2_counters.ifinoctets = 0; \
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Socket API (to be used from non-TCPIP threads)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -38,12 +43,10 @@
|
||||
|
||||
#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
#include <string.h> /* for FD_ZERO */
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/errno.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -191,6 +194,7 @@ struct msghdr {
|
||||
#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
|
||||
#define SO_NO_CHECK 0x100a /* don't create UDP checksum */
|
||||
|
||||
|
||||
/*
|
||||
* Structure used for manipulating linger option.
|
||||
*/
|
||||
@ -250,11 +254,6 @@ struct linger {
|
||||
#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
|
||||
#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
|
||||
#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WINDOW 0x06 /* set pcb->per_soc_tcp_wnd */
|
||||
#define TCP_SNDBUF 0x07 /* set pcb->per_soc_tcp_snd_buf */
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#if LWIP_IPV6
|
||||
@ -264,6 +263,7 @@ struct linger {
|
||||
#define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
|
||||
#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
|
||||
|
||||
#if ESP_LWIP
|
||||
#if LWIP_IPV6_MLD
|
||||
/* Socket options for IPV6 multicast, uses the MLD interface to manage group memberships. RFC2133. */
|
||||
#define IPV6_MULTICAST_IF 0x300
|
||||
@ -283,6 +283,7 @@ typedef struct ip6_mreq {
|
||||
#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
|
||||
|
||||
#endif /* LWIP_IPV6_MLD */
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
@ -466,8 +467,6 @@ void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initializ
|
||||
void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */
|
||||
|
||||
#if LWIP_COMPAT_SOCKETS == 2
|
||||
|
||||
|
||||
/* This helps code parsers/code completion by not having the COMPAT functions as defines */
|
||||
#define lwip_accept accept
|
||||
#define lwip_bind bind
|
||||
@ -541,6 +540,7 @@ int lwip_setsockopt_r (int s, int level, int optname, const void *optval, sockle
|
||||
int lwip_close_r(int s);
|
||||
int lwip_connect_r(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int lwip_listen_r(int s, int backlog);
|
||||
int lwip_recvmsg_r(int s, struct msghdr *message, int flags);
|
||||
int lwip_recv_r(int s, void *mem, size_t len, int flags);
|
||||
int lwip_read_r(int s, void *mem, size_t len);
|
||||
int lwip_recvfrom_r(int s, void *mem, size_t len, int flags,
|
||||
@ -577,6 +577,8 @@ static inline int connect(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_connect_r(s,name,namelen); }
|
||||
static inline int listen(int s,int backlog)
|
||||
{ return lwip_listen_r(s,backlog); }
|
||||
static inline int recvmsg(int sockfd, struct msghdr *msg, int flags)
|
||||
{ return lwip_recvmsg_r(sockfd, msg, flags); }
|
||||
static inline int recv(int s,void *mem,size_t len,int flags)
|
||||
{ return lwip_recv_r(s,mem,len,flags); }
|
||||
static inline int recvfrom(int s,void *mem,size_t len,int flags,struct sockaddr *from,socklen_t *fromlen)
|
||||
@ -609,71 +611,106 @@ static inline int fcntl(int s,int cmd,int val)
|
||||
{ return lwip_fcntl_r(s,cmd,val); }
|
||||
static inline int ioctl(int s,long cmd,void *argp)
|
||||
{ return lwip_ioctl_r(s,cmd,argp); }
|
||||
#endif /* { RETURN LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
|
||||
#else
|
||||
|
||||
static inline int accept(int s,struct sockaddr *addr,socklen_t *addrlen)
|
||||
{ return lwip_accept(s,addr,addrlen); }
|
||||
static inline int bind(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_bind(s,name,namelen); }
|
||||
static inline int shutdown(int s,int how)
|
||||
{ return lwip_shutdown(s,how); }
|
||||
static inline int getpeername(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getpeername(s,name,namelen); }
|
||||
static inline int getsockname(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getsockname(s,name,namelen); }
|
||||
static inline int setsockopt(int s,int level,int optname,const void *opval,socklen_t optlen)
|
||||
{ return lwip_setsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int getsockopt(int s,int level,int optname,void *opval,socklen_t *optlen)
|
||||
{ return lwip_getsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int closesocket(int s)
|
||||
{ return lwip_close(s); }
|
||||
static inline int connect(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_connect(s,name,namelen); }
|
||||
static inline int listen(int s,int backlog)
|
||||
{ return lwip_listen(s,backlog); }
|
||||
static inline int recv(int s,void *mem,size_t len,int flags)
|
||||
{ return lwip_recv(s,mem,len,flags); }
|
||||
static inline int recvfrom(int s,void *mem,size_t len,int flags,struct sockaddr *from,socklen_t *fromlen)
|
||||
{ return lwip_recvfrom(s,mem,len,flags,from,fromlen); }
|
||||
static inline int send(int s,const void *dataptr,size_t size,int flags)
|
||||
{ return lwip_send(s,dataptr,size,flags); }
|
||||
static inline int sendmsg(int s,const struct msghdr *message,int flags)
|
||||
{ return lwip_sendmsg(s,message,flags); }
|
||||
static inline int sendto(int s,const void *dataptr,size_t size,int flags,const struct sockaddr *to,socklen_t tolen)
|
||||
{ return lwip_sendto(s,dataptr,size,flags,to,tolen); }
|
||||
static inline int socket(int domain,int type,int protocol)
|
||||
{ return lwip_socket(domain,type,protocol); }
|
||||
#ifndef ESP_HAS_SELECT
|
||||
static inline int select(int maxfdp1,fd_set t*readset,fd_set *writeset,fd_set *exceptset,struct timeval *timeout)
|
||||
{ return lwip_select(maxfdp1,readset,writeset,exceptset,timeout); }
|
||||
#endif /* ESP_HAS_SELECT */
|
||||
static inline int ioctlsocket(int s,long cmd,void *argp)
|
||||
{ return lwip_ioctl(s,cmd,argp); }
|
||||
/** @ingroup socket */
|
||||
#define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen)
|
||||
/** @ingroup socket */
|
||||
#define bind(s,name,namelen) lwip_bind(s,name,namelen)
|
||||
/** @ingroup socket */
|
||||
#define shutdown(s,how) lwip_shutdown(s,how)
|
||||
/** @ingroup socket */
|
||||
#define getpeername(s,name,namelen) lwip_getpeername(s,name,namelen)
|
||||
/** @ingroup socket */
|
||||
#define getsockname(s,name,namelen) lwip_getsockname(s,name,namelen)
|
||||
/** @ingroup socket */
|
||||
#define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt(s,level,optname,opval,optlen)
|
||||
/** @ingroup socket */
|
||||
#define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt(s,level,optname,opval,optlen)
|
||||
/** @ingroup socket */
|
||||
#define closesocket(s) lwip_close(s)
|
||||
/** @ingroup socket */
|
||||
#define connect(s,name,namelen) lwip_connect(s,name,namelen)
|
||||
/** @ingroup socket */
|
||||
#define listen(s,backlog) lwip_listen(s,backlog)
|
||||
/** @ingroup socket */
|
||||
#define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags)
|
||||
/** @ingroup socket */
|
||||
#define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen)
|
||||
/** @ingroup socket */
|
||||
#define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags)
|
||||
/** @ingroup socket */
|
||||
#define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags)
|
||||
/** @ingroup socket */
|
||||
#define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen)
|
||||
/** @ingroup socket */
|
||||
#define socket(domain,type,protocol) lwip_socket(domain,type,protocol)
|
||||
/** @ingroup socket */
|
||||
#define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
|
||||
/** @ingroup socket */
|
||||
#define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp)
|
||||
|
||||
#if LWIP_POSIX_SOCKETS_IO_NAMES
|
||||
static inline int read(int s,void *mem,size_t len)
|
||||
{ return lwip_read(s,mem,len); }
|
||||
static inline int write(int s,const void *dataptr,size_t len)
|
||||
{ return lwip_write(s,dataptr,len); }
|
||||
static inline int writev(int s,const struct iovec *iov,int iovcnt)
|
||||
{ return lwip_writev(s,iov,iovcnt); }
|
||||
static inline int close(int s)
|
||||
{ return lwip_close(s); }
|
||||
static inline int fcntl(int s,long cmd,void *val)
|
||||
{ return lwip_fcntl(s,cmd,val); }
|
||||
static inline int ioctl(int s,int cmd,int argp)
|
||||
{ return lwip_ioctl(s,cmd,argp); }
|
||||
/** @ingroup socket */
|
||||
#define read(s,mem,len) lwip_read(s,mem,len)
|
||||
/** @ingroup socket */
|
||||
#define write(s,dataptr,len) lwip_write(s,dataptr,len)
|
||||
/** @ingroup socket */
|
||||
#define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt)
|
||||
/** @ingroup socket */
|
||||
#define close(s) lwip_close(s)
|
||||
/** @ingroup socket */
|
||||
#define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val)
|
||||
/** @ingroup socket */
|
||||
#define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp)
|
||||
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
#endif /* ESP_THREAD_SAFE */
|
||||
|
||||
#endif /* ESP_THREAD_SAFE */
|
||||
#endif /* LWIP_COMPAT_SOCKETS != 2 */
|
||||
|
||||
#if ESP_LWIP
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
#define lwip_inet_ntop(af,src,dst,size) \
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) \
|
||||
: (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL))
|
||||
#define lwip_inet_pton(af,src,dst) \
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
|
||||
: (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
|
||||
#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
#define lwip_inet_ntop(af,src,dst,size) \
|
||||
(((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL)
|
||||
#define lwip_inet_pton(af,src,dst) \
|
||||
(((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)
|
||||
#else /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
#define lwip_inet_ntop(af,src,dst,size) \
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) : NULL)
|
||||
#define lwip_inet_pton(af,src,dst) \
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) : 0)
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
#if LWIP_COMPAT_SOCKET_INET == 1
|
||||
/* Some libraries have problems with inet_... being macros, so please use this define
|
||||
to declare normal functions */
|
||||
static inline const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
|
||||
{ lwip_inet_ntop(af, src, dst, size); return dst; }
|
||||
static inline int inet_pton(int af, const char *src, void *dst)
|
||||
{ lwip_inet_pton(af, src, dst); return 1; }
|
||||
#else
|
||||
/* By default fall back to original inet_... macros */
|
||||
# define inet_ntop(a,b,c,d) lwip_inet_ntop(a,b,c,d)
|
||||
# define inet_pton(a,b,c) lwip_inet_pton(a,b,c)
|
||||
#endif /* LWIP_COMPAT_SOCKET_INET */
|
||||
|
||||
#else /* ESP_LWIP*/
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/** @ingroup socket */
|
||||
#define inet_ntop(af,src,dst,size) \
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) \
|
||||
: (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL))
|
||||
/** @ingroup socket */
|
||||
#define inet_pton(af,src,dst) \
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
|
||||
: (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
|
||||
@ -689,6 +726,7 @@ static inline int ioctl(int s,int cmd,int argp)
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) : 0)
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
#endif /* ESP_LWIP */
|
||||
#endif /* LWIP_COMPAT_SOCKETS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Statistics API (to be used from TCPIP thread)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -55,6 +60,7 @@ extern "C" {
|
||||
#define STAT_COUNTER_F U16_F
|
||||
#endif
|
||||
|
||||
/** Protocol related stats */
|
||||
struct stats_proto {
|
||||
STAT_COUNTER xmit; /* Transmitted packets. */
|
||||
STAT_COUNTER recv; /* Received packets. */
|
||||
@ -70,6 +76,7 @@ struct stats_proto {
|
||||
STAT_COUNTER cachehit;
|
||||
};
|
||||
|
||||
/** IGMP stats */
|
||||
struct stats_igmp {
|
||||
STAT_COUNTER xmit; /* Transmitted packets. */
|
||||
STAT_COUNTER recv; /* Received packets. */
|
||||
@ -87,10 +94,11 @@ struct stats_igmp {
|
||||
STAT_COUNTER tx_report; /* Sent reports. */
|
||||
};
|
||||
|
||||
/** Memory stats */
|
||||
struct stats_mem {
|
||||
#ifdef LWIP_DEBUG
|
||||
#if defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY
|
||||
const char *name;
|
||||
#endif /* LWIP_DEBUG */
|
||||
#endif /* defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY */
|
||||
STAT_COUNTER err;
|
||||
mem_size_t avail;
|
||||
mem_size_t used;
|
||||
@ -98,18 +106,21 @@ struct stats_mem {
|
||||
STAT_COUNTER illegal;
|
||||
};
|
||||
|
||||
/** System element stats */
|
||||
struct stats_syselem {
|
||||
STAT_COUNTER used;
|
||||
STAT_COUNTER max;
|
||||
STAT_COUNTER err;
|
||||
};
|
||||
|
||||
/** System stats */
|
||||
struct stats_sys {
|
||||
struct stats_syselem sem;
|
||||
struct stats_syselem mutex;
|
||||
struct stats_syselem mbox;
|
||||
};
|
||||
|
||||
/** SNMP MIB2 stats */
|
||||
struct stats_mib2 {
|
||||
/* IP */
|
||||
u32_t ipinhdrerrors;
|
||||
@ -168,51 +179,56 @@ struct stats_mib2 {
|
||||
u32_t icmpoutechoreps;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup netif_mib2
|
||||
* SNMP MIB2 interface stats
|
||||
*/
|
||||
struct stats_mib2_netif_ctrs {
|
||||
/* The total number of octets received on the interface, including framing characters */
|
||||
/** The total number of octets received on the interface, including framing characters */
|
||||
u32_t ifinoctets;
|
||||
/* The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
|
||||
/** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
|
||||
* not addressed to a multicast or broadcast address at this sub-layer */
|
||||
u32_t ifinucastpkts;
|
||||
/* The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
|
||||
/** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
|
||||
* addressed to a multicast or broadcast address at this sub-layer */
|
||||
u32_t ifinnucastpkts;
|
||||
/* The number of inbound packets which were chosen to be discarded even though no errors had
|
||||
* been detected to prevent their being deliverable to a higher-layer protocol. One possible
|
||||
/** The number of inbound packets which were chosen to be discarded even though no errors had
|
||||
* been detected to prevent their being deliverable to a higher-layer protocol. One possible
|
||||
* reason for discarding such a packet could be to free up buffer space */
|
||||
u32_t ifindiscards;
|
||||
/* For packet-oriented interfaces, the number of inbound packets that contained errors
|
||||
/** For packet-oriented interfaces, the number of inbound packets that contained errors
|
||||
* preventing them from being deliverable to a higher-layer protocol. For character-
|
||||
* oriented or fixed-length interfaces, the number of inbound transmission units that
|
||||
* oriented or fixed-length interfaces, the number of inbound transmission units that
|
||||
* contained errors preventing them from being deliverable to a higher-layer protocol. */
|
||||
u32_t ifinerrors;
|
||||
/* For packet-oriented interfaces, the number of packets received via the interface which
|
||||
/** For packet-oriented interfaces, the number of packets received via the interface which
|
||||
* were discarded because of an unknown or unsupported protocol. For character-oriented
|
||||
* or fixed-length interfaces that support protocol multiplexing the number of transmission
|
||||
* units received via the interface which were discarded because of an unknown or unsupported
|
||||
* protocol. For any interface that does not support protocol multiplexing, this counter will
|
||||
* always be 0 */
|
||||
u32_t ifinunknownprotos;
|
||||
/* The total number of octets transmitted out of the interface, including framing characters. */
|
||||
/** The total number of octets transmitted out of the interface, including framing characters. */
|
||||
u32_t ifoutoctets;
|
||||
/* The total number of packets that higher-level protocols requested be transmitted, and
|
||||
/** The total number of packets that higher-level protocols requested be transmitted, and
|
||||
* which were not addressed to a multicast or broadcast address at this sub-layer, including
|
||||
* those that were discarded or not sent. */
|
||||
u32_t ifoutucastpkts;
|
||||
/* The total number of packets that higher-level protocols requested be transmitted, and which
|
||||
/** The total number of packets that higher-level protocols requested be transmitted, and which
|
||||
* were addressed to a multicast or broadcast address at this sub-layer, including
|
||||
* those that were discarded or not sent. */
|
||||
u32_t ifoutnucastpkts;
|
||||
/* The number of outbound packets which were chosen to be discarded even though no errors had
|
||||
/** The number of outbound packets which were chosen to be discarded even though no errors had
|
||||
* been detected to prevent their being transmitted. One possible reason for discarding
|
||||
* such a packet could be to free up buffer space. */
|
||||
u32_t ifoutdiscards;
|
||||
/* For packet-oriented interfaces, the number of outbound packets that could not be transmitted
|
||||
/** For packet-oriented interfaces, the number of outbound packets that could not be transmitted
|
||||
* because of errors. For character-oriented or fixed-length interfaces, the number of outbound
|
||||
* transmission units that could not be transmitted because of errors. */
|
||||
u32_t ifouterrors;
|
||||
};
|
||||
|
||||
#if ESP_STATS_DROP
|
||||
struct stats_esp {
|
||||
/* mbox post fail stats */
|
||||
u32_t rx_rawmbox_post_fail;
|
||||
@ -229,66 +245,88 @@ struct stats_esp {
|
||||
u32_t wlanif_input_pbuf_fail;
|
||||
u32_t wlanif_outut_pbuf_fail;
|
||||
};
|
||||
#endif
|
||||
|
||||
/** lwIP stats container */
|
||||
struct stats_ {
|
||||
#if LINK_STATS
|
||||
/** Link level */
|
||||
struct stats_proto link;
|
||||
#endif
|
||||
#if ETHARP_STATS
|
||||
/** ARP */
|
||||
struct stats_proto etharp;
|
||||
#endif
|
||||
#if IPFRAG_STATS
|
||||
/** Fragmentation */
|
||||
struct stats_proto ip_frag;
|
||||
#endif
|
||||
#if IP_STATS
|
||||
/** IP */
|
||||
struct stats_proto ip;
|
||||
#endif
|
||||
#if ICMP_STATS
|
||||
/** ICMP */
|
||||
struct stats_proto icmp;
|
||||
#endif
|
||||
#if IGMP_STATS
|
||||
/** IGMP */
|
||||
struct stats_igmp igmp;
|
||||
#endif
|
||||
#if UDP_STATS
|
||||
/** UDP */
|
||||
struct stats_proto udp;
|
||||
#endif
|
||||
#if TCP_STATS
|
||||
/** TCP */
|
||||
struct stats_proto tcp;
|
||||
#endif
|
||||
#if MEM_STATS
|
||||
/** Heap */
|
||||
struct stats_mem mem;
|
||||
#endif
|
||||
#if MEMP_STATS
|
||||
struct stats_mem memp[MEMP_MAX];
|
||||
/** Internal memory pools */
|
||||
struct stats_mem *memp[MEMP_MAX];
|
||||
#endif
|
||||
#if SYS_STATS
|
||||
/** System */
|
||||
struct stats_sys sys;
|
||||
#endif
|
||||
#if IP6_STATS
|
||||
/** IPv6 */
|
||||
struct stats_proto ip6;
|
||||
#endif
|
||||
#if ICMP6_STATS
|
||||
/** ICMP6 */
|
||||
struct stats_proto icmp6;
|
||||
#endif
|
||||
#if IP6_FRAG_STATS
|
||||
/** IPv6 fragmentation */
|
||||
struct stats_proto ip6_frag;
|
||||
#endif
|
||||
#if MLD6_STATS
|
||||
/** Multicast listener discovery */
|
||||
struct stats_igmp mld6;
|
||||
#endif
|
||||
#if ND6_STATS
|
||||
/** Neighbor discovery */
|
||||
struct stats_proto nd6;
|
||||
#endif
|
||||
#if MIB2_STATS
|
||||
/** SNMP MIB2 */
|
||||
struct stats_mib2 mib2;
|
||||
#endif
|
||||
|
||||
#if ESP_STATS_DROP
|
||||
struct stats_esp esp;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Global variable containing lwIP internal statistics. Add this to your debugger's watchlist. */
|
||||
extern struct stats_ lwip_stats;
|
||||
|
||||
/** Init statistics */
|
||||
void stats_init(void);
|
||||
|
||||
#define STATS_INC(x) ++lwip_stats.x
|
||||
@ -372,9 +410,9 @@ void stats_init(void);
|
||||
|
||||
#if MEM_STATS
|
||||
#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
|
||||
#define MEM_STATS_INC(x) STATS_INC(mem.x)
|
||||
#define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y)
|
||||
#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
|
||||
#define MEM_STATS_INC(x) SYS_ARCH_INC(lwip_stats.mem.x, 1)
|
||||
#define MEM_STATS_INC_USED(x, y) SYS_ARCH_INC(lwip_stats.mem.x, y)
|
||||
#define MEM_STATS_DEC_USED(x, y) SYS_ARCH_DEC(lwip_stats.mem.x, y)
|
||||
#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
|
||||
#else
|
||||
#define MEM_STATS_AVAIL(x, y)
|
||||
@ -384,18 +422,12 @@ void stats_init(void);
|
||||
#define MEM_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if MEMP_STATS
|
||||
#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
|
||||
#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
|
||||
#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
|
||||
#define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1)
|
||||
#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
|
||||
#define MEMP_STATS_GET(x, i) STATS_GET(memp[i].x)
|
||||
#else
|
||||
#define MEMP_STATS_AVAIL(x, i, y)
|
||||
#define MEMP_STATS_INC(x, i)
|
||||
#if MEMP_STATS
|
||||
#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i]->x)
|
||||
#define MEMP_STATS_DISPLAY(i) stats_display_memp(lwip_stats.memp[i], i)
|
||||
#define MEMP_STATS_GET(x, i) STATS_GET(memp[i]->x)
|
||||
#else
|
||||
#define MEMP_STATS_DEC(x, i)
|
||||
#define MEMP_STATS_INC_USED(x, i)
|
||||
#define MEMP_STATS_DISPLAY(i)
|
||||
#define MEMP_STATS_GET(x, i) 0
|
||||
#endif
|
||||
@ -474,7 +506,10 @@ void stats_display_igmp(struct stats_igmp *igmp, const char *name);
|
||||
void stats_display_mem(struct stats_mem *mem, const char *name);
|
||||
void stats_display_memp(struct stats_mem *mem, int index);
|
||||
void stats_display_sys(struct stats_sys *sys);
|
||||
#if ESP_STATS_DROP
|
||||
void stats_display_esp(struct stats_esp *esp);
|
||||
#endif
|
||||
|
||||
#else /* LWIP_STATS_DISPLAY */
|
||||
#define stats_display()
|
||||
#define stats_display_proto(proto, name)
|
||||
@ -482,7 +517,10 @@ void stats_display_esp(struct stats_esp *esp);
|
||||
#define stats_display_mem(mem, name)
|
||||
#define stats_display_memp(mem, index)
|
||||
#define stats_display_sys(sys)
|
||||
#if ESP_STATS_DROP
|
||||
#define stats_display_esp(esp)
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_STATS_DISPLAY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* OS abstraction layer
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -27,8 +32,8 @@
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_SYS_H
|
||||
#define LWIP_HDR_SYS_H
|
||||
|
||||
@ -115,134 +120,215 @@ typedef void (*lwip_thread_fn)(void *arg);
|
||||
|
||||
#else /* LWIP_COMPAT_MUTEX */
|
||||
|
||||
/** Create a new mutex
|
||||
/**
|
||||
* @ingroup sys_mutex
|
||||
* Create a new mutex.
|
||||
* Note that mutexes are expected to not be taken recursively by the lwIP code,
|
||||
* so both implementation types (recursive or non-recursive) should work.
|
||||
* @param mutex pointer to the mutex to create
|
||||
* @return a new mutex */
|
||||
* @return ERR_OK if successful, another err_t otherwise
|
||||
*/
|
||||
err_t sys_mutex_new(sys_mutex_t *mutex);
|
||||
/** Lock a mutex
|
||||
* @param mutex the mutex to lock */
|
||||
/**
|
||||
* @ingroup sys_mutex
|
||||
* Lock a mutex
|
||||
* @param mutex the mutex to lock
|
||||
*/
|
||||
void sys_mutex_lock(sys_mutex_t *mutex);
|
||||
/** Unlock a mutex
|
||||
* @param mutex the mutex to unlock */
|
||||
/**
|
||||
* @ingroup sys_mutex
|
||||
* Unlock a mutex
|
||||
* @param mutex the mutex to unlock
|
||||
*/
|
||||
void sys_mutex_unlock(sys_mutex_t *mutex);
|
||||
/** Delete a semaphore
|
||||
* @param mutex the mutex to delete */
|
||||
/**
|
||||
* @ingroup sys_mutex
|
||||
* Delete a semaphore
|
||||
* @param mutex the mutex to delete
|
||||
*/
|
||||
void sys_mutex_free(sys_mutex_t *mutex);
|
||||
#ifndef sys_mutex_valid
|
||||
/** Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid */
|
||||
/**
|
||||
* @ingroup sys_mutex
|
||||
* Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid
|
||||
*/
|
||||
int sys_mutex_valid(sys_mutex_t *mutex);
|
||||
#endif
|
||||
#ifndef sys_mutex_set_invalid
|
||||
/** Set a mutex invalid so that sys_mutex_valid returns 0 */
|
||||
/**
|
||||
* @ingroup sys_mutex
|
||||
* Set a mutex invalid so that sys_mutex_valid returns 0
|
||||
*/
|
||||
void sys_mutex_set_invalid(sys_mutex_t *mutex);
|
||||
#endif
|
||||
#endif /* LWIP_COMPAT_MUTEX */
|
||||
|
||||
/* Semaphore functions: */
|
||||
|
||||
/** Create a new semaphore
|
||||
/**
|
||||
* @ingroup sys_sem
|
||||
* Create a new semaphore
|
||||
* @param sem pointer to the semaphore to create
|
||||
* @param count initial count of the semaphore
|
||||
* @return ERR_OK if successful, another err_t otherwise */
|
||||
* @return ERR_OK if successful, another err_t otherwise
|
||||
*/
|
||||
err_t sys_sem_new(sys_sem_t *sem, u8_t count);
|
||||
/** Signals a semaphore
|
||||
* @param sem the semaphore to signal */
|
||||
/**
|
||||
* @ingroup sys_sem
|
||||
* Signals a semaphore
|
||||
* @param sem the semaphore to signal
|
||||
*/
|
||||
void sys_sem_signal(sys_sem_t *sem);
|
||||
|
||||
#if ESP_LWIP
|
||||
/** Signals a semaphore (ISR version)
|
||||
* @param sem the semaphore to signal
|
||||
* @return non-zero if a higher priority task has been woken */
|
||||
int sys_sem_signal_isr(sys_sem_t *sem);
|
||||
/** Wait for a semaphore for the specified timeout
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup sys_sem
|
||||
* Wait for a semaphore for the specified timeout
|
||||
* @param sem the semaphore to wait for
|
||||
* @param timeout timeout in milliseconds to wait (0 = wait forever)
|
||||
* @return time (in milliseconds) waited for the semaphore
|
||||
* or SYS_ARCH_TIMEOUT on timeout */
|
||||
* or SYS_ARCH_TIMEOUT on timeout
|
||||
*/
|
||||
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout);
|
||||
/** Delete a semaphore
|
||||
* @param sem semaphore to delete */
|
||||
/**
|
||||
* @ingroup sys_sem
|
||||
* Delete a semaphore
|
||||
* @param sem semaphore to delete
|
||||
*/
|
||||
void sys_sem_free(sys_sem_t *sem);
|
||||
/** Wait for a semaphore - forever/no timeout */
|
||||
#define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0)
|
||||
#ifndef sys_sem_valid
|
||||
/** Check if a semaphore is valid/allocated: return 1 for valid, 0 for invalid */
|
||||
/**
|
||||
* @ingroup sys_sem
|
||||
* Check if a semaphore is valid/allocated: return 1 for valid, 0 for invalid
|
||||
*/
|
||||
int sys_sem_valid(sys_sem_t *sem);
|
||||
#endif
|
||||
#ifndef sys_sem_set_invalid
|
||||
/** Set a semaphore invalid so that sys_sem_valid returns 0 */
|
||||
/**
|
||||
* @ingroup sys_sem
|
||||
* Set a semaphore invalid so that sys_sem_valid returns 0
|
||||
*/
|
||||
void sys_sem_set_invalid(sys_sem_t *sem);
|
||||
#endif
|
||||
#ifndef sys_sem_valid_val
|
||||
/** Same as sys_sem_valid() but taking a value, not a pointer */
|
||||
/**
|
||||
* Same as sys_sem_valid() but taking a value, not a pointer
|
||||
*/
|
||||
#define sys_sem_valid_val(sem) sys_sem_valid(&(sem))
|
||||
#endif
|
||||
#ifndef sys_sem_set_invalid_val
|
||||
/** Same as sys_sem_set_invalid() but taking a value, not a pointer */
|
||||
/**
|
||||
* Same as sys_sem_set_invalid() but taking a value, not a pointer
|
||||
*/
|
||||
#define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem))
|
||||
#endif
|
||||
|
||||
/* Time functions. */
|
||||
#ifndef sys_msleep
|
||||
/**
|
||||
* @ingroup sys_misc
|
||||
* Sleep for specified number of ms
|
||||
*/
|
||||
void sys_msleep(u32_t ms); /* only has a (close to) 1 ms resolution. */
|
||||
#endif
|
||||
|
||||
/* Mailbox functions. */
|
||||
|
||||
/** Create a new mbox of specified size
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Create a new mbox of specified size
|
||||
* @param mbox pointer to the mbox to create
|
||||
* @param size (minimum) number of messages in this mbox
|
||||
* @return ERR_OK if successful, another err_t otherwise */
|
||||
* @return ERR_OK if successful, another err_t otherwise
|
||||
*/
|
||||
err_t sys_mbox_new(sys_mbox_t *mbox, int size);
|
||||
/** Post a message to an mbox - may not fail
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Post a message to an mbox - may not fail
|
||||
* -> blocks if full, only used from tasks not from ISR
|
||||
* @param mbox mbox to posts the message
|
||||
* @param msg message to post (ATTENTION: can be NULL) */
|
||||
* @param msg message to post (ATTENTION: can be NULL)
|
||||
*/
|
||||
void sys_mbox_post(sys_mbox_t *mbox, void *msg);
|
||||
/** Try to post a message to an mbox - may fail if full or ISR
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Try to post a message to an mbox - may fail if full or ISR
|
||||
* @param mbox mbox to posts the message
|
||||
* @param msg message to post (ATTENTION: can be NULL) */
|
||||
* @param msg message to post (ATTENTION: can be NULL)
|
||||
*/
|
||||
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg);
|
||||
/** Wait for a new message to arrive in the mbox
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Wait for a new message to arrive in the mbox
|
||||
* @param mbox mbox to get a message from
|
||||
* @param msg pointer where the message is stored
|
||||
* @param timeout maximum time (in milliseconds) to wait for a message (0 = wait forever)
|
||||
* @return time (in milliseconds) waited for a message, may be 0 if not waited
|
||||
or SYS_ARCH_TIMEOUT on timeout
|
||||
* The returned time has to be accurate to prevent timer jitter! */
|
||||
* The returned time has to be accurate to prevent timer jitter!
|
||||
*/
|
||||
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout);
|
||||
/* Allow port to override with a macro, e.g. special timeout for sys_arch_mbox_fetch() */
|
||||
#ifndef sys_arch_mbox_tryfetch
|
||||
/** Wait for a new message to arrive in the mbox
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Wait for a new message to arrive in the mbox
|
||||
* @param mbox mbox to get a message from
|
||||
* @param msg pointer where the message is stored
|
||||
* @return 0 (milliseconds) if a message has been received
|
||||
* or SYS_MBOX_EMPTY if the mailbox is empty */
|
||||
* or SYS_MBOX_EMPTY if the mailbox is empty
|
||||
*/
|
||||
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg);
|
||||
#endif
|
||||
/** For now, we map straight to sys_arch implementation. */
|
||||
/**
|
||||
* For now, we map straight to sys_arch implementation.
|
||||
*/
|
||||
#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg)
|
||||
/** Delete an mbox
|
||||
* @param mbox mbox to delete */
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Delete an mbox
|
||||
* @param mbox mbox to delete
|
||||
*/
|
||||
void sys_mbox_free(sys_mbox_t *mbox);
|
||||
#define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0)
|
||||
#ifndef sys_mbox_valid
|
||||
/** Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid
|
||||
*/
|
||||
int sys_mbox_valid(sys_mbox_t *mbox);
|
||||
#endif
|
||||
#ifndef sys_mbox_set_invalid
|
||||
/** Set an mbox invalid so that sys_mbox_valid returns 0 */
|
||||
/**
|
||||
* @ingroup sys_mbox
|
||||
* Set an mbox invalid so that sys_mbox_valid returns 0
|
||||
*/
|
||||
void sys_mbox_set_invalid(sys_mbox_t *mbox);
|
||||
#endif
|
||||
#ifndef sys_mbox_valid_val
|
||||
/** Same as sys_mbox_valid() but taking a value, not a pointer */
|
||||
/**
|
||||
* Same as sys_mbox_valid() but taking a value, not a pointer
|
||||
*/
|
||||
#define sys_mbox_valid_val(mbox) sys_mbox_valid(&(mbox))
|
||||
#endif
|
||||
#ifndef sys_mbox_set_invalid_val
|
||||
/** Same as sys_mbox_set_invalid() but taking a value, not a pointer */
|
||||
/**
|
||||
* Same as sys_mbox_set_invalid() but taking a value, not a pointer
|
||||
*/
|
||||
#define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox))
|
||||
#endif
|
||||
|
||||
|
||||
/** The only thread function:
|
||||
/**
|
||||
* @ingroup sys_misc
|
||||
* The only thread function:
|
||||
* Creates a new thread
|
||||
* ATTENTION: although this function returns a value, it MUST NOT FAIL (ports have to assert this!)
|
||||
* @param name human-readable name for the thread (used for debugging purposes)
|
||||
@ -258,12 +344,17 @@ sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg,
|
||||
void sys_init(void);
|
||||
|
||||
#ifndef sys_jiffies
|
||||
/** Ticks/jiffies since power up. */
|
||||
/**
|
||||
* Ticks/jiffies since power up.
|
||||
*/
|
||||
u32_t sys_jiffies(void);
|
||||
#endif
|
||||
|
||||
/** Returns the current time in milliseconds,
|
||||
* may be the same as sys_jiffies or at least based on it. */
|
||||
/**
|
||||
* @ingroup sys_time
|
||||
* Returns the current time in milliseconds,
|
||||
* may be the same as sys_jiffies or at least based on it.
|
||||
*/
|
||||
u32_t sys_now(void);
|
||||
|
||||
/* Critical Region Protection */
|
||||
@ -279,13 +370,17 @@ u32_t sys_now(void);
|
||||
*/
|
||||
#if SYS_LIGHTWEIGHT_PROT
|
||||
|
||||
/** SYS_ARCH_DECL_PROTECT
|
||||
/**
|
||||
* @ingroup sys_prot
|
||||
* SYS_ARCH_DECL_PROTECT
|
||||
* declare a protection variable. This macro will default to defining a variable of
|
||||
* type sys_prot_t. If a particular port needs a different implementation, then
|
||||
* this macro may be defined in sys_arch.h.
|
||||
*/
|
||||
#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
|
||||
/** SYS_ARCH_PROTECT
|
||||
/**
|
||||
* @ingroup sys_prot
|
||||
* SYS_ARCH_PROTECT
|
||||
* Perform a "fast" protect. This could be implemented by
|
||||
* disabling interrupts for an embedded system or by using a semaphore or
|
||||
* mutex. The implementation should allow calling SYS_ARCH_PROTECT when
|
||||
@ -295,7 +390,9 @@ u32_t sys_now(void);
|
||||
* different implementation, then this macro may be defined in sys_arch.h
|
||||
*/
|
||||
#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
|
||||
/** SYS_ARCH_UNPROTECT
|
||||
/**
|
||||
* @ingroup sys_prot
|
||||
* SYS_ARCH_UNPROTECT
|
||||
* Perform a "fast" set of the protection level to "lev". This could be
|
||||
* implemented by setting the interrupt level to "lev" within the MACRO or by
|
||||
* using a semaphore or mutex. This macro will default to calling the
|
||||
|
@ -1,3 +1,9 @@
|
||||
/**
|
||||
* @file
|
||||
* TCP API (to be used from TCPIP thread)\n
|
||||
* See also @ref tcp_raw
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -117,7 +123,7 @@ typedef void (*tcp_err_fn)(void *arg, err_t err);
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
|
||||
* @param tpcb The connection pcb which is connected
|
||||
* @param err An unused error code, always ERR_OK currently ;-) TODO!
|
||||
* @param err An unused error code, always ERR_OK currently ;-) @todo!
|
||||
* Only return ERR_ABRT if you have called tcp_abort from within the
|
||||
* callback function!
|
||||
*
|
||||
@ -129,15 +135,19 @@ typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err);
|
||||
#define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale))
|
||||
#define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale))
|
||||
#define TCPWND16(x) ((u16_t)LWIP_MIN((x), 0xFFFF))
|
||||
#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND(pcb) : TCPWND16(TCP_WND(pcb))))
|
||||
#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND)))
|
||||
typedef u32_t tcpwnd_size_t;
|
||||
typedef u16_t tcpflags_t;
|
||||
#else
|
||||
#define RCV_WND_SCALE(pcb, wnd) (wnd)
|
||||
#define SND_WND_SCALE(pcb, wnd) (wnd)
|
||||
#define TCPWND16(x) (x)
|
||||
#define TCP_WND_MAX(pcb) TCP_WND(pcb)
|
||||
#define TCP_WND_MAX(pcb) TCP_WND
|
||||
typedef u16_t tcpwnd_size_t;
|
||||
#endif
|
||||
|
||||
#if LWIP_WND_SCALE || TCP_LISTEN_BACKLOG || LWIP_TCP_TIMESTAMPS
|
||||
typedef u16_t tcpflags_t;
|
||||
#else
|
||||
typedef u8_t tcpflags_t;
|
||||
#endif
|
||||
|
||||
@ -155,34 +165,38 @@ enum tcp_state {
|
||||
TIME_WAIT = 10
|
||||
};
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
/* Function to call when a listener has been connected.
|
||||
* @param arg user-supplied argument (tcp_pcb.callback_arg)
|
||||
* @param pcb a new tcp_pcb that now is connected
|
||||
* @param err an error argument (TODO: that is current always ERR_OK?)
|
||||
* @return ERR_OK: accept the new connection,
|
||||
* any other err_t aborts the new connection
|
||||
*/
|
||||
#define DEF_ACCEPT_CALLBACK tcp_accept_fn accept;
|
||||
#else /* LWIP_CALLBACK_API */
|
||||
#define DEF_ACCEPT_CALLBACK
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
/**
|
||||
* members common to struct tcp_pcb and struct tcp_listen_pcb
|
||||
*/
|
||||
#define TCP_PCB_COMMON(type) \
|
||||
type *next; /* for the linked list */ \
|
||||
void *callback_arg; \
|
||||
/* the accept callback for listen- and normal pcbs, if LWIP_CALLBACK_API */ \
|
||||
DEF_ACCEPT_CALLBACK \
|
||||
enum tcp_state state; /* TCP state */ \
|
||||
u8_t prio; \
|
||||
/* ports are in host byte order */ \
|
||||
u16_t local_port
|
||||
|
||||
|
||||
/* the TCP protocol control block */
|
||||
/** the TCP protocol control block for listening pcbs */
|
||||
struct tcp_pcb_listen {
|
||||
/** Common members of all PCB types */
|
||||
IP_PCB;
|
||||
/** Protocol specific PCB members */
|
||||
TCP_PCB_COMMON(struct tcp_pcb_listen);
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
/* Function to call when a listener has been connected. */
|
||||
tcp_accept_fn accept;
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
u8_t backlog;
|
||||
u8_t accepts_pending;
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
};
|
||||
|
||||
|
||||
/** the TCP protocol control block */
|
||||
struct tcp_pcb {
|
||||
/** common PCB members */
|
||||
IP_PCB;
|
||||
@ -196,13 +210,19 @@ struct tcp_pcb {
|
||||
#define TF_ACK_DELAY 0x01U /* Delayed ACK. */
|
||||
#define TF_ACK_NOW 0x02U /* Immediate ACK. */
|
||||
#define TF_INFR 0x04U /* In fast recovery. */
|
||||
#define TF_TIMESTAMP 0x08U /* Timestamp option enabled */
|
||||
#define TF_CLOSEPEND 0x08U /* If this is set, tcp_close failed to enqueue the FIN (retried in tcp_tmr) */
|
||||
#define TF_RXCLOSED 0x10U /* rx closed by tcp_shutdown */
|
||||
#define TF_FIN 0x20U /* Connection was closed locally (FIN segment enqueued). */
|
||||
#define TF_NODELAY 0x40U /* Disable Nagle algorithm */
|
||||
#define TF_NAGLEMEMERR 0x80U /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */
|
||||
#if LWIP_WND_SCALE
|
||||
#define TF_WND_SCALE 0x0100U /* Window Scale option enabled */
|
||||
#endif
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
#define TF_BACKLOGPEND 0x0200U /* If this is set, a connection pcb has increased the backlog on its listener */
|
||||
#endif
|
||||
#if LWIP_TCP_TIMESTAMPS
|
||||
#define TF_TIMESTAMP 0x0400U /* Timestamp option enabled */
|
||||
#endif
|
||||
|
||||
/* the rest of the fields are in host byte order
|
||||
@ -236,11 +256,6 @@ struct tcp_pcb {
|
||||
u8_t dupacks;
|
||||
u32_t lastack; /* Highest acknowledged seqno. */
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
tcpwnd_size_t per_soc_tcp_wnd; /* per tcp socket tcp window size */
|
||||
tcpwnd_size_t per_soc_tcp_snd_buf; /* per tcp socket tcp send buffer size */
|
||||
#endif
|
||||
|
||||
/* congestion avoidance/control variables */
|
||||
tcpwnd_size_t cwnd;
|
||||
tcpwnd_size_t ssthresh;
|
||||
@ -253,8 +268,6 @@ struct tcp_pcb {
|
||||
tcpwnd_size_t snd_wnd; /* sender window */
|
||||
tcpwnd_size_t snd_wnd_max; /* the maximum sender window announced by the remote host */
|
||||
|
||||
tcpwnd_size_t acked;
|
||||
|
||||
tcpwnd_size_t snd_buf; /* Available buffer space for sending (in bytes). */
|
||||
#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3)
|
||||
u16_t snd_queuelen; /* Number of pbufs currently in the send buffer. */
|
||||
@ -273,6 +286,10 @@ struct tcp_pcb {
|
||||
|
||||
struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */
|
||||
|
||||
#if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG
|
||||
struct tcp_pcb_listen* listener;
|
||||
#endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
/* Function to be called when more send buffer space is available. */
|
||||
tcp_sent_fn sent;
|
||||
@ -333,18 +350,6 @@ struct tcp_pcb {
|
||||
#define ESP_STATS_TCP_PCB(pcb)
|
||||
#endif
|
||||
|
||||
struct tcp_pcb_listen {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
/* Protocol specific PCB members */
|
||||
TCP_PCB_COMMON(struct tcp_pcb_listen);
|
||||
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
u8_t backlog;
|
||||
u8_t accepts_pending;
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
};
|
||||
|
||||
#if LWIP_EVENT_API
|
||||
|
||||
enum lwip_event {
|
||||
@ -369,30 +374,40 @@ struct tcp_pcb * tcp_new (void);
|
||||
struct tcp_pcb * tcp_new_ip_type (u8_t type);
|
||||
|
||||
void tcp_arg (struct tcp_pcb *pcb, void *arg);
|
||||
void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept);
|
||||
#if LWIP_CALLBACK_API
|
||||
void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv);
|
||||
void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent);
|
||||
void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval);
|
||||
void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err);
|
||||
void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept);
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval);
|
||||
|
||||
#if LWIP_TCP_TIMESTAMPS
|
||||
#define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss)
|
||||
#else /* LWIP_TCP_TIMESTAMPS */
|
||||
#define tcp_mss(pcb) ((pcb)->mss)
|
||||
#endif /* LWIP_TCP_TIMESTAMPS */
|
||||
#define tcp_sndbuf(pcb) (TCPWND16((pcb)->snd_buf))
|
||||
#define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen)
|
||||
/** @ingroup tcp_raw */
|
||||
#define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY)
|
||||
/** @ingroup tcp_raw */
|
||||
#define tcp_nagle_enable(pcb) ((pcb)->flags = (tcpflags_t)((pcb)->flags & ~TF_NODELAY))
|
||||
/** @ingroup tcp_raw */
|
||||
#define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0)
|
||||
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
#define tcp_accepted(pcb) do { \
|
||||
LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", pcb->state == LISTEN); \
|
||||
(((struct tcp_pcb_listen *)(pcb))->accepts_pending--); } while(0)
|
||||
#define tcp_backlog_set(pcb, new_backlog) do { \
|
||||
LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", (pcb)->state == LISTEN); \
|
||||
((struct tcp_pcb_listen *)(pcb))->backlog = ((new_backlog) ? (new_backlog) : 1); } while(0)
|
||||
void tcp_backlog_delayed(struct tcp_pcb* pcb);
|
||||
void tcp_backlog_accepted(struct tcp_pcb* pcb);
|
||||
#else /* TCP_LISTEN_BACKLOG */
|
||||
#define tcp_accepted(pcb) LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", \
|
||||
(pcb)->state == LISTEN)
|
||||
#define tcp_backlog_set(pcb, new_backlog)
|
||||
#define tcp_backlog_delayed(pcb)
|
||||
#define tcp_backlog_accepted(pcb)
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
#define tcp_accepted(pcb) /* compatibility define, not needed any more */
|
||||
|
||||
void tcp_recved (struct tcp_pcb *pcb, u16_t len);
|
||||
err_t tcp_bind (struct tcp_pcb *pcb, const ip_addr_t *ipaddr,
|
||||
@ -400,7 +415,9 @@ err_t tcp_bind (struct tcp_pcb *pcb, const ip_addr_t *ipaddr,
|
||||
err_t tcp_connect (struct tcp_pcb *pcb, const ip_addr_t *ipaddr,
|
||||
u16_t port, tcp_connected_fn connected);
|
||||
|
||||
struct tcp_pcb * tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err);
|
||||
struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog);
|
||||
/** @ingroup tcp_raw */
|
||||
#define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG)
|
||||
|
||||
void tcp_abort (struct tcp_pcb *pcb);
|
||||
@ -428,10 +445,6 @@ const char* tcp_debug_state_str(enum tcp_state s);
|
||||
/* for compatibility with older implementation */
|
||||
#define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6)
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define PER_SOC_WND(pcb) (pcb->per_soc_wnd)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Functions to sync with TCPIP thread
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -37,13 +42,25 @@
|
||||
#if !NO_SYS /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/timers.h"
|
||||
#include "lwip/timeouts.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
/** The global semaphore to lock the stack. */
|
||||
extern sys_mutex_t lock_tcpip_core;
|
||||
/** Lock lwIP core mutex (needs @ref LWIP_TCPIP_CORE_LOCKING 1) */
|
||||
#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
|
||||
/** Unlock lwIP core mutex (needs @ref LWIP_TCPIP_CORE_LOCKING 1) */
|
||||
#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#define LOCK_TCPIP_CORE()
|
||||
#define UNLOCK_TCPIP_CORE()
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
struct pbuf;
|
||||
struct netif;
|
||||
|
||||
@ -61,6 +78,10 @@ err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn);
|
||||
err_t tcpip_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
|
||||
/**
|
||||
* @ingroup lwip_os
|
||||
* @see tcpip_callback_with_block
|
||||
*/
|
||||
#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
|
||||
|
||||
struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx);
|
||||
@ -71,10 +92,10 @@ err_t tcpip_trycallback(struct tcpip_callback_msg* msg);
|
||||
err_t pbuf_free_callback(struct pbuf *p);
|
||||
err_t mem_free_callback(void *m);
|
||||
|
||||
#if LWIP_TCPIP_TIMEOUT
|
||||
#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
|
||||
err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
|
||||
err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
|
||||
#endif /* LWIP_TCPIP_TIMEOUT */
|
||||
#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file
|
||||
* Timer implementations
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -30,16 +35,10 @@
|
||||
* Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_TIMERS_H
|
||||
#define LWIP_HDR_TIMERS_H
|
||||
#ifndef LWIP_HDR_TIMEOUTS_H
|
||||
#define LWIP_HDR_TIMEOUTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */
|
||||
#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS))
|
||||
|
||||
#if LWIP_TIMERS
|
||||
|
||||
#include "lwip/err.h"
|
||||
#if !NO_SYS
|
||||
#include "lwip/sys.h"
|
||||
@ -57,6 +56,26 @@ extern "C" {
|
||||
#endif /* LWIP_DEBUG*/
|
||||
#endif
|
||||
|
||||
/** Function prototype for a stack-internal timer function that has to be
|
||||
* called at a defined interval */
|
||||
typedef void (* lwip_cyclic_timer_handler)(void);
|
||||
|
||||
/** This struct contains information about a stack-internal timer function
|
||||
that has to be called at a defined interval */
|
||||
struct lwip_cyclic_timer {
|
||||
u32_t interval_ms;
|
||||
lwip_cyclic_timer_handler handler;
|
||||
#if LWIP_DEBUG_TIMERNAMES
|
||||
const char* handler_name;
|
||||
#endif /* LWIP_DEBUG_TIMERNAMES */
|
||||
};
|
||||
|
||||
/** This array contains all stack-internal cyclic timers. To get the number of
|
||||
* timers, use LWIP_ARRAYSIZE() */
|
||||
extern const struct lwip_cyclic_timer lwip_cyclic_timers[];
|
||||
|
||||
#if LWIP_TIMERS
|
||||
|
||||
/** Function prototype for a timeout callback function. Register such a function
|
||||
* using sys_timeout().
|
||||
*
|
||||
@ -84,18 +103,19 @@ void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg);
|
||||
#endif /* LWIP_DEBUG_TIMERNAMES */
|
||||
|
||||
void sys_untimeout(sys_timeout_handler handler, void *arg);
|
||||
void sys_restart_timeouts(void);
|
||||
#if NO_SYS
|
||||
void sys_check_timeouts(void);
|
||||
void sys_restart_timeouts(void);
|
||||
u32_t sys_timeouts_sleeptime(void);
|
||||
#else /* NO_SYS */
|
||||
void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg);
|
||||
#endif /* NO_SYS */
|
||||
|
||||
|
||||
#endif /* LWIP_TIMERS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_TIMERS */
|
||||
#endif /* LWIP_HDR_TIMERS_H */
|
||||
#endif /* LWIP_HDR_TIMEOUTS_H */
|
@ -1,3 +1,9 @@
|
||||
/**
|
||||
* @file
|
||||
* UDP API (to be used from TCPIP thread)\n
|
||||
* See also @ref udp_raw
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
@ -41,29 +47,12 @@
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/prot/udp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UDP_HLEN 8
|
||||
|
||||
/* Fields are (of course) in network byte order. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct udp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t src);
|
||||
PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */
|
||||
PACK_STRUCT_FIELD(u16_t len);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define UDP_FLAGS_NOCHKSUM 0x01U
|
||||
#define UDP_FLAGS_UDPLITE 0x02U
|
||||
#define UDP_FLAGS_CONNECTED 0x04U
|
||||
@ -88,8 +77,9 @@ struct udp_pcb;
|
||||
typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *addr, u16_t port);
|
||||
|
||||
/** the UDP protocol control block */
|
||||
struct udp_pcb {
|
||||
/* Common members of all PCB types */
|
||||
/** Common members of all PCB types */
|
||||
IP_PCB;
|
||||
|
||||
/* Protocol specific PCB members */
|
||||
@ -174,10 +164,12 @@ void udp_init (void);
|
||||
#define udp_set_multicast_ttl(pcb, value) do { (pcb)->mcast_ttl = value; } while(0)
|
||||
#define udp_get_multicast_ttl(pcb) ((pcb)->mcast_ttl)
|
||||
|
||||
#if ESP_LWIP
|
||||
#if LWIP_IPV6_MLD
|
||||
#define udp_set_multicast_netif_ip6addr(pcb, ip6addr) ip_addr_copy_from_ip6((pcb)->multicast_ip, *(ip6addr))
|
||||
#define udp_get_multicast_netif_ip6addr(pcb) ip_2_ip6(&(pcb)->multicast_ip)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
@ -187,9 +179,7 @@ void udp_debug_print(struct udp_hdr *udphdr);
|
||||
#define udp_debug_print(udphdr)
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV4
|
||||
void udp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* new_addr);
|
||||
#endif /* LWIP_IPV4 */
|
||||
void udp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include "esp_system.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "netif/dhcp_state.h"
|
||||
|
||||
/* Enable all Espressif-only options */
|
||||
|
||||
/*
|
||||
@ -220,6 +222,19 @@
|
||||
*/
|
||||
#define DHCP_DOES_ARP_CHECK CONFIG_LWIP_DHCP_DOES_ARP_CHECK
|
||||
|
||||
|
||||
/**
|
||||
* CONFIG_LWIP_DHCP_RESTORE_LAST_IP==1: Last valid IP address obtained from DHCP server
|
||||
* is restored after reset/power-up.
|
||||
*/
|
||||
#if CONFIG_LWIP_DHCP_RESTORE_LAST_IP
|
||||
|
||||
#define LWIP_DHCP_IP_ADDR_RESTORE() dhcp_ip_addr_restore(netif)
|
||||
#define LWIP_DHCP_IP_ADDR_STORE() dhcp_ip_addr_store(netif)
|
||||
#define LWIP_DHCP_IP_ADDR_ERASE() dhcp_ip_addr_erase(esp_netif[tcpip_if])
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- AUTOIP options ----------
|
||||
@ -626,7 +641,6 @@
|
||||
---------------------------------------
|
||||
*/
|
||||
#define LWIP_HOOK_IP4_ROUTE_SRC ip4_route_src_hook
|
||||
|
||||
/*
|
||||
---------------------------------------
|
||||
---------- Debugging options ----------
|
||||
@ -720,7 +734,7 @@
|
||||
|
||||
#define ESP_LWIP 1
|
||||
#define ESP_LWIP_ARP 1
|
||||
#define ESP_PER_SOC_TCP_WND 1
|
||||
#define ESP_PER_SOC_TCP_WND 0
|
||||
#define ESP_THREAD_SAFE 1
|
||||
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
|
||||
#define ESP_DHCP 1
|
||||
@ -735,9 +749,12 @@
|
||||
#define ESP_STATS_DROP CONFIG_LWIP_STATS
|
||||
#define ESP_STATS_TCP 0
|
||||
#define ESP_DHCP_TIMER 1
|
||||
#define ESP_DHCPS_TIMER 1
|
||||
#define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__)
|
||||
#define ESP_PING 1
|
||||
#define ESP_HAS_SELECT 1
|
||||
#define ESP_AUTO_RECV 1
|
||||
#define ESP_GRATUITOUS_ARP CONFIG_ESP_GRATUITOUS_ARP
|
||||
|
||||
#if CONFIG_LWIP_IRAM_OPTIMIZATION
|
||||
#define ESP_IRAM_ATTR IRAM_ATTR
|
||||
@ -745,9 +762,6 @@
|
||||
#define ESP_IRAM_ATTR
|
||||
#endif
|
||||
|
||||
#define TCP_WND_DEFAULT CONFIG_TCP_WND_DEFAULT
|
||||
#define TCP_SND_BUF_DEFAULT CONFIG_TCP_SND_BUF_DEFAULT
|
||||
|
||||
#if ESP_PERF
|
||||
#define DBG_PERF_PATH_SET(dir, point)
|
||||
#define DBG_PERF_FILTER_LEN 1000
|
||||
@ -772,9 +786,18 @@ enum {
|
||||
#define DBG_PERF_FILTER_LEN 1000
|
||||
#endif
|
||||
|
||||
#define TCP_SND_BUF CONFIG_TCP_SND_BUF_DEFAULT
|
||||
#define TCP_WND CONFIG_TCP_WND_DEFAULT
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND_DEFAULT CONFIG_TCP_WND_DEFAULT
|
||||
#define TCP_SND_BUF_DEFAULT CONFIG_TCP_SND_BUF_DEFAULT
|
||||
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
|
||||
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
|
||||
#define TCP_SND_QUEUELEN(pcb) ((4 * (TCP_SND_BUF((pcb))) + (TCP_MSS - 1))/(TCP_MSS))
|
||||
#define TCP_SNDLOWAT(pcb) LWIP_MIN(LWIP_MAX(((TCP_SND_BUF((pcb)))/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF((pcb))) - 1)
|
||||
#define TCP_SNDQUEUELOWAT(pcb) LWIP_MAX(((TCP_SND_QUEUELEN((pcb)))/2), 5)
|
||||
#define TCP_WND_UPDATE_THRESHOLD(pcb) LWIP_MIN((TCP_WND((pcb)) / 4), (TCP_MSS * 4))
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -31,3 +31,10 @@
|
||||
*/
|
||||
|
||||
#include "lwip/netdb.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
int getnameinfo(const struct sockaddr *addr, socklen_t addrlen,
|
||||
char *host, socklen_t hostlen,
|
||||
char *serv, socklen_t servlen, int flags);
|
||||
|
||||
#endif
|
||||
|
33
tools/sdk/include/lwip/netif/dhcp_state.h
Normal file
33
tools/sdk/include/lwip/netif/dhcp_state.h
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2018 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 _DHCP_STATE_H_
|
||||
#define _DHCP_STATE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool dhcp_ip_addr_restore(void *netif);
|
||||
|
||||
void dhcp_ip_addr_store(void *netif);
|
||||
|
||||
void dhcp_ip_addr_erase(void *netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DHCP_STATE_H_ */
|
@ -1,147 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_NETIF_ETHARP_H
|
||||
#define LWIP_HDR_NETIF_ETHARP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip4.h"
|
||||
/* ARP has been moved to core/ipv4, provide this #include for compatibility only */
|
||||
#include "lwip/etharp.h"
|
||||
#include "netif/ethernet.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef ETHARP_HWADDR_LEN
|
||||
#define ETHARP_HWADDR_LEN ETH_HWADDR_LEN
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** the ARP message, see RFC 826 ("Packet format") */
|
||||
struct etharp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t hwtype);
|
||||
PACK_STRUCT_FIELD(u16_t proto);
|
||||
PACK_STRUCT_FLD_8(u8_t hwlen);
|
||||
PACK_STRUCT_FLD_8(u8_t protolen);
|
||||
PACK_STRUCT_FIELD(u16_t opcode);
|
||||
PACK_STRUCT_FLD_S(struct eth_addr shwaddr);
|
||||
PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr);
|
||||
PACK_STRUCT_FLD_S(struct eth_addr dhwaddr);
|
||||
PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define SIZEOF_ETHARP_HDR 28
|
||||
|
||||
#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
|
||||
#if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET)
|
||||
#define SIZEOF_ETHARP_PACKET_TX (SIZEOF_ETHARP_PACKET + SIZEOF_VLAN_HDR)
|
||||
#else /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */
|
||||
#define SIZEOF_ETHARP_PACKET_TX SIZEOF_ETHARP_PACKET
|
||||
#endif /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */
|
||||
|
||||
/** 1 seconds period */
|
||||
#define ARP_TMR_INTERVAL 1000
|
||||
|
||||
/** ARP message types (opcodes) */
|
||||
#define ARP_REQUEST 1
|
||||
#define ARP_REPLY 2
|
||||
|
||||
#if ARP_QUEUEING
|
||||
/** struct for queueing outgoing packets for unknown address
|
||||
* defined here to be accessed by memp.h
|
||||
*/
|
||||
struct etharp_q_entry {
|
||||
struct etharp_q_entry *next;
|
||||
struct pbuf *p;
|
||||
};
|
||||
#endif /* ARP_QUEUEING */
|
||||
|
||||
#define etharp_init() /* Compatibility define, no init needed. */
|
||||
void etharp_tmr(void);
|
||||
s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
||||
struct eth_addr **eth_ret, const ip4_addr_t **ip_ret);
|
||||
u8_t etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_addr **eth_ret);
|
||||
err_t etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
|
||||
err_t etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q);
|
||||
err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr);
|
||||
/** For Ethernet network interfaces, we might want to send "gratuitous ARP";
|
||||
* this is an ARP packet sent by a node in order to spontaneously cause other
|
||||
* nodes to update an entry in their ARP cache.
|
||||
* From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
|
||||
#define etharp_gratuitous(netif) etharp_request((netif), netif_ip4_addr(netif))
|
||||
void etharp_cleanup_netif(struct netif *netif);
|
||||
|
||||
#if ETHARP_SUPPORT_STATIC_ENTRIES
|
||||
err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr);
|
||||
err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr);
|
||||
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
|
||||
|
||||
#if LWIP_AUTOIP
|
||||
err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
|
||||
const struct eth_addr *ethdst_addr,
|
||||
const struct eth_addr *hwsrc_addr, const ip4_addr_t *ipsrc_addr,
|
||||
const struct eth_addr *hwdst_addr, const ip4_addr_t *ipdst_addr,
|
||||
const u16_t opcode);
|
||||
#endif /* LWIP_AUTOIP */
|
||||
|
||||
#endif /* LWIP_IPV4 && LWIP_ARP */
|
||||
|
||||
void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p);
|
||||
|
||||
#if ETHARP_TRUST_IP_MAC
|
||||
void etharp_ip_input(struct netif *netif, struct pbuf *p);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_ARP || LWIP_ETHERNET */
|
||||
|
||||
#endif /* LWIP_HDR_NETIF_ETHARP_H */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user