mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-03 00:21:44 +01:00
Feature/sync lwip as submodule
This commit is contained in:
committed by
Jiang Jiang Jian
parent
de0e9a1e05
commit
3578fe39e0
106
components/lwip/include/apps/ping/esp_ping.h
Normal file
106
components/lwip/include/apps/ping/esp_ping.h
Normal file
@@ -0,0 +1,106 @@
|
||||
// Copyright 2015-2016 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 ESP_PING_H_
|
||||
#define ESP_PING_H_
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_ERR_PING_BASE 0x6000
|
||||
|
||||
#define ESP_ERR_PING_INVALID_PARAMS ESP_ERR_PING_BASE + 0x01
|
||||
#define ESP_ERR_PING_NO_MEM ESP_ERR_PING_BASE + 0x02
|
||||
|
||||
#define ESP_PING_CHECK_OPTLEN(optlen, opttype) do { if ((optlen) < sizeof(opttype)) { return ESP_ERR_PING_INVALID_PARAMS; }}while(0)
|
||||
|
||||
typedef struct _ping_found {
|
||||
uint32_t resp_time;
|
||||
uint32_t timeout_count;
|
||||
uint32_t send_count;
|
||||
uint32_t recv_count;
|
||||
uint32_t err_count;
|
||||
uint32_t bytes;
|
||||
uint32_t total_bytes;
|
||||
uint32_t total_time;
|
||||
uint32_t min_time;
|
||||
uint32_t max_time;
|
||||
int8_t ping_err;
|
||||
} esp_ping_found;
|
||||
|
||||
typedef enum {
|
||||
PING_TARGET_IP_ADDRESS = 50, /**< target IP address */
|
||||
PING_TARGET_IP_ADDRESS_COUNT = 51, /**< target IP address total counter */
|
||||
PING_TARGET_RCV_TIMEO = 52, /**< receive timeout in milliseconds */
|
||||
PING_TARGET_DELAY_TIME = 53, /**< delay time in milliseconds */
|
||||
PING_TARGET_ID = 54, /**< identifier */
|
||||
PING_TARGET_RES_FN = 55, /**< ping result callback function */
|
||||
PING_TARGET_RES_RESET = 56 /**< ping result statistic reset */
|
||||
} ping_target_id_t;
|
||||
|
||||
typedef enum {
|
||||
PING_RES_TIMEOUT = 0,
|
||||
PING_RES_OK = 1,
|
||||
PING_RES_FINISH = 2,
|
||||
} ping_res_t;
|
||||
|
||||
typedef void (* esp_ping_found_fn)(ping_target_id_t found_id, esp_ping_found *found_val);
|
||||
|
||||
/**
|
||||
* @brief Set PING function option
|
||||
*
|
||||
* @param[in] opt_id: option index, 50 for IP, 51 for COUNT, 52 for RCV TIMEOUT, 53 for DELAY TIME, 54 for ID
|
||||
* @param[in] opt_val: option parameter
|
||||
* @param[in] opt_len: option length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_PING_INVALID_PARAMS
|
||||
*/
|
||||
esp_err_t esp_ping_set_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len);
|
||||
|
||||
/**
|
||||
* @brief Get PING function option
|
||||
*
|
||||
* @param[in] opt_id: option index, 50 for IP, 51 for COUNT, 52 for RCV TIMEOUT, 53 for DELAY TIME, 54 for ID
|
||||
* @param[in] opt_val: option parameter
|
||||
* @param[in] opt_len: option length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_PING_INVALID_PARAMS
|
||||
*/
|
||||
esp_err_t esp_ping_get_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len);
|
||||
|
||||
/**
|
||||
* @brief Get PING function result action
|
||||
*
|
||||
* @param[in] res_val: ping function action, 1 for successful, 0 for fail.
|
||||
* res_len: response bytes
|
||||
* res_time: response time
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_PING_INVALID_PARAMS
|
||||
*/
|
||||
esp_err_t esp_ping_result(uint8_t res_val, uint16_t res_len, uint32_t res_time);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ESP_PING_H_ */
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* @file
|
||||
* This file is a posix wrapper for lwip/netdb.h.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
@@ -30,11 +28,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#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);
|
||||
#ifndef LWIP_PING_H
|
||||
#define LWIP_PING_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used
|
||||
*/
|
||||
#ifndef PING_USE_SOCKETS
|
||||
#define PING_USE_SOCKETS LWIP_SOCKET
|
||||
#endif
|
||||
|
||||
|
||||
int ping_init(void);
|
||||
|
||||
#ifdef ESP_PING
|
||||
void ping_deinit(void);
|
||||
#endif
|
||||
|
||||
#if !PING_USE_SOCKETS
|
||||
void ping_send_now(void);
|
||||
#endif /* !PING_USE_SOCKETS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_PING_H */
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Frédéric Bernon, 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: Frédéric Bernon, Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNTP_H
|
||||
#define LWIP_HDR_APPS_SNTP_H
|
||||
|
||||
#include "apps/sntp/sntp_opts.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* SNTP operating modes: default is to poll using unicast.
|
||||
The mode has to be set before calling sntp_init(). */
|
||||
#define SNTP_OPMODE_POLL 0
|
||||
#define SNTP_OPMODE_LISTENONLY 1
|
||||
void sntp_setoperatingmode(u8_t operating_mode);
|
||||
u8_t sntp_getoperatingmode(void);
|
||||
|
||||
void sntp_init(void);
|
||||
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);
|
||||
|
||||
#if SNTP_SERVER_DNS
|
||||
void sntp_setservername(u8_t idx, char *server);
|
||||
char *sntp_getservername(u8_t idx);
|
||||
#endif /* SNTP_SERVER_DNS */
|
||||
|
||||
#if SNTP_GET_SERVERS_FROM_DHCP
|
||||
void sntp_servermode_dhcp(int set_servers_from_dhcp);
|
||||
#else /* SNTP_GET_SERVERS_FROM_DHCP */
|
||||
#define sntp_servermode_dhcp(x)
|
||||
#endif /* SNTP_GET_SERVERS_FROM_DHCP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNTP_H */
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2009 Frédéric Bernon, 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: Frédéric Bernon, Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_APPS_SNTP_OPTS_H
|
||||
#define LWIP_HDR_APPS_SNTP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/** 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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#define SNTP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** SNTP server port */
|
||||
#ifndef SNTP_PORT
|
||||
#define SNTP_PORT 123
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to allow config of SNTP server(s) by DNS name */
|
||||
#ifndef SNTP_SERVER_DNS
|
||||
#define SNTP_SERVER_DNS 0
|
||||
#endif
|
||||
|
||||
/** Sanity check:
|
||||
* Define this to
|
||||
* - 0 to turn off sanity checks (default; smaller code)
|
||||
* - >= 1 to check address and port of the response packet to ensure the
|
||||
* response comes from the server we sent the request to.
|
||||
* - >= 2 to check returned Originate Timestamp against Transmit Timestamp
|
||||
* sent to the server (to ensure response to older request).
|
||||
* - >= 3 @todo: discard reply if any of the LI, Stratum, or Transmit Timestamp
|
||||
* fields is 0 or the Mode field is not 4 (unicast) or 5 (broadcast).
|
||||
* - >= 4 @todo: to check that the Root Delay and Root Dispersion fields are each
|
||||
* greater than or equal to 0 and less than infinity, where infinity is
|
||||
* 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
|
||||
#define SNTP_CHECK_RESPONSE 0
|
||||
#endif
|
||||
|
||||
/** According to the RFC, this shall be a random delay
|
||||
* between 1 and 5 minutes (in milliseconds) to prevent load peaks.
|
||||
* This can be defined to a random generation function,
|
||||
* which must return the delay in milliseconds as u32_t.
|
||||
* Turned off by default.
|
||||
*/
|
||||
#ifndef SNTP_STARTUP_DELAY
|
||||
#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
|
||||
#define SNTP_STARTUP_DELAY_FUNC SNTP_STARTUP_DELAY
|
||||
#endif
|
||||
|
||||
/** SNTP receive timeout - in milliseconds
|
||||
* Also used as retry timeout - this shouldn't be too low.
|
||||
* Default is 3 seconds.
|
||||
*/
|
||||
#ifndef SNTP_RECV_TIMEOUT
|
||||
#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
|
||||
#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
|
||||
#define SNTP_GET_SYSTEM_TIME(sec, us) do { (sec) = 0; (us) = 0; } while(0)
|
||||
#endif
|
||||
|
||||
/** Default retry timeout (in milliseconds) if the response
|
||||
* received is invalid.
|
||||
* This is doubled with each retry until SNTP_RETRY_TIMEOUT_MAX is reached.
|
||||
*/
|
||||
#ifndef SNTP_RETRY_TIMEOUT
|
||||
#define SNTP_RETRY_TIMEOUT SNTP_RECV_TIMEOUT
|
||||
#endif
|
||||
|
||||
/** Maximum retry timeout (in milliseconds). */
|
||||
#ifndef SNTP_RETRY_TIMEOUT_MAX
|
||||
#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
|
||||
#define SNTP_RETRY_TIMEOUT_EXP 1
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_SNTP_OPTS_H */
|
||||
@@ -1,364 +0,0 @@
|
||||
/*
|
||||
* 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_API_H
|
||||
#define LWIP_HDR_API_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
|
||||
/* 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/netbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Throughout this file, IP addresses and port numbers are expected to be in
|
||||
* the same byte order as in the corresponding pcb.
|
||||
*/
|
||||
|
||||
/* Flags for netconn_write (u8_t) */
|
||||
#define NETCONN_NOFLAG 0x00
|
||||
#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */
|
||||
#define NETCONN_COPY 0x01
|
||||
#define NETCONN_MORE 0x02
|
||||
#define NETCONN_DONTBLOCK 0x04
|
||||
|
||||
/* Flags for struct netconn.flags (u8_t) */
|
||||
/** Should this netconn avoid blocking? */
|
||||
#define NETCONN_FLAG_NON_BLOCKING 0x02
|
||||
/** Was the last connect action a non-blocking one? */
|
||||
#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
|
||||
/** 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
|
||||
/** 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
|
||||
#if LWIP_IPV6
|
||||
/** If this flag is set then only IPv6 communication is allowed on the
|
||||
netconn. As per RFC#3493 this features defaults to OFF allowing
|
||||
dual-stack usage by default. */
|
||||
#define NETCONN_FLAG_IPV6_V6ONLY 0x20
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
|
||||
/* 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
|
||||
#define NETCONN_TYPE_IPV6 0x08
|
||||
#define NETCONNTYPE_ISIPV6(t) (((t)&NETCONN_TYPE_IPV6) != 0)
|
||||
#define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF3) == NETCONN_UDPLITE)
|
||||
#define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF3) == NETCONN_UDPNOCHKSUM)
|
||||
#else /* LWIP_IPV6 */
|
||||
#define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE)
|
||||
#define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM)
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/** Protocol family and type of the netconn */
|
||||
enum netconn_type {
|
||||
NETCONN_INVALID = 0,
|
||||
/* NETCONN_TCP Group */
|
||||
NETCONN_TCP = 0x10,
|
||||
#if LWIP_IPV6
|
||||
NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 /* 0x18 */,
|
||||
#endif /* LWIP_IPV6 */
|
||||
/* NETCONN_UDP Group */
|
||||
NETCONN_UDP = 0x20,
|
||||
NETCONN_UDPLITE = 0x21,
|
||||
NETCONN_UDPNOCHKSUM = 0x22,
|
||||
|
||||
#if LWIP_IPV6
|
||||
NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 /* 0x28 */,
|
||||
NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 /* 0x29 */,
|
||||
NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 /* 0x2a */,
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/* NETCONN_RAW Group */
|
||||
NETCONN_RAW = 0x40
|
||||
#if LWIP_IPV6
|
||||
, NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6 /* 0x48 */
|
||||
#endif /* LWIP_IPV6 */
|
||||
};
|
||||
|
||||
/** Current state of the netconn. Non-TCP netconns are always
|
||||
* in state NETCONN_NONE! */
|
||||
enum netconn_state {
|
||||
NETCONN_NONE,
|
||||
NETCONN_WRITE,
|
||||
NETCONN_LISTEN,
|
||||
NETCONN_CONNECT,
|
||||
NETCONN_CLOSE
|
||||
};
|
||||
|
||||
/** Use to inform the callback function about changes */
|
||||
enum netconn_evt {
|
||||
NETCONN_EVT_RCVPLUS,
|
||||
NETCONN_EVT_RCVMINUS,
|
||||
NETCONN_EVT_SENDPLUS,
|
||||
NETCONN_EVT_SENDMINUS,
|
||||
NETCONN_EVT_ERROR
|
||||
};
|
||||
|
||||
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
|
||||
/** Used for netconn_join_leave_group() */
|
||||
enum netconn_igmp {
|
||||
NETCONN_JOIN,
|
||||
NETCONN_LEAVE
|
||||
};
|
||||
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
|
||||
|
||||
#if LWIP_DNS
|
||||
/* Used for netconn_gethostbyname_addrtype(), these should match the DNS_ADDRTYPE defines in dns.h */
|
||||
#define NETCONN_DNS_DEFAULT NETCONN_DNS_IPV4_IPV6
|
||||
#define NETCONN_DNS_IPV4 0
|
||||
#define NETCONN_DNS_IPV6 1
|
||||
#define NETCONN_DNS_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */
|
||||
#define NETCONN_DNS_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
/* forward-declare some structs to avoid to include their headers */
|
||||
struct ip_pcb;
|
||||
struct tcp_pcb;
|
||||
struct udp_pcb;
|
||||
struct raw_pcb;
|
||||
struct netconn;
|
||||
struct api_msg_msg;
|
||||
|
||||
/** A callback prototype to inform about events for a netconn */
|
||||
typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
|
||||
|
||||
/** A netconn descriptor */
|
||||
struct netconn {
|
||||
/** type of the netconn (TCP, UDP or RAW) */
|
||||
enum netconn_type type;
|
||||
/** current state of the netconn */
|
||||
enum netconn_state state;
|
||||
/** the lwIP internal protocol control block */
|
||||
union {
|
||||
struct ip_pcb *ip;
|
||||
struct tcp_pcb *tcp;
|
||||
struct udp_pcb *udp;
|
||||
struct raw_pcb *raw;
|
||||
} 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;
|
||||
#if LWIP_TCP
|
||||
/** mbox where new connections are stored until processed
|
||||
by the application thread */
|
||||
sys_mbox_t acceptmbox;
|
||||
#endif /* LWIP_TCP */
|
||||
/** only used for socket layer */
|
||||
#if LWIP_SOCKET
|
||||
int socket;
|
||||
#endif /* LWIP_SOCKET */
|
||||
#if LWIP_SO_SNDTIMEO
|
||||
/** timeout to wait for sending data (which means enqueueing data for sending
|
||||
in internal buffers) in milliseconds */
|
||||
s32_t send_timeout;
|
||||
#endif /* LWIP_SO_RCVTIMEO */
|
||||
#if LWIP_SO_RCVTIMEO
|
||||
/** timeout in milliseconds to wait for new data to be received
|
||||
(or connections to arrive for listening netconns) */
|
||||
int recv_timeout;
|
||||
#endif /* LWIP_SO_RCVTIMEO */
|
||||
#if LWIP_SO_RCVBUF
|
||||
/** maximum amount of bytes queued in recvmbox
|
||||
not used for TCP: adjust TCP_WND instead! */
|
||||
int recv_bufsize;
|
||||
/** number of bytes currently in recvmbox to be received,
|
||||
tested against recv_bufsize to limit bytes on recvmbox
|
||||
for UDP and RAW, used for FIONREAD */
|
||||
int recv_avail;
|
||||
#endif /* LWIP_SO_RCVBUF */
|
||||
#if LWIP_SO_LINGER
|
||||
/** values <0 mean linger is disabled, values > 0 are seconds to linger */
|
||||
s16_t linger;
|
||||
#endif /* LWIP_SO_LINGER */
|
||||
/** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */
|
||||
u8_t flags;
|
||||
#if LWIP_TCP
|
||||
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
||||
this temporarily stores how much is already sent. */
|
||||
size_t write_offset;
|
||||
/** 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;
|
||||
#endif /* LWIP_TCP */
|
||||
/** A callback function that is informed about events for this netconn */
|
||||
netconn_callback callback;
|
||||
};
|
||||
|
||||
/** Register an Network connection event */
|
||||
#define API_EVENT(c,e,l) if (c->callback) { \
|
||||
(*c->callback)(c, e, l); \
|
||||
}
|
||||
|
||||
/** Set conn->last_err to err but don't overwrite fatal errors */
|
||||
#define NETCONN_SET_SAFE_ERR(conn, err) do { if ((conn) != NULL) { \
|
||||
SYS_ARCH_DECL_PROTECT(netconn_set_safe_err_lev); \
|
||||
SYS_ARCH_PROTECT(netconn_set_safe_err_lev); \
|
||||
if (!ERR_IS_FATAL((conn)->last_err)) { \
|
||||
(conn)->last_err = err; \
|
||||
} \
|
||||
SYS_ARCH_UNPROTECT(netconn_set_safe_err_lev); \
|
||||
}} while(0);
|
||||
|
||||
/* Network connection functions: */
|
||||
#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,
|
||||
netconn_callback callback);
|
||||
err_t netconn_delete(struct netconn *conn);
|
||||
/** Get the type of a netconn (as enum netconn_type). */
|
||||
#define netconn_type(conn) (conn->type)
|
||||
|
||||
err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr,
|
||||
u16_t *port, u8_t local);
|
||||
#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
|
||||
#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);
|
||||
#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);
|
||||
void netconn_recved(struct netconn *conn, u32_t length);
|
||||
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);
|
||||
#define netconn_write(conn, dataptr, size, apiflags) \
|
||||
netconn_write_partly(conn, dataptr, size, apiflags, NULL)
|
||||
err_t netconn_close(struct netconn *conn);
|
||||
err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx);
|
||||
|
||||
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
|
||||
err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr,
|
||||
const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave);
|
||||
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
|
||||
#if LWIP_DNS
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
err_t netconn_gethostbyname_addrtype(const char *name, ip_addr_t *addr, u8_t dns_addrtype);
|
||||
#define netconn_gethostbyname(name, addr) netconn_gethostbyname_addrtype(name, addr, NETCONN_DNS_DEFAULT)
|
||||
#else /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
|
||||
#define netconn_gethostbyname_addrtype(name, addr, dns_addrtype) netconn_gethostbyname(name, addr)
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
#define netconn_err(conn) ((conn)->last_err)
|
||||
#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
|
||||
|
||||
/** Set the blocking status of netconn calls (@todo: write/send is missing) */
|
||||
#define netconn_set_nonblocking(conn, val) do { if(val) { \
|
||||
(conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \
|
||||
} else { \
|
||||
(conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0)
|
||||
/** Get the blocking status of netconn calls (@todo: write/send is missing) */
|
||||
#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
|
||||
|
||||
/** 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; \
|
||||
} else { \
|
||||
(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)
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** 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) */
|
||||
#define netconn_get_ipv6only(conn) (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0)
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#if LWIP_SO_SNDTIMEO
|
||||
/** Set the send timeout in milliseconds */
|
||||
#define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout))
|
||||
/** Get the send timeout in milliseconds */
|
||||
#define netconn_get_sendtimeout(conn) ((conn)->send_timeout)
|
||||
#endif /* LWIP_SO_SNDTIMEO */
|
||||
#if LWIP_SO_RCVTIMEO
|
||||
/** Set the receive timeout in milliseconds */
|
||||
#define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout))
|
||||
/** Get the receive timeout in milliseconds */
|
||||
#define netconn_get_recvtimeout(conn) ((conn)->recv_timeout)
|
||||
#endif /* LWIP_SO_RCVTIMEO */
|
||||
#if LWIP_SO_RCVBUF
|
||||
/** Set the receive buffer in bytes */
|
||||
#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize))
|
||||
/** Get the receive buffer in bytes */
|
||||
#define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize)
|
||||
#endif /* LWIP_SO_RCVBUF*/
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
void netconn_thread_init(void);
|
||||
void netconn_thread_cleanup(void);
|
||||
#else /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
#define netconn_thread_init()
|
||||
#define netconn_thread_cleanup()
|
||||
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_NETCONN || LWIP_SOCKET */
|
||||
|
||||
#endif /* LWIP_HDR_API_H */
|
||||
@@ -1,238 +0,0 @@
|
||||
/*
|
||||
* 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_ARCH_H
|
||||
#define LWIP_HDR_ARCH_H
|
||||
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
#ifndef X8_F
|
||||
#define X8_F "02x"
|
||||
#endif /* X8_F */
|
||||
|
||||
/** 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#endif /* PACK_STRUCT_BEGIN */
|
||||
|
||||
#ifndef PACK_STRUCT_END
|
||||
#define PACK_STRUCT_END
|
||||
#endif /* PACK_STRUCT_END */
|
||||
|
||||
#ifndef PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#endif /* PACK_STRUCT_STRUCT */
|
||||
|
||||
#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 */
|
||||
#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 */
|
||||
#ifndef PACK_STRUCT_FLD_S
|
||||
#define PACK_STRUCT_FLD_S(x) PACK_STRUCT_FIELD(x)
|
||||
#endif /* PACK_STRUCT_FLD_S */
|
||||
|
||||
|
||||
#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
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_ARCH_H */
|
||||
@@ -1,124 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* AutoIP Automatic LinkLocal IP Configuration
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Please coordinate changes and requests with Dominik Spies
|
||||
* <kontakt@dspies.de>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_AUTOIP_H
|
||||
#define LWIP_HDR_AUTOIP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/netif.h"
|
||||
/* #include "lwip/udp.h" */
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* AutoIP Timing */
|
||||
#define AUTOIP_TMR_INTERVAL 100
|
||||
#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
|
||||
|
||||
/* 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) */
|
||||
#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) */
|
||||
#define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */
|
||||
|
||||
/* AutoIP client states */
|
||||
#define AUTOIP_STATE_OFF 0
|
||||
#define AUTOIP_STATE_PROBING 1
|
||||
#define AUTOIP_STATE_ANNOUNCING 2
|
||||
#define AUTOIP_STATE_BOUND 3
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
|
||||
#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);
|
||||
|
||||
/** check if AutoIP supplied netif->ip_addr */
|
||||
u8_t autoip_supplied_address(struct netif *netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV4 && LWIP_AUTOIP */
|
||||
|
||||
#endif /* LWIP_HDR_AUTOIP_H */
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* 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_DEBUG_H
|
||||
#define LWIP_HDR_DEBUG_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/** lower two bits indicate debug level
|
||||
* - 0 all
|
||||
* - 1 warning
|
||||
* - 2 serious
|
||||
* - 3 severe
|
||||
*/
|
||||
#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
|
||||
|
||||
/** 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
|
||||
|
||||
/** 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) */
|
||||
#define LWIP_DBG_STATE 0x20U
|
||||
/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
|
||||
#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.
|
||||
*/
|
||||
#ifndef LWIP_NOASSERT
|
||||
#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
|
||||
#else /* LWIP_NOASSERT */
|
||||
#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)
|
||||
#elif defined LWIP_DEBUG
|
||||
#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_DIAG((message))
|
||||
#else
|
||||
#define LWIP_PLATFORM_ERROR(message)
|
||||
#endif
|
||||
|
||||
#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
|
||||
LWIP_PLATFORM_ERROR(message); handler;}} while(0)
|
||||
#endif /* LWIP_ERROR */
|
||||
|
||||
#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) && \
|
||||
((debug) & LWIP_DBG_TYPES_ON) && \
|
||||
((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
|
||||
LWIP_PLATFORM_DIAG(message); \
|
||||
if ((debug) & LWIP_DBG_HALT) { \
|
||||
while(1); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#else /* LWIP_DEBUG */
|
||||
#define LWIP_DEBUGF(debug, message)
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
#endif /* LWIP_HDR_DEBUG_H */
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* 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_DEF_H
|
||||
#define LWIP_HDR_DEF_H
|
||||
|
||||
/* arch.h might define NULL already */
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_PERF
|
||||
#include "arch/perf.h"
|
||||
#else /* LWIP_PERF */
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
#endif /* LWIP_PERF */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y))
|
||||
#define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y))
|
||||
|
||||
/* Get the number of entries in an array ('x' must NOT be a pointer!) */
|
||||
#define LWIP_ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
#ifndef NULL
|
||||
#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)
|
||||
#define lwip_htonl(x) (x)
|
||||
#define lwip_ntohl(x) (x)
|
||||
#define PP_HTONS(x) (x)
|
||||
#define PP_NTOHS(x) (x)
|
||||
#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 */
|
||||
u16_t lwip_htons(u16_t x);
|
||||
u16_t lwip_ntohs(u16_t x);
|
||||
u32_t lwip_htonl(u32_t x);
|
||||
u32_t lwip_ntohl(u32_t x);
|
||||
#endif /* LWIP_PLATFORM_BYTESWAP */
|
||||
|
||||
/* 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_NTOHS(x) PP_HTONS(x)
|
||||
#define PP_HTONL(x) ((((x) & 0xff) << 24) | \
|
||||
(((x) & 0xff00) << 8) | \
|
||||
(((x) & 0xff0000UL) >> 8) | \
|
||||
(((x) & 0xff000000UL) >> 24))
|
||||
#define PP_NTOHL(x) PP_HTONL(x)
|
||||
|
||||
#endif /* BYTE_ORDER == BIG_ENDIAN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_DEF_H */
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
/*
|
||||
* 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_DHCP_H
|
||||
#define LWIP_HDR_DHCP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/udp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** period (in seconds) of the application calling dhcp_coarse_tmr() */
|
||||
#define DHCP_COARSE_TIMER_SECS 1
|
||||
/** 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_CHADDR_LEN 16U
|
||||
#define DHCP_SNAME_LEN 64U
|
||||
#define DHCP_FILE_LEN 128U
|
||||
|
||||
struct dhcp
|
||||
{
|
||||
/** transaction identifier of last sent request */
|
||||
u32_t xid;
|
||||
/** incoming msg */
|
||||
struct dhcp_msg *msg_in;
|
||||
/** track PCB allocation state */
|
||||
u8_t pcb_allocated;
|
||||
/** current DHCP state machine state */
|
||||
u8_t state;
|
||||
/** retries of current request */
|
||||
u8_t tries;
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
u8_t autoip_coop_state;
|
||||
#endif
|
||||
u8_t subnet_mask_given;
|
||||
|
||||
struct pbuf *p_out; /* pbuf of outcoming msg */
|
||||
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 */
|
||||
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;
|
||||
ip4_addr_t offered_gw_addr;
|
||||
|
||||
u32_t offered_t0_lease; /* lease period (in seconds) */
|
||||
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];
|
||||
#endif /* LWIP_DHCP_BOOTPFILE */
|
||||
|
||||
/* Espressif add start. */
|
||||
#ifdef ESP_LWIP
|
||||
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 */
|
||||
#endif
|
||||
/* 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)
|
||||
void dhcp_cleanup(struct netif *netif);
|
||||
/* Espressif add start. */
|
||||
/** set callback for DHCP */
|
||||
#ifdef ESP_LWIP
|
||||
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 */
|
||||
void dhcp_coarse_tmr(void);
|
||||
/** 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.
|
||||
* See LWIP_DHCP_MAX_NTP_SERVERS */
|
||||
extern void dhcp_set_ntp_servers(u8_t num_ntp_servers, const ip4_addr_t* ntp_server_addrs);
|
||||
#endif /* LWIP_DHCP_GET_NTP_SRV */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_DHCP */
|
||||
|
||||
#endif /*LWIP_HDR_DHCP_H*/
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* IPv6 address autoconfiguration as per RFC 4862.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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>
|
||||
*
|
||||
* IPv6 address autoconfiguration as per RFC 4862.
|
||||
*
|
||||
* Please coordinate changes and requests with Ivan Delamer
|
||||
* <delamer@inicotech.com>
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_IP6_DHCP6_H
|
||||
#define LWIP_HDR_IP6_DHCP6_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
|
||||
struct dhcp6
|
||||
{
|
||||
/*TODO: implement DHCP6*/
|
||||
};
|
||||
|
||||
#endif /* LWIP_IPV6_DHCP6 */
|
||||
|
||||
#endif /* LWIP_HDR_IP6_DHCP6_H */
|
||||
@@ -1,119 +0,0 @@
|
||||
/**
|
||||
* lwip DNS resolver header file.
|
||||
|
||||
* Author: Jim Pettinato
|
||||
* April 2007
|
||||
|
||||
* ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels.
|
||||
*
|
||||
* 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_DNS_H
|
||||
#define LWIP_HDR_DNS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if ESP_DNS
|
||||
#include "lwip/err.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if LWIP_DNS
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** DNS timer period */
|
||||
#define DNS_TMR_INTERVAL 1000
|
||||
|
||||
/* DNS resolve types: */
|
||||
#define LWIP_DNS_ADDRTYPE_IPV4 0
|
||||
#define LWIP_DNS_ADDRTYPE_IPV6 1
|
||||
#define LWIP_DNS_ADDRTYPE_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */
|
||||
#define LWIP_DNS_ADDRTYPE_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
#ifndef LWIP_DNS_ADDRTYPE_DEFAULT
|
||||
#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4_IPV6
|
||||
#endif
|
||||
#elif defined(LWIP_IPV4)
|
||||
#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4
|
||||
#else
|
||||
#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV6
|
||||
#endif
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST
|
||||
/** struct used for local host-list */
|
||||
struct local_hostlist_entry {
|
||||
/** static hostname */
|
||||
const char *name;
|
||||
/** static host address in network byteorder */
|
||||
ip_addr_t addr;
|
||||
struct local_hostlist_entry *next;
|
||||
};
|
||||
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
|
||||
#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH
|
||||
#endif
|
||||
#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
|
||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
#endif /* DNS_LOCAL_HOSTLIST */
|
||||
|
||||
/** 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.
|
||||
* @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname,
|
||||
* or NULL if the name could not be found (or on any other error).
|
||||
* @param callback_arg a user-specified callback argument passed to dns_gethostbyname
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST && 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 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
#endif /* LWIP_HDR_DNS_H */
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* 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_ERR_H
|
||||
#define LWIP_HDR_ERR_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** 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
|
||||
typedef LWIP_ERR_T err_t;
|
||||
#else /* LWIP_ERR_T */
|
||||
typedef s8_t err_t;
|
||||
#endif /* LWIP_ERR_T*/
|
||||
|
||||
/* Definitions for error constants. */
|
||||
|
||||
#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. */
|
||||
|
||||
|
||||
#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);
|
||||
#else
|
||||
#define lwip_strerr(x) ""
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_ERR_H */
|
||||
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Ethernet output for IPv6. Uses ND tables for link-layer addressing.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_ETHIP6_H
|
||||
#define LWIP_HDR_ETHIP6_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV6 && LWIP_ETHERNET /* 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"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6 && LWIP_ETHERNET */
|
||||
|
||||
#endif /* LWIP_HDR_ETHIP6_H */
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* 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_ICMP_H
|
||||
#define LWIP_HDR_ICMP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#if LWIP_IPV6 && LWIP_ICMP6
|
||||
#include "lwip/icmp6.h"
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
enum icmp_te_type {
|
||||
ICMP_TE_TTL = 0, /* time to live exceeded in transit */
|
||||
ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
|
||||
};
|
||||
|
||||
#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);
|
||||
void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
|
||||
void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
|
||||
|
||||
#endif /* LWIP_IPV4 && LWIP_ICMP */
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
#if LWIP_ICMP && LWIP_ICMP6
|
||||
#define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \
|
||||
icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \
|
||||
icmp_dest_unreach(pbuf, ICMP_DUR_PORT))
|
||||
#elif LWIP_ICMP
|
||||
#define icmp_port_unreach(isipv6, pbuf) do{ if(!(isipv6)) { icmp_dest_unreach(pbuf, ICMP_DUR_PORT);}}while(0)
|
||||
#elif LWIP_ICMP6
|
||||
#define icmp_port_unreach(isipv6, pbuf) do{ if(isipv6) { icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT);}}while(0)
|
||||
#else
|
||||
#define icmp_port_unreach(isipv6, pbuf)
|
||||
#endif
|
||||
#elif LWIP_IPV6 && LWIP_ICMP6
|
||||
#define icmp_port_unreach(isipv6, pbuf) icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT)
|
||||
#elif LWIP_IPV4 && LWIP_ICMP
|
||||
#define icmp_port_unreach(isipv6, pbuf) icmp_dest_unreach(pbuf, ICMP_DUR_PORT)
|
||||
#else /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) */
|
||||
#define icmp_port_unreach(isipv6, pbuf)
|
||||
#endif /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) LWIP_IPV4*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_ICMP_H */
|
||||
@@ -1,152 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* IPv6 version of ICMP, as per RFC 4443.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_ICMP6_H
|
||||
#define LWIP_HDR_ICMP6_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/netif.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);
|
||||
void icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c);
|
||||
void icmp6_packet_too_big(struct pbuf *p, u32_t mtu);
|
||||
void icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c);
|
||||
void icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, u32_t pointer);
|
||||
|
||||
#endif /* LWIP_ICMP6 && LWIP_IPV6 */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* LWIP_HDR_ICMP6_H */
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002 CITEL 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. Neither the name of CITEL Technologies Ltd 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 CITEL TECHNOLOGIES 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 CITEL TECHNOLOGIES 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 a contribution to the lwIP TCP/IP stack.
|
||||
* The Swedish Institute of Computer Science and Adam Dunkels
|
||||
* are specifically granted permission to redistribute this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_IGMP_H
|
||||
#define LWIP_HDR_IGMP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifdef __cplusplus
|
||||
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
|
||||
|
||||
|
||||
/**
|
||||
* igmp group structure - there is
|
||||
* a list of groups for each interface
|
||||
* these should really be linked from the interface, but
|
||||
* if we keep them separate we will not affect the lwip original code
|
||||
* too much
|
||||
*
|
||||
* There will be a group for the all systems group address but this
|
||||
* will not run the state machine as it is used to kick off reports
|
||||
* from all the other groups
|
||||
*/
|
||||
struct igmp_group {
|
||||
/** 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 */
|
||||
u8_t last_reporter_flag;
|
||||
/** current state of the group */
|
||||
u8_t group_state;
|
||||
/** timer for reporting, negative is OFF */
|
||||
u16_t timer;
|
||||
/** counter of simultaneous uses */
|
||||
u8_t use;
|
||||
};
|
||||
|
||||
/* Prototypes */
|
||||
void igmp_init(void);
|
||||
err_t igmp_start(struct netif *netif);
|
||||
err_t igmp_stop(struct netif *netif);
|
||||
void igmp_report_groups(struct netif *netif);
|
||||
struct igmp_group *igmp_lookfor_group(struct netif *ifp, const ip4_addr_t *addr);
|
||||
void igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest);
|
||||
err_t igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr);
|
||||
err_t igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV4 && LWIP_IGMP */
|
||||
|
||||
#endif /* LWIP_HDR_IGMP_H */
|
||||
@@ -1,172 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* This file (together with sockets.h) aims to provide structs and functions from
|
||||
* - arpa/inet.h
|
||||
* - netinet/in.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_INET_H
|
||||
#define LWIP_HDR_INET_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* If your port already typedef's in_addr_t, define IN_ADDR_T_DEFINED
|
||||
to prevent this code from redefining it. */
|
||||
#if !defined(in_addr_t) && !defined(IN_ADDR_T_DEFINED)
|
||||
typedef u32_t in_addr_t;
|
||||
#endif
|
||||
|
||||
struct in_addr {
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
|
||||
struct in6_addr {
|
||||
union {
|
||||
u32_t u32_addr[4];
|
||||
u8_t u8_addr[16];
|
||||
} un;
|
||||
#define s6_addr un.u8_addr
|
||||
};
|
||||
|
||||
/** 255.255.255.255 */
|
||||
#define INADDR_NONE IPADDR_NONE
|
||||
/** 127.0.0.1 */
|
||||
#define INADDR_LOOPBACK IPADDR_LOOPBACK
|
||||
/** 0.0.0.0 */
|
||||
#define INADDR_ANY IPADDR_ANY
|
||||
/** 255.255.255.255 */
|
||||
#define INADDR_BROADCAST IPADDR_BROADCAST
|
||||
|
||||
/** This macro can be used to initialize a variable of type struct in6_addr
|
||||
to the IPv6 wildcard address. */
|
||||
#define IN6ADDR_ANY_INIT {{{0,0,0,0}}}
|
||||
/** This macro can be used to initialize a variable of type struct in6_addr
|
||||
to the IPv6 loopback address. */
|
||||
#define IN6ADDR_LOOPBACK_INIT {{{0,0,0,PP_HTONL(1)}}}
|
||||
/** This variable is initialized by the system to contain the wildcard IPv6 address. */
|
||||
extern const struct in6_addr in6addr_any;
|
||||
|
||||
/* Definitions of the bits in an (IPv4) Internet address integer.
|
||||
|
||||
On subnets, host and network parts are found according to
|
||||
the subnet mask, not these masks. */
|
||||
#define IN_CLASSA(a) IP_CLASSA(a)
|
||||
#define IN_CLASSA_NET IP_CLASSA_NET
|
||||
#define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT
|
||||
#define IN_CLASSA_HOST IP_CLASSA_HOST
|
||||
#define IN_CLASSA_MAX IP_CLASSA_MAX
|
||||
|
||||
#define IN_CLASSB(b) IP_CLASSB(b)
|
||||
#define IN_CLASSB_NET IP_CLASSB_NET
|
||||
#define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT
|
||||
#define IN_CLASSB_HOST IP_CLASSB_HOST
|
||||
#define IN_CLASSB_MAX IP_CLASSB_MAX
|
||||
|
||||
#define IN_CLASSC(c) IP_CLASSC(c)
|
||||
#define IN_CLASSC_NET IP_CLASSC_NET
|
||||
#define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT
|
||||
#define IN_CLASSC_HOST IP_CLASSC_HOST
|
||||
#define IN_CLASSC_MAX IP_CLASSC_MAX
|
||||
|
||||
#define IN_CLASSD(d) IP_CLASSD(d)
|
||||
#define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */
|
||||
#define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */
|
||||
#define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */
|
||||
#define IN_CLASSD_MAX IP_CLASSD_MAX
|
||||
|
||||
#define IN_MULTICAST(a) IP_MULTICAST(a)
|
||||
|
||||
#define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a)
|
||||
#define IN_BADCLASS(a) IP_BADCLASS(a)
|
||||
|
||||
#define IN_LOOPBACKNET IP_LOOPBACKNET
|
||||
|
||||
|
||||
#ifndef INET_ADDRSTRLEN
|
||||
#define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX
|
||||
#endif
|
||||
#if LWIP_IPV6
|
||||
#ifndef INET6_ADDRSTRLEN
|
||||
#define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#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))
|
||||
|
||||
/* directly map this to the lwip internal functions */
|
||||
#define inet_addr(cp) ipaddr_addr(cp)
|
||||
#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr)
|
||||
#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr))
|
||||
#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if LWIP_IPV6
|
||||
#define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \
|
||||
(target_in6addr)->un.u32_addr[1] = (source_ip6addr)->addr[1]; \
|
||||
(target_in6addr)->un.u32_addr[2] = (source_ip6addr)->addr[2]; \
|
||||
(target_in6addr)->un.u32_addr[3] = (source_ip6addr)->addr[3];}
|
||||
#define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->un.u32_addr[0]; \
|
||||
(target_ip6addr)->addr[1] = (source_in6addr)->un.u32_addr[1]; \
|
||||
(target_ip6addr)->addr[2] = (source_in6addr)->un.u32_addr[2]; \
|
||||
(target_ip6addr)->addr[3] = (source_in6addr)->un.u32_addr[3];}
|
||||
/* ATTENTION: the next define only works because both in6_addr and ip6_addr_t are an u32_t[4] effectively! */
|
||||
#define inet6_addr_to_ip6addr_p(target_ip6addr_p, source_in6addr) ((target_ip6addr_p) = (ip6_addr_t*)(source_in6addr))
|
||||
|
||||
/* directly map this to the lwip internal functions */
|
||||
#define inet6_aton(cp, addr) ip6addr_aton(cp, (ip6_addr_t*)addr)
|
||||
#define inet6_ntoa(addr) ip6addr_ntoa((const ip6_addr_t*)&(addr))
|
||||
#define inet6_ntoa_r(addr, buf, buflen) ip6addr_ntoa_r((const ip6_addr_t*)&(addr), buf, buflen)
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_INET_H */
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* 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_INET_CHKSUM_H
|
||||
#define LWIP_HDR_INET_CHKSUM_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
/** Swap the bytes in an u16_t: much like 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 */
|
||||
#ifndef FOLD_U32T
|
||||
#define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL))
|
||||
#endif
|
||||
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
/** Function-like macro: same as MEMCPY but returns the checksum of copied data
|
||||
as u16_t */
|
||||
# ifndef LWIP_CHKSUM_COPY
|
||||
# define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len)
|
||||
# ifndef LWIP_CHKSUM_COPY_ALGORITHM
|
||||
# define LWIP_CHKSUM_COPY_ALGORITHM 1
|
||||
# endif /* LWIP_CHKSUM_COPY_ALGORITHM */
|
||||
# else /* LWIP_CHKSUM_COPY */
|
||||
# define LWIP_CHKSUM_COPY_ALGORITHM 0
|
||||
# endif /* LWIP_CHKSUM_COPY */
|
||||
#else /* LWIP_CHECKSUM_ON_COPY */
|
||||
# define LWIP_CHKSUM_COPY_ALGORITHM 0
|
||||
#endif /* LWIP_CHECKSUM_ON_COPY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
u16_t inet_chksum(const void *dataptr, u16_t len);
|
||||
u16_t inet_chksum_pbuf(struct pbuf *p);
|
||||
#if LWIP_CHKSUM_COPY_ALGORITHM
|
||||
u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len);
|
||||
#endif /* LWIP_CHKSUM_COPY_ALGORITHM */
|
||||
|
||||
#if LWIP_IPV4
|
||||
u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len,
|
||||
const ip4_addr_t *src, const ip4_addr_t *dest);
|
||||
u16_t inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto,
|
||||
u16_t proto_len, u16_t chksum_len, const ip4_addr_t *src, const ip4_addr_t *dest);
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if LWIP_IPV6
|
||||
u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len,
|
||||
const ip6_addr_t *src, const ip6_addr_t *dest);
|
||||
u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len,
|
||||
u16_t chksum_len, const ip6_addr_t *src, const ip6_addr_t *dest);
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
|
||||
u16_t ip_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len,
|
||||
const ip_addr_t *src, const ip_addr_t *dest);
|
||||
u16_t ip_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len,
|
||||
u16_t chksum_len, const ip_addr_t *src, const ip_addr_t *dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_INET_H */
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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_INIT_H
|
||||
#define LWIP_HDR_INIT_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** X.x.x: Major version of the stack */
|
||||
#define LWIP_VERSION_MAJOR 1U
|
||||
/** x.X.x: Minor version of the stack */
|
||||
#define LWIP_VERSION_MINOR 5U
|
||||
/** x.x.X: Revision of the stack */
|
||||
#define LWIP_VERSION_REVISION 0U
|
||||
/** 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
|
||||
|
||||
/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
|
||||
#define LWIP_RC_RELEASE 255U
|
||||
/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions */
|
||||
#define LWIP_RC_DEVELOPMENT 0U
|
||||
|
||||
#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))
|
||||
|
||||
/** Provides the version of the stack */
|
||||
#define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \
|
||||
LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC)
|
||||
|
||||
/* Modules initialization */
|
||||
void lwip_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_INIT_H */
|
||||
@@ -1,304 +0,0 @@
|
||||
/*
|
||||
* 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_IP_H__
|
||||
#define LWIP_HDR_IP_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip4.h"
|
||||
#include "lwip/ip6.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
|
||||
|
||||
/** 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 */
|
||||
#ifndef LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX
|
||||
#define LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p) LWIP_ASSERT("p->ref == 1", (p)->ref == 1)
|
||||
#endif
|
||||
|
||||
#if LWIP_NETIF_HWADDRHINT
|
||||
#define IP_PCB_ADDRHINT ;u8_t addr_hint
|
||||
#else
|
||||
#define IP_PCB_ADDRHINT
|
||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||
|
||||
/* 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. */
|
||||
#define IP_PCB \
|
||||
/* ip addresses in network byte order */ \
|
||||
ip_addr_t local_ip; \
|
||||
ip_addr_t remote_ip; \
|
||||
/* Socket options */ \
|
||||
u8_t so_options; \
|
||||
/* Type Of Service */ \
|
||||
u8_t tos; \
|
||||
/* Time To Live */ \
|
||||
u8_t ttl \
|
||||
/* link layer address resolution hint */ \
|
||||
IP_PCB_ADDRHINT
|
||||
|
||||
struct ip_pcb {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
};
|
||||
|
||||
/*
|
||||
* Option flags per-socket. These are the same like SO_XXX in sockets.h
|
||||
*/
|
||||
#define SOF_REUSEADDR 0x04U /* allow local address reuse */
|
||||
#define SOF_KEEPALIVE 0x08U /* keep connections alive */
|
||||
#define SOF_BROADCAST 0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
|
||||
|
||||
/* 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. */
|
||||
struct ip_globals
|
||||
{
|
||||
/** The interface that accepted the packet for the current callback invocation. */
|
||||
struct netif *current_netif;
|
||||
/** The interface that received the packet for the current callback invocation. */
|
||||
struct netif *current_input_netif;
|
||||
#if LWIP_IPV4
|
||||
/** Header of the input packet currently being processed. */
|
||||
struct ip_hdr *current_ip4_header;
|
||||
#endif /* LWIP_IPV4 */
|
||||
#if LWIP_IPV6
|
||||
/** Header of the input IPv6 packet currently being processed. */
|
||||
struct ip6_hdr *current_ip6_header;
|
||||
#endif /* LWIP_IPV6 */
|
||||
/** Total header length of current_ip4/6_header (i.e. after this, the UDP/TCP header starts) */
|
||||
u16_t current_ip_header_tot_len;
|
||||
/** Source IP address of current_header */
|
||||
ip_addr_t current_iphdr_src;
|
||||
/** Destination IP address of current_header */
|
||||
ip_addr_t current_iphdr_dest;
|
||||
};
|
||||
extern struct ip_globals ip_data;
|
||||
|
||||
|
||||
/** Get the interface that accepted the current packet.
|
||||
* This may or may not be the receiving netif, depending on your netif/network setup.
|
||||
* This function must only be called from a receive callback (udp_recv,
|
||||
* raw_recv, tcp_accept). It will return NULL otherwise. */
|
||||
#define ip_current_netif() (ip_data.current_netif)
|
||||
/** Get the interface that received the current packet.
|
||||
* This function must only be called from a receive callback (udp_recv,
|
||||
* raw_recv, tcp_accept). It will return NULL otherwise. */
|
||||
#define ip_current_input_netif() (ip_data.current_input_netif)
|
||||
/** Total header length of ip(6)_current_header() (i.e. after this, the UDP/TCP header starts) */
|
||||
#define ip_current_header_tot_len() (ip_data.current_ip_header_tot_len)
|
||||
/** Source IP address of current_header */
|
||||
#define ip_current_src_addr() (&ip_data.current_iphdr_src)
|
||||
/** Destination IP address of current_header */
|
||||
#define ip_current_dest_addr() (&ip_data.current_iphdr_dest)
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/** Get the IPv4 header of the current packet.
|
||||
* This function must only be called from a receive callback (udp_recv,
|
||||
* raw_recv, tcp_accept). It will return NULL otherwise. */
|
||||
#define ip4_current_header() ((const struct ip_hdr*)(ip_data.current_ip4_header))
|
||||
/** Get the IPv6 header of the current packet.
|
||||
* This function must only be called from a receive callback (udp_recv,
|
||||
* raw_recv, tcp_accept). It will return NULL otherwise. */
|
||||
#define ip6_current_header() ((const struct ip6_hdr*)(ip_data.current_ip6_header))
|
||||
/** Returns TRUE if the current IP input packet is IPv6, FALSE if it is IPv4 */
|
||||
#define ip_current_is_v6() (ip6_current_header() != NULL)
|
||||
/** Source IPv6 address of current_header */
|
||||
#define ip6_current_src_addr() (ip_2_ip6(&ip_data.current_iphdr_src))
|
||||
/** Destination IPv6 address of current_header */
|
||||
#define ip6_current_dest_addr() (ip_2_ip6(&ip_data.current_iphdr_dest))
|
||||
/** Get the transport layer protocol */
|
||||
#define ip_current_header_proto() (ip_current_is_v6() ? \
|
||||
IP6H_NEXTH(ip6_current_header()) :\
|
||||
IPH_PROTO(ip4_current_header()))
|
||||
/** Get the transport layer header */
|
||||
#define ip_next_header_ptr() ((const void*)((ip_current_is_v6() ? \
|
||||
(const u8_t*)ip6_current_header() : (const u8_t*)ip4_current_header()) + ip_current_header_tot_len()))
|
||||
|
||||
/** Source IP4 address of current_header */
|
||||
#define ip4_current_src_addr() (ip_2_ip4(&ip_data.current_iphdr_src))
|
||||
/** Destination IP4 address of current_header */
|
||||
#define ip4_current_dest_addr() (ip_2_ip4(&ip_data.current_iphdr_dest))
|
||||
|
||||
#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
/** Get the IPv4 header of the current packet.
|
||||
* This function must only be called from a receive callback (udp_recv,
|
||||
* raw_recv, tcp_accept). It will return NULL otherwise. */
|
||||
#define ip4_current_header() ((const struct ip_hdr*)(ip_data.current_ip4_header))
|
||||
/** Always returns FALSE when only supporting IPv4 only */
|
||||
#define ip_current_is_v6() 0
|
||||
/** Get the transport layer protocol */
|
||||
#define ip_current_header_proto() IPH_PROTO(ip4_current_header())
|
||||
/** Get the transport layer header */
|
||||
#define ip_next_header_ptr() ((const void*)((const u8_t*)ip4_current_header() + ip_current_header_tot_len()))
|
||||
/** Source IP4 address of current_header */
|
||||
#define ip4_current_src_addr() (&ip_data.current_iphdr_src)
|
||||
/** Destination IP4 address of current_header */
|
||||
#define ip4_current_dest_addr() (&ip_data.current_iphdr_dest)
|
||||
|
||||
#elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
/** Get the IPv6 header of the current packet.
|
||||
* This function must only be called from a receive callback (udp_recv,
|
||||
* raw_recv, tcp_accept). It will return NULL otherwise. */
|
||||
#define ip6_current_header() ((const struct ip6_hdr*)(ip_data.current_ip6_header))
|
||||
/** Always returns TRUE when only supporting IPv6 only */
|
||||
#define ip_current_is_v6() 1
|
||||
/** Get the transport layer protocol */
|
||||
#define ip_current_header_proto() IP6H_NEXTH(ip6_current_header())
|
||||
/** Get the transport layer header */
|
||||
#define ip_next_header_ptr() ((const void*)((const u8_t*)ip6_current_header()))
|
||||
/** Source IP6 address of current_header */
|
||||
#define ip6_current_src_addr() (&ip_data.current_iphdr_src)
|
||||
/** Destination IP6 address of current_header */
|
||||
#define ip6_current_dest_addr() (&ip_data.current_iphdr_dest)
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/** Union source address of current_header */
|
||||
#define ip_current_src_addr() (&ip_data.current_iphdr_src)
|
||||
/** Union destination address of current_header */
|
||||
#define ip_current_dest_addr() (&ip_data.current_iphdr_dest)
|
||||
|
||||
/** Gets an IP pcb option (SOF_* flags) */
|
||||
#define ip_get_option(pcb, opt) ((pcb)->so_options & (opt))
|
||||
/** Sets an IP pcb option (SOF_* flags) */
|
||||
#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt))
|
||||
/** Resets an IP pcb option (SOF_* flags) */
|
||||
#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt))
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
#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))
|
||||
#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))
|
||||
#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))
|
||||
#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))
|
||||
#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)))
|
||||
#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))
|
||||
#define ip_debug_print(is_ipv6, p) ((is_ipv6) ? ip6_debug_print(p) : ip4_debug_print(p))
|
||||
|
||||
err_t ip_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
#define ip_output(p, src, dest, ttl, tos, proto) \
|
||||
ip4_output(p, src, dest, ttl, tos, proto)
|
||||
#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \
|
||||
ip4_output_if(p, src, dest, ttl, tos, proto, netif)
|
||||
#define ip_output_if_src(p, src, dest, ttl, tos, proto, netif) \
|
||||
ip4_output_if_src(p, src, dest, ttl, tos, proto, netif)
|
||||
#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \
|
||||
ip4_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
|
||||
#define ip_route(src, dest) \
|
||||
ip4_route_src(dest, src)
|
||||
#define ip_netif_get_local_ip(netif, dest) \
|
||||
ip4_netif_get_local_ip(netif)
|
||||
#define ip_debug_print(is_ipv6, p) ip4_debug_print(p)
|
||||
|
||||
#define ip_input ip4_input
|
||||
|
||||
#elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
#define ip_output(p, src, dest, ttl, tos, proto) \
|
||||
ip6_output(p, src, dest, ttl, tos, proto)
|
||||
#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \
|
||||
ip6_output_if(p, src, dest, ttl, tos, proto, netif)
|
||||
#define ip_output_if_src(p, src, dest, ttl, tos, proto, netif) \
|
||||
ip6_output_if_src(p, src, dest, ttl, tos, proto, netif)
|
||||
#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \
|
||||
ip6_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
|
||||
#define ip_route(src, dest) \
|
||||
ip6_route(src, dest)
|
||||
#define ip_netif_get_local_ip(netif, dest) \
|
||||
ip6_netif_get_local_ip(netif, dest)
|
||||
#define ip_debug_print(is_ipv6, p) ip6_debug_print(p)
|
||||
|
||||
#define ip_input ip6_input
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#define ip_route_get_local_ip(src, dest, netif, ipaddr) do { \
|
||||
(netif) = ip_route(src, dest); \
|
||||
(ipaddr) = ip_netif_get_local_ip(netif, dest); \
|
||||
}while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_IP_H__ */
|
||||
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* 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_IP4_H
|
||||
#define LWIP_HDR_IP4_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_HOOK_IP4_ROUTE_SRC
|
||||
#define LWIP_IPV4_SRC_ROUTING 1
|
||||
#else
|
||||
#define LWIP_IPV4_SRC_ROUTING 0
|
||||
#endif
|
||||
|
||||
/** 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
|
||||
struct netif *ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src);
|
||||
#else /* LWIP_IPV4_SRC_ROUTING */
|
||||
#define ip4_route_src(dest, src) ip4_route(dest)
|
||||
#endif /* LWIP_IPV4_SRC_ROUTING */
|
||||
err_t ip4_input(struct pbuf *p, struct netif *inp);
|
||||
err_t ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto);
|
||||
err_t ip4_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif);
|
||||
err_t ip4_output_if_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif);
|
||||
#if LWIP_NETIF_HWADDRHINT
|
||||
err_t ip4_output_hinted(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
|
||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||
#if IP_OPTIONS_SEND
|
||||
err_t ip4_output_if_opt(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
|
||||
u16_t optlen);
|
||||
err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
|
||||
u16_t optlen);
|
||||
#endif /* IP_OPTIONS_SEND */
|
||||
|
||||
#if LWIP_MULTICAST_TX_OPTIONS
|
||||
void ip4_set_default_multicast_netif(struct netif* default_multicast_netif);
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
#define ip4_netif_get_local_ip(netif) (((netif) != NULL) ? netif_ip_addr4(netif) : NULL)
|
||||
|
||||
#if IP_DEBUG
|
||||
void ip4_debug_print(struct pbuf *p);
|
||||
#else
|
||||
#define ip4_debug_print(p)
|
||||
#endif /* IP_DEBUG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#endif /* LWIP_HDR_IP_H */
|
||||
|
||||
|
||||
@@ -1,253 +0,0 @@
|
||||
/*
|
||||
* 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_IP4_ADDR_H
|
||||
#define LWIP_HDR_IP4_ADDR_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip4_addr2 {
|
||||
PACK_STRUCT_FIELD(u16_t addrw[2]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* Forward declaration to not include netif.h */
|
||||
struct netif;
|
||||
|
||||
/** 255.255.255.255 */
|
||||
#define IPADDR_NONE ((u32_t)0xffffffffUL)
|
||||
/** 127.0.0.1 */
|
||||
#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL)
|
||||
/** 0.0.0.0 */
|
||||
#define IPADDR_ANY ((u32_t)0x00000000UL)
|
||||
/** 255.255.255.255 */
|
||||
#define IPADDR_BROADCAST ((u32_t)0xffffffffUL)
|
||||
|
||||
/* Definitions of the bits in an Internet address integer.
|
||||
|
||||
On subnets, host and network parts are found according to
|
||||
the subnet mask, not these masks. */
|
||||
#define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0)
|
||||
#define IP_CLASSA_NET 0xff000000
|
||||
#define IP_CLASSA_NSHIFT 24
|
||||
#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET)
|
||||
#define IP_CLASSA_MAX 128
|
||||
|
||||
#define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL)
|
||||
#define IP_CLASSB_NET 0xffff0000
|
||||
#define IP_CLASSB_NSHIFT 16
|
||||
#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET)
|
||||
#define IP_CLASSB_MAX 65536
|
||||
|
||||
#define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL)
|
||||
#define IP_CLASSC_NET 0xffffff00
|
||||
#define IP_CLASSC_NSHIFT 8
|
||||
#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET)
|
||||
|
||||
#define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL)
|
||||
#define IP_CLASSD_NET 0xf0000000 /* These ones aren't really */
|
||||
#define IP_CLASSD_NSHIFT 28 /* net and host fields, but */
|
||||
#define IP_CLASSD_HOST 0x0fffffff /* routing needn't know. */
|
||||
#define IP_MULTICAST(a) IP_CLASSD(a)
|
||||
|
||||
#define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
|
||||
#define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
|
||||
|
||||
#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
|
||||
|
||||
/** 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
|
||||
* this to copying 2 u16_t's) - no NULL-pointer-checking needed. */
|
||||
#ifndef IPADDR2_COPY
|
||||
#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip4_addr_t))
|
||||
#endif
|
||||
|
||||
/** Copy IP address - faster than ip4_addr_set: no NULL check */
|
||||
#define ip4_addr_copy(dest, src) ((dest).addr = (src).addr)
|
||||
/** Safely copy one IP address to another (src may be NULL) */
|
||||
#define ip4_addr_set(dest, src) ((dest)->addr = \
|
||||
((src) == NULL ? 0 : \
|
||||
(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()) */
|
||||
#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))
|
||||
/** Check if an address is in the loopback region */
|
||||
#define ip4_addr_isloopback(ipaddr) (((ipaddr)->addr & PP_HTONL(IP_CLASSA_NET)) == PP_HTONL(((u32_t)IP_LOOPBACKNET) << 24))
|
||||
/** Safely copy one IP address to another and change byte order
|
||||
* from host- to network-order. */
|
||||
#define ip4_addr_set_hton(dest, src) ((dest)->addr = \
|
||||
((src) == NULL ? 0:\
|
||||
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 */
|
||||
#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr)
|
||||
|
||||
/** Get the network address by combining host address with netmask */
|
||||
#define ip4_addr_get_network(target, host, netmask) do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0)
|
||||
|
||||
/**
|
||||
* Determine if two address are on the same network.
|
||||
*
|
||||
* @arg addr1 IP address 1
|
||||
* @arg addr2 IP address 2
|
||||
* @arg mask network identifier mask
|
||||
* @return !0 if the network identifiers of both address match
|
||||
*/
|
||||
#define ip4_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
|
||||
(mask)->addr) == \
|
||||
((addr2)->addr & \
|
||||
(mask)->addr))
|
||||
#define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
|
||||
|
||||
#define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY)
|
||||
#define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1)))
|
||||
|
||||
#define ip4_addr_isbroadcast(addr1, netif) ip4_addr_isbroadcast_u32((addr1)->addr, netif)
|
||||
u8_t ip4_addr_isbroadcast_u32(u32_t addr, const struct netif *netif);
|
||||
|
||||
#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr)
|
||||
u8_t ip4_addr_netmask_valid(u32_t netmask);
|
||||
|
||||
#define ip4_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL))
|
||||
|
||||
#define ip4_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
|
||||
|
||||
#define ip4_addr_debug_print_parts(debug, a, b, c, d) \
|
||||
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)
|
||||
#define ip4_addr_debug_print_val(debug, ipaddr) \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
ip4_addr1_16(&(ipaddr)), \
|
||||
ip4_addr2_16(&(ipaddr)), \
|
||||
ip4_addr3_16(&(ipaddr)), \
|
||||
ip4_addr4_16(&(ipaddr)))
|
||||
|
||||
/* Get one byte from the 4-byte address */
|
||||
#define ip4_addr1(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[0])
|
||||
#define ip4_addr2(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[1])
|
||||
#define ip4_addr3(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[2])
|
||||
#define ip4_addr4(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[3])
|
||||
/* These are cast to u16_t, with the intent that they are often arguments
|
||||
* to printf using the U16_F format from cc.h. */
|
||||
#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
|
||||
#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
|
||||
#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
|
||||
#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)
|
||||
|
||||
u32_t ipaddr_addr(const char *cp);
|
||||
int ip4addr_aton(const char *cp, ip4_addr_t *addr);
|
||||
/** returns ptr to static buffer; not reentrant! */
|
||||
char *ip4addr_ntoa(const ip4_addr_t *addr);
|
||||
char *ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#endif /* LWIP_HDR_IP_ADDR_H */
|
||||
@@ -1,197 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* IPv6 layer.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_IP6_H
|
||||
#define LWIP_HDR_IP6_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
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);
|
||||
err_t ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||
u8_t hl, u8_t tc, u8_t nexth);
|
||||
err_t ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||
u8_t hl, u8_t tc, u8_t nexth, struct netif *netif);
|
||||
err_t ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||
u8_t hl, u8_t tc, u8_t nexth, struct netif *netif);
|
||||
#if LWIP_NETIF_HWADDRHINT
|
||||
err_t ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||
u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint);
|
||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||
#if LWIP_IPV6_MLD
|
||||
err_t ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value);
|
||||
#endif /* LWIP_IPV6_MLD */
|
||||
|
||||
#define ip6_netif_get_local_ip(netif, dest) (((netif) != NULL) ? \
|
||||
ip6_select_source_address(netif, dest) : NULL)
|
||||
|
||||
#if IP6_DEBUG
|
||||
void ip6_debug_print(struct pbuf *p);
|
||||
#else
|
||||
#define ip6_debug_print(p)
|
||||
#endif /* IP6_DEBUG */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#endif /* LWIP_HDR_IP6_H */
|
||||
@@ -1,301 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* IPv6 addresses.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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>
|
||||
*
|
||||
* Structs and macros for handling IPv6 addresses.
|
||||
*
|
||||
* Please coordinate changes and requests with Ivan Delamer
|
||||
* <delamer@inicotech.com>
|
||||
*/
|
||||
#ifndef LWIP_HDR_IP6_ADDR_H
|
||||
#define LWIP_HDR_IP6_ADDR_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* 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
|
||||
|
||||
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. */
|
||||
#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
|
||||
|
||||
/** Set a full IPv6 address by passing the 4 u32_t indices in network byte order
|
||||
(use PP_HTONL() for constants) */
|
||||
#define IP6_ADDR(ip6addr, idx0, idx1, idx2, idx3) do { \
|
||||
(ip6addr)->addr[0] = idx0; \
|
||||
(ip6addr)->addr[1] = idx1; \
|
||||
(ip6addr)->addr[2] = idx2; \
|
||||
(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)
|
||||
|
||||
/** Copy IPv6 address - faster than ip6_addr_set: no NULL check */
|
||||
#define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \
|
||||
(dest).addr[1] = (src).addr[1]; \
|
||||
(dest).addr[2] = (src).addr[2]; \
|
||||
(dest).addr[3] = (src).addr[3];}while(0)
|
||||
/** Safely copy one IPv6 address to another (src may be NULL) */
|
||||
#define ip6_addr_set(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \
|
||||
(dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \
|
||||
(dest)->addr[2] = (src) == NULL ? 0 : (src)->addr[2]; \
|
||||
(dest)->addr[3] = (src) == NULL ? 0 : (src)->addr[3];}while(0)
|
||||
|
||||
/** Set complete address to zero */
|
||||
#define ip6_addr_set_zero(ip6addr) do{(ip6addr)->addr[0] = 0; \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = 0;}while(0)
|
||||
|
||||
/** Set address to ipv6 'any' (no need for 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; \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(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)
|
||||
|
||||
|
||||
/**
|
||||
* Determine if two IPv6 address are on the same network.
|
||||
*
|
||||
* @arg addr1 IPv6 address 1
|
||||
* @arg addr2 IPv6 address 2
|
||||
* @return !0 if the network identifiers of both address match
|
||||
*/
|
||||
#define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
|
||||
((addr1)->addr[1] == (addr2)->addr[1]))
|
||||
|
||||
#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
|
||||
((addr1)->addr[1] == (addr2)->addr[1]) && \
|
||||
((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_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \
|
||||
((ip6addr).addr[1] == 0) && \
|
||||
((ip6addr).addr[2] == 0) && \
|
||||
((ip6addr).addr[3] == 0))
|
||||
#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || ip6_addr_isany_val(*(ip6addr)))
|
||||
|
||||
#define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \
|
||||
((ip6addr)->addr[1] == 0UL) && \
|
||||
((ip6addr)->addr[2] == 0UL) && \
|
||||
((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
|
||||
|
||||
#define ip6_addr_isglobal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xe0000000UL)) == PP_HTONL(0x20000000UL))
|
||||
|
||||
#define ip6_addr_islinklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfe800000UL))
|
||||
|
||||
#define ip6_addr_issitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfec00000UL))
|
||||
|
||||
#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL))
|
||||
|
||||
#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_MULTICAST_SCOPE_RESERVED 0x0
|
||||
#define IP6_MULTICAST_SCOPE_RESERVED0 0x0
|
||||
#define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1
|
||||
#define IP6_MULTICAST_SCOPE_LINK_LOCAL 0x2
|
||||
#define IP6_MULTICAST_SCOPE_RESERVED3 0x3
|
||||
#define IP6_MULTICAST_SCOPE_ADMIN_LOCAL 0x4
|
||||
#define IP6_MULTICAST_SCOPE_SITE_LOCAL 0x5
|
||||
#define IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL 0x8
|
||||
#define IP6_MULTICAST_SCOPE_GLOBAL 0xe
|
||||
#define IP6_MULTICAST_SCOPE_RESERVEDF 0xf
|
||||
#define ip6_addr_ismulticast_iflocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff010000UL))
|
||||
#define ip6_addr_ismulticast_linklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff020000UL))
|
||||
#define ip6_addr_ismulticast_adminlocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff040000UL))
|
||||
#define ip6_addr_ismulticast_sitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff050000UL))
|
||||
#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 */
|
||||
#define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \
|
||||
((ip6addr)->addr[1] == 0UL) && \
|
||||
((ip6addr)->addr[2] == 0UL) && \
|
||||
((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
|
||||
|
||||
#define ip6_addr_isallnodes_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
|
||||
((ip6addr)->addr[1] == 0UL) && \
|
||||
((ip6addr)->addr[2] == 0UL) && \
|
||||
((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
|
||||
#define ip6_addr_set_allnodes_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0)
|
||||
|
||||
#define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
|
||||
((ip6addr)->addr[1] == 0UL) && \
|
||||
((ip6addr)->addr[2] == 0UL) && \
|
||||
((ip6addr)->addr[3] == PP_HTONL(0x00000002UL)))
|
||||
#define ip6_addr_set_allrouters_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = 0; \
|
||||
(ip6addr)->addr[3] = PP_HTONL(0x00000002UL);}while(0)
|
||||
|
||||
#define ip6_addr_issolicitednode(ip6addr) ( ((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
|
||||
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
|
||||
(((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) )
|
||||
|
||||
#define ip6_addr_set_solicitednode(ip6addr, if_id) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
|
||||
(ip6addr)->addr[1] = 0; \
|
||||
(ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \
|
||||
(ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id));}while(0)
|
||||
|
||||
#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
|
||||
((ip6addr)->addr[1] == 0) && \
|
||||
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
|
||||
((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3])))
|
||||
|
||||
/* IPv6 address states. */
|
||||
#define IP6_ADDR_INVALID 0x00
|
||||
#define IP6_ADDR_TENTATIVE 0x08
|
||||
#define IP6_ADDR_TENTATIVE_1 0x09 /* 1 probe sent */
|
||||
#define IP6_ADDR_TENTATIVE_2 0x0a /* 2 probes sent */
|
||||
#define IP6_ADDR_TENTATIVE_3 0x0b /* 3 probes sent */
|
||||
#define IP6_ADDR_TENTATIVE_4 0x0c /* 4 probes sent */
|
||||
#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_PREFERRED 0x30
|
||||
#define IP6_ADDR_DEPRECATED 0x50
|
||||
|
||||
#define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID)
|
||||
#define ip6_addr_istentative(addr_state) (addr_state & IP6_ADDR_TENTATIVE)
|
||||
#define ip6_addr_isvalid(addr_state) (addr_state & IP6_ADDR_VALID) /* Include valid, preferred, and deprecated. */
|
||||
#define ip6_addr_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED)
|
||||
#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED)
|
||||
|
||||
#define ip6_addr_debug_print_parts(debug, a, b, c, d, e, f, g, h) \
|
||||
LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
|
||||
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)
|
||||
#define ip6_addr_debug_print_val(debug, ipaddr) \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
IP6_ADDR_BLOCK1(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK2(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK3(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK4(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK5(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK6(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK7(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK8(&(ipaddr)))
|
||||
|
||||
#define IP6ADDR_STRLEN_MAX 46
|
||||
|
||||
int ip6addr_aton(const char *cp, ip6_addr_t *addr);
|
||||
/** returns ptr to static buffer; not reentrant! */
|
||||
char *ip6addr_ntoa(const ip6_addr_t *addr);
|
||||
char *ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#endif /* LWIP_HDR_IP6_ADDR_H */
|
||||
@@ -1,120 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* IPv6 fragmentation and reassembly.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_IP6_FRAG_H
|
||||
#define LWIP_HDR_IP6_FRAG_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/ip6.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/** IP6_FRAG_COPYHEADER==1: for platforms where sizeof(void*) > 4, this needs to
|
||||
* be enabled (to not overwrite part of the data). When enabled, the IPv6 header
|
||||
* is copied instead of referencing it, which gives more room for struct ip6_reass_helper */
|
||||
#ifndef IPV6_FRAG_COPYHEADER
|
||||
#define IPV6_FRAG_COPYHEADER 0
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
or just point to its original location in the first pbuf? */
|
||||
#if IPV6_FRAG_COPYHEADER
|
||||
#define IPV6_FRAG_HDRPTR
|
||||
#define IPV6_FRAG_HDRREF(hdr) (&(hdr))
|
||||
#else /* IPV6_FRAG_COPYHEADER */
|
||||
#define IPV6_FRAG_HDRPTR *
|
||||
#define IPV6_FRAG_HDRREF(hdr) (hdr)
|
||||
#endif /* IPV6_FRAG_COPYHEADER */
|
||||
|
||||
/* IPv6 reassembly helper struct.
|
||||
* This is exported because memp needs to know the size.
|
||||
*/
|
||||
struct ip6_reassdata {
|
||||
struct ip6_reassdata *next;
|
||||
struct pbuf *p;
|
||||
struct ip6_hdr IPV6_FRAG_HDRPTR iphdr;
|
||||
u32_t identification;
|
||||
u16_t datagram_len;
|
||||
u8_t nexth;
|
||||
u8_t timer;
|
||||
};
|
||||
|
||||
#define ip6_reass_init() /* Compatibility define */
|
||||
void ip6_reass_tmr(void);
|
||||
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 */
|
||||
|
||||
/** 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;
|
||||
/** pointer to the original pbuf that is referenced */
|
||||
struct pbuf *original;
|
||||
};
|
||||
#endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */
|
||||
|
||||
err_t ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest);
|
||||
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_IP6_FRAG_H */
|
||||
@@ -1,318 +0,0 @@
|
||||
/*
|
||||
* 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_IP_ADDR_H__
|
||||
#define LWIP_HDR_IP_ADDR_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
|
||||
#include "lwip/ip4_addr.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
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
|
||||
|
||||
#define IP_IS_V4_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V4)
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/** A union struct for both IP version's addresses.
|
||||
* ATTENTION: watch out for its size when adding IPv6 address scope!
|
||||
*/
|
||||
typedef struct _ip_addr {
|
||||
union {
|
||||
ip6_addr_t ip6;
|
||||
ip4_addr_t ip4;
|
||||
} u_addr;
|
||||
u8_t type;
|
||||
} ip_addr_t;
|
||||
|
||||
extern const ip_addr_t ip_addr_any_type;
|
||||
|
||||
#define IPADDR4_INIT(u32val) { { { { u32val, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_V4 }
|
||||
#define IPADDR6_INIT(a, b, c, d) { { { { a, b, c, d } } }, IPADDR_TYPE_V6 }
|
||||
|
||||
#define IP_IS_ANY_TYPE_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_ANY)
|
||||
#define IPADDR_ANY_TYPE_INIT { { { { 0ul, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_ANY }
|
||||
|
||||
#define IP_IS_V6_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V6)
|
||||
#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(*(ipaddr)))
|
||||
|
||||
#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))
|
||||
|
||||
#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)
|
||||
#define IP_GET_TYPE(ipaddr) ((ipaddr)->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 */
|
||||
#define ip_2_ip6(ipaddr) (&((ipaddr)->u_addr.ip6))
|
||||
#define ip_2_ip4(ipaddr) (&((ipaddr)->u_addr.ip4))
|
||||
|
||||
#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)
|
||||
#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)
|
||||
|
||||
#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)
|
||||
#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)
|
||||
#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)
|
||||
#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)) ? \
|
||||
ip4_addr_get_u32(ip_2_ip4(ipaddr)) : 0)
|
||||
|
||||
#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)
|
||||
|
||||
#define ip_addr_set_ipaddr(dest, src) ip_addr_set(dest, src)
|
||||
#define ip_addr_set_zero(ipaddr) do{ \
|
||||
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, 0); }while(0)
|
||||
#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)
|
||||
#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)
|
||||
#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)
|
||||
#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)
|
||||
#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)
|
||||
#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)
|
||||
#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))
|
||||
#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))))
|
||||
#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_isany(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isany(ip_2_ip4(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))))
|
||||
#define ip_addr_isbroadcast(ipaddr, netif) ((IP_IS_V6(ipaddr)) ? \
|
||||
0 : \
|
||||
ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
|
||||
#define ip_addr_ismulticast(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_ismulticast(ip_2_ip4(ipaddr)))
|
||||
#define ip_addr_isloopback(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isloopback(ip_2_ip4(ipaddr)))
|
||||
#define ip_addr_islinklocal(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_islinklocal(ip_2_ip4(ipaddr)))
|
||||
#define ip_addr_debug_print(debug, ipaddr) do { if(IP_IS_V6(ipaddr)) { \
|
||||
ip6_addr_debug_print(debug, ip_2_ip6(ipaddr)); } else { \
|
||||
ip4_addr_debug_print(debug, ip_2_ip4(ipaddr)); }}while(0)
|
||||
#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)
|
||||
#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
|
||||
#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.
|
||||
|
||||
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)
|
||||
|
||||
/* Convert an IPv4 mapped V6 address to an IPV4 address.
|
||||
|
||||
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)
|
||||
|
||||
#else /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
#define IP_ADDR_PCB_VERSION_MATCH(addr, pcb) 1
|
||||
#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) 1
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
typedef ip4_addr_t ip_addr_t;
|
||||
#define IPADDR4_INIT(u32val) { u32val }
|
||||
#define IP_IS_V6_VAL(ipaddr) 0
|
||||
#define IP_IS_V6(ipaddr) 0
|
||||
#define IP_IS_ANY_TYPE_VAL(ipaddr) 0
|
||||
#define IP_SET_TYPE_VAL(ipaddr, iptype)
|
||||
#define IP_SET_TYPE(ipaddr, iptype)
|
||||
#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V4
|
||||
#define ip_2_ip4(ipaddr) (ipaddr)
|
||||
#define IP_ADDR4(ipaddr,a,b,c,d) IP4_ADDR(ipaddr,a,b,c,d)
|
||||
|
||||
#define ip_addr_copy(dest, src) ip4_addr_copy(dest, src)
|
||||
#define ip_addr_copy_from_ip4(dest, src) ip4_addr_copy(dest, src)
|
||||
#define ip_addr_set_ip4_u32(ipaddr, val) ip4_addr_set_u32(ip_2_ip4(ipaddr), val)
|
||||
#define ip_addr_get_ip4_u32(ipaddr) ip4_addr_get_u32(ip_2_ip4(ipaddr))
|
||||
#define ip_addr_set(dest, src) ip4_addr_set(dest, src)
|
||||
#define ip_addr_set_ipaddr(dest, src) ip4_addr_set(dest, src)
|
||||
#define ip_addr_set_zero(ipaddr) ip4_addr_set_zero(ipaddr)
|
||||
#define ip_addr_set_zero_ip4(ipaddr) ip4_addr_set_zero(ipaddr)
|
||||
#define ip_addr_set_any(is_ipv6, ipaddr) ip4_addr_set_any(ipaddr)
|
||||
#define ip_addr_set_loopback(is_ipv6, ipaddr) ip4_addr_set_loopback(ipaddr)
|
||||
#define ip_addr_set_hton(dest, src) ip4_addr_set_hton(dest, src)
|
||||
#define ip_addr_get_network(target, host, mask) ip4_addr_get_network(target, host, mask)
|
||||
#define ip_addr_netcmp(addr1, addr2, mask) ip4_addr_netcmp(addr1, addr2, mask)
|
||||
#define ip_addr_cmp(addr1, addr2) ip4_addr_cmp(addr1, addr2)
|
||||
#define ip_addr_isany(ipaddr) ip4_addr_isany(ipaddr)
|
||||
#define ip_addr_isany_val(ipaddr) ip4_addr_isany_val(ipaddr)
|
||||
#define ip_addr_isloopback(ipaddr) ip4_addr_isloopback(ipaddr)
|
||||
#define ip_addr_islinklocal(ipaddr) ip4_addr_islinklocal(ipaddr)
|
||||
#define ip_addr_isbroadcast(addr, netif) ip4_addr_isbroadcast(addr, netif)
|
||||
#define ip_addr_ismulticast(ipaddr) ip4_addr_ismulticast(ipaddr)
|
||||
#define ip_addr_debug_print(debug, ipaddr) ip4_addr_debug_print(debug, ipaddr)
|
||||
#define ip_addr_debug_print_val(debug, ipaddr) ip4_addr_debug_print_val(debug, ipaddr)
|
||||
#define ipaddr_ntoa(ipaddr) ip4addr_ntoa(ipaddr)
|
||||
#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip4addr_ntoa_r(ipaddr, buf, buflen)
|
||||
#define ipaddr_aton(cp, addr) ip4addr_aton(cp, addr)
|
||||
|
||||
#else /* LWIP_IPV4 */
|
||||
|
||||
typedef ip6_addr_t ip_addr_t;
|
||||
#define IPADDR6_INIT(a, b, c, d) { { a, b, c, d } }
|
||||
#define IP_IS_V6_VAL(ipaddr) 1
|
||||
#define IP_IS_V6(ipaddr) 1
|
||||
#define IP_IS_ANY_TYPE_VAL(ipaddr) 0
|
||||
#define IP_SET_TYPE_VAL(ipaddr, iptype)
|
||||
#define IP_SET_TYPE(ipaddr, iptype)
|
||||
#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_addr_copy(dest, src) ip6_addr_copy(dest, src)
|
||||
#define ip_addr_copy_from_ip6(dest, src) ip6_addr_copy(dest, src)
|
||||
#define ip_addr_set(dest, src) ip6_addr_set(dest, src)
|
||||
#define ip_addr_set_ipaddr(dest, src) ip6_addr_set(dest, src)
|
||||
#define ip_addr_set_zero(ipaddr) ip6_addr_set_zero(ipaddr)
|
||||
#define ip_addr_set_zero_ip6(ipaddr) ip6_addr_set_zero(ipaddr)
|
||||
#define ip_addr_set_any(is_ipv6, ipaddr) ip6_addr_set_any(ipaddr)
|
||||
#define ip_addr_set_loopback(is_ipv6, ipaddr) ip6_addr_set_loopback(ipaddr)
|
||||
#define ip_addr_set_hton(dest, src) ip6_addr_set_hton(dest, src)
|
||||
#define ip_addr_get_network(target, host, mask) ip6_addr_set_zero(target)
|
||||
#define ip_addr_netcmp(addr1, addr2, mask) 0
|
||||
#define ip_addr_cmp(addr1, addr2) ip6_addr_cmp(addr1, addr2)
|
||||
#define ip_addr_isany(ipaddr) ip6_addr_isany(ipaddr)
|
||||
#define ip_addr_isany_val(ipaddr) ip6_addr_isany_val(ipaddr)
|
||||
#define ip_addr_isloopback(ipaddr) ip6_addr_isloopback(ipaddr)
|
||||
#define ip_addr_islinklocal(ipaddr) ip6_addr_islinklocal(ipaddr)
|
||||
#define ip_addr_isbroadcast(addr, netif) 0
|
||||
#define ip_addr_ismulticast(ipaddr) ip6_addr_ismulticast(ipaddr)
|
||||
#define ip_addr_debug_print(debug, ipaddr) ip6_addr_debug_print(debug, ipaddr)
|
||||
#define ip_addr_debug_print_val(debug, ipaddr) ip6_addr_debug_print_val(debug, ipaddr)
|
||||
#define ipaddr_ntoa(ipaddr) ip6addr_ntoa(ipaddr)
|
||||
#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip6addr_ntoa_r(ipaddr, buf, buflen)
|
||||
#define ipaddr_aton(cp, addr) ip6addr_aton(cp, addr)
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
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
|
||||
*/
|
||||
#define IP_ADDR_ANY (&ip_addr_any)
|
||||
#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))
|
||||
#define IP4_ADDR_BROADCAST (ip_2_ip4(&ip_addr_broadcast))
|
||||
|
||||
#endif /* LWIP_IPV4*/
|
||||
|
||||
#if LWIP_IPV6
|
||||
|
||||
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
|
||||
*/
|
||||
#define IP6_ADDR_ANY (&ip6_addr_any)
|
||||
/** 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: */
|
||||
#define IP_ADDR_ANY IP6_ADDR_ANY
|
||||
#endif /* !LWIP_IPV4 */
|
||||
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
#define IP_ANY_TYPE (&ip_addr_any_type)
|
||||
#else
|
||||
#define IP_ANY_TYPE IP_ADDR_ANY
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_IP_ADDR_H__ */
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* 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: Jani Monoses <jani@iv.ro>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_IP_FRAG_H
|
||||
#define LWIP_HDR_IP_FRAG_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/ip.h"
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if IP_REASSEMBLY
|
||||
/* The IP reassembly timer interval in milliseconds. */
|
||||
#define IP_TMR_INTERVAL 1000
|
||||
|
||||
/* IP reassembly helper struct.
|
||||
* This is exported because memp needs to know the size.
|
||||
*/
|
||||
struct ip_reassdata {
|
||||
struct ip_reassdata *next;
|
||||
struct pbuf *p;
|
||||
struct ip_hdr iphdr;
|
||||
u16_t datagram_len;
|
||||
u8_t flags;
|
||||
u8_t timer;
|
||||
};
|
||||
|
||||
void ip_reass_init(void);
|
||||
void ip_reass_tmr(void);
|
||||
struct pbuf * ip4_reass(struct pbuf *p);
|
||||
#endif /* IP_REASSEMBLY */
|
||||
|
||||
#if IP_FRAG
|
||||
#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
|
||||
/** 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;
|
||||
/** pointer to the original pbuf that is referenced */
|
||||
struct pbuf *original;
|
||||
};
|
||||
#endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */
|
||||
#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
|
||||
|
||||
err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest);
|
||||
#endif /* IP_FRAG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#endif /* LWIP_HDR_IP_FRAG_H */
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright 2015-2016 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 _LWIP_DEBUG_H
|
||||
#define _LWIP_DEBUG_H
|
||||
|
||||
void dbg_lwip_tcp_pcb_show(void);
|
||||
void dbg_lwip_udp_pcb_show(void);
|
||||
void dbg_lwip_tcp_rxtx_show(void);
|
||||
void dbg_lwip_udp_rxtx_show(void);
|
||||
void dbg_lwip_mem_cnt_show(void);
|
||||
|
||||
#endif
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* 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_MEM_H
|
||||
#define LWIP_HDR_MEM_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if MEM_LIBC_MALLOC
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef mem_free
|
||||
#define mem_free free
|
||||
#endif
|
||||
/**
|
||||
* 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
|
||||
* internal memory then.
|
||||
*/
|
||||
#if CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST
|
||||
#ifndef mem_malloc
|
||||
#define mem_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#endif
|
||||
#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 */
|
||||
|
||||
/* MEM_SIZE would have to be aligned, but using 64000 here instead of
|
||||
* 65535 leaves some room for alignment...
|
||||
*/
|
||||
#if MEM_SIZE > 64000L
|
||||
typedef u32_t mem_size_t;
|
||||
#define MEM_SIZE_F U32_F
|
||||
#else
|
||||
typedef u16_t mem_size_t;
|
||||
#define MEM_SIZE_F U16_F
|
||||
#endif /* MEM_SIZE > 64000 */
|
||||
|
||||
#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
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_MEM_H */
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* 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_MEMP_H
|
||||
#define LWIP_HDR_MEMP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* run once with empty definition to handle all custom includes in lwippools.h */
|
||||
#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 */
|
||||
typedef enum {
|
||||
#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
|
||||
#include "lwip/priv/memp_std.h"
|
||||
MEMP_MAX
|
||||
} memp_t;
|
||||
|
||||
#include "lwip/priv/memp_priv.h"
|
||||
|
||||
/* 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")
|
||||
* - call ONCE before using pool (e.g. in some init() function): LWIP_MEMPOOL_INIT(my_private_pool);
|
||||
* - allocate: void* my_new_mem = LWIP_MEMPOOL_ALLOC(my_private_pool);
|
||||
* - free: LWIP_MEMPOOL_FREE(my_private_pool, my_new_mem);
|
||||
*
|
||||
* 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)))]; \
|
||||
\
|
||||
static struct memp *memp_tab_ ## name; \
|
||||
\
|
||||
const struct memp_desc memp_ ## name = { \
|
||||
LWIP_MEM_ALIGN_SIZE(size), \
|
||||
(num), \
|
||||
DECLARE_LWIP_MEMPOOL_DESC(desc) \
|
||||
memp_memory_ ## name ## _base, \
|
||||
&memp_tab_ ## name \
|
||||
};
|
||||
|
||||
#define LWIP_MEMPOOL_INIT(name) memp_init_pool(&memp_ ## name)
|
||||
#define LWIP_MEMPOOL_ALLOC(name) memp_malloc_pool(&memp_ ## name)
|
||||
#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. */
|
||||
struct memp_malloc_helper
|
||||
{
|
||||
memp_t poolnr;
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
u16_t size;
|
||||
#endif /* MEMP_OVERFLOW_CHECK */
|
||||
};
|
||||
|
||||
#endif /* MEM_USE_POOLS */
|
||||
|
||||
void memp_init(void);
|
||||
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
void *memp_malloc_fn(memp_t type, const char* file, const int line);
|
||||
#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
|
||||
#else
|
||||
void *memp_malloc(memp_t type);
|
||||
#endif
|
||||
void memp_free(memp_t type, void *mem);
|
||||
|
||||
#endif /* MEMP_MEM_MALLOC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_MEMP_H */
|
||||
@@ -1,119 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Multicast listener discovery for IPv6. Aims to be compliant with RFC 2710.
|
||||
* No support for MLDv2.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_MLD6_H
|
||||
#define LWIP_HDR_MLD6_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV6_MLD && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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 */
|
||||
u8_t last_reporter_flag;
|
||||
/** current state of the group */
|
||||
u8_t group_state;
|
||||
/** timer for reporting */
|
||||
u16_t timer;
|
||||
/** counter of simultaneous uses */
|
||||
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);
|
||||
struct mld_group *mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr);
|
||||
void mld6_input(struct pbuf *p, struct netif *inp);
|
||||
err_t mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr);
|
||||
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);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6_MLD && LWIP_IPV6 */
|
||||
|
||||
#endif /* LWIP_HDR_MLD6_H */
|
||||
@@ -1,365 +0,0 @@
|
||||
/**
|
||||
* @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_H
|
||||
#define LWIP_HDR_ND6_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.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/netif.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;
|
||||
|
||||
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);
|
||||
#if LWIP_ND6_TCP_REACHABILITY_HINTS
|
||||
void nd6_reachability_hint(const ip6_addr_t * ip6addr);
|
||||
#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */
|
||||
|
||||
#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
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#endif /* LWIP_HDR_ND6_H */
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* 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_NETBUF_H
|
||||
#define LWIP_HDR_NETBUF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
|
||||
/* Note: Netconn API is always available when sockets are enabled -
|
||||
* sockets are implemented on top of them */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** This netbuf has dest-addr/port set */
|
||||
#define NETBUF_FLAG_DESTADDR 0x01
|
||||
/** This netbuf includes a checksum */
|
||||
#define NETBUF_FLAG_CHKSUM 0x02
|
||||
|
||||
struct netbuf {
|
||||
struct pbuf *p, *ptr;
|
||||
ip_addr_t addr;
|
||||
u16_t port;
|
||||
#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
u8_t flags;
|
||||
#endif /* LWIP_CHECKSUM_ON_COPY */
|
||||
u16_t toport_chksum;
|
||||
#if LWIP_NETBUF_RECVINFO
|
||||
ip_addr_t toaddr;
|
||||
#endif /* LWIP_NETBUF_RECVINFO */
|
||||
#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */
|
||||
};
|
||||
|
||||
/* Network buffer functions: */
|
||||
struct netbuf * netbuf_new (void);
|
||||
void netbuf_delete (struct netbuf *buf);
|
||||
void * netbuf_alloc (struct netbuf *buf, u16_t size);
|
||||
void netbuf_free (struct netbuf *buf);
|
||||
err_t netbuf_ref (struct netbuf *buf,
|
||||
const void *dataptr, u16_t size);
|
||||
void netbuf_chain (struct netbuf *head, struct netbuf *tail);
|
||||
|
||||
err_t netbuf_data (struct netbuf *buf,
|
||||
void **dataptr, u16_t *len);
|
||||
s8_t netbuf_next (struct netbuf *buf);
|
||||
void netbuf_first (struct netbuf *buf);
|
||||
|
||||
|
||||
#define netbuf_copy_partial(buf, dataptr, len, offset) \
|
||||
pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
|
||||
#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
|
||||
#define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
|
||||
#define netbuf_len(buf) ((buf)->p->tot_len)
|
||||
#define netbuf_fromaddr(buf) (&((buf)->addr))
|
||||
#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set(&((buf)->addr), fromaddr)
|
||||
#define netbuf_fromport(buf) ((buf)->port)
|
||||
#if LWIP_NETBUF_RECVINFO
|
||||
#define netbuf_destaddr(buf) (&((buf)->toaddr))
|
||||
#define netbuf_set_destaddr(buf, destaddr) ip_addr_set(&((buf)->toaddr), destaddr)
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
#define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
|
||||
#else /* LWIP_CHECKSUM_ON_COPY */
|
||||
#define netbuf_destport(buf) ((buf)->toport_chksum)
|
||||
#endif /* LWIP_CHECKSUM_ON_COPY */
|
||||
#endif /* LWIP_NETBUF_RECVINFO */
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
#define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \
|
||||
(buf)->toport_chksum = chksum; } while(0)
|
||||
#endif /* LWIP_CHECKSUM_ON_COPY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_NETCONN || LWIP_SOCKET */
|
||||
|
||||
#endif /* LWIP_HDR_NETBUF_H */
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* 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_NETDB_H
|
||||
#define LWIP_HDR_NETDB_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/sockets.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* some rarely used options */
|
||||
#ifndef LWIP_DNS_API_DECLARE_H_ERRNO
|
||||
#define LWIP_DNS_API_DECLARE_H_ERRNO 1
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_DNS_API_DEFINE_ERRORS
|
||||
#define LWIP_DNS_API_DEFINE_ERRORS 1
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_DNS_API_DEFINE_FLAGS
|
||||
#define LWIP_DNS_API_DEFINE_FLAGS 1
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_DNS_API_DECLARE_STRUCTS
|
||||
#define LWIP_DNS_API_DECLARE_STRUCTS 1
|
||||
#endif
|
||||
|
||||
#if LWIP_DNS_API_DEFINE_ERRORS
|
||||
/** Errors used by the DNS API functions, h_errno can be one of them */
|
||||
#define EAI_NONAME 200
|
||||
#define EAI_SERVICE 201
|
||||
#define EAI_FAIL 202
|
||||
#define EAI_MEMORY 203
|
||||
#define EAI_FAMILY 204
|
||||
|
||||
#define HOST_NOT_FOUND 210
|
||||
#define NO_DATA 211
|
||||
#define NO_RECOVERY 212
|
||||
#define TRY_AGAIN 213
|
||||
#endif /* LWIP_DNS_API_DEFINE_ERRORS */
|
||||
|
||||
#if LWIP_DNS_API_DEFINE_FLAGS
|
||||
/* input flags for struct addrinfo */
|
||||
#define AI_PASSIVE 0x01
|
||||
#define AI_CANONNAME 0x02
|
||||
#define AI_NUMERICHOST 0x04
|
||||
#define AI_NUMERICSERV 0x08
|
||||
#define AI_V4MAPPED 0x10
|
||||
#define AI_ALL 0x20
|
||||
#define AI_ADDRCONFIG 0x40
|
||||
#endif /* LWIP_DNS_API_DEFINE_FLAGS */
|
||||
|
||||
#if LWIP_DNS_API_DECLARE_STRUCTS
|
||||
struct hostent {
|
||||
char *h_name; /* Official name of the host. */
|
||||
char **h_aliases; /* A pointer to an array of pointers to alternative host names,
|
||||
terminated by a null pointer. */
|
||||
int h_addrtype; /* Address type. */
|
||||
int h_length; /* The length, in bytes, of the address. */
|
||||
char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
|
||||
network byte order) for the host, terminated by a null pointer. */
|
||||
#define h_addr h_addr_list[0] /* for backward compatibility */
|
||||
};
|
||||
|
||||
struct addrinfo {
|
||||
int ai_flags; /* Input flags. */
|
||||
int ai_family; /* Address family of socket. */
|
||||
int ai_socktype; /* Socket type. */
|
||||
int ai_protocol; /* Protocol of socket. */
|
||||
socklen_t ai_addrlen; /* Length of socket address. */
|
||||
struct sockaddr *ai_addr; /* Socket address of socket. */
|
||||
char *ai_canonname; /* Canonical name of service location. */
|
||||
struct addrinfo *ai_next; /* Pointer to next in list. */
|
||||
};
|
||||
#endif /* LWIP_DNS_API_DECLARE_STRUCTS */
|
||||
|
||||
#define NETDB_ELEM_SIZE (sizeof(struct addrinfo) + sizeof(struct sockaddr_storage) + DNS_MAX_NAME_LENGTH + 1)
|
||||
|
||||
#if LWIP_DNS_API_DECLARE_H_ERRNO
|
||||
/* application accessible error code set by the DNS API functions */
|
||||
extern int h_errno;
|
||||
#endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
|
||||
|
||||
struct hostent *lwip_gethostbyname(const char *name);
|
||||
int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
|
||||
size_t buflen, struct hostent **result, int *h_errnop);
|
||||
void lwip_freeaddrinfo(struct addrinfo *ai);
|
||||
int lwip_getaddrinfo(const char *nodename,
|
||||
const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **res);
|
||||
|
||||
#if LWIP_COMPAT_SOCKETS
|
||||
#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 */
|
||||
|
||||
#define gethostbyname(name) lwip_gethostbyname(name)
|
||||
#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
|
||||
lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
|
||||
#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo)
|
||||
#define getaddrinfo(nodname, servname, hints, res) \
|
||||
lwip_getaddrinfo(nodname, servname, hints, res)
|
||||
#endif /* LWIP_COMPAT_SOCKET_ADDR == 1 */
|
||||
#endif /* LWIP_COMPAT_SOCKETS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_DNS && LWIP_SOCKET */
|
||||
|
||||
#endif /* LWIP_HDR_NETDB_H */
|
||||
@@ -1,451 +0,0 @@
|
||||
/*
|
||||
* 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_NETIF_H
|
||||
#define LWIP_HDR_NETIF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#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
|
||||
|
||||
/* Throughout this file, IP addresses are expected to be in
|
||||
* the same byte order as in IP_PCB. */
|
||||
|
||||
/** Must be the maximum of all used hardware address lengths
|
||||
across all types of interfaces in use.
|
||||
This does not have to be changed, normally. */
|
||||
#ifndef NETIF_MAX_HWADDR_LEN
|
||||
#define NETIF_MAX_HWADDR_LEN 6U
|
||||
#endif
|
||||
|
||||
/** Whether the network interface is 'up'. This is
|
||||
* a software flag used to control whether this network
|
||||
* interface is enabled and processes traffic.
|
||||
* It must be set by the startup code before this netif can be used
|
||||
* (also for dhcp/autoip).
|
||||
*/
|
||||
#define NETIF_FLAG_UP 0x01U
|
||||
/** If set, the netif has broadcast capability.
|
||||
* Set by the netif driver in its init function. */
|
||||
#define NETIF_FLAG_BROADCAST 0x02U
|
||||
/** If set, the interface has an active link
|
||||
* (set by the network interface driver).
|
||||
* Either set by the netif driver in its init function (if the link
|
||||
* is up at that time) or at a later point once the link comes up
|
||||
* (if link detection is supported by the hardware). */
|
||||
#define NETIF_FLAG_LINK_UP 0x04U
|
||||
/** If set, the netif is an ethernet device using ARP.
|
||||
* Set by the netif driver in its init function.
|
||||
* Used to check input packet types and use of DHCP. */
|
||||
#define NETIF_FLAG_ETHARP 0x08U
|
||||
/** If set, the netif is an ethernet device. It might not use
|
||||
* ARP or TCP/IP if it is used for PPPoE only.
|
||||
*/
|
||||
#define NETIF_FLAG_ETHERNET 0x10U
|
||||
/** If set, the netif has IGMP capability.
|
||||
* Set by the netif driver in its init function. */
|
||||
#define NETIF_FLAG_IGMP 0x20U
|
||||
/** If set, the netif has MLD6 capability.
|
||||
* Set by the netif driver in its init function. */
|
||||
#define NETIF_FLAG_MLD6 0x40U
|
||||
|
||||
#if LWIP_CHECKSUM_CTRL_PER_NETIF
|
||||
#define NETIF_CHECKSUM_GEN_IP 0x0001
|
||||
#define NETIF_CHECKSUM_GEN_UDP 0x0002
|
||||
#define NETIF_CHECKSUM_GEN_TCP 0x0004
|
||||
#define NETIF_CHECKSUM_GEN_ICMP 0x0008
|
||||
#define NETIF_CHECKSUM_GEN_ICMP6 0x0010
|
||||
#define NETIF_CHECKSUM_CHECK_IP 0x0100
|
||||
#define NETIF_CHECKSUM_CHECK_UDP 0x0200
|
||||
#define NETIF_CHECKSUM_CHECK_TCP 0x0400
|
||||
#define NETIF_CHECKSUM_CHECK_ICMP 0x0800
|
||||
#define NETIF_CHECKSUM_CHECK_ICMP6 0x1000
|
||||
#define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF
|
||||
#define NETIF_CHECKSUM_DISABLE_ALL 0x0000
|
||||
#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */
|
||||
|
||||
struct netif;
|
||||
|
||||
/** Function prototype for netif init functions. Set up flags and output/linkoutput
|
||||
* callback functions in this function.
|
||||
*
|
||||
* @param netif The netif to initialize
|
||||
*/
|
||||
typedef err_t (*netif_init_fn)(struct netif *netif);
|
||||
/** Function prototype for netif->input functions. This function is saved as 'input'
|
||||
* callback function in the netif struct. Call it when a packet has been received.
|
||||
*
|
||||
* @param p The received packet, copied into a pbuf
|
||||
* @param inp The netif which received the packet
|
||||
*/
|
||||
typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp);
|
||||
|
||||
#if LWIP_IPV4
|
||||
/** Function prototype for netif->output functions. Called by lwIP when a packet
|
||||
* shall be sent. For ethernet netif, set this to 'etharp_output' and set
|
||||
* 'linkoutput'.
|
||||
*
|
||||
* @param netif The netif which shall send a packet
|
||||
* @param p The packet to send (p->payload points to IP header)
|
||||
* @param ipaddr The IP address to which the packet shall be sent
|
||||
*/
|
||||
typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p,
|
||||
const ip4_addr_t *ipaddr);
|
||||
#endif /* LWIP_IPV4*/
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** Function prototype for netif->output_ip6 functions. Called by lwIP when a packet
|
||||
* shall be sent. For ethernet netif, set this to 'ethip6_output' and set
|
||||
* 'linkoutput'.
|
||||
*
|
||||
* @param netif The netif which shall send a packet
|
||||
* @param p The packet to send (p->payload points to IP header)
|
||||
* @param ipaddr The IPv6 address to which the packet shall be sent
|
||||
*/
|
||||
typedef err_t (*netif_output_ip6_fn)(struct netif *netif, struct pbuf *p,
|
||||
const ip6_addr_t *ipaddr);
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/** Function prototype for netif->linkoutput functions. Only used for ethernet
|
||||
* netifs. This function is called by ARP when a packet shall be sent.
|
||||
*
|
||||
* @param netif The netif which shall send a packet
|
||||
* @param p The packet to send (raw ethernet packet)
|
||||
*/
|
||||
typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p);
|
||||
/** Function prototype for netif status- or link-callback functions. */
|
||||
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);
|
||||
#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);
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
|
||||
|
||||
#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 */
|
||||
struct netif {
|
||||
/** pointer to next in linked list */
|
||||
struct netif *next;
|
||||
|
||||
#if LWIP_IPV4
|
||||
/** IP address configuration in network byte order */
|
||||
ip_addr_t ip_addr;
|
||||
ip_addr_t netmask;
|
||||
ip_addr_t gw;
|
||||
#endif /* LWIP_IPV4 */
|
||||
#if LWIP_IPV6
|
||||
/** Array of IPv6 addresses for this netif. */
|
||||
ip_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES];
|
||||
/** The state of each IPv6 address (Tentative, Preferred, etc).
|
||||
* @see ip6_addr.h */
|
||||
u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES];
|
||||
#if ESP_LWIP
|
||||
void (*ipv6_addr_cb)(struct netif* netif, u8_t ip_idex); /* callback for ipv6 addr states changed */
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
/** This function is called by the network device driver
|
||||
* to pass a packet up the TCP/IP stack. */
|
||||
netif_input_fn input;
|
||||
#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. */
|
||||
netif_output_fn output;
|
||||
#endif /* LWIP_IPV4 */
|
||||
/** This function is called by the ARP module 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. */
|
||||
netif_output_ip6_fn output_ip6;
|
||||
#endif /* LWIP_IPV6 */
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
/** This function is called when the netif state is set to up or down
|
||||
*/
|
||||
netif_status_callback_fn status_callback;
|
||||
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
/** This function is called when the netif link is set to up or down
|
||||
*/
|
||||
netif_status_callback_fn link_callback;
|
||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||
#if LWIP_NETIF_REMOVE_CALLBACK
|
||||
/** This function is called when the netif has been removed */
|
||||
netif_status_callback_fn remove_callback;
|
||||
#endif /* LWIP_NETIF_REMOVE_CALLBACK */
|
||||
/** 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;
|
||||
|
||||
#if ESP_LWIP
|
||||
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) */
|
||||
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;
|
||||
/** (estimate) link speed */
|
||||
u32_t link_speed;
|
||||
/** timestamp at last change made (up/down) */
|
||||
u32_t ts;
|
||||
/** 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 */
|
||||
#if ENABLE_LOOPBACK
|
||||
/* List of packets to be queued for ourselves. */
|
||||
struct pbuf *loop_first;
|
||||
struct pbuf *loop_last;
|
||||
#if LWIP_LOOPBACK_MAX_PBUFS
|
||||
u16_t loop_cnt_current;
|
||||
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
||||
#endif /* ENABLE_LOOPBACK */
|
||||
|
||||
#if ESP_LWIP
|
||||
void (*l2_buffer_free_notify)(void *user_buf); /* Allows LWIP to notify driver when a L2-supplied pbuf can be freed */
|
||||
ip_addr_t last_ip_addr; /* Store last non-zero ip address */
|
||||
#endif
|
||||
};
|
||||
|
||||
#if LWIP_CHECKSUM_CTRL_PER_NETIF
|
||||
#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \
|
||||
(netif)->chksum_flags = chksumflags; } while(0)
|
||||
#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0))
|
||||
#else /* LWIP_CHECKSUM_CTRL_PER_NETIF */
|
||||
#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags)
|
||||
#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
|
||||
#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */
|
||||
|
||||
/** The list of network interfaces. */
|
||||
extern struct netif *netif_list;
|
||||
/** The default network interface. */
|
||||
extern struct netif *netif_default;
|
||||
|
||||
void netif_init(void);
|
||||
|
||||
struct netif *netif_add(struct netif *netif,
|
||||
#if LWIP_IPV4
|
||||
const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
|
||||
#endif /* LWIP_IPV4 */
|
||||
void *state, netif_init_fn init, netif_input_fn input);
|
||||
#if LWIP_IPV4
|
||||
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 */
|
||||
void netif_remove(struct netif * netif);
|
||||
|
||||
/* Returns a network interface given its name. The name is of the form
|
||||
"et0", where the first two letters are the "name" field in the
|
||||
netif structure, and the digit is in the num field in the same
|
||||
structure. */
|
||||
struct netif *netif_find(const char *name);
|
||||
|
||||
void netif_set_default(struct netif *netif);
|
||||
|
||||
#if LWIP_IPV4
|
||||
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);
|
||||
#define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr)))
|
||||
#define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask)))
|
||||
#define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw)))
|
||||
#define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr))
|
||||
#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 */
|
||||
#define netif_is_up(netif) ( ((netif) && ((netif)->flags & NETIF_FLAG_UP)) ? (u8_t)1 : (u8_t)0)
|
||||
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback);
|
||||
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||
#if LWIP_NETIF_REMOVE_CALLBACK
|
||||
void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback);
|
||||
#endif /* LWIP_NETIF_REMOVE_CALLBACK */
|
||||
|
||||
void netif_set_link_up(struct netif *netif);
|
||||
void netif_set_link_down(struct netif *netif);
|
||||
/** Ask if a link is up */
|
||||
#define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
|
||||
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback);
|
||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
|
||||
#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
#if LWIP_IGMP
|
||||
#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
|
||||
#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)
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
|
||||
#if ENABLE_LOOPBACK
|
||||
err_t netif_loop_output(struct netif *netif, struct pbuf *p);
|
||||
void netif_poll(struct netif *netif);
|
||||
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
|
||||
void netif_poll_all(void);
|
||||
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
||||
#endif /* ENABLE_LOOPBACK */
|
||||
|
||||
#if LWIP_IPV6
|
||||
#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
|
||||
#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)
|
||||
#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))
|
||||
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);
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#if LWIP_NETIF_HWADDRHINT
|
||||
#define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint))
|
||||
#else /* LWIP_NETIF_HWADDRHINT */
|
||||
#define NETIF_SET_HWADDRHINT(netif, hint)
|
||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_NETIF_H */
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* 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_NETIFAPI_H
|
||||
#define LWIP_HDR_NETIFAPI_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
#define NETIFAPI_IPADDR_DEF(type, m) type m
|
||||
#else /* LWIP_MPU_COMPATIBLE */
|
||||
#define NETIFAPI_IPADDR_DEF(type, m) const type * m
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
|
||||
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 netif *netif;
|
||||
union {
|
||||
struct {
|
||||
#if LWIP_IPV4
|
||||
NETIFAPI_IPADDR_DEF(ip4_addr_t, ipaddr);
|
||||
NETIFAPI_IPADDR_DEF(ip4_addr_t, netmask);
|
||||
NETIFAPI_IPADDR_DEF(ip4_addr_t, gw);
|
||||
#endif /* LWIP_IPV4 */
|
||||
void *state;
|
||||
netif_init_fn init;
|
||||
netif_input_fn input;
|
||||
} add;
|
||||
struct {
|
||||
netifapi_void_fn voidfunc;
|
||||
netifapi_errt_fn errtfunc;
|
||||
} common;
|
||||
} msg;
|
||||
};
|
||||
|
||||
|
||||
/* API for application */
|
||||
err_t netifapi_netif_add(struct netif *netif,
|
||||
#if LWIP_IPV4
|
||||
const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
|
||||
#endif /* LWIP_IPV4 */
|
||||
void *state, netif_init_fn init, netif_input_fn input);
|
||||
|
||||
#if LWIP_IPV4
|
||||
err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
||||
const ip4_addr_t *netmask, const ip4_addr_t *gw);
|
||||
#endif /* LWIP_IPV4*/
|
||||
|
||||
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)
|
||||
#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
|
||||
#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
|
||||
#define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL)
|
||||
#define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew)
|
||||
#define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release)
|
||||
#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
|
||||
#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_NETIF_API */
|
||||
|
||||
#endif /* LWIP_HDR_NETIFAPI_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,234 +0,0 @@
|
||||
/*
|
||||
* 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_PBUF_H
|
||||
#define LWIP_HDR_PBUF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** LWIP_SUPPORT_CUSTOM_PBUF==1: Custom pbufs behave much like their pbuf type
|
||||
* but they are allocated by external code (initialised by calling
|
||||
* pbuf_alloced_custom()) and when pbuf_free gives up their last reference, they
|
||||
* are freed by calling pbuf_custom->custom_free_function().
|
||||
* 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))
|
||||
#endif
|
||||
|
||||
/* @todo: We need a mechanism to prevent wasting memory in every pbuf
|
||||
(TCP vs. UDP, IPv4 vs. IPv6: UDP/IPv4 packets may waste up to 28 bytes) */
|
||||
|
||||
#define PBUF_TRANSPORT_HLEN 20
|
||||
#if LWIP_IPV6
|
||||
#define PBUF_IP_HLEN 40
|
||||
#else
|
||||
#define PBUF_IP_HLEN 20
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PBUF_TRANSPORT,
|
||||
PBUF_IP,
|
||||
PBUF_LINK,
|
||||
PBUF_RAW_TX,
|
||||
PBUF_RAW
|
||||
} pbuf_layer;
|
||||
|
||||
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)
|
||||
pbuf_alloc() allocates PBUF_RAM pbufs as unchained pbufs (although that might
|
||||
change in future versions) */
|
||||
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
|
||||
have to be copied when queued for transmission. */
|
||||
PBUF_ROM,
|
||||
/** pbuf comes from the pbuf pool. Much like PBUF_ROM but payload might change
|
||||
so it has to be duplicated when queued before transmitting, depending on
|
||||
who has a 'ref' to it. */
|
||||
PBUF_REF,
|
||||
/** 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) */
|
||||
PBUF_POOL
|
||||
} pbuf_type;
|
||||
|
||||
|
||||
/** indicates this packet's data should be immediately passed to the application */
|
||||
#define PBUF_FLAG_PUSH 0x01U
|
||||
/** indicates this is a custom pbuf: pbuf_free calls pbuf_custom->custom_free_function()
|
||||
when the last reference is released (plus custom PBUF_RAM cannot be trimmed) */
|
||||
#define PBUF_FLAG_IS_CUSTOM 0x02U
|
||||
/** indicates this pbuf is UDP multicast to be looped back */
|
||||
#define PBUF_FLAG_MCASTLOOP 0x04U
|
||||
/** indicates this pbuf was received as link-level broadcast */
|
||||
#define PBUF_FLAG_LLBCAST 0x08U
|
||||
/** indicates this pbuf was received as link-level multicast */
|
||||
#define PBUF_FLAG_LLMCAST 0x10U
|
||||
/** indicates this pbuf includes a TCP FIN flag */
|
||||
#define PBUF_FLAG_TCP_FIN 0x20U
|
||||
|
||||
struct pbuf {
|
||||
/** next pbuf in singly linked pbuf chain */
|
||||
struct pbuf *next;
|
||||
|
||||
/** pointer to the actual data in the buffer */
|
||||
void *payload;
|
||||
|
||||
/**
|
||||
* total length of this buffer and all next buffers in chain
|
||||
* belonging to the same packet.
|
||||
*
|
||||
* For non-queue packet chains this is the invariant:
|
||||
* p->tot_len == p->len + (p->next? p->next->tot_len: 0)
|
||||
*/
|
||||
u16_t tot_len;
|
||||
|
||||
/** length of this buffer */
|
||||
u16_t len;
|
||||
|
||||
/** pbuf_type as u8_t instead of enum to save space */
|
||||
u8_t /*pbuf_type*/ type;
|
||||
|
||||
/** misc flags */
|
||||
u8_t flags;
|
||||
|
||||
/**
|
||||
* the reference count always equals the number of pointers
|
||||
* that refer to this pbuf. This can be pointers from an application,
|
||||
* the stack itself, or pbuf->next pointers from a chain.
|
||||
*/
|
||||
u16_t ref;
|
||||
|
||||
#if ESP_LWIP
|
||||
struct netif *l2_owner;
|
||||
void *l2_buf;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/** Helper struct for const-correctness only.
|
||||
* The only meaning of this one is to provide a const payload pointer
|
||||
* for PBUF_ROM type.
|
||||
*/
|
||||
struct pbuf_rom {
|
||||
/** next pbuf in singly linked pbuf chain */
|
||||
struct pbuf *next;
|
||||
|
||||
/** pointer to the actual data in the buffer */
|
||||
const void *payload;
|
||||
};
|
||||
|
||||
#if LWIP_SUPPORT_CUSTOM_PBUF
|
||||
/** Prototype for a function to free a custom pbuf */
|
||||
typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
|
||||
|
||||
/** A custom pbuf: like a pbuf, but following a function pointer to free it. */
|
||||
struct pbuf_custom {
|
||||
/** The actual pbuf */
|
||||
struct pbuf pbuf;
|
||||
/** This function is called when pbuf_free deallocates this pbuf(_custom) */
|
||||
pbuf_free_custom_fn custom_free_function;
|
||||
};
|
||||
#endif /* LWIP_SUPPORT_CUSTOM_PBUF */
|
||||
|
||||
|
||||
/** 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 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()
|
||||
at regular intervals from main level to check if ooseq pbufs need to be
|
||||
freed! */
|
||||
#define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \
|
||||
/* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \
|
||||
ooseq queued pbufs now */ \
|
||||
pbuf_free_ooseq(); }}while(0)
|
||||
#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()
|
||||
|
||||
struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
|
||||
#if LWIP_SUPPORT_CUSTOM_PBUF
|
||||
struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
|
||||
struct pbuf_custom *p, void *payload_mem,
|
||||
u16_t payload_mem_len);
|
||||
#endif /* LWIP_SUPPORT_CUSTOM_PBUF */
|
||||
void pbuf_realloc(struct pbuf *p, u16_t size);
|
||||
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);
|
||||
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_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);
|
||||
struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
|
||||
u16_t len, u16_t *chksum);
|
||||
#endif /* LWIP_CHECKSUM_ON_COPY */
|
||||
#if LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE
|
||||
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);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_PBUF_H */
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* 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_PPPAPI_H__
|
||||
#define __LWIP_PPPAPI_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_PPP_API /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
#include "netif/ppp/ppp.h"
|
||||
#if PPPOS_SUPPORT
|
||||
#include "netif/ppp/pppos.h"
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct pppapi_msg_msg {
|
||||
ppp_pcb *ppp;
|
||||
union {
|
||||
struct {
|
||||
u8_t authtype;
|
||||
const char *user;
|
||||
const char *passwd;
|
||||
} setauth;
|
||||
#if PPP_NOTIFY_PHASE
|
||||
struct {
|
||||
ppp_notify_phase_cb_fn notify_phase_cb;
|
||||
} setnotifyphasecb;
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
#if PPPOS_SUPPORT
|
||||
struct {
|
||||
struct netif *pppif;
|
||||
pppos_output_cb_fn output_cb;
|
||||
ppp_link_status_cb_fn link_status_cb;
|
||||
void *ctx_cb;
|
||||
} serialcreate;
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
#if PPPOE_SUPPORT
|
||||
struct {
|
||||
struct netif *pppif;
|
||||
struct netif *ethif;
|
||||
const char *service_name;
|
||||
const char *concentrator_name;
|
||||
ppp_link_status_cb_fn link_status_cb;
|
||||
void *ctx_cb;
|
||||
} ethernetcreate;
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
struct {
|
||||
struct netif *pppif;
|
||||
struct netif *netif;
|
||||
ip_addr_t *ipaddr;
|
||||
u16_t port;
|
||||
#if PPPOL2TP_AUTH_SUPPORT
|
||||
const u8_t *secret;
|
||||
u8_t secret_len;
|
||||
#endif /* PPPOL2TP_AUTH_SUPPORT */
|
||||
ppp_link_status_cb_fn link_status_cb;
|
||||
void *ctx_cb;
|
||||
} l2tpcreate;
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
struct {
|
||||
u16_t holdoff;
|
||||
} connect;
|
||||
#if PPP_SERVER
|
||||
struct {
|
||||
struct ppp_addrs *addrs;
|
||||
} listen;
|
||||
#endif /* PPP_SERVER */
|
||||
struct {
|
||||
u8_t nocarrier;
|
||||
} close;
|
||||
struct {
|
||||
u8_t cmd;
|
||||
void *arg;
|
||||
} ioctl;
|
||||
} msg;
|
||||
};
|
||||
|
||||
struct pppapi_msg {
|
||||
struct tcpip_api_call call;
|
||||
struct pppapi_msg_msg msg;
|
||||
};
|
||||
|
||||
/* API for application */
|
||||
void pppapi_set_default(ppp_pcb *pcb);
|
||||
void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
|
||||
#if PPP_NOTIFY_PHASE
|
||||
void pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
#if PPPOS_SUPPORT
|
||||
ppp_pcb *pppapi_pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
#if PPPOE_SUPPORT
|
||||
ppp_pcb *pppapi_pppoe_create(struct netif *pppif, struct netif *ethif, const char *service_name,
|
||||
const char *concentrator_name, ppp_link_status_cb_fn link_status_cb,
|
||||
void *ctx_cb);
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
|
||||
const u8_t *secret, u8_t secret_len,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff);
|
||||
#if PPP_SERVER
|
||||
err_t pppapi_listen(ppp_pcb *pcb, struct ppp_addrs *addrs);
|
||||
#endif /* PPP_SERVER */
|
||||
err_t pppapi_close(ppp_pcb *pcb, u8_t nocarrier);
|
||||
err_t pppapi_free(ppp_pcb *pcb);
|
||||
err_t pppapi_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_PPP_API */
|
||||
|
||||
#endif /* __LWIP_PPPAPI_H__ */
|
||||
@@ -1,259 +0,0 @@
|
||||
/*
|
||||
* 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_API_MSG_H
|
||||
#define LWIP_HDR_API_MSG_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
|
||||
/* 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/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/api.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 */
|
||||
|
||||
/* For the netconn API, these values are use as a bitmask! */
|
||||
#define NETCONN_SHUT_RD 1
|
||||
#define NETCONN_SHUT_WR 2
|
||||
#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR)
|
||||
|
||||
/* IP addresses and port numbers are expected to be in
|
||||
* the same byte order as in the corresponding pcb.
|
||||
*/
|
||||
/** 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 {
|
||||
/** 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;
|
||||
/** The return value of the function executed in tcpip_thread. */
|
||||
err_t err;
|
||||
/** Depending on the executed function, one of these union members is used */
|
||||
union {
|
||||
/** used for lwip_netconn_do_send */
|
||||
struct netbuf *b;
|
||||
/** used for lwip_netconn_do_newconn */
|
||||
struct {
|
||||
u8_t proto;
|
||||
} n;
|
||||
/** used for lwip_netconn_do_bind and lwip_netconn_do_connect */
|
||||
struct {
|
||||
API_MSG_M_DEF_C(ip_addr_t, ipaddr);
|
||||
u16_t port;
|
||||
} bc;
|
||||
/** used for lwip_netconn_do_getaddr */
|
||||
struct {
|
||||
ip_addr_t API_MSG_M_DEF(ipaddr);
|
||||
u16_t API_MSG_M_DEF(port);
|
||||
u8_t local;
|
||||
} ad;
|
||||
/** used for lwip_netconn_do_write */
|
||||
struct {
|
||||
const void *dataptr;
|
||||
size_t len;
|
||||
u8_t apiflags;
|
||||
#if LWIP_SO_SNDTIMEO
|
||||
u32_t time_started;
|
||||
#endif /* LWIP_SO_SNDTIMEO */
|
||||
} w;
|
||||
/** used for lwip_netconn_do_recv */
|
||||
struct {
|
||||
u32_t len;
|
||||
} r;
|
||||
#if LWIP_TCP
|
||||
/** used for lwip_netconn_do_close (/shutdown) */
|
||||
struct {
|
||||
u8_t shut;
|
||||
#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER
|
||||
u32_t time_started;
|
||||
#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
|
||||
u8_t polls_left;
|
||||
#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
|
||||
} sd;
|
||||
#endif /* LWIP_TCP */
|
||||
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
|
||||
/** used for lwip_netconn_do_join_leave_group */
|
||||
struct {
|
||||
API_MSG_M_DEF_C(ip_addr_t, multiaddr);
|
||||
API_MSG_M_DEF_C(ip_addr_t, netif_addr);
|
||||
enum netconn_igmp join_or_leave;
|
||||
} jl;
|
||||
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
struct {
|
||||
u8_t backlog;
|
||||
} lb;
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
} msg;
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
sys_sem_t* op_completed_sem;
|
||||
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
};
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
#define LWIP_API_MSG_SEM(msg) ((msg)->op_completed_sem)
|
||||
#else /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
#define LWIP_API_MSG_SEM(msg) (&(msg)->conn->op_completed)
|
||||
#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).
|
||||
lwip_netconn_do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
|
||||
(see netconn_gethostbyname). */
|
||||
struct dns_api_msg {
|
||||
/** Hostname to query or dotted IP address string */
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
char name[DNS_MAX_NAME_LENGTH];
|
||||
#else /* LWIP_MPU_COMPATIBLE */
|
||||
const char *name;
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
/** The resolved address is stored here */
|
||||
ip_addr_t API_MSG_M_DEF(addr);
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/** Type of resolve call */
|
||||
u8_t dns_addrtype;
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
/** This semaphore is posted when the name is resolved, the application thread
|
||||
should wait on it. */
|
||||
sys_sem_t API_MSG_M_DEF_SEM(sem);
|
||||
/** Errors are given back here */
|
||||
err_t API_MSG_M_DEF(err);
|
||||
};
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
#if ESP_THREAD_SAFE
|
||||
#define LWIP_NETCONN_THREAD_SEM_GET() sys_thread_sem_get()
|
||||
#define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_thread_sem_init()
|
||||
#define LWIP_NETCONN_THREAD_SEM_FREE() sys_thread_sem_deinit()
|
||||
#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 */
|
||||
|
||||
void lwip_netconn_do_newconn (void *m);
|
||||
void lwip_netconn_do_delconn (void *m);
|
||||
void lwip_netconn_do_bind (void *m);
|
||||
void lwip_netconn_do_connect (void *m);
|
||||
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
|
||||
void lwip_netconn_do_write (void *m);
|
||||
void lwip_netconn_do_getaddr (void *m);
|
||||
void lwip_netconn_do_close (void *m);
|
||||
void lwip_netconn_do_shutdown (void *m);
|
||||
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
|
||||
void lwip_netconn_do_join_leave_group(void *m);
|
||||
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
|
||||
|
||||
#if LWIP_DNS
|
||||
void lwip_netconn_do_gethostbyname(void *arg);
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
|
||||
void netconn_free(struct netconn *conn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_NETCONN || LWIP_SOCKET */
|
||||
|
||||
#endif /* LWIP_HDR_API_MSG_H */
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* 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_MEMP_PRIV_H
|
||||
#define LWIP_HDR_MEMP_PRIV_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lwip/mem.h"
|
||||
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
/* if MEMP_OVERFLOW_CHECK is turned on, we reserve some bytes at the beginning
|
||||
* and at the end of each element, initialize them as 0xcd and check
|
||||
* them later. */
|
||||
/* If MEMP_OVERFLOW_CHECK is >= 2, on every call to memp_malloc or memp_free,
|
||||
* every single element in each pool is checked!
|
||||
* This is VERY SLOW but also very helpful. */
|
||||
/* MEMP_SANITY_REGION_BEFORE and MEMP_SANITY_REGION_AFTER can be overridden in
|
||||
* lwipopts.h to change the amount reserved for checking. */
|
||||
#ifndef MEMP_SANITY_REGION_BEFORE
|
||||
#define MEMP_SANITY_REGION_BEFORE 16
|
||||
#endif /* MEMP_SANITY_REGION_BEFORE*/
|
||||
#if MEMP_SANITY_REGION_BEFORE > 0
|
||||
#define MEMP_SANITY_REGION_BEFORE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_BEFORE)
|
||||
#else
|
||||
#define MEMP_SANITY_REGION_BEFORE_ALIGNED 0
|
||||
#endif /* MEMP_SANITY_REGION_BEFORE*/
|
||||
#ifndef MEMP_SANITY_REGION_AFTER
|
||||
#define MEMP_SANITY_REGION_AFTER 16
|
||||
#endif /* MEMP_SANITY_REGION_AFTER*/
|
||||
#if MEMP_SANITY_REGION_AFTER > 0
|
||||
#define MEMP_SANITY_REGION_AFTER_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_AFTER)
|
||||
#else
|
||||
#define MEMP_SANITY_REGION_AFTER_ALIGNED 0
|
||||
#endif /* MEMP_SANITY_REGION_AFTER*/
|
||||
|
||||
/* MEMP_SIZE: save space for struct memp and for sanity check */
|
||||
#define MEMP_SIZE (LWIP_MEM_ALIGN_SIZE(sizeof(struct memp)) + MEMP_SANITY_REGION_BEFORE_ALIGNED)
|
||||
#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x) + MEMP_SANITY_REGION_AFTER_ALIGNED)
|
||||
|
||||
#else /* MEMP_OVERFLOW_CHECK */
|
||||
|
||||
/* No sanity checks
|
||||
* We don't need to preserve the struct memp while not allocated, so we
|
||||
* can save a little space and set MEMP_SIZE to 0.
|
||||
*/
|
||||
#define MEMP_SIZE 0
|
||||
#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x))
|
||||
|
||||
#endif /* MEMP_OVERFLOW_CHECK */
|
||||
|
||||
struct memp {
|
||||
struct memp *next;
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
const char *file;
|
||||
int line;
|
||||
#endif /* MEMP_OVERFLOW_CHECK */
|
||||
};
|
||||
|
||||
#if MEM_USE_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:
|
||||
MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
|
||||
MEMP_POOL_HELPER_FIRST = ((u8_t)
|
||||
#define LWIP_MEMPOOL(name,num,size,desc)
|
||||
#define LWIP_MALLOC_MEMPOOL_START 1
|
||||
#define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
|
||||
#define LWIP_MALLOC_MEMPOOL_END
|
||||
#include "lwip/priv/memp_std.h"
|
||||
) ,
|
||||
/* Get the last (via:
|
||||
MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
|
||||
MEMP_POOL_HELPER_LAST = ((u8_t)
|
||||
#define LWIP_MEMPOOL(name,num,size,desc)
|
||||
#define LWIP_MALLOC_MEMPOOL_START
|
||||
#define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
|
||||
#define LWIP_MALLOC_MEMPOOL_END 1
|
||||
#include "lwip/priv/memp_std.h"
|
||||
)
|
||||
} memp_pool_helper_t;
|
||||
|
||||
/* The actual start and stop values are here (cast them over)
|
||||
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 */
|
||||
|
||||
struct memp_desc {
|
||||
/** Element size */
|
||||
u16_t size;
|
||||
|
||||
#if !MEMP_MEM_MALLOC
|
||||
/** 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;
|
||||
|
||||
/** 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
|
||||
#define DECLARE_LWIP_MEMPOOL_DESC(desc) (desc),
|
||||
#else
|
||||
#define DECLARE_LWIP_MEMPOOL_DESC(desc)
|
||||
#endif
|
||||
|
||||
void memp_init_pool(const struct memp_desc *desc);
|
||||
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
void *memp_malloc_pool_fn(const struct memp_desc* desc, const char* file, const int line);
|
||||
#define memp_malloc_pool(d) memp_malloc_pool_fn((d), __FILE__, __LINE__)
|
||||
#else
|
||||
void *memp_malloc_pool(const struct memp_desc *desc);
|
||||
#endif
|
||||
void memp_free_pool(const struct memp_desc* desc, void *mem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_MEMP_PRIV_H */
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* SETUP: Make sure we define everything we will need.
|
||||
*
|
||||
* We have create three types of pools:
|
||||
* 1) MEMPOOL - standard pools
|
||||
* 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
|
||||
* 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
|
||||
*
|
||||
* If the include'r doesn't require any special treatment of each of the types
|
||||
* above, then will declare #2 & #3 to be just standard mempools.
|
||||
*/
|
||||
#ifndef LWIP_MALLOC_MEMPOOL
|
||||
/* This treats "malloc pools" just like any other pool.
|
||||
The pools are a little bigger to provide 'size' as the amount of user data. */
|
||||
#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size)
|
||||
#define LWIP_MALLOC_MEMPOOL_START
|
||||
#define LWIP_MALLOC_MEMPOOL_END
|
||||
#endif /* LWIP_MALLOC_MEMPOOL */
|
||||
|
||||
#ifndef LWIP_PBUF_MEMPOOL
|
||||
/* This treats "pbuf pools" just like any other pool.
|
||||
* Allocates buffers for a pbuf struct AND a payload size */
|
||||
#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
|
||||
#endif /* LWIP_PBUF_MEMPOOL */
|
||||
|
||||
|
||||
/*
|
||||
* A list of internal pools used by LWIP.
|
||||
*
|
||||
* LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
|
||||
* creates a pool name MEMP_pool_name. description is used in stats.c
|
||||
*/
|
||||
#if LWIP_RAW
|
||||
LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB")
|
||||
#endif /* LWIP_RAW */
|
||||
|
||||
#if LWIP_UDP
|
||||
LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB")
|
||||
#endif /* LWIP_UDP */
|
||||
|
||||
#if LWIP_TCP
|
||||
LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB")
|
||||
LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
|
||||
LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG")
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#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)
|
||||
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 */
|
||||
|
||||
#if LWIP_NETCONN || LWIP_SOCKET
|
||||
LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF")
|
||||
LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN")
|
||||
#endif /* LWIP_NETCONN || LWIP_SOCKET */
|
||||
|
||||
#if NO_SYS==0
|
||||
LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API")
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
LWIP_MEMPOOL(API_MSG, MEMP_NUM_API_MSG, sizeof(struct api_msg), "API_MSG")
|
||||
#if LWIP_DNS
|
||||
LWIP_MEMPOOL(DNS_API_MSG, MEMP_NUM_DNS_API_MSG, sizeof(struct dns_api_msg), "DNS_API_MSG")
|
||||
#endif
|
||||
#if LWIP_SOCKET && !LWIP_TCPIP_CORE_LOCKING
|
||||
LWIP_MEMPOOL(SOCKET_SETGETSOCKOPT_DATA, MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA, sizeof(struct lwip_setgetsockopt_data), "SOCKET_SETGETSOCKOPT_DATA")
|
||||
#endif
|
||||
#if LWIP_NETIF_API
|
||||
LWIP_MEMPOOL(NETIFAPI_MSG, MEMP_NUM_NETIFAPI_MSG, sizeof(struct netifapi_msg), "NETIFAPI_MSG")
|
||||
#endif
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
#if !LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||
LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT")
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
|
||||
#endif /* NO_SYS==0 */
|
||||
|
||||
#if LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING
|
||||
LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE")
|
||||
#endif /* LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING */
|
||||
|
||||
#if LWIP_IGMP
|
||||
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 */
|
||||
LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT")
|
||||
#endif /* LWIP_TIMERS */
|
||||
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB")
|
||||
#endif /* LWIP_DNS && LWIP_SOCKET */
|
||||
#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
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 */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_IPV6_REASS
|
||||
LWIP_MEMPOOL(IP6_REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip6_reassdata), "IP6_REASSDATA")
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
||||
LWIP_MEMPOOL(MLD6_GROUP, MEMP_NUM_MLD6_GROUP, sizeof(struct mld_group), "MLD6_GROUP")
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
|
||||
|
||||
|
||||
/*
|
||||
* A list of pools of pbuf's used by LWIP.
|
||||
*
|
||||
* LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
|
||||
* creates a pool name MEMP_pool_name. description is used in stats.c
|
||||
* This allocates enough space for the pbuf struct and a payload.
|
||||
* (Example: pbuf_payload_size=0 allocates only size for the struct)
|
||||
*/
|
||||
LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM")
|
||||
LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL")
|
||||
|
||||
|
||||
/*
|
||||
* Allow for user-defined pools; this must be explicitly set in lwipopts.h
|
||||
* since the default is to NOT look for lwippools.h
|
||||
*/
|
||||
#if MEMP_USE_CUSTOM_POOLS
|
||||
#include "lwippools.h"
|
||||
#endif /* MEMP_USE_CUSTOM_POOLS */
|
||||
|
||||
/*
|
||||
* REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
|
||||
* (#undef is ignored for something that is not defined)
|
||||
*/
|
||||
#undef LWIP_MEMPOOL
|
||||
#undef LWIP_MALLOC_MEMPOOL
|
||||
#undef LWIP_MALLOC_MEMPOOL_START
|
||||
#undef LWIP_MALLOC_MEMPOOL_END
|
||||
#undef LWIP_PBUF_MEMPOOL
|
||||
@@ -1,545 +0,0 @@
|
||||
/*
|
||||
* 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_TCP_IMPL_H
|
||||
#define LWIP_HDR_TCP_IMPL_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/icmp.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/ip6.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Functions for interfacing with TCP: */
|
||||
|
||||
/* Lower layer interface to TCP: */
|
||||
void tcp_init (void); /* Initialize this module. */
|
||||
void tcp_tmr (void); /* Must be called every
|
||||
TCP_TMR_INTERVAL
|
||||
ms. (Typically 250 ms). */
|
||||
/* It is also possible to call these two functions at the right
|
||||
intervals (instead of calling tcp_tmr()). */
|
||||
void tcp_slowtmr (void);
|
||||
void tcp_fasttmr (void);
|
||||
|
||||
/* Call this from a netif driver (watch out for threading issues!) that has
|
||||
returned a memory error on transmit and now has free buffers to send more.
|
||||
This iterates all active pcbs that had an error and tries to call
|
||||
tcp_output, so use this with care as it might slow down the system. */
|
||||
void tcp_txnow (void);
|
||||
|
||||
/* Only used by IP to pass a TCP segment to TCP: */
|
||||
void tcp_input (struct pbuf *p, struct netif *inp);
|
||||
/* Used within the TCP code only: */
|
||||
struct tcp_pcb * tcp_alloc (u8_t prio);
|
||||
void tcp_abandon (struct tcp_pcb *pcb, int reset);
|
||||
err_t tcp_send_empty_ack(struct tcp_pcb *pcb);
|
||||
void tcp_rexmit (struct tcp_pcb *pcb);
|
||||
void tcp_rexmit_rto (struct tcp_pcb *pcb);
|
||||
void tcp_rexmit_fast (struct tcp_pcb *pcb);
|
||||
u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb);
|
||||
err_t tcp_process_refused_data(struct tcp_pcb *pcb);
|
||||
|
||||
/**
|
||||
* This is the Nagle algorithm: try to combine user data to send as few TCP
|
||||
* segments as possible. Only send if
|
||||
* - no previously transmitted data on the connection remains unacknowledged or
|
||||
* - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or
|
||||
* - the only unsent segment is at least pcb->mss bytes long (or there is more
|
||||
* than one unsent segment - with lwIP, this can happen although unsent->len < mss)
|
||||
* - or if we are in fast-retransmit (TF_INFR)
|
||||
*/
|
||||
#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \
|
||||
((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))) \
|
||||
) ? 1 : 0)
|
||||
#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK)
|
||||
|
||||
|
||||
#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0)
|
||||
#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0)
|
||||
#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0)
|
||||
#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0)
|
||||
/* is b<=a<=c? */
|
||||
#if 0 /* see bug #10548 */
|
||||
#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. */
|
||||
#endif /* TCP_TMR_INTERVAL */
|
||||
|
||||
#ifndef TCP_FAST_INTERVAL
|
||||
#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */
|
||||
#endif /* TCP_FAST_INTERVAL */
|
||||
|
||||
#ifndef TCP_SLOW_INTERVAL
|
||||
#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */
|
||||
#endif /* TCP_SLOW_INTERVAL */
|
||||
|
||||
#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */
|
||||
#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */
|
||||
|
||||
#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */
|
||||
|
||||
#ifndef TCP_MSL
|
||||
#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */
|
||||
#endif
|
||||
|
||||
/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */
|
||||
#ifndef TCP_KEEPIDLE_DEFAULT
|
||||
#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */
|
||||
#endif
|
||||
|
||||
#ifndef TCP_KEEPINTVL_DEFAULT
|
||||
#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */
|
||||
#endif
|
||||
|
||||
#ifndef TCP_KEEPCNT_DEFAULT
|
||||
#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */
|
||||
#endif
|
||||
|
||||
#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
|
||||
*/
|
||||
#define TF_RESET (u8_t)0x08U /* Connection was reset. */
|
||||
#define TF_CLOSED (u8_t)0x10U /* Connection was successfully closed. */
|
||||
#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */
|
||||
|
||||
|
||||
#if LWIP_EVENT_API
|
||||
|
||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_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)
|
||||
#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_RECV, (p), 0, (err))
|
||||
#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
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))
|
||||
|
||||
#else /* LWIP_EVENT_API */
|
||||
|
||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) \
|
||||
do { \
|
||||
if((pcb)->accept != NULL) \
|
||||
(ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \
|
||||
else (ret) = ERR_ARG; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_EVENT_SENT(pcb,space,ret) \
|
||||
do { \
|
||||
if((pcb)->sent != NULL) \
|
||||
(ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \
|
||||
else (ret) = ERR_OK; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_EVENT_RECV(pcb,p,err,ret) \
|
||||
do { \
|
||||
if((pcb)->recv != NULL) { \
|
||||
(ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\
|
||||
} else { \
|
||||
(ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TCP_EVENT_CLOSED(pcb,ret) \
|
||||
do { \
|
||||
if(((pcb)->recv != NULL)) { \
|
||||
(ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\
|
||||
} else { \
|
||||
(ret) = ERR_OK; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TCP_EVENT_CONNECTED(pcb,err,ret) \
|
||||
do { \
|
||||
if((pcb)->connected != NULL) \
|
||||
(ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \
|
||||
else (ret) = ERR_OK; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_EVENT_POLL(pcb,ret) \
|
||||
do { \
|
||||
if((pcb)->poll != NULL) \
|
||||
(ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \
|
||||
else (ret) = ERR_OK; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_EVENT_ERR(errf,arg,err) \
|
||||
do { \
|
||||
if((errf) != NULL) \
|
||||
(errf)((arg),(err)); \
|
||||
} while (0)
|
||||
|
||||
#endif /* LWIP_EVENT_API */
|
||||
|
||||
/** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */
|
||||
#if TCP_OVERSIZE && defined(LWIP_DEBUG)
|
||||
#define TCP_OVERSIZE_DBGCHECK 1
|
||||
#else
|
||||
#define TCP_OVERSIZE_DBGCHECK 0
|
||||
#endif
|
||||
|
||||
/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */
|
||||
#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP)
|
||||
|
||||
/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */
|
||||
struct tcp_seg {
|
||||
struct tcp_seg *next; /* used when putting segments on a queue */
|
||||
struct pbuf *p; /* buffer containing data + TCP header */
|
||||
u16_t len; /* the TCP length of this segment */
|
||||
#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) */
|
||||
#endif /* TCP_OVERSIZE_DBGCHECK */
|
||||
#if TCP_CHECKSUM_ON_COPY
|
||||
u16_t chksum;
|
||||
u8_t chksum_swapped;
|
||||
#endif /* TCP_CHECKSUM_ON_COPY */
|
||||
u8_t flags;
|
||||
#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */
|
||||
#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */
|
||||
#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is
|
||||
checksummed into 'chksum' */
|
||||
#define TF_SEG_OPTS_WND_SCALE (u8_t)0x08U /* Include WND SCALE option */
|
||||
struct tcp_hdr *tcphdr; /* the TCP header */
|
||||
};
|
||||
|
||||
#define LWIP_TCP_OPT_EOL 0
|
||||
#define LWIP_TCP_OPT_NOP 1
|
||||
#define LWIP_TCP_OPT_MSS 2
|
||||
#define LWIP_TCP_OPT_WS 3
|
||||
#define LWIP_TCP_OPT_TS 8
|
||||
|
||||
#define LWIP_TCP_OPT_LEN_MSS 4
|
||||
#if LWIP_TCP_TIMESTAMPS
|
||||
#define LWIP_TCP_OPT_LEN_TS 10
|
||||
#define LWIP_TCP_OPT_LEN_TS_OUT 12 /* aligned for output (includes NOP padding) */
|
||||
#else
|
||||
#define LWIP_TCP_OPT_LEN_TS_OUT 0
|
||||
#endif
|
||||
#if LWIP_WND_SCALE
|
||||
#define LWIP_TCP_OPT_LEN_WS 3
|
||||
#define LWIP_TCP_OPT_LEN_WS_OUT 4 /* aligned for output (includes NOP padding) */
|
||||
#else
|
||||
#define LWIP_TCP_OPT_LEN_WS_OUT 0
|
||||
#endif
|
||||
|
||||
#define LWIP_TCP_OPT_LENGTH(flags) \
|
||||
(flags & TF_SEG_OPTS_MSS ? LWIP_TCP_OPT_LEN_MSS : 0) + \
|
||||
(flags & TF_SEG_OPTS_TS ? LWIP_TCP_OPT_LEN_TS_OUT : 0) + \
|
||||
(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))
|
||||
|
||||
#if LWIP_WND_SCALE
|
||||
#define TCPWNDSIZE_F U32_F
|
||||
#define TCPWND_MAX 0xFFFFFFFFU
|
||||
#define TCPWND_CHECK16(x) LWIP_ASSERT("window size > 0xFFFF", (x) <= 0xFFFF)
|
||||
#define TCPWND_MIN16(x) ((u16_t)LWIP_MIN((x), 0xFFFF))
|
||||
#else /* LWIP_WND_SCALE */
|
||||
#define TCPWNDSIZE_F U16_F
|
||||
#define TCPWND_MAX 0xFFFFU
|
||||
#define TCPWND_CHECK16(x)
|
||||
#define TCPWND_MIN16(x) x
|
||||
#endif /* LWIP_WND_SCALE */
|
||||
|
||||
/* Global variables: */
|
||||
extern struct tcp_pcb *tcp_input_pcb;
|
||||
extern u32_t tcp_ticks;
|
||||
extern u8_t tcp_active_pcbs_changed;
|
||||
|
||||
/* The TCP PCB lists. */
|
||||
union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */
|
||||
struct tcp_pcb_listen *listen_pcbs;
|
||||
struct tcp_pcb *pcbs;
|
||||
};
|
||||
extern struct tcp_pcb *tcp_bound_pcbs;
|
||||
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
|
||||
extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
|
||||
state in which they accept or send
|
||||
data. */
|
||||
extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
|
||||
|
||||
#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3
|
||||
#define NUM_TCP_PCB_LISTS 4
|
||||
extern struct tcp_pcb ** const tcp_pcb_lists[NUM_TCP_PCB_LISTS];
|
||||
|
||||
/* Axioms about the above lists:
|
||||
1) Every TCP PCB that is not CLOSED is in one of the lists.
|
||||
2) A PCB is only in one of the lists.
|
||||
3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.
|
||||
4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state.
|
||||
*/
|
||||
/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
|
||||
with a PCB list or removes a PCB from a list, respectively. */
|
||||
#ifndef TCP_DEBUG_PCB_LISTS
|
||||
#define TCP_DEBUG_PCB_LISTS 0
|
||||
#endif
|
||||
#if TCP_DEBUG_PCB_LISTS
|
||||
#define TCP_REG(pcbs, npcb) do {\
|
||||
struct tcp_pcb *tcp_tmp_pcb; \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \
|
||||
for (tcp_tmp_pcb = *(pcbs); \
|
||||
tcp_tmp_pcb != NULL; \
|
||||
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
||||
LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \
|
||||
} \
|
||||
LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \
|
||||
(npcb)->next = *(pcbs); \
|
||||
LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \
|
||||
*(pcbs) = (npcb); \
|
||||
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
|
||||
tcp_timer_needed(); \
|
||||
} while(0)
|
||||
#define TCP_RMV(pcbs, npcb) do { \
|
||||
struct tcp_pcb *tcp_tmp_pcb; \
|
||||
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
|
||||
if(*(pcbs) == (npcb)) { \
|
||||
*(pcbs) = (*pcbs)->next; \
|
||||
} else for (tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
||||
if(tcp_tmp_pcb->next == (npcb)) { \
|
||||
tcp_tmp_pcb->next = (npcb)->next; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
(npcb)->next = NULL; \
|
||||
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \
|
||||
} while(0)
|
||||
|
||||
#else /* LWIP_DEBUG */
|
||||
|
||||
#define TCP_REG(pcbs, npcb) \
|
||||
do { \
|
||||
(npcb)->next = *pcbs; \
|
||||
*(pcbs) = (npcb); \
|
||||
tcp_timer_needed(); \
|
||||
} while (0)
|
||||
|
||||
#define TCP_RMV(pcbs, npcb) \
|
||||
do { \
|
||||
if(*(pcbs) == (npcb)) { \
|
||||
(*(pcbs)) = (*pcbs)->next; \
|
||||
} \
|
||||
else { \
|
||||
struct tcp_pcb *tcp_tmp_pcb; \
|
||||
for (tcp_tmp_pcb = *pcbs; \
|
||||
tcp_tmp_pcb != NULL; \
|
||||
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
||||
if(tcp_tmp_pcb->next == (npcb)) { \
|
||||
tcp_tmp_pcb->next = (npcb)->next; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
(npcb)->next = NULL; \
|
||||
} while(0)
|
||||
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
#define TCP_REG_ACTIVE(npcb) \
|
||||
do { \
|
||||
TCP_REG(&tcp_active_pcbs, npcb); \
|
||||
tcp_active_pcbs_changed = 1; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_RMV_ACTIVE(npcb) \
|
||||
do { \
|
||||
TCP_RMV(&tcp_active_pcbs, npcb); \
|
||||
tcp_active_pcbs_changed = 1; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_PCB_REMOVE_ACTIVE(pcb) \
|
||||
do { \
|
||||
tcp_pcb_remove(&tcp_active_pcbs, pcb); \
|
||||
tcp_active_pcbs_changed = 1; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Internal functions: */
|
||||
struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);
|
||||
void tcp_pcb_purge(struct tcp_pcb *pcb);
|
||||
void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);
|
||||
|
||||
void tcp_segs_free(struct tcp_seg *seg);
|
||||
void tcp_seg_free(struct tcp_seg *seg);
|
||||
struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);
|
||||
|
||||
#define tcp_ack(pcb) \
|
||||
do { \
|
||||
if((pcb)->flags & TF_ACK_DELAY) { \
|
||||
(pcb)->flags &= ~TF_ACK_DELAY; \
|
||||
(pcb)->flags |= TF_ACK_NOW; \
|
||||
} \
|
||||
else { \
|
||||
(pcb)->flags |= TF_ACK_DELAY; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define tcp_ack_now(pcb) \
|
||||
do { \
|
||||
(pcb)->flags |= TF_ACK_NOW; \
|
||||
} while (0)
|
||||
|
||||
err_t tcp_send_fin(struct tcp_pcb *pcb);
|
||||
err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags);
|
||||
|
||||
void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
|
||||
|
||||
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);
|
||||
|
||||
err_t tcp_keepalive(struct tcp_pcb *pcb);
|
||||
err_t tcp_zero_window_probe(struct tcp_pcb *pcb);
|
||||
void tcp_trigger_input_pcb_close(void);
|
||||
|
||||
#if TCP_CALCULATE_EFF_SEND_MSS
|
||||
u16_t tcp_eff_send_mss_impl(u16_t sendmss, const ip_addr_t *dest
|
||||
#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING
|
||||
, const ip_addr_t *src
|
||||
#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */
|
||||
);
|
||||
#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING
|
||||
#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest, src)
|
||||
#else /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */
|
||||
#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest)
|
||||
#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */
|
||||
#endif /* TCP_CALCULATE_EFF_SEND_MSS */
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
|
||||
void tcp_debug_print(struct tcp_hdr *tcphdr);
|
||||
void tcp_debug_print_flags(u8_t flags);
|
||||
void tcp_debug_print_state(enum tcp_state s);
|
||||
void tcp_debug_print_pcbs(void);
|
||||
s16_t tcp_pcbs_sane(void);
|
||||
#else
|
||||
# define tcp_debug_print(tcphdr)
|
||||
# define tcp_debug_print_flags(flags)
|
||||
# define tcp_debug_print_state(s)
|
||||
# define tcp_debug_print_pcbs()
|
||||
# define tcp_pcbs_sane() 1
|
||||
#endif /* TCP_DEBUG */
|
||||
|
||||
/** External function (implemented in timers.c), called when TCP detects
|
||||
* 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 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#endif /* LWIP_HDR_TCP_H */
|
||||
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* 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_TCPIP_PRIV_H
|
||||
#define LWIP_HDR_TCPIP_PRIV_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if !NO_SYS /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/timers.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 { \
|
||||
name = (type *)memp_malloc(pool); \
|
||||
if (name == NULL) { \
|
||||
return ERR_MEM; \
|
||||
} \
|
||||
} while(0)
|
||||
#define API_VAR_ALLOC_DONTFAIL(type, pool, name) do { \
|
||||
name = (type *)memp_malloc(pool); \
|
||||
LWIP_ASSERT("pool empty", name != NULL); \
|
||||
} while(0)
|
||||
#define API_VAR_FREE(pool, name) memp_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
|
||||
#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_FREE(pool, name)
|
||||
#define API_EXPR_REF(expr) expr
|
||||
#define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr)
|
||||
#define API_EXPR_DEREF(expr) *(expr)
|
||||
#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 */
|
||||
|
||||
struct tcpip_api_call;
|
||||
typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call* call);
|
||||
struct tcpip_api_call
|
||||
{
|
||||
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 */
|
||||
sys_sem_t sem;
|
||||
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||
err_t err;
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
};
|
||||
err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call *call);
|
||||
|
||||
enum tcpip_msg_type {
|
||||
TCPIP_MSG_API,
|
||||
TCPIP_MSG_API_CALL,
|
||||
TCPIP_MSG_INPKT,
|
||||
#if LWIP_TCPIP_TIMEOUT
|
||||
TCPIP_MSG_TIMEOUT,
|
||||
TCPIP_MSG_UNTIMEOUT,
|
||||
#endif /* LWIP_TCPIP_TIMEOUT */
|
||||
TCPIP_MSG_CALLBACK,
|
||||
TCPIP_MSG_CALLBACK_STATIC
|
||||
};
|
||||
|
||||
struct tcpip_msg {
|
||||
enum tcpip_msg_type type;
|
||||
union {
|
||||
struct {
|
||||
tcpip_callback_fn function;
|
||||
void* msg;
|
||||
} api;
|
||||
struct tcpip_api_call *api_call;
|
||||
struct {
|
||||
struct pbuf *p;
|
||||
struct netif *netif;
|
||||
netif_input_fn input_fn;
|
||||
} inp;
|
||||
struct {
|
||||
tcpip_callback_fn function;
|
||||
void *ctx;
|
||||
} cb;
|
||||
#if LWIP_TCPIP_TIMEOUT
|
||||
struct {
|
||||
u32_t msecs;
|
||||
sys_timeout_handler h;
|
||||
void *arg;
|
||||
} tmo;
|
||||
#endif /* LWIP_TCPIP_TIMEOUT */
|
||||
} msg;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !NO_SYS */
|
||||
|
||||
#endif /* LWIP_HDR_TCPIP_PRIV_H */
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* 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_RAW_H
|
||||
#define LWIP_HDR_RAW_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct raw_pcb;
|
||||
|
||||
/** Function prototype for raw pcb receive callback functions.
|
||||
* @param arg user supplied argument (raw_pcb.recv_arg)
|
||||
* @param pcb the raw_pcb which received data
|
||||
* @param p the packet buffer that was received
|
||||
* @param addr the remote IP address from which the packet was received
|
||||
* @return 1 if the packet was 'eaten' (aka. deleted),
|
||||
* 0 if the packet lives on
|
||||
* If returning 1, the callback is responsible for freeing the pbuf
|
||||
* if it's not used any more.
|
||||
*/
|
||||
typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *addr);
|
||||
|
||||
struct raw_pcb {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
|
||||
struct raw_pcb *next;
|
||||
|
||||
u8_t protocol;
|
||||
|
||||
/** receive callback function */
|
||||
raw_recv_fn recv;
|
||||
/* user-supplied argument for the recv callback */
|
||||
void *recv_arg;
|
||||
#if LWIP_IPV6
|
||||
/* fields for handling checksum computations as per RFC3542. */
|
||||
u16_t chksum_offset;
|
||||
u8_t chksum_reqd;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* The following functions is the application layer interface to the
|
||||
RAW code. */
|
||||
struct raw_pcb * raw_new (u8_t proto);
|
||||
struct raw_pcb * raw_new_ip_type(u8_t type, u8_t proto);
|
||||
void raw_remove (struct raw_pcb *pcb);
|
||||
err_t raw_bind (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
|
||||
err_t raw_connect (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
|
||||
|
||||
err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr);
|
||||
err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
|
||||
|
||||
void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg);
|
||||
|
||||
/* The following functions are the lower layer interface to RAW. */
|
||||
u8_t raw_input (struct pbuf *p, struct netif *inp);
|
||||
#define raw_init() /* Compatibility define, no init needed. */
|
||||
|
||||
/* for compatibility with older implementation */
|
||||
#define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_RAW */
|
||||
|
||||
#endif /* LWIP_HDR_RAW_H */
|
||||
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the interface to the platform specific serial IO module
|
||||
* It needs to be implemented by those platforms which need SLIP or PPP
|
||||
*/
|
||||
|
||||
#ifndef SIO_H
|
||||
#define SIO_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* If you want to define sio_fd_t elsewhere or differently,
|
||||
define this in your cc.h file. */
|
||||
#ifndef __sio_fd_t_defined
|
||||
typedef void * sio_fd_t;
|
||||
#endif
|
||||
|
||||
/* The following functions can be defined to something else in your cc.h file
|
||||
or be implemented in your custom sio.c file. */
|
||||
|
||||
#ifndef sio_open
|
||||
/**
|
||||
* Opens a serial device for communication.
|
||||
*
|
||||
* @param devnum device number
|
||||
* @return handle to serial device if successful, NULL otherwise
|
||||
*/
|
||||
sio_fd_t sio_open(u8_t devnum);
|
||||
#endif
|
||||
|
||||
#ifndef sio_send
|
||||
/**
|
||||
* Sends a single character to the serial device.
|
||||
*
|
||||
* @param c character to send
|
||||
* @param fd serial device handle
|
||||
*
|
||||
* @note This function will block until the character can be sent.
|
||||
*/
|
||||
void sio_send(u8_t c, sio_fd_t fd);
|
||||
#endif
|
||||
|
||||
#ifndef sio_recv
|
||||
/**
|
||||
* Receives a single character from the serial device.
|
||||
*
|
||||
* @param fd serial device handle
|
||||
*
|
||||
* @note This function will block until a character is received.
|
||||
*/
|
||||
u8_t sio_recv(sio_fd_t fd);
|
||||
#endif
|
||||
|
||||
#ifndef sio_read
|
||||
/**
|
||||
* Reads from the serial device.
|
||||
*
|
||||
* @param fd serial device handle
|
||||
* @param data pointer to data buffer for receiving
|
||||
* @param len maximum length (in bytes) of data to receive
|
||||
* @return number of bytes actually received - may be 0 if aborted by sio_read_abort
|
||||
*
|
||||
* @note This function will block until data can be received. The blocking
|
||||
* can be cancelled by calling sio_read_abort().
|
||||
*/
|
||||
u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);
|
||||
#endif
|
||||
|
||||
#ifndef sio_tryread
|
||||
/**
|
||||
* Tries to read from the serial device. Same as sio_read but returns
|
||||
* immediately if no data is available and never blocks.
|
||||
*
|
||||
* @param fd serial device handle
|
||||
* @param data pointer to data buffer for receiving
|
||||
* @param len maximum length (in bytes) of data to receive
|
||||
* @return number of bytes actually received
|
||||
*/
|
||||
u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len);
|
||||
#endif
|
||||
|
||||
#ifndef sio_write
|
||||
/**
|
||||
* Writes to the serial device.
|
||||
*
|
||||
* @param fd serial device handle
|
||||
* @param data pointer to data to send
|
||||
* @param len length (in bytes) of data to send
|
||||
* @return number of bytes actually sent
|
||||
*
|
||||
* @note This function will block until all data can be sent.
|
||||
*/
|
||||
u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);
|
||||
#endif
|
||||
|
||||
#ifndef sio_read_abort
|
||||
/**
|
||||
* Aborts a blocking sio_read() call.
|
||||
*
|
||||
* @param fd serial device handle
|
||||
*/
|
||||
void sio_read_abort(sio_fd_t fd);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SIO_H */
|
||||
@@ -1,195 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* MIB2 callback functions called from throughout the stack to integrate a MIB2
|
||||
* into lwIP (together with MIB2_STATS).
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_SNMP_H
|
||||
#define LWIP_HDR_SNMP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct udp_pcb;
|
||||
struct netif;
|
||||
|
||||
/* MIB2 statistics functions */
|
||||
#if MIB2_STATS /* don't build if not configured for use in lwipopts.h */
|
||||
/**
|
||||
* @see RFC1213, "MIB-II, 6. Definitions"
|
||||
*/
|
||||
enum snmp_ifType {
|
||||
snmp_ifType_other=1, /* none of the following */
|
||||
snmp_ifType_regular1822,
|
||||
snmp_ifType_hdh1822,
|
||||
snmp_ifType_ddn_x25,
|
||||
snmp_ifType_rfc877_x25,
|
||||
snmp_ifType_ethernet_csmacd,
|
||||
snmp_ifType_iso88023_csmacd,
|
||||
snmp_ifType_iso88024_tokenBus,
|
||||
snmp_ifType_iso88025_tokenRing,
|
||||
snmp_ifType_iso88026_man,
|
||||
snmp_ifType_starLan,
|
||||
snmp_ifType_proteon_10Mbit,
|
||||
snmp_ifType_proteon_80Mbit,
|
||||
snmp_ifType_hyperchannel,
|
||||
snmp_ifType_fddi,
|
||||
snmp_ifType_lapb,
|
||||
snmp_ifType_sdlc,
|
||||
snmp_ifType_ds1, /* T-1 */
|
||||
snmp_ifType_e1, /* european equiv. of T-1 */
|
||||
snmp_ifType_basicISDN,
|
||||
snmp_ifType_primaryISDN, /* proprietary serial */
|
||||
snmp_ifType_propPointToPointSerial,
|
||||
snmp_ifType_ppp,
|
||||
snmp_ifType_softwareLoopback,
|
||||
snmp_ifType_eon, /* CLNP over IP [11] */
|
||||
snmp_ifType_ethernet_3Mbit,
|
||||
snmp_ifType_nsip, /* XNS over IP */
|
||||
snmp_ifType_slip, /* generic SLIP */
|
||||
snmp_ifType_ultra, /* ULTRA technologies */
|
||||
snmp_ifType_ds3, /* T-3 */
|
||||
snmp_ifType_sip, /* SMDS */
|
||||
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. */
|
||||
#ifndef MIB2_COPY_SYSUPTIME_TO
|
||||
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10))
|
||||
#endif
|
||||
|
||||
#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0)
|
||||
#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0)
|
||||
|
||||
#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; \
|
||||
(netif)->mib2_counters.ifinucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifinnucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifindiscards = 0; \
|
||||
(netif)->mib2_counters.ifinerrors = 0; \
|
||||
(netif)->mib2_counters.ifinunknownprotos = 0; \
|
||||
(netif)->mib2_counters.ifoutoctets = 0; \
|
||||
(netif)->mib2_counters.ifoutucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifoutnucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifoutdiscards = 0; \
|
||||
(netif)->mib2_counters.ifouterrors = 0; } while(0)
|
||||
#else /* MIB2_STATS */
|
||||
#ifndef MIB2_COPY_SYSUPTIME_TO
|
||||
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal)
|
||||
#endif
|
||||
#define MIB2_INIT_NETIF(netif, type, speed)
|
||||
#define MIB2_STATS_NETIF_INC(n, x)
|
||||
#define MIB2_STATS_NETIF_ADD(n, x, val)
|
||||
#endif /* MIB2_STATS */
|
||||
|
||||
/* LWIP MIB2 callbacks */
|
||||
#if LWIP_MIB2_CALLBACKS /* don't build if not configured for use in lwipopts.h */
|
||||
/* network interface */
|
||||
void mib2_netif_added(struct netif *ni);
|
||||
void mib2_netif_removed(struct netif *ni);
|
||||
|
||||
#if LWIP_IPV4 && LWIP_ARP
|
||||
/* ARP (for atTable and ipNetToMediaTable) */
|
||||
void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip);
|
||||
void mib2_remove_arp_entry(struct netif *ni, ip4_addr_t *ip);
|
||||
#else /* LWIP_IPV4 && LWIP_ARP */
|
||||
#define mib2_add_arp_entry(ni,ip)
|
||||
#define mib2_remove_arp_entry(ni,ip)
|
||||
#endif /* LWIP_IPV4 && LWIP_ARP */
|
||||
|
||||
/* IP */
|
||||
#if LWIP_IPV4
|
||||
void mib2_add_ip4(struct netif *ni);
|
||||
void mib2_remove_ip4(struct netif *ni);
|
||||
void mib2_add_route_ip4(u8_t dflt, struct netif *ni);
|
||||
void mib2_remove_route_ip4(u8_t dflt, struct netif *ni);
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
/* UDP */
|
||||
#if LWIP_UDP
|
||||
void mib2_udp_bind(struct udp_pcb *pcb);
|
||||
void mib2_udp_unbind(struct udp_pcb *pcb);
|
||||
#endif /* LWIP_UDP */
|
||||
|
||||
#else /* LWIP_MIB2_CALLBACKS */
|
||||
/* LWIP_MIB2_CALLBACKS support not available */
|
||||
/* define everything to be empty */
|
||||
|
||||
/* network interface */
|
||||
#define mib2_netif_added(ni)
|
||||
#define mib2_netif_removed(ni)
|
||||
|
||||
/* ARP */
|
||||
#define mib2_add_arp_entry(ni,ip)
|
||||
#define mib2_remove_arp_entry(ni,ip)
|
||||
|
||||
/* IP */
|
||||
#define mib2_add_ip4(ni)
|
||||
#define mib2_remove_ip4(ni)
|
||||
#define mib2_add_route_ip4(dflt, ni)
|
||||
#define mib2_remove_route_ip4(dflt, ni)
|
||||
|
||||
/* UDP */
|
||||
#define mib2_udp_bind(pcb)
|
||||
#define mib2_udp_unbind(pcb)
|
||||
#endif /* LWIP_MIB2_CALLBACKS */
|
||||
|
||||
/* for source-code compatibility reasons only, can be removed (not used internally) */
|
||||
#define NETIF_INIT_SNMP MIB2_INIT_NETIF
|
||||
#define snmp_add_ifinoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifinoctets, value)
|
||||
#define snmp_inc_ifinucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinucastpkts)
|
||||
#define snmp_inc_ifinnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinnucastpkts)
|
||||
#define snmp_inc_ifindiscards(ni) MIB2_STATS_NETIF_INC(ni, ifindiscards)
|
||||
#define snmp_inc_ifinerrors(ni) MIB2_STATS_NETIF_INC(ni, ifinerrors)
|
||||
#define snmp_inc_ifinunknownprotos(ni) MIB2_STATS_NETIF_INC(ni, ifinunknownprotos)
|
||||
#define snmp_add_ifoutoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifoutoctets, value)
|
||||
#define snmp_inc_ifoutucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutucastpkts)
|
||||
#define snmp_inc_ifoutnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutnucastpkts)
|
||||
#define snmp_inc_ifoutdiscards(ni) MIB2_STATS_NETIF_INC(ni, ifoutdiscards)
|
||||
#define snmp_inc_ifouterrors(ni) MIB2_STATS_NETIF_INC(ni, ifouterrors)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_SNMP_H */
|
||||
@@ -1,717 +0,0 @@
|
||||
/*
|
||||
* 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_SOCKETS_H
|
||||
#define LWIP_HDR_SOCKETS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED
|
||||
to prevent this code from redefining it. */
|
||||
#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
|
||||
typedef u8_t sa_family_t;
|
||||
#endif
|
||||
/* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED
|
||||
to prevent this code from redefining it. */
|
||||
#if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
|
||||
typedef u16_t in_port_t;
|
||||
#endif
|
||||
|
||||
#if LWIP_IPV4
|
||||
/* members are in network byte order */
|
||||
struct sockaddr_in {
|
||||
u8_t sin_len;
|
||||
sa_family_t sin_family;
|
||||
in_port_t sin_port;
|
||||
struct in_addr sin_addr;
|
||||
#define SIN_ZERO_LEN 8
|
||||
char sin_zero[SIN_ZERO_LEN];
|
||||
};
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if LWIP_IPV6
|
||||
struct sockaddr_in6 {
|
||||
u8_t sin6_len; /* length of this structure */
|
||||
sa_family_t sin6_family; /* AF_INET6 */
|
||||
in_port_t sin6_port; /* Transport layer port # */
|
||||
u32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
u32_t sin6_scope_id; /* Set of interfaces for scope */
|
||||
};
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
struct sockaddr {
|
||||
u8_t sa_len;
|
||||
sa_family_t sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
struct sockaddr_storage {
|
||||
u8_t s2_len;
|
||||
sa_family_t ss_family;
|
||||
char s2_data1[2];
|
||||
u32_t s2_data2[3];
|
||||
#if LWIP_IPV6
|
||||
u32_t s2_data3[3];
|
||||
#endif /* LWIP_IPV6 */
|
||||
};
|
||||
|
||||
/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED
|
||||
to prevent this code from redefining it. */
|
||||
#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
|
||||
typedef u32_t socklen_t;
|
||||
#endif
|
||||
|
||||
struct lwip_sock;
|
||||
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
/** Maximum optlen used by setsockopt/getsockopt */
|
||||
#define LWIP_SETGETSOCKOPT_MAXOPTLEN 16
|
||||
|
||||
/** This struct is used to pass data to the set/getsockopt_internal
|
||||
* functions running in tcpip_thread context (only a void* is allowed) */
|
||||
struct lwip_setgetsockopt_data {
|
||||
/** socket index for which to change options */
|
||||
int s;
|
||||
/** level of the option to process */
|
||||
int level;
|
||||
/** name of the option to process */
|
||||
int optname;
|
||||
/** set: value to set the option to
|
||||
* get: value of the option is stored here */
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN];
|
||||
#else
|
||||
union {
|
||||
void *p;
|
||||
const void *pc;
|
||||
} optval;
|
||||
#endif
|
||||
/** size of *optval */
|
||||
socklen_t optlen;
|
||||
/** if an error occurs, it is temporarily stored here */
|
||||
err_t err;
|
||||
/** semaphore to wake up the calling task */
|
||||
void* completed_sem;
|
||||
};
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
#if !defined(iovec)
|
||||
struct iovec {
|
||||
void *iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct msghdr {
|
||||
void *msg_name;
|
||||
socklen_t msg_namelen;
|
||||
struct iovec *msg_iov;
|
||||
int msg_iovlen;
|
||||
void *msg_control;
|
||||
socklen_t msg_controllen;
|
||||
int msg_flags;
|
||||
};
|
||||
|
||||
/* Socket protocol types (TCP/UDP/RAW) */
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
#define SOCK_RAW 3
|
||||
|
||||
/*
|
||||
* Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
|
||||
*/
|
||||
#define SO_REUSEADDR 0x0004 /* Allow local address reuse */
|
||||
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
||||
#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
|
||||
|
||||
|
||||
/*
|
||||
* Additional options, not kept in so_options.
|
||||
*/
|
||||
#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */
|
||||
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
||||
#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */
|
||||
#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
|
||||
#define SO_LINGER 0x0080 /* linger on close if data present */
|
||||
#define SO_DONTLINGER ((int)(~SO_LINGER))
|
||||
#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */
|
||||
#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */
|
||||
#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */
|
||||
#define SO_RCVBUF 0x1002 /* receive buffer size */
|
||||
#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */
|
||||
#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */
|
||||
#define SO_SNDTIMEO 0x1005 /* send timeout */
|
||||
#define SO_RCVTIMEO 0x1006 /* receive timeout */
|
||||
#define SO_ERROR 0x1007 /* get error status and clear */
|
||||
#define SO_TYPE 0x1008 /* get socket type */
|
||||
#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
|
||||
#define SO_NO_CHECK 0x100a /* don't create UDP checksum */
|
||||
|
||||
/*
|
||||
* Structure used for manipulating linger option.
|
||||
*/
|
||||
struct linger {
|
||||
int l_onoff; /* option on/off */
|
||||
int l_linger; /* linger time in seconds */
|
||||
};
|
||||
|
||||
/*
|
||||
* Level number for (get/set)sockopt() to apply to socket itself.
|
||||
*/
|
||||
#define SOL_SOCKET 0xfff /* options for socket level */
|
||||
|
||||
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_INET 2
|
||||
#if LWIP_IPV6
|
||||
#define AF_INET6 10
|
||||
#else /* LWIP_IPV6 */
|
||||
#define AF_INET6 AF_UNSPEC
|
||||
#endif /* LWIP_IPV6 */
|
||||
#define PF_INET AF_INET
|
||||
#define PF_INET6 AF_INET6
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
|
||||
#define IPPROTO_IP 0
|
||||
#define IPPROTO_ICMP 1
|
||||
#define IPPROTO_TCP 6
|
||||
#define IPPROTO_UDP 17
|
||||
#if LWIP_IPV6
|
||||
#define IPPROTO_IPV6 41
|
||||
#define IPPROTO_ICMPV6 58
|
||||
#endif /* LWIP_IPV6 */
|
||||
#define IPPROTO_UDPLITE 136
|
||||
#define IPPROTO_RAW 255
|
||||
|
||||
/* Flags we can use with send and recv. */
|
||||
#define MSG_PEEK 0x01 /* Peeks at an incoming message */
|
||||
#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
|
||||
#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
|
||||
#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */
|
||||
#define MSG_MORE 0x10 /* Sender will send more */
|
||||
|
||||
|
||||
/*
|
||||
* Options for level IPPROTO_IP
|
||||
*/
|
||||
#define IP_TOS 1
|
||||
#define IP_TTL 2
|
||||
|
||||
#if LWIP_TCP
|
||||
/*
|
||||
* Options for level IPPROTO_TCP
|
||||
*/
|
||||
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
|
||||
#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
|
||||
#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
|
||||
/*
|
||||
* Options for level IPPROTO_IPV6
|
||||
*/
|
||||
#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 LWIP_IPV6_MLD
|
||||
/* Socket options for IPV6 multicast, uses the MLD interface to manage group memberships. RFC2133. */
|
||||
#define IPV6_MULTICAST_IF 0x300
|
||||
#define IPV6_MULTICAST_HOPS 0x301
|
||||
#define IPV6_MULTICAST_LOOP 0x302
|
||||
#define IPV6_ADD_MEMBERSHIP 0x303
|
||||
#define IPV6_DROP_MEMBERSHIP 0x304
|
||||
|
||||
/* Structure used for IPV6_ADD/DROP_MEMBERSHIP */
|
||||
typedef struct ip6_mreq {
|
||||
struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */
|
||||
struct in6_addr ipv6mr_interface; /* local IP address of interface */
|
||||
} ip6_mreq;
|
||||
|
||||
/* Commonly used synonyms for these options */
|
||||
#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
|
||||
#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
|
||||
|
||||
#endif /* LWIP_IPV6_MLD */
|
||||
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#if LWIP_UDP && LWIP_UDPLITE
|
||||
/*
|
||||
* Options for level IPPROTO_UDPLITE
|
||||
*/
|
||||
#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
|
||||
#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
|
||||
#endif /* LWIP_UDP && LWIP_UDPLITE*/
|
||||
|
||||
|
||||
#if LWIP_MULTICAST_TX_OPTIONS
|
||||
/*
|
||||
* Options and types for UDP multicast traffic handling
|
||||
*/
|
||||
#define IP_MULTICAST_TTL 5
|
||||
#define IP_MULTICAST_IF 6
|
||||
#define IP_MULTICAST_LOOP 7
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
#if LWIP_IGMP
|
||||
/*
|
||||
* Options and types related to multicast membership
|
||||
*/
|
||||
#define IP_ADD_MEMBERSHIP 3
|
||||
#define IP_DROP_MEMBERSHIP 4
|
||||
|
||||
typedef struct ip_mreq {
|
||||
struct in_addr imr_multiaddr; /* IP multicast address of group */
|
||||
struct in_addr imr_interface; /* local IP address of interface */
|
||||
} ip_mreq;
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
/*
|
||||
* The Type of Service provides an indication of the abstract
|
||||
* parameters of the quality of service desired. These parameters are
|
||||
* to be used to guide the selection of the actual service parameters
|
||||
* when transmitting a datagram through a particular network. Several
|
||||
* networks offer service precedence, which somehow treats high
|
||||
* precedence traffic as more important than other traffic (generally
|
||||
* by accepting only traffic above a certain precedence at time of high
|
||||
* load). The major choice is a three way tradeoff between low-delay,
|
||||
* high-reliability, and high-throughput.
|
||||
* The use of the Delay, Throughput, and Reliability indications may
|
||||
* increase the cost (in some sense) of the service. In many networks
|
||||
* better performance for one of these parameters is coupled with worse
|
||||
* performance on another. Except for very unusual cases at most two
|
||||
* of these three indications should be set.
|
||||
*/
|
||||
#define IPTOS_TOS_MASK 0x1E
|
||||
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
|
||||
#define IPTOS_LOWDELAY 0x10
|
||||
#define IPTOS_THROUGHPUT 0x08
|
||||
#define IPTOS_RELIABILITY 0x04
|
||||
#define IPTOS_LOWCOST 0x02
|
||||
#define IPTOS_MINCOST IPTOS_LOWCOST
|
||||
|
||||
/*
|
||||
* The Network Control precedence designation is intended to be used
|
||||
* within a network only. The actual use and control of that
|
||||
* designation is up to each network. The Internetwork Control
|
||||
* designation is intended for use by gateway control originators only.
|
||||
* If the actual use of these precedence designations is of concern to
|
||||
* a particular network, it is the responsibility of that network to
|
||||
* control the access to, and use of, those precedence designations.
|
||||
*/
|
||||
#define IPTOS_PREC_MASK 0xe0
|
||||
#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
|
||||
#define IPTOS_PREC_NETCONTROL 0xe0
|
||||
#define IPTOS_PREC_INTERNETCONTROL 0xc0
|
||||
#define IPTOS_PREC_CRITIC_ECP 0xa0
|
||||
#define IPTOS_PREC_FLASHOVERRIDE 0x80
|
||||
#define IPTOS_PREC_FLASH 0x60
|
||||
#define IPTOS_PREC_IMMEDIATE 0x40
|
||||
#define IPTOS_PREC_PRIORITY 0x20
|
||||
#define IPTOS_PREC_ROUTINE 0x00
|
||||
|
||||
|
||||
/*
|
||||
* Commands for ioctlsocket(), taken from the BSD file fcntl.h.
|
||||
* lwip_ioctl only supports FIONREAD and FIONBIO, for now
|
||||
*
|
||||
* Ioctl's have the command encoded in the lower word,
|
||||
* and the size of any in or out parameters in the upper
|
||||
* word. The high 2 bits of the upper word are used
|
||||
* to encode the in/out status of the parameter; for now
|
||||
* we restrict parameters to at most 128 bytes.
|
||||
*/
|
||||
#if !defined(FIONREAD) || !defined(FIONBIO)
|
||||
#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */
|
||||
#define IOC_VOID 0x20000000UL /* no parameters */
|
||||
#define IOC_OUT 0x40000000UL /* copy out parameters */
|
||||
#define IOC_IN 0x80000000UL /* copy in parameters */
|
||||
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
||||
/* 0x20000000 distinguishes new &
|
||||
old ioctl's */
|
||||
#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
|
||||
|
||||
#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
||||
|
||||
#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
||||
#endif /* !defined(FIONREAD) || !defined(FIONBIO) */
|
||||
|
||||
#ifndef FIONREAD
|
||||
#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
|
||||
#endif
|
||||
#ifndef FIONBIO
|
||||
#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
|
||||
#endif
|
||||
|
||||
/* Socket I/O Controls: unimplemented */
|
||||
#ifndef SIOCSHIWAT
|
||||
#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
|
||||
#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
|
||||
#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
|
||||
#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
|
||||
#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
|
||||
#endif
|
||||
|
||||
/* commands for fnctl */
|
||||
#ifndef F_GETFL
|
||||
#define F_GETFL 3
|
||||
#endif
|
||||
#ifndef F_SETFL
|
||||
#define F_SETFL 4
|
||||
#endif
|
||||
|
||||
/* File status flags and file access modes for fnctl,
|
||||
these are bits in an int. */
|
||||
#ifndef O_NONBLOCK
|
||||
#define O_NONBLOCK 1 /* nonblocking I/O */
|
||||
#endif
|
||||
#ifndef O_NDELAY
|
||||
#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */
|
||||
#endif
|
||||
|
||||
#ifndef SHUT_RD
|
||||
#define SHUT_RD 0
|
||||
#define SHUT_WR 1
|
||||
#define SHUT_RDWR 2
|
||||
#endif
|
||||
|
||||
/* FD_SET used for lwip_select */
|
||||
#ifndef FD_SET
|
||||
#undef FD_SETSIZE
|
||||
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
||||
#define FD_SETSIZE MEMP_NUM_NETCONN
|
||||
#define FDSETSAFESET(n, code) do { \
|
||||
if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
code; }} while(0)
|
||||
#define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
|
||||
(code) : 0)
|
||||
#define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_CLR(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
|
||||
|
||||
typedef struct fd_set
|
||||
{
|
||||
unsigned char fd_bits [(FD_SETSIZE+7)/8];
|
||||
} fd_set;
|
||||
|
||||
#endif /* FD_SET */
|
||||
|
||||
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
|
||||
* by your system, set this to 0 and include <sys/time.h> in cc.h */
|
||||
#ifndef LWIP_TIMEVAL_PRIVATE
|
||||
#define LWIP_TIMEVAL_PRIVATE 1
|
||||
#endif
|
||||
|
||||
#if LWIP_TIMEVAL_PRIVATE
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* and microseconds */
|
||||
};
|
||||
#endif /* LWIP_TIMEVAL_PRIVATE */
|
||||
|
||||
#define lwip_socket_init() /* Compatibility define, no init needed. */
|
||||
void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */
|
||||
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
|
||||
#define lwip_shutdown shutdown
|
||||
#define lwip_getpeername getpeername
|
||||
#define lwip_getsockname getsockname
|
||||
#define lwip_setsockopt setsockopt
|
||||
#define lwip_getsockopt getsockopt
|
||||
#define lwip_close closesocket
|
||||
#define lwip_connect connect
|
||||
#define lwip_listen listen
|
||||
#define lwip_recv recv
|
||||
#define lwip_recvfrom recvfrom
|
||||
#define lwip_send send
|
||||
#define lwip_sendmsg sendmsg
|
||||
#define lwip_sendto sendto
|
||||
#define lwip_socket socket
|
||||
#define lwip_select select
|
||||
#define lwip_ioctlsocket ioctl
|
||||
|
||||
#if LWIP_POSIX_SOCKETS_IO_NAMES
|
||||
#define lwip_read read
|
||||
#define lwip_write write
|
||||
#define lwip_writev writev
|
||||
#undef lwip_close
|
||||
#define lwip_close close
|
||||
#define closesocket(s) close(s)
|
||||
#define lwip_fcntl fcntl
|
||||
#define lwip_ioctl ioctl
|
||||
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
#endif /* LWIP_COMPAT_SOCKETS == 2 */
|
||||
|
||||
int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
|
||||
int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int lwip_shutdown(int s, int how);
|
||||
int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
|
||||
int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
|
||||
int lwip_close(int s);
|
||||
int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int lwip_listen(int s, int backlog);
|
||||
int lwip_recv(int s, void *mem, size_t len, int flags);
|
||||
int lwip_read(int s, void *mem, size_t len);
|
||||
int lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen);
|
||||
int lwip_send(int s, const void *dataptr, size_t size, int flags);
|
||||
int lwip_sendmsg(int s, const struct msghdr *message, int flags);
|
||||
int lwip_sendto(int s, const void *dataptr, size_t size, int flags,
|
||||
const struct sockaddr *to, socklen_t tolen);
|
||||
int lwip_socket(int domain, int type, int protocol);
|
||||
int lwip_write(int s, const void *dataptr, size_t size);
|
||||
int lwip_writev(int s, const struct iovec *iov, int iovcnt);
|
||||
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
struct timeval *timeout);
|
||||
int lwip_ioctl(int s, long cmd, void *argp);
|
||||
int lwip_fcntl(int s, int cmd, int val);
|
||||
|
||||
#if LWIP_COMPAT_SOCKETS
|
||||
#if LWIP_COMPAT_SOCKETS != 2
|
||||
|
||||
#if ESP_THREAD_SAFE
|
||||
int lwip_accept_r(int s, struct sockaddr *addr, socklen_t *addrlen);
|
||||
int lwip_bind_r(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int lwip_shutdown_r(int s, int how);
|
||||
int lwip_getpeername_r (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int lwip_getsockname_r (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int lwip_getsockopt_r (int s, int level, int optname, void *optval, socklen_t *optlen);
|
||||
int lwip_setsockopt_r (int s, int level, int optname, const void *optval, socklen_t optlen);
|
||||
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,
|
||||
struct sockaddr *from, socklen_t *fromlen);
|
||||
int lwip_send_r(int s, const void *dataptr, size_t size, int flags);
|
||||
int lwip_sendmsg_r(int s, const struct msghdr *message, int flags);
|
||||
int lwip_sendto_r(int s, const void *dataptr, size_t size, int flags,
|
||||
const struct sockaddr *to, socklen_t tolen);
|
||||
int lwip_socket(int domain, int type, int protocol);
|
||||
int lwip_write_r(int s, const void *dataptr, size_t size);
|
||||
int lwip_writev_r(int s, const struct iovec *iov, int iovcnt);
|
||||
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
struct timeval *timeout);
|
||||
int lwip_ioctl_r(int s, long cmd, void *argp);
|
||||
int lwip_fcntl_r(int s, int cmd, int val);
|
||||
|
||||
static inline int accept(int s,struct sockaddr *addr,socklen_t *addrlen)
|
||||
{ return lwip_accept_r(s,addr,addrlen); }
|
||||
static inline int bind(int s,const struct sockaddr *name, socklen_t namelen)
|
||||
{ return lwip_bind_r(s,name,namelen); }
|
||||
static inline int shutdown(int s,int how)
|
||||
{ return lwip_shutdown_r(s,how); }
|
||||
static inline int getpeername(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getpeername_r(s,name,namelen); }
|
||||
static inline int getsockname(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getsockname_r(s,name,namelen); }
|
||||
static inline int setsockopt(int s,int level,int optname,const void *opval,socklen_t optlen)
|
||||
{ return lwip_setsockopt_r(s,level,optname,opval,optlen); }
|
||||
static inline int getsockopt(int s,int level,int optname,void *opval,socklen_t *optlen)
|
||||
{ return lwip_getsockopt_r(s,level,optname,opval,optlen); }
|
||||
static inline int closesocket(int s)
|
||||
{ return lwip_close_r(s); }
|
||||
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)
|
||||
{ return lwip_recvfrom_r(s,mem,len,flags,from,fromlen); }
|
||||
static inline int send(int s,const void *dataptr,size_t size,int flags)
|
||||
{ return lwip_send_r(s,dataptr,size,flags); }
|
||||
static inline int sendmsg(int s,const struct msghdr *message,int flags)
|
||||
{ return lwip_sendmsg_r(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_r(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 *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_r(s,cmd,argp); }
|
||||
|
||||
#if LWIP_POSIX_SOCKETS_IO_NAMES
|
||||
static inline int read(int s,void *mem,size_t len)
|
||||
{ return lwip_read_r(s,mem,len); }
|
||||
static inline int write(int s,const void *dataptr,size_t len)
|
||||
{ return lwip_write_r(s,dataptr,len); }
|
||||
static inline int writev(int s,const struct iovec *iov,int iovcnt)
|
||||
{ return lwip_writev_r(s,iov,iovcnt); }
|
||||
static inline int close(int s)
|
||||
{ return lwip_close_r(s); }
|
||||
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 */
|
||||
|
||||
#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 recvmsg(int sockfd, struct msghdr *msg, int flags)
|
||||
{ return lwip_recvmsg(sockfd, msg, flags); }
|
||||
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); }
|
||||
|
||||
#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); }
|
||||
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
#endif /* ESP_THREAD_SAFE */
|
||||
|
||||
#endif /* LWIP_COMPAT_SOCKETS != 2 */
|
||||
|
||||
#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 */
|
||||
|
||||
#endif /* LWIP_COMPAT_SOCKETS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_SOCKET */
|
||||
|
||||
#endif /* LWIP_HDR_SOCKETS_H */
|
||||
@@ -1,492 +0,0 @@
|
||||
/*
|
||||
* 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_STATS_H
|
||||
#define LWIP_HDR_STATS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if LWIP_STATS
|
||||
|
||||
#ifndef LWIP_STATS_LARGE
|
||||
#define LWIP_STATS_LARGE 0
|
||||
#endif
|
||||
|
||||
#if LWIP_STATS_LARGE
|
||||
#define STAT_COUNTER u32_t
|
||||
#define STAT_COUNTER_F U32_F
|
||||
#else
|
||||
#define STAT_COUNTER u16_t
|
||||
#define STAT_COUNTER_F U16_F
|
||||
#endif
|
||||
|
||||
struct stats_proto {
|
||||
STAT_COUNTER xmit; /* Transmitted packets. */
|
||||
STAT_COUNTER recv; /* Received packets. */
|
||||
STAT_COUNTER fw; /* Forwarded packets. */
|
||||
STAT_COUNTER drop; /* Dropped packets. */
|
||||
STAT_COUNTER chkerr; /* Checksum error. */
|
||||
STAT_COUNTER lenerr; /* Invalid length error. */
|
||||
STAT_COUNTER memerr; /* Out of memory error. */
|
||||
STAT_COUNTER rterr; /* Routing error. */
|
||||
STAT_COUNTER proterr; /* Protocol error. */
|
||||
STAT_COUNTER opterr; /* Error in options. */
|
||||
STAT_COUNTER err; /* Misc error. */
|
||||
STAT_COUNTER cachehit;
|
||||
};
|
||||
|
||||
struct stats_igmp {
|
||||
STAT_COUNTER xmit; /* Transmitted packets. */
|
||||
STAT_COUNTER recv; /* Received packets. */
|
||||
STAT_COUNTER drop; /* Dropped packets. */
|
||||
STAT_COUNTER chkerr; /* Checksum error. */
|
||||
STAT_COUNTER lenerr; /* Invalid length error. */
|
||||
STAT_COUNTER memerr; /* Out of memory error. */
|
||||
STAT_COUNTER proterr; /* Protocol error. */
|
||||
STAT_COUNTER rx_v1; /* Received v1 frames. */
|
||||
STAT_COUNTER rx_group; /* Received group-specific queries. */
|
||||
STAT_COUNTER rx_general; /* Received general queries. */
|
||||
STAT_COUNTER rx_report; /* Received reports. */
|
||||
STAT_COUNTER tx_join; /* Sent joins. */
|
||||
STAT_COUNTER tx_leave; /* Sent leaves. */
|
||||
STAT_COUNTER tx_report; /* Sent reports. */
|
||||
};
|
||||
|
||||
struct stats_mem {
|
||||
#ifdef LWIP_DEBUG
|
||||
const char *name;
|
||||
#endif /* LWIP_DEBUG */
|
||||
STAT_COUNTER err;
|
||||
mem_size_t avail;
|
||||
mem_size_t used;
|
||||
mem_size_t max;
|
||||
STAT_COUNTER illegal;
|
||||
};
|
||||
|
||||
struct stats_syselem {
|
||||
STAT_COUNTER used;
|
||||
STAT_COUNTER max;
|
||||
STAT_COUNTER err;
|
||||
};
|
||||
|
||||
struct stats_sys {
|
||||
struct stats_syselem sem;
|
||||
struct stats_syselem mutex;
|
||||
struct stats_syselem mbox;
|
||||
};
|
||||
|
||||
struct stats_mib2 {
|
||||
/* IP */
|
||||
u32_t ipinhdrerrors;
|
||||
u32_t ipinaddrerrors;
|
||||
u32_t ipinunknownprotos;
|
||||
u32_t ipindiscards;
|
||||
u32_t ipindelivers;
|
||||
u32_t ipoutrequests;
|
||||
u32_t ipoutdiscards;
|
||||
u32_t ipoutnoroutes;
|
||||
u32_t ipreasmoks;
|
||||
u32_t ipreasmfails;
|
||||
u32_t ipfragoks;
|
||||
u32_t ipfragfails;
|
||||
u32_t ipfragcreates;
|
||||
u32_t ipreasmreqds;
|
||||
u32_t ipforwdatagrams;
|
||||
u32_t ipinreceives;
|
||||
|
||||
/* TCP */
|
||||
u32_t tcpactiveopens;
|
||||
u32_t tcppassiveopens;
|
||||
u32_t tcpattemptfails;
|
||||
u32_t tcpestabresets;
|
||||
u32_t tcpoutsegs;
|
||||
u32_t tcpretranssegs;
|
||||
u32_t tcpinsegs;
|
||||
u32_t tcpinerrs;
|
||||
u32_t tcpoutrsts;
|
||||
|
||||
/* UDP */
|
||||
u32_t udpindatagrams;
|
||||
u32_t udpnoports;
|
||||
u32_t udpinerrors;
|
||||
u32_t udpoutdatagrams;
|
||||
|
||||
/* ICMP */
|
||||
u32_t icmpinmsgs;
|
||||
u32_t icmpinerrors;
|
||||
u32_t icmpindestunreachs;
|
||||
u32_t icmpintimeexcds;
|
||||
u32_t icmpinparmprobs;
|
||||
u32_t icmpinsrcquenchs;
|
||||
u32_t icmpinredirects;
|
||||
u32_t icmpinechos;
|
||||
u32_t icmpinechoreps;
|
||||
u32_t icmpintimestamps;
|
||||
u32_t icmpintimestampreps;
|
||||
u32_t icmpinaddrmasks;
|
||||
u32_t icmpinaddrmaskreps;
|
||||
u32_t icmpoutmsgs;
|
||||
u32_t icmpouterrors;
|
||||
u32_t icmpoutdestunreachs;
|
||||
u32_t icmpouttimeexcds;
|
||||
u32_t icmpoutechos; /* can be incremented by user application ('ping') */
|
||||
u32_t icmpoutechoreps;
|
||||
};
|
||||
|
||||
struct stats_mib2_netif_ctrs {
|
||||
/* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* preventing them from being deliverable to a higher-layer protocol. For character-
|
||||
* 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
|
||||
* 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. */
|
||||
u32_t ifoutoctets;
|
||||
/* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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;
|
||||
};
|
||||
|
||||
struct stats_esp {
|
||||
/* mbox post fail stats */
|
||||
u32_t rx_rawmbox_post_fail;
|
||||
u32_t rx_udpmbox_post_fail;
|
||||
u32_t rx_tcpmbox_post_fail;
|
||||
u32_t err_tcp_rxmbox_post_fail;
|
||||
u32_t err_tcp_acceptmbox_post_fail;
|
||||
u32_t acceptmbox_post_fail;
|
||||
u32_t free_mbox_post_fail;
|
||||
u32_t tcpip_inpkt_post_fail;
|
||||
u32_t tcpip_cb_post_fail;
|
||||
|
||||
/* memory malloc/free/failed stats */
|
||||
u32_t wlanif_input_pbuf_fail;
|
||||
u32_t wlanif_outut_pbuf_fail;
|
||||
};
|
||||
|
||||
struct stats_ {
|
||||
#if LINK_STATS
|
||||
struct stats_proto link;
|
||||
#endif
|
||||
#if ETHARP_STATS
|
||||
struct stats_proto etharp;
|
||||
#endif
|
||||
#if IPFRAG_STATS
|
||||
struct stats_proto ip_frag;
|
||||
#endif
|
||||
#if IP_STATS
|
||||
struct stats_proto ip;
|
||||
#endif
|
||||
#if ICMP_STATS
|
||||
struct stats_proto icmp;
|
||||
#endif
|
||||
#if IGMP_STATS
|
||||
struct stats_igmp igmp;
|
||||
#endif
|
||||
#if UDP_STATS
|
||||
struct stats_proto udp;
|
||||
#endif
|
||||
#if TCP_STATS
|
||||
struct stats_proto tcp;
|
||||
#endif
|
||||
#if MEM_STATS
|
||||
struct stats_mem mem;
|
||||
#endif
|
||||
#if MEMP_STATS
|
||||
struct stats_mem memp[MEMP_MAX];
|
||||
#endif
|
||||
#if SYS_STATS
|
||||
struct stats_sys sys;
|
||||
#endif
|
||||
#if IP6_STATS
|
||||
struct stats_proto ip6;
|
||||
#endif
|
||||
#if ICMP6_STATS
|
||||
struct stats_proto icmp6;
|
||||
#endif
|
||||
#if IP6_FRAG_STATS
|
||||
struct stats_proto ip6_frag;
|
||||
#endif
|
||||
#if MLD6_STATS
|
||||
struct stats_igmp mld6;
|
||||
#endif
|
||||
#if ND6_STATS
|
||||
struct stats_proto nd6;
|
||||
#endif
|
||||
#if MIB2_STATS
|
||||
struct stats_mib2 mib2;
|
||||
#endif
|
||||
#if ESP_STATS_DROP
|
||||
struct stats_esp esp;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern struct stats_ lwip_stats;
|
||||
|
||||
void stats_init(void);
|
||||
|
||||
#define STATS_INC(x) ++lwip_stats.x
|
||||
#define STATS_DEC(x) --lwip_stats.x
|
||||
#define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \
|
||||
if (lwip_stats.x.max < lwip_stats.x.used) { \
|
||||
lwip_stats.x.max = lwip_stats.x.used; \
|
||||
} \
|
||||
} while(0)
|
||||
#define STATS_GET(x) lwip_stats.x
|
||||
#else /* LWIP_STATS */
|
||||
#define stats_init()
|
||||
#define STATS_INC(x)
|
||||
#define STATS_DEC(x)
|
||||
#define STATS_INC_USED(x)
|
||||
#endif /* LWIP_STATS */
|
||||
|
||||
#if TCP_STATS
|
||||
#define TCP_STATS_INC(x) STATS_INC(x)
|
||||
#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
|
||||
#else
|
||||
#define TCP_STATS_INC(x)
|
||||
#define TCP_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if UDP_STATS
|
||||
#define UDP_STATS_INC(x) STATS_INC(x)
|
||||
#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
|
||||
#else
|
||||
#define UDP_STATS_INC(x)
|
||||
#define UDP_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if ICMP_STATS
|
||||
#define ICMP_STATS_INC(x) STATS_INC(x)
|
||||
#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
|
||||
#else
|
||||
#define ICMP_STATS_INC(x)
|
||||
#define ICMP_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if IGMP_STATS
|
||||
#define IGMP_STATS_INC(x) STATS_INC(x)
|
||||
#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp, "IGMP")
|
||||
#else
|
||||
#define IGMP_STATS_INC(x)
|
||||
#define IGMP_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if IP_STATS
|
||||
#define IP_STATS_INC(x) STATS_INC(x)
|
||||
#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
|
||||
#else
|
||||
#define IP_STATS_INC(x)
|
||||
#define IP_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if IPFRAG_STATS
|
||||
#define IPFRAG_STATS_INC(x) STATS_INC(x)
|
||||
#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
|
||||
#else
|
||||
#define IPFRAG_STATS_INC(x)
|
||||
#define IPFRAG_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if ETHARP_STATS
|
||||
#define ETHARP_STATS_INC(x) STATS_INC(x)
|
||||
#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
|
||||
#else
|
||||
#define ETHARP_STATS_INC(x)
|
||||
#define ETHARP_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if LINK_STATS
|
||||
#define LINK_STATS_INC(x) STATS_INC(x)
|
||||
#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
|
||||
#else
|
||||
#define LINK_STATS_INC(x)
|
||||
#define LINK_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#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_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
|
||||
#else
|
||||
#define MEM_STATS_AVAIL(x, y)
|
||||
#define MEM_STATS_INC(x)
|
||||
#define MEM_STATS_INC_USED(x, y)
|
||||
#define MEM_STATS_DEC_USED(x, y)
|
||||
#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)
|
||||
#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
|
||||
|
||||
#if SYS_STATS
|
||||
#define SYS_STATS_INC(x) STATS_INC(sys.x)
|
||||
#define SYS_STATS_DEC(x) STATS_DEC(sys.x)
|
||||
#define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1)
|
||||
#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
|
||||
#else
|
||||
#define SYS_STATS_INC(x)
|
||||
#define SYS_STATS_DEC(x)
|
||||
#define SYS_STATS_INC_USED(x)
|
||||
#define SYS_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if IP6_STATS
|
||||
#define IP6_STATS_INC(x) STATS_INC(x)
|
||||
#define IP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6, "IPv6")
|
||||
#else
|
||||
#define IP6_STATS_INC(x)
|
||||
#define IP6_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if ICMP6_STATS
|
||||
#define ICMP6_STATS_INC(x) STATS_INC(x)
|
||||
#define ICMP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp6, "ICMPv6")
|
||||
#else
|
||||
#define ICMP6_STATS_INC(x)
|
||||
#define ICMP6_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if IP6_FRAG_STATS
|
||||
#define IP6_FRAG_STATS_INC(x) STATS_INC(x)
|
||||
#define IP6_FRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6_frag, "IPv6 FRAG")
|
||||
#else
|
||||
#define IP6_FRAG_STATS_INC(x)
|
||||
#define IP6_FRAG_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if MLD6_STATS
|
||||
#define MLD6_STATS_INC(x) STATS_INC(x)
|
||||
#define MLD6_STATS_DISPLAY() stats_display_igmp(&lwip_stats.mld6, "MLDv1")
|
||||
#else
|
||||
#define MLD6_STATS_INC(x)
|
||||
#define MLD6_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if ND6_STATS
|
||||
#define ND6_STATS_INC(x) STATS_INC(x)
|
||||
#define ND6_STATS_DISPLAY() stats_display_proto(&lwip_stats.nd6, "ND")
|
||||
#else
|
||||
#define ND6_STATS_INC(x)
|
||||
#define ND6_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if MIB2_STATS
|
||||
#define MIB2_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define MIB2_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
#if ESP_STATS_DROP
|
||||
#define ESP_STATS_DROP_INC(x) STATS_INC(x)
|
||||
#define ESP_STATS_DROP_DISPLAY() stats_display_esp(&lwip_stats.esp);
|
||||
#else
|
||||
#define ESP_STATS_DROP_INC(x)
|
||||
#define ESP_STATS_DROP_DISPLAY()
|
||||
#endif
|
||||
|
||||
/* Display of statistics */
|
||||
#if LWIP_STATS_DISPLAY
|
||||
void stats_display(void);
|
||||
void stats_display_proto(struct stats_proto *proto, const char *name);
|
||||
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);
|
||||
void stats_display_esp(struct stats_esp *esp);
|
||||
#else /* LWIP_STATS_DISPLAY */
|
||||
#define stats_display()
|
||||
#define stats_display_proto(proto, name)
|
||||
#define stats_display_igmp(igmp, name)
|
||||
#define stats_display_mem(mem, name)
|
||||
#define stats_display_memp(mem, index)
|
||||
#define stats_display_sys(sys)
|
||||
#define stats_display_esp(esp)
|
||||
#endif /* LWIP_STATS_DISPLAY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_STATS_H */
|
||||
@@ -1,366 +0,0 @@
|
||||
/*
|
||||
* 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_SYS_H
|
||||
#define LWIP_HDR_SYS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if NO_SYS
|
||||
|
||||
/* For a totally minimal and standalone system, we provide null
|
||||
definitions of the sys_ functions. */
|
||||
typedef u8_t sys_sem_t;
|
||||
typedef u8_t sys_mutex_t;
|
||||
typedef u8_t sys_mbox_t;
|
||||
|
||||
#define sys_sem_new(s, c) ERR_OK
|
||||
#define sys_sem_signal(s)
|
||||
#define sys_sem_wait(s)
|
||||
#define sys_arch_sem_wait(s,t)
|
||||
#define sys_sem_free(s)
|
||||
#define sys_sem_valid(s) 0
|
||||
#define sys_sem_valid_val(s) 0
|
||||
#define sys_sem_set_invalid(s)
|
||||
#define sys_sem_set_invalid_val(s)
|
||||
#define sys_mutex_new(mu) ERR_OK
|
||||
#define sys_mutex_lock(mu)
|
||||
#define sys_mutex_unlock(mu)
|
||||
#define sys_mutex_free(mu)
|
||||
#define sys_mutex_valid(mu) 0
|
||||
#define sys_mutex_set_invalid(mu)
|
||||
#define sys_mbox_new(m, s) ERR_OK
|
||||
#define sys_mbox_fetch(m,d)
|
||||
#define sys_mbox_tryfetch(m,d)
|
||||
#define sys_mbox_post(m,d)
|
||||
#define sys_mbox_trypost(m,d)
|
||||
#define sys_mbox_free(m)
|
||||
#define sys_mbox_valid(m)
|
||||
#define sys_mbox_valid_val(m)
|
||||
#define sys_mbox_set_invalid(m)
|
||||
#define sys_mbox_set_invalid_val(m)
|
||||
|
||||
#define sys_thread_new(n,t,a,s,p)
|
||||
|
||||
#define sys_msleep(t)
|
||||
|
||||
#else /* NO_SYS */
|
||||
|
||||
/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
|
||||
#define SYS_ARCH_TIMEOUT 0xffffffffUL
|
||||
|
||||
/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate.
|
||||
* For now we use the same magic value, but we allow this to change in future.
|
||||
*/
|
||||
#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "arch/sys_arch.h"
|
||||
|
||||
/** Function prototype for thread functions */
|
||||
typedef void (*lwip_thread_fn)(void *arg);
|
||||
|
||||
/* Function prototypes for functions to be implemented by platform ports
|
||||
(in sys_arch.c) */
|
||||
|
||||
/* Mutex functions: */
|
||||
|
||||
/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
|
||||
should be used instead */
|
||||
#ifndef LWIP_COMPAT_MUTEX
|
||||
#define LWIP_COMPAT_MUTEX 0
|
||||
#endif
|
||||
|
||||
#if LWIP_COMPAT_MUTEX
|
||||
/* for old ports that don't have mutexes: define them to binary semaphores */
|
||||
#define sys_mutex_t sys_sem_t
|
||||
#define sys_mutex_new(mutex) sys_sem_new(mutex, 1)
|
||||
#define sys_mutex_lock(mutex) sys_sem_wait(mutex)
|
||||
#define sys_mutex_unlock(mutex) sys_sem_signal(mutex)
|
||||
#define sys_mutex_free(mutex) sys_sem_free(mutex)
|
||||
#define sys_mutex_valid(mutex) sys_sem_valid(mutex)
|
||||
#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex)
|
||||
|
||||
#else /* LWIP_COMPAT_MUTEX */
|
||||
|
||||
/** Create a new mutex
|
||||
* @param mutex pointer to the mutex to create
|
||||
* @return a new mutex */
|
||||
err_t sys_mutex_new(sys_mutex_t *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 */
|
||||
void sys_mutex_unlock(sys_mutex_t *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 */
|
||||
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 */
|
||||
void sys_mutex_set_invalid(sys_mutex_t *mutex);
|
||||
#endif
|
||||
#endif /* LWIP_COMPAT_MUTEX */
|
||||
|
||||
/* Semaphore functions: */
|
||||
|
||||
/** 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 */
|
||||
err_t sys_sem_new(sys_sem_t *sem, u8_t count);
|
||||
/** Signals a semaphore
|
||||
* @param sem the semaphore to signal */
|
||||
void sys_sem_signal(sys_sem_t *sem);
|
||||
/** 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
|
||||
* @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 */
|
||||
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout);
|
||||
/** 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 */
|
||||
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 */
|
||||
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 */
|
||||
#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 */
|
||||
#define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem))
|
||||
#endif
|
||||
|
||||
/* Time functions. */
|
||||
#ifndef sys_msleep
|
||||
void sys_msleep(u32_t ms); /* only has a (close to) 1 ms resolution. */
|
||||
#endif
|
||||
|
||||
/* Mailbox functions. */
|
||||
|
||||
/** 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 */
|
||||
err_t sys_mbox_new(sys_mbox_t *mbox, int size);
|
||||
/** 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) */
|
||||
void sys_mbox_post(sys_mbox_t *mbox, void *msg);
|
||||
/** 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) */
|
||||
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg);
|
||||
/** 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! */
|
||||
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
|
||||
* @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 */
|
||||
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg);
|
||||
#endif
|
||||
/** 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 */
|
||||
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 */
|
||||
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 */
|
||||
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 */
|
||||
#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 */
|
||||
#define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox))
|
||||
#endif
|
||||
|
||||
|
||||
/** 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)
|
||||
* @param thread thread-function
|
||||
* @param arg parameter passed to 'thread'
|
||||
* @param stacksize stack size in bytes for the new thread (may be ignored by ports)
|
||||
* @param prio priority of the new thread (may be ignored by ports) */
|
||||
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
|
||||
|
||||
#endif /* NO_SYS */
|
||||
|
||||
/* sys_init() must be called before anything else. */
|
||||
void sys_init(void);
|
||||
|
||||
#ifndef sys_jiffies
|
||||
/** 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. */
|
||||
u32_t sys_now(void);
|
||||
|
||||
/* Critical Region Protection */
|
||||
/* These functions must be implemented in the sys_arch.c file.
|
||||
In some implementations they can provide a more light-weight protection
|
||||
mechanism than using semaphores. Otherwise semaphores can be used for
|
||||
implementation */
|
||||
#ifndef SYS_ARCH_PROTECT
|
||||
/** SYS_LIGHTWEIGHT_PROT
|
||||
* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
|
||||
* for certain critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#if SYS_LIGHTWEIGHT_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
|
||||
* 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
|
||||
* already protected. The old protection level is returned in the variable
|
||||
* "lev". This macro will default to calling the sys_arch_protect() function
|
||||
* which should be implemented in sys_arch.c. If a particular port needs a
|
||||
* different implementation, then this macro may be defined in sys_arch.h
|
||||
*/
|
||||
#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
|
||||
/** 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
|
||||
* sys_arch_unprotect() function which should be implemented in
|
||||
* sys_arch.c. If a particular port needs a different implementation, then
|
||||
* this macro may be defined in sys_arch.h
|
||||
*/
|
||||
#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)
|
||||
sys_prot_t sys_arch_protect(void);
|
||||
void sys_arch_unprotect(sys_prot_t pval);
|
||||
|
||||
#else
|
||||
|
||||
#define SYS_ARCH_DECL_PROTECT(lev)
|
||||
#define SYS_ARCH_PROTECT(lev)
|
||||
#define SYS_ARCH_UNPROTECT(lev)
|
||||
|
||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
||||
|
||||
#endif /* SYS_ARCH_PROTECT */
|
||||
|
||||
/*
|
||||
* Macros to set/get and increase/decrease variables in a thread-safe way.
|
||||
* Use these for accessing variable that are used from more than one thread.
|
||||
*/
|
||||
|
||||
#ifndef SYS_ARCH_INC
|
||||
#define SYS_ARCH_INC(var, val) do { \
|
||||
SYS_ARCH_DECL_PROTECT(old_level); \
|
||||
SYS_ARCH_PROTECT(old_level); \
|
||||
var += val; \
|
||||
SYS_ARCH_UNPROTECT(old_level); \
|
||||
} while(0)
|
||||
#endif /* SYS_ARCH_INC */
|
||||
|
||||
#ifndef SYS_ARCH_DEC
|
||||
#define SYS_ARCH_DEC(var, val) do { \
|
||||
SYS_ARCH_DECL_PROTECT(old_level); \
|
||||
SYS_ARCH_PROTECT(old_level); \
|
||||
var -= val; \
|
||||
SYS_ARCH_UNPROTECT(old_level); \
|
||||
} while(0)
|
||||
#endif /* SYS_ARCH_DEC */
|
||||
|
||||
#ifndef SYS_ARCH_GET
|
||||
#define SYS_ARCH_GET(var, ret) do { \
|
||||
SYS_ARCH_DECL_PROTECT(old_level); \
|
||||
SYS_ARCH_PROTECT(old_level); \
|
||||
ret = var; \
|
||||
SYS_ARCH_UNPROTECT(old_level); \
|
||||
} while(0)
|
||||
#endif /* SYS_ARCH_GET */
|
||||
|
||||
#ifndef SYS_ARCH_SET
|
||||
#define SYS_ARCH_SET(var, val) do { \
|
||||
SYS_ARCH_DECL_PROTECT(old_level); \
|
||||
SYS_ARCH_PROTECT(old_level); \
|
||||
var = val; \
|
||||
SYS_ARCH_UNPROTECT(old_level); \
|
||||
} while(0)
|
||||
#endif /* SYS_ARCH_SET */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_SYS_H */
|
||||
@@ -1,449 +0,0 @@
|
||||
/*
|
||||
* 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_TCP_H
|
||||
#define LWIP_HDR_TCP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/icmp.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/ip6.h"
|
||||
#include "lwip/ip6_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct tcp_pcb;
|
||||
|
||||
/** Function prototype for tcp accept callback functions. Called when a new
|
||||
* connection can be accepted on a listening pcb.
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
|
||||
* @param newpcb The new connection pcb
|
||||
* @param err An error code if there has been an error accepting.
|
||||
* Only return ERR_ABRT if you have called tcp_abort from within the
|
||||
* callback function!
|
||||
*/
|
||||
typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err);
|
||||
|
||||
/** Function prototype for tcp receive callback functions. Called when data has
|
||||
* been received.
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
|
||||
* @param tpcb The connection pcb which received data
|
||||
* @param p The received data (or NULL when the connection has been closed!)
|
||||
* @param err An error code if there has been an error receiving
|
||||
* Only return ERR_ABRT if you have called tcp_abort from within the
|
||||
* callback function!
|
||||
*/
|
||||
typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb,
|
||||
struct pbuf *p, err_t err);
|
||||
|
||||
/** Function prototype for tcp sent callback functions. Called when sent data has
|
||||
* been acknowledged by the remote side. Use it to free corresponding resources.
|
||||
* This also means that the pcb has now space available to send new data.
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
|
||||
* @param tpcb The connection pcb for which data has been acknowledged
|
||||
* @param len The amount of bytes acknowledged
|
||||
* @return ERR_OK: try to send some data by calling tcp_output
|
||||
* Only return ERR_ABRT if you have called tcp_abort from within the
|
||||
* callback function!
|
||||
*/
|
||||
typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb,
|
||||
u16_t len);
|
||||
|
||||
/** Function prototype for tcp poll callback functions. Called periodically as
|
||||
* specified by @see tcp_poll.
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
|
||||
* @param tpcb tcp pcb
|
||||
* @return ERR_OK: try to send some data by calling tcp_output
|
||||
* Only return ERR_ABRT if you have called tcp_abort from within the
|
||||
* callback function!
|
||||
*/
|
||||
typedef err_t (*tcp_poll_fn)(void *arg, struct tcp_pcb *tpcb);
|
||||
|
||||
/** Function prototype for tcp error callback functions. Called when the pcb
|
||||
* receives a RST or is unexpectedly closed for any other reason.
|
||||
*
|
||||
* @note The corresponding pcb is already freed when this callback is called!
|
||||
*
|
||||
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
|
||||
* @param err Error code to indicate why the pcb has been closed
|
||||
* ERR_ABRT: aborted through tcp_abort or by a TCP timer
|
||||
* ERR_RST: the connection was reset by the remote host
|
||||
*/
|
||||
typedef void (*tcp_err_fn)(void *arg, err_t err);
|
||||
|
||||
/** Function prototype for tcp connected callback functions. Called when a pcb
|
||||
* is connected to the remote side after initiating a connection attempt by
|
||||
* calling tcp_connect().
|
||||
*
|
||||
* @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!
|
||||
* Only return ERR_ABRT if you have called tcp_abort from within the
|
||||
* callback function!
|
||||
*
|
||||
* @note When a connection attempt fails, the error callback is currently called!
|
||||
*/
|
||||
typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err);
|
||||
|
||||
#if LWIP_WND_SCALE
|
||||
#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))))
|
||||
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)
|
||||
typedef u16_t tcpwnd_size_t;
|
||||
typedef u16_t tcpflags_t;
|
||||
#endif
|
||||
|
||||
enum tcp_state {
|
||||
CLOSED = 0,
|
||||
LISTEN = 1,
|
||||
SYN_SENT = 2,
|
||||
SYN_RCVD = 3,
|
||||
ESTABLISHED = 4,
|
||||
FIN_WAIT_1 = 5,
|
||||
FIN_WAIT_2 = 6,
|
||||
CLOSE_WAIT = 7,
|
||||
CLOSING = 8,
|
||||
LAST_ACK = 9,
|
||||
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 */
|
||||
struct tcp_pcb {
|
||||
/** common PCB members */
|
||||
IP_PCB;
|
||||
/** protocol specific PCB members */
|
||||
TCP_PCB_COMMON(struct tcp_pcb);
|
||||
|
||||
/* ports are in host byte order */
|
||||
u16_t remote_port;
|
||||
|
||||
tcpflags_t flags;
|
||||
#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_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
|
||||
|
||||
/* the rest of the fields are in host byte order
|
||||
as we have to do some math with them */
|
||||
|
||||
/* Timers */
|
||||
u8_t polltmr, pollinterval;
|
||||
u8_t last_timer;
|
||||
u32_t tmr;
|
||||
|
||||
/* receiver variables */
|
||||
u32_t rcv_nxt; /* next seqno expected */
|
||||
tcpwnd_size_t rcv_wnd; /* receiver window available */
|
||||
tcpwnd_size_t rcv_ann_wnd; /* receiver window to announce */
|
||||
u32_t rcv_ann_right_edge; /* announced right edge of window */
|
||||
|
||||
/* Retransmission timer. */
|
||||
s16_t rtime;
|
||||
|
||||
u16_t mss; /* maximum segment size */
|
||||
|
||||
/* RTT (round trip time) estimation variables */
|
||||
u32_t rttest; /* RTT estimate in 500ms ticks */
|
||||
u32_t rtseq; /* sequence number being timed */
|
||||
s16_t sa, sv; /* @todo document this */
|
||||
|
||||
s16_t rto; /* retransmission time-out */
|
||||
u8_t nrtx; /* number of retransmissions */
|
||||
|
||||
/* fast retransmit/recovery */
|
||||
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;
|
||||
|
||||
/* sender variables */
|
||||
u32_t snd_nxt; /* next new seqno to be sent */
|
||||
u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last
|
||||
window update. */
|
||||
u32_t snd_lbb; /* Sequence number of next byte to be buffered. */
|
||||
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. */
|
||||
|
||||
#if TCP_OVERSIZE
|
||||
/* Extra bytes available at the end of the last pbuf in unsent. */
|
||||
u16_t unsent_oversize;
|
||||
#endif /* TCP_OVERSIZE */
|
||||
|
||||
/* These are ordered by sequence number: */
|
||||
struct tcp_seg *unsent; /* Unsent (queued) segments. */
|
||||
struct tcp_seg *unacked; /* Sent but unacknowledged segments. */
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
struct tcp_seg *ooseq; /* Received out of sequence segments. */
|
||||
#endif /* TCP_QUEUE_OOSEQ */
|
||||
|
||||
struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
/* Function to be called when more send buffer space is available. */
|
||||
tcp_sent_fn sent;
|
||||
/* Function to be called when (in-sequence) data has arrived. */
|
||||
tcp_recv_fn recv;
|
||||
/* Function to be called when a connection has been set up. */
|
||||
tcp_connected_fn connected;
|
||||
/* Function which is called periodically. */
|
||||
tcp_poll_fn poll;
|
||||
/* Function to be called whenever a fatal error occurs. */
|
||||
tcp_err_fn errf;
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
#if LWIP_TCP_TIMESTAMPS
|
||||
u32_t ts_lastacksent;
|
||||
u32_t ts_recent;
|
||||
#endif /* LWIP_TCP_TIMESTAMPS */
|
||||
|
||||
/* idle time before KEEPALIVE is sent */
|
||||
u32_t keep_idle;
|
||||
#if LWIP_TCP_KEEPALIVE
|
||||
u32_t keep_intvl;
|
||||
u32_t keep_cnt;
|
||||
#endif /* LWIP_TCP_KEEPALIVE */
|
||||
|
||||
/* Persist timer counter */
|
||||
u8_t persist_cnt;
|
||||
/* Persist timer back-off */
|
||||
u8_t persist_backoff;
|
||||
|
||||
/* KEEPALIVE counter */
|
||||
u8_t keep_cnt_sent;
|
||||
|
||||
#if LWIP_WND_SCALE
|
||||
u8_t snd_scale;
|
||||
u8_t rcv_scale;
|
||||
#endif
|
||||
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
struct tcp_pcb_listen *listener;
|
||||
#endif
|
||||
|
||||
#if ESP_STATS_TCP
|
||||
#define ESP_STATS_TCP_ARRAY_SIZE 20
|
||||
u16_t retry_cnt[TCP_MAXRTX];
|
||||
u16_t rto_cnt[ESP_STATS_TCP_ARRAY_SIZE];
|
||||
#endif
|
||||
};
|
||||
|
||||
#if ESP_STATS_TCP
|
||||
#define ESP_STATS_TCP_PCB(_pcb) do {\
|
||||
if ((_pcb)->unacked) {\
|
||||
(_pcb)->retry_cnt[(_pcb)->nrtx]++;\
|
||||
if ((_pcb)->rto < ESP_STATS_TCP_ARRAY_SIZE) {\
|
||||
(_pcb)->rto_cnt[(_pcb)->rto]++;\
|
||||
} else {\
|
||||
(_pcb)->rto_cnt[ESP_STATS_TCP_ARRAY_SIZE-1] ++;\
|
||||
}\
|
||||
}\
|
||||
} while(0)
|
||||
#else
|
||||
#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 {
|
||||
LWIP_EVENT_ACCEPT,
|
||||
LWIP_EVENT_SENT,
|
||||
LWIP_EVENT_RECV,
|
||||
LWIP_EVENT_CONNECTED,
|
||||
LWIP_EVENT_POLL,
|
||||
LWIP_EVENT_ERR
|
||||
};
|
||||
|
||||
err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
|
||||
enum lwip_event,
|
||||
struct pbuf *p,
|
||||
u16_t size,
|
||||
err_t err);
|
||||
|
||||
#endif /* LWIP_EVENT_API */
|
||||
|
||||
/* Application program's interface: */
|
||||
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);
|
||||
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);
|
||||
|
||||
#define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss)
|
||||
#define tcp_sndbuf(pcb) (TCPWND16((pcb)->snd_buf))
|
||||
#define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen)
|
||||
#define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY)
|
||||
#define tcp_nagle_enable(pcb) ((pcb)->flags = (tcpflags_t)((pcb)->flags & ~TF_NODELAY))
|
||||
#define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0)
|
||||
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
#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_backlog_set(pcb, new_backlog)
|
||||
#define tcp_backlog_delayed(pcb)
|
||||
#define tcp_backlog_accepted(pcb)
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
#define tcp_accepted(pcb) do { LWIP_UNUSED_ARG(pcb); } while(0) /* 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,
|
||||
u16_t port);
|
||||
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(struct tcp_pcb *pcb, u8_t backlog);
|
||||
#define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG)
|
||||
|
||||
void tcp_abort (struct tcp_pcb *pcb);
|
||||
err_t tcp_close (struct tcp_pcb *pcb);
|
||||
err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx);
|
||||
|
||||
/* Flags for "apiflags" parameter in tcp_write */
|
||||
#define TCP_WRITE_FLAG_COPY 0x01
|
||||
#define TCP_WRITE_FLAG_MORE 0x02
|
||||
|
||||
err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
|
||||
u8_t apiflags);
|
||||
|
||||
void tcp_setprio (struct tcp_pcb *pcb, u8_t prio);
|
||||
|
||||
#define TCP_PRIO_MIN 1
|
||||
#define TCP_PRIO_NORMAL 64
|
||||
#define TCP_PRIO_MAX 127
|
||||
|
||||
err_t tcp_output (struct tcp_pcb *pcb);
|
||||
|
||||
|
||||
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
|
||||
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#endif /* LWIP_HDR_TCP_H */
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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_TCPIP_H
|
||||
#define LWIP_HDR_TCPIP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if !NO_SYS /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/timers.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct pbuf;
|
||||
struct netif;
|
||||
|
||||
/** Function prototype for the init_done function passed to tcpip_init */
|
||||
typedef void (*tcpip_init_done_fn)(void *arg);
|
||||
/** Function prototype for functions passed to tcpip_callback() */
|
||||
typedef void (*tcpip_callback_fn)(void *ctx);
|
||||
|
||||
/* Forward declarations */
|
||||
struct tcpip_callback_msg;
|
||||
|
||||
void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
|
||||
|
||||
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);
|
||||
#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);
|
||||
void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg);
|
||||
err_t tcpip_trycallback(struct tcpip_callback_msg* msg);
|
||||
|
||||
/* free pbufs or heap memory from another context without blocking */
|
||||
err_t pbuf_free_callback(struct pbuf *p);
|
||||
err_t mem_free_callback(void *m);
|
||||
|
||||
#if LWIP_TCPIP_TIMEOUT
|
||||
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 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !NO_SYS */
|
||||
|
||||
#endif /* LWIP_HDR_TCPIP_H */
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* 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>
|
||||
* Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_TIMERS_H
|
||||
#define LWIP_HDR_TIMERS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/err.h"
|
||||
#if !NO_SYS
|
||||
#include "lwip/sys.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_DEBUG_TIMERNAMES
|
||||
#ifdef LWIP_DEBUG
|
||||
#define LWIP_DEBUG_TIMERNAMES SYS_DEBUG
|
||||
#else /* LWIP_DEBUG */
|
||||
#define LWIP_DEBUG_TIMERNAMES 0
|
||||
#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().
|
||||
*
|
||||
* @param arg Additional argument to pass to the function - set up by sys_timeout()
|
||||
*/
|
||||
typedef void (* sys_timeout_handler)(void *arg);
|
||||
|
||||
struct sys_timeo {
|
||||
struct sys_timeo *next;
|
||||
u32_t time;
|
||||
sys_timeout_handler h;
|
||||
void *arg;
|
||||
#if LWIP_DEBUG_TIMERNAMES
|
||||
const char* handler_name;
|
||||
#endif /* LWIP_DEBUG_TIMERNAMES */
|
||||
};
|
||||
|
||||
void sys_timeouts_init(void);
|
||||
|
||||
#if LWIP_DEBUG_TIMERNAMES
|
||||
void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name);
|
||||
#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler)
|
||||
#else /* LWIP_DEBUG_TIMERNAMES */
|
||||
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);
|
||||
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_HDR_TIMERS_H */
|
||||
|
||||
@@ -1,200 +0,0 @@
|
||||
/*
|
||||
* 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_UDP_H
|
||||
#define LWIP_HDR_UDP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/ip6_addr.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
|
||||
#define UDP_FLAGS_MULTICAST_LOOP 0x08U
|
||||
|
||||
struct udp_pcb;
|
||||
|
||||
/** Function prototype for udp pcb receive callback functions
|
||||
* addr and port are in same byte order as in the pcb
|
||||
* The callback is responsible for freeing the pbuf
|
||||
* if it's not used any more.
|
||||
*
|
||||
* ATTENTION: Be aware that 'addr' might point into the pbuf 'p' so freeing this pbuf
|
||||
* can make 'addr' invalid, too.
|
||||
*
|
||||
* @param arg user supplied argument (udp_pcb.recv_arg)
|
||||
* @param pcb the udp_pcb which received data
|
||||
* @param p the packet buffer that was received
|
||||
* @param addr the remote IP address from which the packet was received
|
||||
* @param port the remote port from which the packet was received
|
||||
*/
|
||||
typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *addr, u16_t port);
|
||||
|
||||
struct udp_pcb {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
|
||||
/* Protocol specific PCB members */
|
||||
|
||||
struct udp_pcb *next;
|
||||
|
||||
u8_t flags;
|
||||
/** ports are in host byte order */
|
||||
u16_t local_port, remote_port;
|
||||
|
||||
#if LWIP_MULTICAST_TX_OPTIONS
|
||||
/** outgoing network interface for multicast packets */
|
||||
ip_addr_t multicast_ip;
|
||||
/** TTL for outgoing multicast packets */
|
||||
u8_t mcast_ttl;
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
#if LWIP_UDPLITE
|
||||
/** used for UDP_LITE only */
|
||||
u16_t chksum_len_rx, chksum_len_tx;
|
||||
#endif /* LWIP_UDPLITE */
|
||||
|
||||
/** receive callback function */
|
||||
udp_recv_fn recv;
|
||||
/** user-supplied argument for the recv callback */
|
||||
void *recv_arg;
|
||||
};
|
||||
/* udp_pcbs export for external reference (e.g. SNMP agent) */
|
||||
extern struct udp_pcb *udp_pcbs;
|
||||
|
||||
/* The following functions is the application layer interface to the
|
||||
UDP code. */
|
||||
struct udp_pcb * udp_new (void);
|
||||
struct udp_pcb * udp_new_ip_type(u8_t type);
|
||||
void udp_remove (struct udp_pcb *pcb);
|
||||
err_t udp_bind (struct udp_pcb *pcb, const ip_addr_t *ipaddr,
|
||||
u16_t port);
|
||||
err_t udp_connect (struct udp_pcb *pcb, const ip_addr_t *ipaddr,
|
||||
u16_t port);
|
||||
void udp_disconnect (struct udp_pcb *pcb);
|
||||
void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv,
|
||||
void *recv_arg);
|
||||
err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *dst_ip, u16_t dst_port,
|
||||
struct netif *netif);
|
||||
err_t udp_sendto_if_src(struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *dst_ip, u16_t dst_port,
|
||||
struct netif *netif, const ip_addr_t *src_ip);
|
||||
err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *dst_ip, u16_t dst_port);
|
||||
err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
|
||||
|
||||
#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
|
||||
err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *dst_ip, u16_t dst_port,
|
||||
struct netif *netif, u8_t have_chksum,
|
||||
u16_t chksum);
|
||||
err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *dst_ip, u16_t dst_port,
|
||||
u8_t have_chksum, u16_t chksum);
|
||||
err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
|
||||
u8_t have_chksum, u16_t chksum);
|
||||
err_t udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p,
|
||||
const ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif,
|
||||
u8_t have_chksum, u16_t chksum, const ip_addr_t *src_ip);
|
||||
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
|
||||
|
||||
#define udp_flags(pcb) ((pcb)->flags)
|
||||
#define udp_setflags(pcb, f) ((pcb)->flags = (f))
|
||||
|
||||
/* The following functions are the lower layer interface to UDP. */
|
||||
void udp_input (struct pbuf *p, struct netif *inp);
|
||||
|
||||
void udp_init (void);
|
||||
|
||||
/* for compatibility with older implementation */
|
||||
#define udp_new_ip6() udp_new_ip_type(IPADDR_TYPE_V6)
|
||||
|
||||
#if LWIP_MULTICAST_TX_OPTIONS
|
||||
#define udp_set_multicast_netif_addr(pcb, ip4addr) ip_addr_copy_from_ip4((pcb)->multicast_ip, *(ip4addr))
|
||||
#define udp_get_multicast_netif_addr(pcb) ip_2_ip4(&(pcb)->multicast_ip)
|
||||
#define udp_set_multicast_ttl(pcb, value) do { (pcb)->mcast_ttl = value; } while(0)
|
||||
#define udp_get_multicast_ttl(pcb) ((pcb)->mcast_ttl)
|
||||
|
||||
#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 /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
#if UDP_DEBUG
|
||||
void udp_debug_print(struct udp_hdr *udphdr);
|
||||
#else
|
||||
#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 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_UDP */
|
||||
|
||||
#endif /* LWIP_HDR_UDP_H */
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* 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 "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 */
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* 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_ETHERNET_H
|
||||
#define LWIP_HDR_NETIF_ETHERNET_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.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)
|
||||
|
||||
#if ETHARP_SUPPORT_VLAN
|
||||
|
||||
#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) (htons((vlan_hdr)->prio_vid) & 0xFFF)
|
||||
|
||||
#endif /* ETHARP_SUPPORT_VLAN */
|
||||
|
||||
/* A list of often ethtypes (although lwIP does not use all of them): */
|
||||
#define ETHTYPE_IP 0x0800U /* Internet protocol v4 */
|
||||
#define ETHTYPE_ARP 0x0806U /* Address resolution protocol */
|
||||
#define ETHTYPE_WOL 0x0842U /* Wake on lan */
|
||||
#define ETHTYPE_VLAN 0x8100U /* Virtual local area network */
|
||||
#define ETHTYPE_IPV6 0x86DDU /* Internet protocol v6 */
|
||||
#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */
|
||||
#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */
|
||||
#define ETHTYPE_JUMBO 0x8870U /* Jumbo Frames */
|
||||
#define ETHTYPE_PROFINET 0x8892U /* Process field network */
|
||||
#define ETHTYPE_ETHERCAT 0x88A4U /* Ethernet for control automation technology */
|
||||
#define ETHTYPE_LLDP 0x88CCU /* Link layer discovery protocol */
|
||||
#define ETHTYPE_SERCOS 0x88CDU /* Serial real-time communication system */
|
||||
#define ETHTYPE_PTP 0x88F7U /* Precision time protocol */
|
||||
#define ETHTYPE_QINQ 0x9100U /* Q-in-Q, 802.1ad */
|
||||
|
||||
/** 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
|
||||
|
||||
#if LWIP_ARP || LWIP_ETHERNET
|
||||
|
||||
/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type)
|
||||
* to a filter function that returns the correct netif when using multiple
|
||||
* netifs on one hardware interface where the netif's low-level receive
|
||||
* routine cannot decide for the correct netif (e.g. when mapping multiple
|
||||
* IP addresses to one hardware interface).
|
||||
*/
|
||||
#ifndef LWIP_ARP_FILTER_NETIF
|
||||
#define LWIP_ARP_FILTER_NETIF 0
|
||||
#endif
|
||||
|
||||
err_t ethernet_input(struct pbuf *p, struct netif *netif);
|
||||
|
||||
#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0)
|
||||
|
||||
extern const struct eth_addr ethbroadcast, ethzero;
|
||||
|
||||
#endif /* LWIP_ARP || LWIP_ETHERNET */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_NETIF_ETHERNET_H */
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* 6LowPAN output for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 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_LOWPAN6_H
|
||||
#define LWIP_HDR_LOWPAN6_H
|
||||
|
||||
#include "netif/lowpan6_opts.h"
|
||||
|
||||
#if LWIP_IPV6 && LWIP_6LOWPAN /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** 1 second period */
|
||||
#define LOWPAN6_TMR_INTERVAL 1000
|
||||
|
||||
void lowpan6_tmr(void);
|
||||
|
||||
err_t lowpan6_set_context(u8_t index, const ip6_addr_t * context);
|
||||
err_t lowpan6_set_short_addr(u8_t addr_high, u8_t addr_low);
|
||||
|
||||
#if LWIP_IPV4
|
||||
err_t lowpan4_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
|
||||
#endif /* LWIP_IPV4 */
|
||||
err_t lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr);
|
||||
err_t lowpan6_input(struct pbuf * p, struct netif *netif);
|
||||
err_t lowpan6_if_init(struct netif *netif);
|
||||
|
||||
/* pan_id in network byte order. */
|
||||
err_t lowpan6_set_pan_id(u16_t pan_id);
|
||||
|
||||
err_t tcpip_6lowpan_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_IPV6 && LWIP_6LOWPAN */
|
||||
|
||||
#endif /* LWIP_HDR_LOWPAN6_H */
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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_LOWPAN6_OPTS_H
|
||||
#define LWIP_HDR_LOWPAN6_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifndef LWIP_6LOWPAN
|
||||
#define LWIP_6LOWPAN 0
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_6LOWPAN_NUM_CONTEXTS
|
||||
#define LWIP_6LOWPAN_NUM_CONTEXTS 10
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_6LOWPAN_INFER_SHORT_ADDRESS
|
||||
#define LWIP_6LOWPAN_INFER_SHORT_ADDRESS 1
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_6LOWPAN_IPHC
|
||||
#define LWIP_6LOWPAN_IPHC 1
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_6LOWPAN_HW_CRC
|
||||
#define LWIP_6LOWPAN_HW_CRC 1
|
||||
#endif
|
||||
|
||||
#ifndef LOWPAN6_DEBUG
|
||||
#define LOWPAN6_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_LOWPAN6_OPTS_H */
|
||||
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
* ccp.h - Definitions for PPP Compression Control Protocol.
|
||||
*
|
||||
* Copyright (c) 1994-2002 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && CCP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef CCP_H
|
||||
#define CCP_H
|
||||
|
||||
/*
|
||||
* CCP codes.
|
||||
*/
|
||||
|
||||
#define CCP_CONFREQ 1
|
||||
#define CCP_CONFACK 2
|
||||
#define CCP_TERMREQ 5
|
||||
#define CCP_TERMACK 6
|
||||
#define CCP_RESETREQ 14
|
||||
#define CCP_RESETACK 15
|
||||
|
||||
/*
|
||||
* Max # bytes for a CCP option
|
||||
*/
|
||||
|
||||
#define CCP_MAX_OPTION_LENGTH 32
|
||||
|
||||
/*
|
||||
* Parts of a CCP packet.
|
||||
*/
|
||||
|
||||
#define CCP_CODE(dp) ((dp)[0])
|
||||
#define CCP_ID(dp) ((dp)[1])
|
||||
#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
|
||||
#define CCP_HDRLEN 4
|
||||
|
||||
#define CCP_OPT_CODE(dp) ((dp)[0])
|
||||
#define CCP_OPT_LENGTH(dp) ((dp)[1])
|
||||
#define CCP_OPT_MINLEN 2
|
||||
|
||||
#if BSDCOMPRESS_SUPPORT
|
||||
/*
|
||||
* Definitions for BSD-Compress.
|
||||
*/
|
||||
|
||||
#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
|
||||
#define CILEN_BSD_COMPRESS 3 /* length of config. option */
|
||||
|
||||
/* Macros for handling the 3rd byte of the BSD-Compress config option. */
|
||||
#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
|
||||
#define BSD_VERSION(x) ((x) >> 5) /* version of option format */
|
||||
#define BSD_CURRENT_VERSION 1 /* current version number */
|
||||
#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
|
||||
|
||||
#define BSD_MIN_BITS 9 /* smallest code size supported */
|
||||
#define BSD_MAX_BITS 15 /* largest code size supported */
|
||||
#endif /* BSDCOMPRESS_SUPPORT */
|
||||
|
||||
#if DEFLATE_SUPPORT
|
||||
/*
|
||||
* Definitions for Deflate.
|
||||
*/
|
||||
|
||||
#define CI_DEFLATE 26 /* config option for Deflate */
|
||||
#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
|
||||
#define CILEN_DEFLATE 4 /* length of its config option */
|
||||
|
||||
#define DEFLATE_MIN_SIZE 9
|
||||
#define DEFLATE_MAX_SIZE 15
|
||||
#define DEFLATE_METHOD_VAL 8
|
||||
#define DEFLATE_SIZE(x) (((x) >> 4) + 8)
|
||||
#define DEFLATE_METHOD(x) ((x) & 0x0F)
|
||||
#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL)
|
||||
#define DEFLATE_CHK_SEQUENCE 0
|
||||
#endif /* DEFLATE_SUPPORT */
|
||||
|
||||
#if MPPE_SUPPORT
|
||||
/*
|
||||
* Definitions for MPPE.
|
||||
*/
|
||||
|
||||
#define CI_MPPE 18 /* config option for MPPE */
|
||||
#define CILEN_MPPE 6 /* length of config option */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
#if PREDICTOR_SUPPORT
|
||||
/*
|
||||
* Definitions for other, as yet unsupported, compression methods.
|
||||
*/
|
||||
|
||||
#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
|
||||
#define CILEN_PREDICTOR_1 2 /* length of its config option */
|
||||
#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
|
||||
#define CILEN_PREDICTOR_2 2 /* length of its config option */
|
||||
#endif /* PREDICTOR_SUPPORT */
|
||||
|
||||
typedef struct ccp_options {
|
||||
#if DEFLATE_SUPPORT
|
||||
unsigned int deflate :1; /* do Deflate? */
|
||||
unsigned int deflate_correct :1; /* use correct code for deflate? */
|
||||
unsigned int deflate_draft :1; /* use draft RFC code for deflate? */
|
||||
#endif /* DEFLATE_SUPPORT */
|
||||
#if BSDCOMPRESS_SUPPORT
|
||||
unsigned int bsd_compress :1; /* do BSD Compress? */
|
||||
#endif /* BSDCOMPRESS_SUPPORT */
|
||||
#if PREDICTOR_SUPPORT
|
||||
unsigned int predictor_1 :1; /* do Predictor-1? */
|
||||
unsigned int predictor_2 :1; /* do Predictor-2? */
|
||||
#endif /* PREDICTOR_SUPPORT */
|
||||
|
||||
#if MPPE_SUPPORT
|
||||
u8_t mppe; /* MPPE bitfield */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
#if BSDCOMPRESS_SUPPORT
|
||||
u_short bsd_bits; /* # bits/code for BSD Compress */
|
||||
#endif /* BSDCOMPRESS_SUPPORT */
|
||||
#if DEFLATE_SUPPORT
|
||||
u_short deflate_size; /* lg(window size) for Deflate */
|
||||
#endif /* DEFLATE_SUPPORT */
|
||||
u8_t method; /* code for chosen compression method */
|
||||
} ccp_options;
|
||||
|
||||
extern const struct protent ccp_protent;
|
||||
|
||||
void ccp_resetrequest(ppp_pcb *pcb); /* Issue a reset-request. */
|
||||
|
||||
#endif /* CCP_H */
|
||||
#endif /* PPP_SUPPORT && CCP_SUPPORT */
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* chap-md5.h - New CHAP/MD5 implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
extern const struct chap_digest_type md5_digest;
|
||||
|
||||
#endif /* PPP_SUPPORT && CHAP_SUPPORT */
|
||||
@@ -1,192 +0,0 @@
|
||||
/*
|
||||
* chap-new.c - New CHAP implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef CHAP_H
|
||||
#define CHAP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* CHAP packets begin with a standard header with code, id, len (2 bytes).
|
||||
*/
|
||||
#define CHAP_HDRLEN 4
|
||||
|
||||
/*
|
||||
* Values for the code field.
|
||||
*/
|
||||
#define CHAP_CHALLENGE 1
|
||||
#define CHAP_RESPONSE 2
|
||||
#define CHAP_SUCCESS 3
|
||||
#define CHAP_FAILURE 4
|
||||
|
||||
/*
|
||||
* CHAP digest codes.
|
||||
*/
|
||||
#define CHAP_MD5 5
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MICROSOFT 0x80
|
||||
#define CHAP_MICROSOFT_V2 0x81
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* Semi-arbitrary limits on challenge and response fields.
|
||||
*/
|
||||
#define MAX_CHALLENGE_LEN 64
|
||||
#define MAX_RESPONSE_LEN 64
|
||||
|
||||
/*
|
||||
* These limits apply to challenge and response packets we send.
|
||||
* The +4 is the +1 that we actually need rounded up.
|
||||
*/
|
||||
#define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN)
|
||||
#define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN)
|
||||
|
||||
/* bitmask of supported algorithms */
|
||||
#if MSCHAP_SUPPORT
|
||||
#define MDTYPE_MICROSOFT_V2 0x1
|
||||
#define MDTYPE_MICROSOFT 0x2
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#define MDTYPE_MD5 0x4
|
||||
#define MDTYPE_NONE 0
|
||||
|
||||
#if MSCHAP_SUPPORT
|
||||
/* Return the digest alg. ID for the most preferred digest type. */
|
||||
#define CHAP_DIGEST(mdtype) \
|
||||
((mdtype) & MDTYPE_MD5)? CHAP_MD5: \
|
||||
((mdtype) & MDTYPE_MICROSOFT_V2)? CHAP_MICROSOFT_V2: \
|
||||
((mdtype) & MDTYPE_MICROSOFT)? CHAP_MICROSOFT: \
|
||||
0
|
||||
#else /* !MSCHAP_SUPPORT */
|
||||
#define CHAP_DIGEST(mdtype) \
|
||||
((mdtype) & MDTYPE_MD5)? CHAP_MD5: \
|
||||
0
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/* Return the bit flag (lsb set) for our most preferred digest type. */
|
||||
#define CHAP_MDTYPE(mdtype) ((mdtype) ^ ((mdtype) - 1)) & (mdtype)
|
||||
|
||||
/* Return the bit flag for a given digest algorithm ID. */
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MDTYPE_D(digest) \
|
||||
((digest) == CHAP_MICROSOFT_V2)? MDTYPE_MICROSOFT_V2: \
|
||||
((digest) == CHAP_MICROSOFT)? MDTYPE_MICROSOFT: \
|
||||
((digest) == CHAP_MD5)? MDTYPE_MD5: \
|
||||
0
|
||||
#else /* !MSCHAP_SUPPORT */
|
||||
#define CHAP_MDTYPE_D(digest) \
|
||||
((digest) == CHAP_MD5)? MDTYPE_MD5: \
|
||||
0
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/* Can we do the requested digest? */
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_CANDIGEST(mdtype, digest) \
|
||||
((digest) == CHAP_MICROSOFT_V2)? (mdtype) & MDTYPE_MICROSOFT_V2: \
|
||||
((digest) == CHAP_MICROSOFT)? (mdtype) & MDTYPE_MICROSOFT: \
|
||||
((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \
|
||||
0
|
||||
#else /* !MSCHAP_SUPPORT */
|
||||
#define CHAP_CANDIGEST(mdtype, digest) \
|
||||
((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \
|
||||
0
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* The code for each digest type has to supply one of these.
|
||||
*/
|
||||
struct chap_digest_type {
|
||||
int code;
|
||||
|
||||
#if PPP_SERVER
|
||||
/*
|
||||
* Note: challenge and response arguments below are formatted as
|
||||
* a length byte followed by the actual challenge/response data.
|
||||
*/
|
||||
void (*generate_challenge)(ppp_pcb *pcb, unsigned char *challenge);
|
||||
int (*verify_response)(ppp_pcb *pcb, int id, const char *name,
|
||||
const unsigned char *secret, int secret_len,
|
||||
const unsigned char *challenge, const unsigned char *response,
|
||||
char *message, int message_space);
|
||||
#endif /* PPP_SERVER */
|
||||
void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name,
|
||||
const unsigned char *challenge, const char *secret, int secret_len,
|
||||
unsigned char *priv);
|
||||
int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv);
|
||||
void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len);
|
||||
};
|
||||
|
||||
/*
|
||||
* Each interface is described by chap structure.
|
||||
*/
|
||||
#if CHAP_SUPPORT
|
||||
typedef struct chap_client_state {
|
||||
u8_t flags;
|
||||
const char *name;
|
||||
const struct chap_digest_type *digest;
|
||||
unsigned char priv[64]; /* private area for digest's use */
|
||||
} chap_client_state;
|
||||
|
||||
#if PPP_SERVER
|
||||
typedef struct chap_server_state {
|
||||
u8_t flags;
|
||||
u8_t id;
|
||||
const char *name;
|
||||
const struct chap_digest_type *digest;
|
||||
int challenge_xmits;
|
||||
int challenge_pktlen;
|
||||
unsigned char challenge[CHAL_MAX_PKTLEN];
|
||||
} chap_server_state;
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
/* Hook for a plugin to validate CHAP challenge */
|
||||
extern int (*chap_verify_hook)(char *name, char *ourname, int id,
|
||||
const struct chap_digest_type *digest,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space);
|
||||
#endif /* UNUSED */
|
||||
|
||||
#if PPP_SERVER
|
||||
/* Called by authentication code to start authenticating the peer. */
|
||||
extern void chap_auth_peer(ppp_pcb *pcb, const char *our_name, int digest_code);
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/* Called by auth. code to start authenticating us to the peer. */
|
||||
extern void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code);
|
||||
|
||||
/* Represents the CHAP protocol to the main pppd code */
|
||||
extern const struct protent chap_protent;
|
||||
|
||||
#endif /* CHAP_H */
|
||||
#endif /* PPP_SUPPORT && CHAP_SUPPORT */
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* chap_ms.h - Challenge Handshake Authentication Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1995 Eric Rosenquist. 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(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef __CHAPMS_INCLUDE__
|
||||
|
||||
extern const struct chap_digest_type chapms_digest;
|
||||
extern const struct chap_digest_type chapms2_digest;
|
||||
|
||||
#define __CHAPMS_INCLUDE__
|
||||
#endif /* __CHAPMS_INCLUDE__ */
|
||||
|
||||
#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* eap.h - Extensible Authentication Protocol for PPP (RFC 2284)
|
||||
*
|
||||
* Copyright (c) 2001 by Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Non-exclusive rights to redistribute, modify, translate, and use
|
||||
* this software in source and binary forms, in whole or in part, is
|
||||
* hereby granted, provided that the above copyright notice is
|
||||
* duplicated in any source form, and that neither the name of the
|
||||
* copyright holder nor the author is used to endorse or promote
|
||||
* products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Original version by James Carlson
|
||||
*
|
||||
* $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_EAP_H
|
||||
#define PPP_EAP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define EAP_HEADERLEN 4
|
||||
|
||||
|
||||
/* EAP message codes. */
|
||||
#define EAP_REQUEST 1
|
||||
#define EAP_RESPONSE 2
|
||||
#define EAP_SUCCESS 3
|
||||
#define EAP_FAILURE 4
|
||||
|
||||
/* EAP types */
|
||||
#define EAPT_IDENTITY 1
|
||||
#define EAPT_NOTIFICATION 2
|
||||
#define EAPT_NAK 3 /* (response only) */
|
||||
#define EAPT_MD5CHAP 4
|
||||
#define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
|
||||
#define EAPT_TOKEN 6 /* Generic Token Card */
|
||||
/* 7 and 8 are unassigned. */
|
||||
#define EAPT_RSA 9 /* RSA Public Key Authentication */
|
||||
#define EAPT_DSS 10 /* DSS Unilateral */
|
||||
#define EAPT_KEA 11 /* KEA */
|
||||
#define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
|
||||
#define EAPT_TLS 13 /* EAP-TLS */
|
||||
#define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
|
||||
#define EAPT_W2K 15 /* Windows 2000 EAP */
|
||||
#define EAPT_ARCOT 16 /* Arcot Systems */
|
||||
#define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
|
||||
#define EAPT_NOKIACARD 18 /* Nokia IP smart card */
|
||||
#define EAPT_SRP 19 /* Secure Remote Password */
|
||||
/* 20 is deprecated */
|
||||
|
||||
/* EAP SRP-SHA1 Subtypes */
|
||||
#define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
|
||||
#define EAPSRP_CKEY 1 /* Response 1 - Client Key */
|
||||
#define EAPSRP_SKEY 2 /* Request 2 - Server Key */
|
||||
#define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
|
||||
#define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
|
||||
#define EAPSRP_ACK 3 /* Response 3 - final ack */
|
||||
#define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
|
||||
|
||||
#define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
|
||||
|
||||
#define SRP_PSEUDO_ID "pseudo_"
|
||||
#define SRP_PSEUDO_LEN 7
|
||||
|
||||
#define MD5_SIGNATURE_SIZE 16
|
||||
#define EAP_MIN_CHALLENGE_LENGTH 17
|
||||
#define EAP_MAX_CHALLENGE_LENGTH 24
|
||||
#define EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH 3 /* 2^3-1 = 7, 17+7 = 24 */
|
||||
|
||||
#define EAP_STATES \
|
||||
"Initial", "Pending", "Closed", "Listen", "Identify", \
|
||||
"SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
|
||||
|
||||
#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen)
|
||||
#if PPP_SERVER
|
||||
#define eap_server_active(pcb) \
|
||||
((pcb)->eap.es_server.ea_state >= eapIdentify && \
|
||||
(pcb)->eap.es_server.ea_state <= eapMD5Chall)
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/*
|
||||
* Complete EAP state for one PPP session.
|
||||
*/
|
||||
enum eap_state_code {
|
||||
eapInitial = 0, /* No EAP authentication yet requested */
|
||||
eapPending, /* Waiting for LCP (no timer) */
|
||||
eapClosed, /* Authentication not in use */
|
||||
eapListen, /* Client ready (and timer running) */
|
||||
eapIdentify, /* EAP Identify sent */
|
||||
eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
|
||||
eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
|
||||
eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
|
||||
eapMD5Chall, /* Sent MD5-Challenge */
|
||||
eapOpen, /* Completed authentication */
|
||||
eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
|
||||
eapBadAuth /* Failed authentication */
|
||||
};
|
||||
|
||||
struct eap_auth {
|
||||
const char *ea_name; /* Our name */
|
||||
char ea_peer[MAXNAMELEN +1]; /* Peer's name */
|
||||
void *ea_session; /* Authentication library linkage */
|
||||
u_char *ea_skey; /* Shared encryption key */
|
||||
u_short ea_namelen; /* Length of our name */
|
||||
u_short ea_peerlen; /* Length of peer's name */
|
||||
enum eap_state_code ea_state;
|
||||
u_char ea_id; /* Current id */
|
||||
u_char ea_requests; /* Number of Requests sent/received */
|
||||
u_char ea_responses; /* Number of Responses */
|
||||
u_char ea_type; /* One of EAPT_* */
|
||||
u32_t ea_keyflags; /* SRP shared key usage flags */
|
||||
};
|
||||
|
||||
#ifndef EAP_MAX_CHALLENGE_LENGTH
|
||||
#define EAP_MAX_CHALLENGE_LENGTH 24
|
||||
#endif
|
||||
typedef struct eap_state {
|
||||
struct eap_auth es_client; /* Client (authenticatee) data */
|
||||
#if PPP_SERVER
|
||||
struct eap_auth es_server; /* Server (authenticator) data */
|
||||
#endif /* PPP_SERVER */
|
||||
int es_savedtime; /* Saved timeout */
|
||||
int es_rechallenge; /* EAP rechallenge interval */
|
||||
int es_lwrechallenge; /* SRP lightweight rechallenge inter */
|
||||
u8_t es_usepseudo; /* Use SRP Pseudonym if offered one */
|
||||
int es_usedpseudo; /* Set if we already sent PN */
|
||||
int es_challen; /* Length of challenge string */
|
||||
u_char es_challenge[EAP_MAX_CHALLENGE_LENGTH];
|
||||
} eap_state;
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#if 0 /* moved to opt.h */
|
||||
#define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
|
||||
#define EAP_DEFTRANSMITS 10 /* max # times to transmit */
|
||||
#define EAP_DEFREQTIME 20 /* Time to wait for peer request */
|
||||
#define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
void eap_authwithpeer(ppp_pcb *pcb, const char *localname);
|
||||
void eap_authpeer(ppp_pcb *pcb, const char *localname);
|
||||
|
||||
extern const struct protent eap_protent;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PPP_EAP_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && EAP_SUPPORT */
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* ecp.h - Definitions for PPP Encryption Control Protocol.
|
||||
*
|
||||
* Copyright (c) 2002 Google, Inc.
|
||||
* 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(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
typedef struct ecp_options {
|
||||
bool required; /* Is ECP required? */
|
||||
unsigned enctype; /* Encryption type */
|
||||
} ecp_options;
|
||||
|
||||
extern fsm ecp_fsm[];
|
||||
extern ecp_options ecp_wantoptions[];
|
||||
extern ecp_options ecp_gotoptions[];
|
||||
extern ecp_options ecp_allowoptions[];
|
||||
extern ecp_options ecp_hisoptions[];
|
||||
|
||||
extern const struct protent ecp_protent;
|
||||
|
||||
#endif /* PPP_SUPPORT && ECP_SUPPORT */
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* eui64.h - EUI64 routines for IPv6CP.
|
||||
*
|
||||
* Copyright (c) 1999 Tommi Komulainen. 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(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Tommi Komulainen
|
||||
* <Tommi.Komulainen@iki.fi>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef __EUI64_H__
|
||||
#define __EUI64_H__
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* Maybe this should be done by processing struct in6_addr directly...
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
u8_t e8[8];
|
||||
u16_t e16[4];
|
||||
u32_t e32[2];
|
||||
} eui64_t;
|
||||
|
||||
#define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0)
|
||||
#define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \
|
||||
((e).e32[1] == (o).e32[1]))
|
||||
#define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0;
|
||||
|
||||
#define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t))
|
||||
|
||||
#define eui64_magic(e) do { \
|
||||
(e).e32[0] = magic(); \
|
||||
(e).e32[1] = magic(); \
|
||||
(e).e8[0] &= ~2; \
|
||||
} while (0)
|
||||
#define eui64_magic_nz(x) do { \
|
||||
eui64_magic(x); \
|
||||
} while (eui64_iszero(x))
|
||||
#define eui64_magic_ne(x, y) do { \
|
||||
eui64_magic(x); \
|
||||
} while (eui64_equals(x, y))
|
||||
|
||||
#define eui64_get(ll, cp) do { \
|
||||
eui64_copy((*cp), (ll)); \
|
||||
(cp) += sizeof(eui64_t); \
|
||||
} while (0)
|
||||
|
||||
#define eui64_put(ll, cp) do { \
|
||||
eui64_copy((ll), (*cp)); \
|
||||
(cp) += sizeof(eui64_t); \
|
||||
} while (0)
|
||||
|
||||
#define eui64_set32(e, l) do { \
|
||||
(e).e32[0] = 0; \
|
||||
(e).e32[1] = htonl(l); \
|
||||
} while (0)
|
||||
#define eui64_setlo32(e, l) eui64_set32(e, l)
|
||||
|
||||
char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */
|
||||
|
||||
#endif /* __EUI64_H__ */
|
||||
#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */
|
||||
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef FSM_H
|
||||
#define FSM_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* CP (LCP, IPCP, etc.) codes.
|
||||
*/
|
||||
#define CONFREQ 1 /* Configuration Request */
|
||||
#define CONFACK 2 /* Configuration Ack */
|
||||
#define CONFNAK 3 /* Configuration Nak */
|
||||
#define CONFREJ 4 /* Configuration Reject */
|
||||
#define TERMREQ 5 /* Termination Request */
|
||||
#define TERMACK 6 /* Termination Ack */
|
||||
#define CODEREJ 7 /* Code Reject */
|
||||
|
||||
|
||||
/*
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
ppp_pcb *pcb; /* PPP Interface */
|
||||
const struct fsm_callbacks *callbacks; /* Callback routines */
|
||||
const char *term_reason; /* Reason for closing protocol */
|
||||
u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */
|
||||
/* -- This is our only flag, we might use u_int :1 if we have more flags */
|
||||
u16_t protocol; /* Data Link Layer Protocol field value */
|
||||
u8_t state; /* State */
|
||||
u8_t flags; /* Contains option bits */
|
||||
u8_t id; /* Current id */
|
||||
u8_t reqid; /* Current request id */
|
||||
u8_t retransmits; /* Number of retransmissions left */
|
||||
u8_t nakloops; /* Number of nak loops since last ack */
|
||||
u8_t rnakloops; /* Number of naks received */
|
||||
u8_t maxnakloops; /* Maximum number of nak loops tolerated
|
||||
(necessary because IPCP require a custom large max nak loops value) */
|
||||
u8_t term_reason_len; /* Length of term_reason */
|
||||
} fsm;
|
||||
|
||||
|
||||
typedef struct fsm_callbacks {
|
||||
void (*resetci) /* Reset our Configuration Information */
|
||||
(fsm *);
|
||||
int (*cilen) /* Length of our Configuration Information */
|
||||
(fsm *);
|
||||
void (*addci) /* Add our Configuration Information */
|
||||
(fsm *, u_char *, int *);
|
||||
int (*ackci) /* ACK our Configuration Information */
|
||||
(fsm *, u_char *, int);
|
||||
int (*nakci) /* NAK our Configuration Information */
|
||||
(fsm *, u_char *, int, int);
|
||||
int (*rejci) /* Reject our Configuration Information */
|
||||
(fsm *, u_char *, int);
|
||||
int (*reqci) /* Request peer's Configuration Information */
|
||||
(fsm *, u_char *, int *, int);
|
||||
void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */
|
||||
(fsm *);
|
||||
void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */
|
||||
(fsm *);
|
||||
void (*starting) /* Called when we want the lower layer */
|
||||
(fsm *);
|
||||
void (*finished) /* Called when we don't want the lower layer */
|
||||
(fsm *);
|
||||
void (*protreject) /* Called when Protocol-Reject received */
|
||||
(int);
|
||||
void (*retransmit) /* Retransmission is necessary */
|
||||
(fsm *);
|
||||
int (*extcode) /* Called when unknown code received */
|
||||
(fsm *, int, int, u_char *, int);
|
||||
const char *proto_name; /* String name for protocol (for messages) */
|
||||
} fsm_callbacks;
|
||||
|
||||
|
||||
/*
|
||||
* Link states.
|
||||
*/
|
||||
#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */
|
||||
#define PPP_FSM_STARTING 1 /* Down, been opened */
|
||||
#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */
|
||||
#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */
|
||||
#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */
|
||||
#define PPP_FSM_STOPPING 5 /* Terminating, but open */
|
||||
#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */
|
||||
#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */
|
||||
#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */
|
||||
#define PPP_FSM_OPENED 9 /* Connection available */
|
||||
|
||||
|
||||
/*
|
||||
* Flags - indicate options controlling FSM operation
|
||||
*/
|
||||
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
|
||||
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
|
||||
#define OPT_SILENT 4 /* Wait for peer to speak first */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#if 0 /* moved to opt.h */
|
||||
#define DEFTIMEOUT 3 /* Timeout time in seconds */
|
||||
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init(fsm *f);
|
||||
void fsm_lowerup(fsm *f);
|
||||
void fsm_lowerdown(fsm *f);
|
||||
void fsm_open(fsm *f);
|
||||
void fsm_close(fsm *f, const char *reason);
|
||||
void fsm_input(fsm *f, u_char *inpacket, int l);
|
||||
void fsm_protreject(fsm *f);
|
||||
void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen);
|
||||
|
||||
|
||||
#endif /* FSM_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipcp.h,v 1.14 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPP_IPV4_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef IPCP_H
|
||||
#define IPCP_H
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_ADDRS 1 /* IP Addresses */
|
||||
#if VJ_SUPPORT
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#endif /* VJ_SUPPORT */
|
||||
#define CI_ADDR 3
|
||||
|
||||
#if LWIP_DNS
|
||||
#define CI_MS_DNS1 129 /* Primary DNS value */
|
||||
#define CI_MS_DNS2 131 /* Secondary DNS value */
|
||||
#endif /* LWIP_DNS */
|
||||
#if 0 /* UNUSED - WINS */
|
||||
#define CI_MS_WINS1 130 /* Primary WINS value */
|
||||
#define CI_MS_WINS2 132 /* Secondary WINS value */
|
||||
#endif /* UNUSED - WINS */
|
||||
|
||||
#if VJ_SUPPORT
|
||||
#define MAX_STATES 16 /* from slcompress.h */
|
||||
|
||||
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
|
||||
#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
|
||||
#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
|
||||
/* maxslot and slot number compression) */
|
||||
|
||||
#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/
|
||||
#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
|
||||
/* compression option*/
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
typedef struct ipcp_options {
|
||||
unsigned int neg_addr :1; /* Negotiate IP Address? */
|
||||
unsigned int old_addrs :1; /* Use old (IP-Addresses) option? */
|
||||
unsigned int req_addr :1; /* Ask peer to send IP address? */
|
||||
#if 0 /* UNUSED */
|
||||
unsigned int default_route :1; /* Assign default route through interface? */
|
||||
unsigned int replace_default_route :1; /* Replace default route through interface? */
|
||||
#endif /* UNUSED */
|
||||
#if 0 /* UNUSED - PROXY ARP */
|
||||
unsigned int proxy_arp :1; /* Make proxy ARP entry for peer? */
|
||||
#endif /* UNUSED - PROXY ARP */
|
||||
#if VJ_SUPPORT
|
||||
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
||||
unsigned int old_vj :1; /* use old (short) form of VJ option? */
|
||||
unsigned int cflag :1;
|
||||
#endif /* VJ_SUPPORT */
|
||||
unsigned int accept_local :1; /* accept peer's value for ouraddr */
|
||||
unsigned int accept_remote :1; /* accept peer's value for hisaddr */
|
||||
#if LWIP_DNS
|
||||
unsigned int req_dns1 :1; /* Ask peer to send primary DNS address? */
|
||||
unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
#if LWIP_DNS
|
||||
u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
#endif /* LWIP_DNS */
|
||||
#if 0 /* UNUSED - WINS */
|
||||
u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
#endif /* UNUSED - WINS */
|
||||
|
||||
#if VJ_SUPPORT
|
||||
u16_t vj_protocol; /* protocol value to use in VJ option */
|
||||
u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||
#endif /* VJ_SUPPORT */
|
||||
} ipcp_options;
|
||||
|
||||
#if 0 /* UNUSED, already defined by lwIP */
|
||||
char *ip_ntoa (u32_t);
|
||||
#endif /* UNUSED, already defined by lwIP */
|
||||
|
||||
extern const struct protent ipcp_protent;
|
||||
|
||||
#endif /* IPCP_H */
|
||||
#endif /* PPP_SUPPORT && PPP_IPV4_SUPPORT */
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* ipv6cp.h - PPP IPV6 Control Protocol.
|
||||
*
|
||||
* Copyright (c) 1999 Tommi Komulainen. 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(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Tommi Komulainen
|
||||
* <Tommi.Komulainen@iki.fi>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Original version, based on RFC2023 :
|
||||
|
||||
Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA Rocquencourt,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Copyright (c) 1998, 1999 Francis.Dupont@inria.fr, GIE DYADE,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Ce travail a été fait au sein du GIE DYADE (Groupement d'Intérêt
|
||||
Économique ayant pour membres BULL S.A. et l'INRIA).
|
||||
|
||||
Ce logiciel informatique est disponible aux conditions
|
||||
usuelles dans la recherche, c'est-à-dire qu'il peut
|
||||
être utilisé, copié, modifié, distribué à l'unique
|
||||
condition que ce texte soit conservé afin que
|
||||
l'origine de ce logiciel soit reconnue.
|
||||
|
||||
Le nom de l'Institut National de Recherche en Informatique
|
||||
et en Automatique (INRIA), de l'IMAG, ou d'une personne morale
|
||||
ou physique ayant participé à l'élaboration de ce logiciel ne peut
|
||||
être utilisé sans son accord préalable explicite.
|
||||
|
||||
Ce logiciel est fourni tel quel sans aucune garantie,
|
||||
support ou responsabilité d'aucune sorte.
|
||||
Ce logiciel est dérivé de sources d'origine
|
||||
"University of California at Berkeley" et
|
||||
"Digital Equipment Corporation" couvertes par des copyrights.
|
||||
|
||||
L'Institut d'Informatique et de Mathématiques Appliquées de Grenoble (IMAG)
|
||||
est une fédération d'unités mixtes de recherche du CNRS, de l'Institut National
|
||||
Polytechnique de Grenoble et de l'Université Joseph Fourier regroupant
|
||||
sept laboratoires dont le laboratoire Logiciels, Systèmes, Réseaux (LSR).
|
||||
|
||||
This work has been done in the context of GIE DYADE (joint R & D venture
|
||||
between BULL S.A. and INRIA).
|
||||
|
||||
This software is available with usual "research" terms
|
||||
with the aim of retain credits of the software.
|
||||
Permission to use, copy, modify and distribute this software for any
|
||||
purpose and without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies,
|
||||
and the name of INRIA, IMAG, or any contributor not be used in advertising
|
||||
or publicity pertaining to this material without the prior explicit
|
||||
permission. The software is provided "as is" without any
|
||||
warranties, support or liabilities of any kind.
|
||||
This software is derived from source code from
|
||||
"University of California at Berkeley" and
|
||||
"Digital Equipment Corporation" protected by copyrights.
|
||||
|
||||
Grenoble's Institute of Computer Science and Applied Mathematics (IMAG)
|
||||
is a federation of seven research units funded by the CNRS, National
|
||||
Polytechnic Institute of Grenoble and University Joseph Fourier.
|
||||
The research unit in Software, Systems, Networks (LSR) is member of IMAG.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Derived from :
|
||||
*
|
||||
*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipv6cp.h,v 1.7 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef IPV6CP_H
|
||||
#define IPV6CP_H
|
||||
|
||||
#include "eui64.h"
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_IFACEID 1 /* Interface Identifier */
|
||||
#ifdef IPV6CP_COMP
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#endif /* IPV6CP_COMP */
|
||||
|
||||
/* No compression types yet defined.
|
||||
*#define IPV6CP_COMP 0x004f
|
||||
*/
|
||||
typedef struct ipv6cp_options {
|
||||
unsigned int neg_ifaceid :1; /* Negotiate interface identifier? */
|
||||
unsigned int req_ifaceid :1; /* Ask peer to send interface identifier? */
|
||||
unsigned int accept_local :1; /* accept peer's value for iface id? */
|
||||
unsigned int opt_local :1; /* ourtoken set by option */
|
||||
unsigned int opt_remote :1; /* histoken set by option */
|
||||
unsigned int use_ip :1; /* use IP as interface identifier */
|
||||
#if 0
|
||||
unsigned int use_persistent :1; /* use uniquely persistent value for address */
|
||||
#endif
|
||||
#ifdef IPV6CP_COMP
|
||||
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
||||
#endif /* IPV6CP_COMP */
|
||||
|
||||
#ifdef IPV6CP_COMP
|
||||
u_short vj_protocol; /* protocol value to use in VJ option */
|
||||
#endif /* IPV6CP_COMP */
|
||||
eui64_t ourid, hisid; /* Interface identifiers */
|
||||
} ipv6cp_options;
|
||||
|
||||
extern const struct protent ipv6cp_protent;
|
||||
|
||||
#endif /* IPV6CP_H */
|
||||
#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* lcp.h - Link Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.20 2004/11/14 22:53:42 carlsonj Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef LCP_H
|
||||
#define LCP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_VENDOR 0 /* Vendor Specific */
|
||||
#define CI_MRU 1 /* Maximum Receive Unit */
|
||||
#define CI_ASYNCMAP 2 /* Async Control Character Map */
|
||||
#define CI_AUTHTYPE 3 /* Authentication Type */
|
||||
#define CI_QUALITY 4 /* Quality Protocol */
|
||||
#define CI_MAGICNUMBER 5 /* Magic Number */
|
||||
#define CI_PCOMPRESSION 7 /* Protocol Field Compression */
|
||||
#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
|
||||
#define CI_FCSALTERN 9 /* FCS-Alternatives */
|
||||
#define CI_SDP 10 /* Self-Describing-Pad */
|
||||
#define CI_NUMBERED 11 /* Numbered-Mode */
|
||||
#define CI_CALLBACK 13 /* callback */
|
||||
#define CI_MRRU 17 /* max reconstructed receive unit; multilink */
|
||||
#define CI_SSNHF 18 /* short sequence numbers for multilink */
|
||||
#define CI_EPDISC 19 /* endpoint discriminator */
|
||||
#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */
|
||||
#define CI_LDISC 23 /* Link-Discriminator */
|
||||
#define CI_LCPAUTH 24 /* LCP Authentication */
|
||||
#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */
|
||||
#define CI_PREFELIS 26 /* Prefix Elision */
|
||||
#define CI_MPHDRFMT 27 /* MP Header Format */
|
||||
#define CI_I18N 28 /* Internationalization */
|
||||
#define CI_SDL 29 /* Simple Data Link */
|
||||
|
||||
/*
|
||||
* LCP-specific packet types (code numbers).
|
||||
*/
|
||||
#define PROTREJ 8 /* Protocol Reject */
|
||||
#define ECHOREQ 9 /* Echo Request */
|
||||
#define ECHOREP 10 /* Echo Reply */
|
||||
#define DISCREQ 11 /* Discard Request */
|
||||
#define IDENTIF 12 /* Identification */
|
||||
#define TIMEREM 13 /* Time Remaining */
|
||||
|
||||
/* Value used as data for CI_CALLBACK option */
|
||||
#define CBCP_OPT 6 /* Use callback control protocol */
|
||||
|
||||
#if 0 /* moved to opt.h */
|
||||
#define DEFMRU 1500 /* Try for this */
|
||||
#define MINMRU 128 /* No MRUs below this */
|
||||
#define MAXMRU 16384 /* Normally limit MRU to this */
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class_; /* -- The word "class" is reserved in C++. */
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
|
||||
/*
|
||||
* The state of options is described by an lcp_options structure.
|
||||
*/
|
||||
typedef struct lcp_options {
|
||||
unsigned int passive :1; /* Don't die if we don't get a response */
|
||||
unsigned int silent :1; /* Wait for the other end to start first */
|
||||
unsigned int restart :1; /* Restart vs. exit after close */
|
||||
unsigned int neg_mru :1; /* Negotiate the MRU? */
|
||||
unsigned int neg_asyncmap :1; /* Negotiate the async map? */
|
||||
#if PAP_SUPPORT
|
||||
unsigned int neg_upap :1; /* Ask for UPAP authentication? */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
unsigned int neg_chap :1; /* Ask for CHAP authentication? */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
unsigned int neg_eap :1; /* Ask for EAP authentication? */
|
||||
#endif /* EAP_SUPPORT */
|
||||
unsigned int neg_magicnumber :1; /* Ask for magic number? */
|
||||
unsigned int neg_pcompression :1; /* HDLC Protocol Field Compression? */
|
||||
unsigned int neg_accompression :1; /* HDLC Address/Control Field Compression? */
|
||||
#if LQR_SUPPORT
|
||||
unsigned int neg_lqr :1; /* Negotiate use of Link Quality Reports */
|
||||
#endif /* LQR_SUPPORT */
|
||||
unsigned int neg_cbcp :1; /* Negotiate use of CBCP */
|
||||
#ifdef HAVE_MULTILINK
|
||||
unsigned int neg_mrru :1; /* negotiate multilink MRRU */
|
||||
#endif /* HAVE_MULTILINK */
|
||||
unsigned int neg_ssnhf :1; /* negotiate short sequence numbers */
|
||||
unsigned int neg_endpoint :1; /* negotiate endpoint discriminator */
|
||||
|
||||
u16_t mru; /* Value of MRU */
|
||||
#ifdef HAVE_MULTILINK
|
||||
u16_t mrru; /* Value of MRRU, and multilink enable */
|
||||
#endif /* MULTILINK */
|
||||
#if CHAP_SUPPORT
|
||||
u8_t chap_mdtype; /* which MD types (hashing algorithm) */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
u32_t asyncmap; /* Value of async map */
|
||||
u32_t magicnumber;
|
||||
u8_t numloops; /* Number of loops during magic number neg. */
|
||||
#if LQR_SUPPORT
|
||||
u32_t lqr_period; /* Reporting period for LQR 1/100ths second */
|
||||
#endif /* LQR_SUPPORT */
|
||||
struct epdisc endpoint; /* endpoint discriminator */
|
||||
} lcp_options;
|
||||
|
||||
void lcp_open(ppp_pcb *pcb);
|
||||
void lcp_close(ppp_pcb *pcb, const char *reason);
|
||||
void lcp_lowerup(ppp_pcb *pcb);
|
||||
void lcp_lowerdown(ppp_pcb *pcb);
|
||||
void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len); /* send protocol reject */
|
||||
|
||||
extern const struct protent lcp_protent;
|
||||
|
||||
#if 0 /* moved to opt.h */
|
||||
/* Default number of times we receive our magic number from the peer
|
||||
before deciding the link is looped-back. */
|
||||
#define DEFLOOPBACKFAIL 10
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
#endif /* LCP_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* magic.h - PPP Magic Number definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $
|
||||
*/
|
||||
/*****************************************************************************
|
||||
* randm.h - Random number generator header file.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* Copyright (c) 1998 Global Election Systems Inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE 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 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.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 98-05-29 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
||||
* Extracted from avos.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef MAGIC_H
|
||||
#define MAGIC_H
|
||||
|
||||
/***********************
|
||||
*** PUBLIC FUNCTIONS ***
|
||||
***********************/
|
||||
|
||||
/*
|
||||
* Initialize the random number generator.
|
||||
*/
|
||||
void magic_init(void);
|
||||
|
||||
/*
|
||||
* Randomize our random seed value. To be called for truely random events
|
||||
* such as user operations and network traffic.
|
||||
*/
|
||||
void magic_randomize(void);
|
||||
|
||||
/*
|
||||
* Return a new random number.
|
||||
*/
|
||||
u32_t magic(void); /* Returns the next magic number */
|
||||
|
||||
/*
|
||||
* Fill buffer with random bytes
|
||||
*
|
||||
* Use the random pool to generate random data. This degrades to pseudo
|
||||
* random when used faster than randomness is supplied using magic_churnrand().
|
||||
* Thus it's important to make sure that the results of this are not
|
||||
* published directly because one could predict the next result to at
|
||||
* least some degree. Also, it's important to get a good seed before
|
||||
* the first use.
|
||||
*/
|
||||
void magic_random_bytes(unsigned char *buf, u32_t buf_len);
|
||||
|
||||
/*
|
||||
* Return a new random number between 0 and (2^pow)-1 included.
|
||||
*/
|
||||
u32_t magic_pow(u8_t pow);
|
||||
|
||||
#endif /* MAGIC_H */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* mppe.h - Definitions for MPPE
|
||||
*
|
||||
* Copyright (c) 2008 Paul Mackerras. 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(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && MPPE_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef MPPE_H
|
||||
#define MPPE_H
|
||||
|
||||
#if LWIP_INCLUDED_POLARSSL_ARC4
|
||||
#include "netif/ppp/polarssl/arc4.h"
|
||||
#else
|
||||
#include "polarssl/arc4.h"
|
||||
#endif
|
||||
|
||||
#define MPPE_PAD 4 /* MPPE growth per frame */
|
||||
#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */
|
||||
|
||||
/* option bits for ccp_options.mppe */
|
||||
#define MPPE_OPT_40 0x01 /* 40 bit */
|
||||
#define MPPE_OPT_128 0x02 /* 128 bit */
|
||||
#define MPPE_OPT_STATEFUL 0x04 /* stateful mode */
|
||||
/* unsupported opts */
|
||||
#define MPPE_OPT_56 0x08 /* 56 bit */
|
||||
#define MPPE_OPT_MPPC 0x10 /* MPPC compression */
|
||||
#define MPPE_OPT_D 0x20 /* Unknown */
|
||||
#define MPPE_OPT_UNSUPPORTED (MPPE_OPT_56|MPPE_OPT_MPPC|MPPE_OPT_D)
|
||||
#define MPPE_OPT_UNKNOWN 0x40 /* Bits !defined in RFC 3078 were set */
|
||||
|
||||
/*
|
||||
* This is not nice ... the alternative is a bitfield struct though.
|
||||
* And unfortunately, we cannot share the same bits for the option
|
||||
* names above since C and H are the same bit. We could do a u_int32
|
||||
* but then we have to do a htonl() all the time and/or we still need
|
||||
* to know which octet is which.
|
||||
*/
|
||||
#define MPPE_C_BIT 0x01 /* MPPC */
|
||||
#define MPPE_D_BIT 0x10 /* Obsolete, usage unknown */
|
||||
#define MPPE_L_BIT 0x20 /* 40-bit */
|
||||
#define MPPE_S_BIT 0x40 /* 128-bit */
|
||||
#define MPPE_M_BIT 0x80 /* 56-bit, not supported */
|
||||
#define MPPE_H_BIT 0x01 /* Stateless (in a different byte) */
|
||||
|
||||
/* Does not include H bit; used for least significant octet only. */
|
||||
#define MPPE_ALL_BITS (MPPE_D_BIT|MPPE_L_BIT|MPPE_S_BIT|MPPE_M_BIT|MPPE_H_BIT)
|
||||
|
||||
/* Build a CI from mppe opts (see RFC 3078) */
|
||||
#define MPPE_OPTS_TO_CI(opts, ci) \
|
||||
do { \
|
||||
u_char *ptr = ci; /* u_char[4] */ \
|
||||
\
|
||||
/* H bit */ \
|
||||
if (opts & MPPE_OPT_STATEFUL) \
|
||||
*ptr++ = 0x0; \
|
||||
else \
|
||||
*ptr++ = MPPE_H_BIT; \
|
||||
*ptr++ = 0; \
|
||||
*ptr++ = 0; \
|
||||
\
|
||||
/* S,L bits */ \
|
||||
*ptr = 0; \
|
||||
if (opts & MPPE_OPT_128) \
|
||||
*ptr |= MPPE_S_BIT; \
|
||||
if (opts & MPPE_OPT_40) \
|
||||
*ptr |= MPPE_L_BIT; \
|
||||
/* M,D,C bits not supported */ \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
/* The reverse of the above */
|
||||
#define MPPE_CI_TO_OPTS(ci, opts) \
|
||||
do { \
|
||||
const u_char *ptr = ci; /* u_char[4] */ \
|
||||
\
|
||||
opts = 0; \
|
||||
\
|
||||
/* H bit */ \
|
||||
if (!(ptr[0] & MPPE_H_BIT)) \
|
||||
opts |= MPPE_OPT_STATEFUL; \
|
||||
\
|
||||
/* S,L bits */ \
|
||||
if (ptr[3] & MPPE_S_BIT) \
|
||||
opts |= MPPE_OPT_128; \
|
||||
if (ptr[3] & MPPE_L_BIT) \
|
||||
opts |= MPPE_OPT_40; \
|
||||
\
|
||||
/* M,D,C bits */ \
|
||||
if (ptr[3] & MPPE_M_BIT) \
|
||||
opts |= MPPE_OPT_56; \
|
||||
if (ptr[3] & MPPE_D_BIT) \
|
||||
opts |= MPPE_OPT_D; \
|
||||
if (ptr[3] & MPPE_C_BIT) \
|
||||
opts |= MPPE_OPT_MPPC; \
|
||||
\
|
||||
/* Other bits */ \
|
||||
if (ptr[0] & ~MPPE_H_BIT) \
|
||||
opts |= MPPE_OPT_UNKNOWN; \
|
||||
if (ptr[1] || ptr[2]) \
|
||||
opts |= MPPE_OPT_UNKNOWN; \
|
||||
if (ptr[3] & ~MPPE_ALL_BITS) \
|
||||
opts |= MPPE_OPT_UNKNOWN; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
/* Shared MPPE padding between MSCHAP and MPPE */
|
||||
#define SHA1_PAD_SIZE 40
|
||||
|
||||
static const u8_t mppe_sha1_pad1[SHA1_PAD_SIZE] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
static const u8_t mppe_sha1_pad2[SHA1_PAD_SIZE] = {
|
||||
0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2,
|
||||
0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2,
|
||||
0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2,
|
||||
0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2
|
||||
};
|
||||
|
||||
/*
|
||||
* State for an MPPE (de)compressor.
|
||||
*/
|
||||
typedef struct ppp_mppe_state {
|
||||
arc4_context arc4;
|
||||
u8_t master_key[MPPE_MAX_KEY_LEN];
|
||||
u8_t session_key[MPPE_MAX_KEY_LEN];
|
||||
u8_t keylen; /* key length in bytes */
|
||||
/* NB: 128-bit == 16, 40-bit == 8!
|
||||
* If we want to support 56-bit, the unit has to change to bits
|
||||
*/
|
||||
u8_t bits; /* MPPE control bits */
|
||||
u16_t ccount; /* 12-bit coherency count (seqno) */
|
||||
u16_t sanity_errors; /* take down LCP if too many */
|
||||
unsigned int stateful :1; /* stateful mode flag */
|
||||
unsigned int discard :1; /* stateful mode packet loss flag */
|
||||
} ppp_mppe_state;
|
||||
|
||||
void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key);
|
||||
void mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options);
|
||||
void mppe_comp_reset(ppp_pcb *pcb, ppp_mppe_state *state);
|
||||
err_t mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t protocol);
|
||||
void mppe_decomp_reset(ppp_pcb *pcb, ppp_mppe_state *state);
|
||||
err_t mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb);
|
||||
|
||||
#endif /* MPPE_H */
|
||||
#endif /* PPP_SUPPORT && MPPE_SUPPORT */
|
||||
@@ -1,81 +0,0 @@
|
||||
/**
|
||||
* \file arc4.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the names of PolarSSL or XySSL 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 COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_ARC4
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_ARC4_H
|
||||
#define LWIP_INCLUDED_POLARSSL_ARC4_H
|
||||
|
||||
/**
|
||||
* \brief ARC4 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int x; /*!< permutation index */
|
||||
int y; /*!< permutation index */
|
||||
unsigned char m[256]; /*!< permutation table */
|
||||
}
|
||||
arc4_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief ARC4 key schedule
|
||||
*
|
||||
* \param ctx ARC4 context to be initialized
|
||||
* \param key the secret key
|
||||
* \param keylen length of the key
|
||||
*/
|
||||
void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen );
|
||||
|
||||
/**
|
||||
* \brief ARC4 cipher function
|
||||
*
|
||||
* \param ctx ARC4 context
|
||||
* \param buf buffer to be processed
|
||||
* \param buflen amount of data in buf
|
||||
*/
|
||||
void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_ARC4_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */
|
||||
@@ -1,92 +0,0 @@
|
||||
/**
|
||||
* \file des.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the names of PolarSSL or XySSL 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 COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_DES
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_DES_H
|
||||
#define LWIP_INCLUDED_POLARSSL_DES_H
|
||||
|
||||
#define DES_ENCRYPT 1
|
||||
#define DES_DECRYPT 0
|
||||
|
||||
/**
|
||||
* \brief DES context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int mode; /*!< encrypt/decrypt */
|
||||
unsigned long sk[32]; /*!< DES subkeys */
|
||||
}
|
||||
des_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief DES key schedule (56-bit, encryption)
|
||||
*
|
||||
* \param ctx DES context to be initialized
|
||||
* \param key 8-byte secret key
|
||||
*/
|
||||
void des_setkey_enc( des_context *ctx, unsigned char key[8] );
|
||||
|
||||
/**
|
||||
* \brief DES key schedule (56-bit, decryption)
|
||||
*
|
||||
* \param ctx DES context to be initialized
|
||||
* \param key 8-byte secret key
|
||||
*/
|
||||
void des_setkey_dec( des_context *ctx, unsigned char key[8] );
|
||||
|
||||
/**
|
||||
* \brief DES-ECB block encryption/decryption
|
||||
*
|
||||
* \param ctx DES context
|
||||
* \param input 64-bit input block
|
||||
* \param output 64-bit output block
|
||||
*/
|
||||
void des_crypt_ecb( des_context *ctx,
|
||||
const unsigned char input[8],
|
||||
unsigned char output[8] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_DES_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_DES */
|
||||
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* \file md4.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the names of PolarSSL or XySSL 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 COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_MD4
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD4_H
|
||||
#define LWIP_INCLUDED_POLARSSL_MD4_H
|
||||
|
||||
/**
|
||||
* \brief MD4 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned long total[2]; /*!< number of bytes processed */
|
||||
unsigned long state[4]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
}
|
||||
md4_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief MD4 context setup
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void md4_starts( md4_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief MD4 process buffer
|
||||
*
|
||||
* \param ctx MD4 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*/
|
||||
void md4_update( md4_context *ctx, const unsigned char *input, int ilen );
|
||||
|
||||
/**
|
||||
* \brief MD4 final digest
|
||||
*
|
||||
* \param ctx MD4 context
|
||||
* \param output MD4 checksum result
|
||||
*/
|
||||
void md4_finish( md4_context *ctx, unsigned char output[16] );
|
||||
|
||||
/**
|
||||
* \brief Output = MD4( input buffer )
|
||||
*
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
* \param output MD4 checksum result
|
||||
*/
|
||||
void md4( unsigned char *input, int ilen, unsigned char output[16] );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD4_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD4 */
|
||||
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* \file md5.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the names of PolarSSL or XySSL 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 COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_MD5
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD5_H
|
||||
#define LWIP_INCLUDED_POLARSSL_MD5_H
|
||||
|
||||
/**
|
||||
* \brief MD5 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned long total[2]; /*!< number of bytes processed */
|
||||
unsigned long state[4]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
}
|
||||
md5_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief MD5 context setup
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void md5_starts( md5_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief MD5 process buffer
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*/
|
||||
void md5_update( md5_context *ctx, const unsigned char *input, int ilen );
|
||||
|
||||
/**
|
||||
* \brief MD5 final digest
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param output MD5 checksum result
|
||||
*/
|
||||
void md5_finish( md5_context *ctx, unsigned char output[16] );
|
||||
|
||||
/**
|
||||
* \brief Output = MD5( input buffer )
|
||||
*
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
* \param output MD5 checksum result
|
||||
*/
|
||||
void md5( unsigned char *input, int ilen, unsigned char output[16] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD5_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD5 */
|
||||
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* \file sha1.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the names of PolarSSL or XySSL 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 COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_SHA1
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_SHA1_H
|
||||
#define LWIP_INCLUDED_POLARSSL_SHA1_H
|
||||
|
||||
/**
|
||||
* \brief SHA-1 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned long total[2]; /*!< number of bytes processed */
|
||||
unsigned long state[5]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
}
|
||||
sha1_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief SHA-1 context setup
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void sha1_starts( sha1_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 process buffer
|
||||
*
|
||||
* \param ctx SHA-1 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*/
|
||||
void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 final digest
|
||||
*
|
||||
* \param ctx SHA-1 context
|
||||
* \param output SHA-1 checksum result
|
||||
*/
|
||||
void sha1_finish( sha1_context *ctx, unsigned char output[20] );
|
||||
|
||||
/**
|
||||
* \brief Output = SHA-1( input buffer )
|
||||
*
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
* \param output SHA-1 checksum result
|
||||
*/
|
||||
void sha1( unsigned char *input, int ilen, unsigned char output[20] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */
|
||||
@@ -1,573 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* ppp.h - Network Point to Point Protocol header file.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* portions Copyright (c) 1997 Global Election Systems Inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE 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 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.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
||||
* Original derived from BSD codes.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_H
|
||||
#define PPP_H
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/sio.h"
|
||||
#include "lwip/timers.h"
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#include "lwip/ip6_addr.h"
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
|
||||
/* Disable non-working or rarely used PPP feature, so rarely that we don't want to bloat opt.h with them */
|
||||
#ifndef PPP_OPTIONS
|
||||
#define PPP_OPTIONS 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_NOTIFY
|
||||
#define PPP_NOTIFY 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_REMOTENAME
|
||||
#define PPP_REMOTENAME 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_IDLETIMELIMIT
|
||||
#define PPP_IDLETIMELIMIT 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_LCP_ADAPTIVE
|
||||
#define PPP_LCP_ADAPTIVE 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_MAXCONNECT
|
||||
#define PPP_MAXCONNECT 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_ALLOWED_ADDRS
|
||||
#define PPP_ALLOWED_ADDRS 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_PROTOCOLNAME
|
||||
#define PPP_PROTOCOLNAME 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_STATS_SUPPORT
|
||||
#define PPP_STATS_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef DEFLATE_SUPPORT
|
||||
#define DEFLATE_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef BSDCOMPRESS_SUPPORT
|
||||
#define BSDCOMPRESS_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef PREDICTOR_SUPPORT
|
||||
#define PREDICTOR_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
*** PUBLIC DEFINITIONS ***
|
||||
*************************/
|
||||
|
||||
/*
|
||||
* The basic PPP frame.
|
||||
*/
|
||||
#define PPP_HDRLEN 4 /* octets for standard ppp header */
|
||||
#define PPP_FCSLEN 2 /* octets for FCS */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PPP_PHASE_DEAD 0
|
||||
#define PPP_PHASE_INITIALIZE 1
|
||||
#define PPP_PHASE_SERIALCONN 2
|
||||
#define PPP_PHASE_DORMANT 3
|
||||
#define PPP_PHASE_ESTABLISH 4
|
||||
#define PPP_PHASE_AUTHENTICATE 5
|
||||
#define PPP_PHASE_CALLBACK 6
|
||||
#define PPP_PHASE_NETWORK 7
|
||||
#define PPP_PHASE_RUNNING 8
|
||||
#define PPP_PHASE_TERMINATE 9
|
||||
#define PPP_PHASE_DISCONNECT 10
|
||||
#define PPP_PHASE_HOLDOFF 11
|
||||
#define PPP_PHASE_MASTER 12
|
||||
|
||||
/* Error codes. */
|
||||
#define PPPERR_NONE 0 /* No error. */
|
||||
#define PPPERR_PARAM 1 /* Invalid parameter. */
|
||||
#define PPPERR_OPEN 2 /* Unable to open PPP session. */
|
||||
#define PPPERR_DEVICE 3 /* Invalid I/O device for PPP. */
|
||||
#define PPPERR_ALLOC 4 /* Unable to allocate resources. */
|
||||
#define PPPERR_USER 5 /* User interrupt. */
|
||||
#define PPPERR_CONNECT 6 /* Connection lost. */
|
||||
#define PPPERR_AUTHFAIL 7 /* Failed authentication challenge. */
|
||||
#define PPPERR_PROTOCOL 8 /* Failed to meet protocol. */
|
||||
#define PPPERR_PEERDEAD 9 /* Connection timeout */
|
||||
#define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */
|
||||
#define PPPERR_CONNECTTIME 11 /* Max connect time reached */
|
||||
#define PPPERR_LOOPBACK 12 /* Loopback detected */
|
||||
|
||||
/* Whether auth support is enabled at all */
|
||||
#define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT)
|
||||
|
||||
/************************
|
||||
*** PUBLIC DATA TYPES ***
|
||||
************************/
|
||||
|
||||
/*
|
||||
* Other headers require ppp_pcb definition for prototypes, but ppp_pcb
|
||||
* require some structure definition from other headers as well, we are
|
||||
* fixing the dependency loop here by declaring the ppp_pcb type then
|
||||
* by including headers containing necessary struct definition for ppp_pcb
|
||||
*/
|
||||
typedef struct ppp_pcb_s ppp_pcb;
|
||||
|
||||
/* Type definitions for BSD code. */
|
||||
#ifndef __u_char_defined
|
||||
typedef unsigned long u_long;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned char u_char;
|
||||
#endif
|
||||
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
#if CCP_SUPPORT
|
||||
#include "ccp.h"
|
||||
#endif /* CCP_SUPPORT */
|
||||
#if MPPE_SUPPORT
|
||||
#include "mppe.h"
|
||||
#endif /* MPPE_SUPPORT */
|
||||
#if PPP_IPV4_SUPPORT
|
||||
#include "ipcp.h"
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#include "ipv6cp.h"
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
#if PAP_SUPPORT
|
||||
#include "upap.h"
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
#include "chap-new.h"
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
#include "eap.h"
|
||||
#endif /* EAP_SUPPORT */
|
||||
#if VJ_SUPPORT
|
||||
#include "vj.h"
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
/* Link status callback function prototype */
|
||||
typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
|
||||
|
||||
/*
|
||||
* PPP configuration.
|
||||
*/
|
||||
typedef struct ppp_settings_s {
|
||||
|
||||
#if PPP_SERVER && PPP_AUTH_SUPPORT
|
||||
unsigned int auth_required :1; /* Peer is required to authenticate */
|
||||
unsigned int null_login :1; /* Username of "" and a password of "" are acceptable */
|
||||
#endif /* PPP_SERVER && PPP_AUTH_SUPPORT */
|
||||
#if PPP_REMOTENAME
|
||||
unsigned int explicit_remote :1; /* remote_name specified with remotename opt */
|
||||
#endif /* PPP_REMOTENAME */
|
||||
#if PAP_SUPPORT
|
||||
unsigned int refuse_pap :1; /* Don't proceed auth. with PAP */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
unsigned int refuse_chap :1; /* Don't proceed auth. with CHAP */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if MSCHAP_SUPPORT
|
||||
unsigned int refuse_mschap :1; /* Don't proceed auth. with MS-CHAP */
|
||||
unsigned int refuse_mschap_v2 :1; /* Don't proceed auth. with MS-CHAPv2 */
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
unsigned int refuse_eap :1; /* Don't proceed auth. with EAP */
|
||||
#endif /* EAP_SUPPORT */
|
||||
#if LWIP_DNS
|
||||
unsigned int usepeerdns :1; /* Ask peer for DNS adds */
|
||||
#endif /* LWIP_DNS */
|
||||
unsigned int persist :1; /* Persist mode, always try to open the connection */
|
||||
#if PRINTPKT_SUPPORT
|
||||
unsigned int hide_password :1; /* Hide password in dumped packets */
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
unsigned int noremoteip :1; /* Let him have no IP address */
|
||||
unsigned int lax_recv :1; /* accept control chars in asyncmap */
|
||||
unsigned int noendpoint :1; /* don't send/accept endpoint discriminator */
|
||||
#if PPP_LCP_ADAPTIVE
|
||||
unsigned int lcp_echo_adaptive :1; /* request echo only if the link was idle */
|
||||
#endif /* PPP_LCP_ADAPTIVE */
|
||||
#if MPPE_SUPPORT
|
||||
unsigned int require_mppe :1; /* Require MPPE (Microsoft Point to Point Encryption) */
|
||||
unsigned int refuse_mppe_40 :1; /* Allow MPPE 40-bit mode? */
|
||||
unsigned int refuse_mppe_128 :1; /* Allow MPPE 128-bit mode? */
|
||||
unsigned int refuse_mppe_stateful :1; /* Allow MPPE stateful mode? */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
u16_t listen_time; /* time to listen first (ms), waiting for peer to send LCP packet */
|
||||
|
||||
#if PPP_IDLETIMELIMIT
|
||||
u16_t idle_time_limit; /* Disconnect if idle for this many seconds */
|
||||
#endif /* PPP_IDLETIMELIMIT */
|
||||
#if PPP_MAXCONNECT
|
||||
u32_t maxconnect; /* Maximum connect time (seconds) */
|
||||
#endif /* PPP_MAXCONNECT */
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/* auth data */
|
||||
const char *user; /* Username for PAP */
|
||||
const char *passwd; /* Password for PAP, secret for CHAP */
|
||||
#if PPP_REMOTENAME
|
||||
char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
|
||||
#endif /* PPP_REMOTENAME */
|
||||
|
||||
#if PAP_SUPPORT
|
||||
u8_t pap_timeout_time; /* Timeout (seconds) for auth-req retrans. */
|
||||
u8_t pap_max_transmits; /* Number of auth-reqs sent */
|
||||
#if PPP_SERVER
|
||||
u8_t pap_req_timeout; /* Time to wait for auth-req from peer */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* PAP_SUPPPORT */
|
||||
|
||||
#if CHAP_SUPPORT
|
||||
u8_t chap_timeout_time; /* Timeout (seconds) for retransmitting req */
|
||||
u8_t chap_max_transmits; /* max # times to send challenge */
|
||||
#if PPP_SERVER
|
||||
u8_t chap_rechallenge_time; /* Time to wait for auth-req from peer */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* CHAP_SUPPPORT */
|
||||
|
||||
#if EAP_SUPPORT
|
||||
u8_t eap_req_time; /* Time to wait (for retransmit/fail) */
|
||||
u8_t eap_allow_req; /* Max Requests allowed */
|
||||
#if PPP_SERVER
|
||||
u8_t eap_timeout_time; /* Time to wait (for retransmit/fail) */
|
||||
u8_t eap_max_transmits; /* Max Requests allowed */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
u8_t fsm_timeout_time; /* Timeout time in seconds */
|
||||
u8_t fsm_max_conf_req_transmits; /* Maximum Configure-Request transmissions */
|
||||
u8_t fsm_max_term_transmits; /* Maximum Terminate-Request transmissions */
|
||||
u8_t fsm_max_nak_loops; /* Maximum number of nak loops tolerated */
|
||||
|
||||
u8_t lcp_loopbackfail; /* Number of times we receive our magic number from the peer
|
||||
before deciding the link is looped-back. */
|
||||
u8_t lcp_echo_interval; /* Interval between LCP echo-requests */
|
||||
u8_t lcp_echo_fails; /* Tolerance to unanswered echo-requests */
|
||||
|
||||
} ppp_settings;
|
||||
|
||||
#if PPP_SERVER
|
||||
struct ppp_addrs {
|
||||
#if PPP_IPV4_SUPPORT
|
||||
ip4_addr_t our_ipaddr, his_ipaddr, netmask;
|
||||
#if LWIP_DNS
|
||||
ip4_addr_t dns1, dns2;
|
||||
#endif /* LWIP_DNS */
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
ip6_addr_t our6_ipaddr, his6_ipaddr;
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
};
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/*
|
||||
* PPP interface control block.
|
||||
*/
|
||||
struct ppp_pcb_s {
|
||||
/* -- below are data that will NOT be cleared between two sessions */
|
||||
ppp_settings settings;
|
||||
const struct link_callbacks *link_cb;
|
||||
void *link_ctx_cb;
|
||||
void (*link_status_cb)(ppp_pcb *pcb, int err_code, void *ctx); /* Status change callback */
|
||||
#if PPP_NOTIFY_PHASE
|
||||
void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase, void *ctx); /* Notify phase callback */
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
void *ctx_cb; /* Callbacks optional pointer */
|
||||
struct netif *netif; /* PPP interface */
|
||||
|
||||
/* -- below are data that will be cleared between two sessions */
|
||||
|
||||
/*
|
||||
* phase must be the first member of cleared members, because it is used to know
|
||||
* which part must not be cleared.
|
||||
*/
|
||||
u8_t phase; /* where the link is at */
|
||||
u8_t err_code; /* Code indicating why interface is down. */
|
||||
|
||||
/* flags */
|
||||
#if PPP_IPV4_SUPPORT
|
||||
unsigned int ipcp_is_open :1; /* haven't called np_finished() */
|
||||
unsigned int ipcp_is_up :1; /* have called ipcp_up() */
|
||||
unsigned int if4_up :1; /* True when the IPv4 interface is up. */
|
||||
#if 0 /* UNUSED - PROXY ARP */
|
||||
unsigned int proxy_arp_set :1; /* Have created proxy arp entry */
|
||||
#endif /* UNUSED - PROXY ARP */
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
unsigned int ipv6cp_is_up :1; /* have called ip6cp_up() */
|
||||
unsigned int if6_up :1; /* True when the IPv6 interface is up. */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
unsigned int lcp_echo_timer_running :1; /* set if a timer is running */
|
||||
#if VJ_SUPPORT
|
||||
unsigned int vj_enabled :1; /* Flag indicating VJ compression enabled. */
|
||||
#endif /* VJ_SUPPORT */
|
||||
#if CCP_SUPPORT
|
||||
unsigned int ccp_all_rejected :1; /* we rejected all peer's options */
|
||||
#endif /* CCP_SUPPORT */
|
||||
#if MPPE_SUPPORT
|
||||
unsigned int mppe_keys_set :1; /* Have the MPPE keys been set? */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/* auth data */
|
||||
#if PPP_SERVER && defined(HAVE_MULTILINK)
|
||||
char peer_authname[MAXNAMELEN + 1]; /* The name by which the peer authenticated itself to us. */
|
||||
#endif /* PPP_SERVER && defined(HAVE_MULTILINK) */
|
||||
u16_t auth_pending; /* Records which authentication operations haven't completed yet. */
|
||||
u16_t auth_done; /* Records which authentication operations have been completed. */
|
||||
|
||||
#if PAP_SUPPORT
|
||||
upap_state upap; /* PAP data */
|
||||
#endif /* PAP_SUPPORT */
|
||||
|
||||
#if CHAP_SUPPORT
|
||||
chap_client_state chap_client; /* CHAP client data */
|
||||
#if PPP_SERVER
|
||||
chap_server_state chap_server; /* CHAP server data */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
#if EAP_SUPPORT
|
||||
eap_state eap; /* EAP data */
|
||||
#endif /* EAP_SUPPORT */
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
fsm lcp_fsm; /* LCP fsm structure */
|
||||
lcp_options lcp_wantoptions; /* Options that we want to request */
|
||||
lcp_options lcp_gotoptions; /* Options that peer ack'd */
|
||||
lcp_options lcp_allowoptions; /* Options we allow peer to request */
|
||||
lcp_options lcp_hisoptions; /* Options that we ack'd */
|
||||
u16_t peer_mru; /* currently negotiated peer MRU */
|
||||
u8_t lcp_echos_pending; /* Number of outstanding echo msgs */
|
||||
u8_t lcp_echo_number; /* ID number of next echo frame */
|
||||
|
||||
u8_t num_np_open; /* Number of network protocols which we have opened. */
|
||||
u8_t num_np_up; /* Number of network protocols which have come up. */
|
||||
|
||||
#if VJ_SUPPORT
|
||||
struct vjcompress vj_comp; /* Van Jacobson compression header. */
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
#if CCP_SUPPORT
|
||||
fsm ccp_fsm; /* CCP fsm structure */
|
||||
ccp_options ccp_wantoptions; /* what to request the peer to use */
|
||||
ccp_options ccp_gotoptions; /* what the peer agreed to do */
|
||||
ccp_options ccp_allowoptions; /* what we'll agree to do */
|
||||
ccp_options ccp_hisoptions; /* what we agreed to do */
|
||||
u8_t ccp_localstate; /* Local state (mainly for handling reset-reqs and reset-acks). */
|
||||
u8_t ccp_receive_method; /* Method chosen on receive path */
|
||||
u8_t ccp_transmit_method; /* Method chosen on transmit path */
|
||||
#if MPPE_SUPPORT
|
||||
ppp_mppe_state mppe_comp; /* MPPE "compressor" structure */
|
||||
ppp_mppe_state mppe_decomp; /* MPPE "decompressor" structure */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
#endif /* CCP_SUPPORT */
|
||||
|
||||
#if PPP_IPV4_SUPPORT
|
||||
fsm ipcp_fsm; /* IPCP fsm structure */
|
||||
ipcp_options ipcp_wantoptions; /* Options that we want to request */
|
||||
ipcp_options ipcp_gotoptions; /* Options that peer ack'd */
|
||||
ipcp_options ipcp_allowoptions; /* Options we allow peer to request */
|
||||
ipcp_options ipcp_hisoptions; /* Options that we ack'd */
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
|
||||
#if PPP_IPV6_SUPPORT
|
||||
fsm ipv6cp_fsm; /* IPV6CP fsm structure */
|
||||
ipv6cp_options ipv6cp_wantoptions; /* Options that we want to request */
|
||||
ipv6cp_options ipv6cp_gotoptions; /* Options that peer ack'd */
|
||||
ipv6cp_options ipv6cp_allowoptions; /* Options we allow peer to request */
|
||||
ipv6cp_options ipv6cp_hisoptions; /* Options that we ack'd */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
};
|
||||
|
||||
/************************
|
||||
*** PUBLIC FUNCTIONS ***
|
||||
************************/
|
||||
|
||||
/*
|
||||
* Set auth helper, optional, you can either fill ppp_pcb->settings.
|
||||
*
|
||||
* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
|
||||
* RFC 1994 says:
|
||||
*
|
||||
* In practice, within or associated with each PPP server, there is a
|
||||
* database which associates "user" names with authentication
|
||||
* information ("secrets"). It is not anticipated that a particular
|
||||
* named user would be authenticated by multiple methods. This would
|
||||
* make the user vulnerable to attacks which negotiate the least secure
|
||||
* method from among a set (such as PAP rather than CHAP). If the same
|
||||
* secret was used, PAP would reveal the secret to be used later with
|
||||
* CHAP.
|
||||
*
|
||||
* Instead, for each user name there should be an indication of exactly
|
||||
* one method used to authenticate that user name. If a user needs to
|
||||
* make use of different authentication methods under different
|
||||
* circumstances, then distinct user names SHOULD be employed, each of
|
||||
* which identifies exactly one authentication method.
|
||||
*
|
||||
*/
|
||||
#define PPPAUTHTYPE_NONE 0x00
|
||||
#define PPPAUTHTYPE_PAP 0x01
|
||||
#define PPPAUTHTYPE_CHAP 0x02
|
||||
#define PPPAUTHTYPE_MSCHAP 0x04
|
||||
#define PPPAUTHTYPE_MSCHAP_V2 0x08
|
||||
#define PPPAUTHTYPE_EAP 0x10
|
||||
#define PPPAUTHTYPE_ANY 0xff
|
||||
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
|
||||
|
||||
/*
|
||||
* Set a PPP interface as the default network interface
|
||||
* (used to output all packets for which no specific route is found).
|
||||
*/
|
||||
#define ppp_set_default(ppp) netif_set_default(ppp->netif)
|
||||
|
||||
#if PPP_NOTIFY_PHASE
|
||||
/*
|
||||
* Set a PPP notify phase callback.
|
||||
*
|
||||
* This can be used for example to set a LED pattern depending on the
|
||||
* current phase of the PPP session.
|
||||
*/
|
||||
typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx);
|
||||
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
|
||||
/*
|
||||
* Initiate a PPP connection.
|
||||
*
|
||||
* This can only be called if PPP is in the dead phase.
|
||||
*
|
||||
* Holdoff is the time to wait (in seconds) before initiating
|
||||
* the connection.
|
||||
*
|
||||
* If this port connects to a modem, the modem connection must be
|
||||
* established before calling this.
|
||||
*/
|
||||
err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff);
|
||||
|
||||
#if PPP_SERVER
|
||||
/*
|
||||
* Listen for an incoming PPP connection.
|
||||
*
|
||||
* This can only be called if PPP is in the dead phase.
|
||||
*
|
||||
* Local and remote interface IP addresses, as well as DNS are
|
||||
* provided through a previously filled struct ppp_addrs.
|
||||
*
|
||||
* If this port connects to a modem, the modem connection must be
|
||||
* established before calling this.
|
||||
*/
|
||||
err_t ppp_listen(ppp_pcb *pcb, struct ppp_addrs *addrs);
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/*
|
||||
* Initiate the end of a PPP connection.
|
||||
* Any outstanding packets in the queues are dropped.
|
||||
*
|
||||
* Setting nocarrier to 1 close the PPP connection without initiating the
|
||||
* shutdown procedure. Always using nocarrier = 0 is still recommended,
|
||||
* this is going to take a little longer time if your link is down, but
|
||||
* is a safer choice for the PPP state machine.
|
||||
*
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier);
|
||||
|
||||
/*
|
||||
* Release the control block.
|
||||
*
|
||||
* This can only be called if PPP is in the dead phase.
|
||||
*
|
||||
* You must use ppp_close() before if you wish to terminate
|
||||
* an established PPP session.
|
||||
*
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
err_t ppp_free(ppp_pcb *pcb);
|
||||
|
||||
/*
|
||||
* PPP IOCTL commands.
|
||||
*
|
||||
* Get the up status - 0 for down, non-zero for up. The argument must
|
||||
* point to an int.
|
||||
*/
|
||||
#define PPPCTLG_UPSTATUS 0
|
||||
|
||||
/*
|
||||
* Get the PPP error code. The argument must point to an int.
|
||||
* Returns a PPPERR_* value.
|
||||
*/
|
||||
#define PPPCTLG_ERRCODE 1
|
||||
|
||||
/*
|
||||
* Get the fd associated with a PPP over serial
|
||||
*/
|
||||
#define PPPCTLG_FD 2
|
||||
|
||||
/*
|
||||
* Get and set parameters for the given connection.
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
err_t ppp_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg);
|
||||
|
||||
/* Get the PPP netif interface */
|
||||
#define ppp_netif(ppp) (ppp->netif)
|
||||
|
||||
/* Set an lwIP-style status-callback for the selected PPP device */
|
||||
#define ppp_set_netif_statuscallback(ppp, status_cb) \
|
||||
netif_set_status_callback(ppp->netif, status_cb);
|
||||
|
||||
/* Set an lwIP-style link-callback for the selected PPP device */
|
||||
#define ppp_set_netif_linkcallback(ppp, link_cb) \
|
||||
netif_set_link_callback(ppp->netif, link_cb);
|
||||
|
||||
#endif /* PPP_H */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
@@ -1,632 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* ppp.h - Network Point to Point Protocol header file.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* portions Copyright (c) 1997 Global Election Systems Inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE 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 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.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
||||
* Original derived from BSD codes.
|
||||
*****************************************************************************/
|
||||
#ifndef LWIP_HDR_PPP_IMPL_H
|
||||
#define LWIP_HDR_PPP_IMPL_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifdef PPP_INCLUDE_SETTINGS_HEADER
|
||||
#include "ppp_settings.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* formats */
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h> /* strtol() */
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/timers.h"
|
||||
|
||||
#include "ppp.h"
|
||||
#include "pppdebug.h"
|
||||
|
||||
/*
|
||||
* Memory used for control packets.
|
||||
*
|
||||
* PPP_CTRL_PBUF_MAX_SIZE is the amount of memory we allocate when we
|
||||
* cannot figure out how much we are going to use before filling the buffer.
|
||||
*/
|
||||
#if PPP_USE_PBUF_RAM
|
||||
#define PPP_CTRL_PBUF_TYPE PBUF_RAM
|
||||
#define PPP_CTRL_PBUF_MAX_SIZE 512
|
||||
#else /* PPP_USE_PBUF_RAM */
|
||||
#define PPP_CTRL_PBUF_TYPE PBUF_POOL
|
||||
#define PPP_CTRL_PBUF_MAX_SIZE PBUF_POOL_BUFSIZE
|
||||
#endif /* PPP_USE_PBUF_RAM */
|
||||
|
||||
/*
|
||||
* The basic PPP frame.
|
||||
*/
|
||||
#define PPP_ADDRESS(p) (((u_char *)(p))[0])
|
||||
#define PPP_CONTROL(p) (((u_char *)(p))[1])
|
||||
#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
|
||||
|
||||
/*
|
||||
* Significant octet values.
|
||||
*/
|
||||
#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
|
||||
#define PPP_UI 0x03 /* Unnumbered Information */
|
||||
#define PPP_FLAG 0x7e /* Flag Sequence */
|
||||
#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
|
||||
#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
|
||||
|
||||
/*
|
||||
* Protocol field values.
|
||||
*/
|
||||
#define PPP_IP 0x21 /* Internet Protocol */
|
||||
#if 0 /* UNUSED */
|
||||
#define PPP_AT 0x29 /* AppleTalk Protocol */
|
||||
#define PPP_IPX 0x2b /* IPX protocol */
|
||||
#endif /* UNUSED */
|
||||
#if VJ_SUPPORT
|
||||
#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
|
||||
#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
|
||||
#endif /* VJ_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
#if CCP_SUPPORT
|
||||
#define PPP_COMP 0xfd /* compressed packet */
|
||||
#endif /* CCP_SUPPORT */
|
||||
#define PPP_IPCP 0x8021 /* IP Control Protocol */
|
||||
#if 0 /* UNUSED */
|
||||
#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
|
||||
#define PPP_IPXCP 0x802b /* IPX Control Protocol */
|
||||
#endif /* UNUSED */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
#if CCP_SUPPORT
|
||||
#define PPP_CCP 0x80fd /* Compression Control Protocol */
|
||||
#endif /* CCP_SUPPORT */
|
||||
#if ECP_SUPPORT
|
||||
#define PPP_ECP 0x8053 /* Encryption Control Protocol */
|
||||
#endif /* ECP_SUPPORT */
|
||||
#define PPP_LCP 0xc021 /* Link Control Protocol */
|
||||
#if PAP_SUPPORT
|
||||
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if LQR_SUPPORT
|
||||
#define PPP_LQR 0xc025 /* Link Quality Report protocol */
|
||||
#endif /* LQR_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if CBCP_SUPPORT
|
||||
#define PPP_CBCP 0xc029 /* Callback Control Protocol */
|
||||
#endif /* CBCP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* The following struct gives the addresses of procedures to call
|
||||
* for a particular lower link level protocol.
|
||||
*/
|
||||
struct link_callbacks {
|
||||
/* Start a connection (e.g. Initiate discovery phase) */
|
||||
err_t (*connect) (ppp_pcb *pcb, void *ctx);
|
||||
#if PPP_SERVER
|
||||
/* Listen for an incoming connection (Passive mode) */
|
||||
err_t (*listen) (ppp_pcb *pcb, void *ctx, struct ppp_addrs *addrs);
|
||||
#endif /* PPP_SERVER */
|
||||
/* End a connection (i.e. initiate disconnect phase) */
|
||||
void (*disconnect) (ppp_pcb *pcb, void *ctx);
|
||||
/* Free lower protocol control block */
|
||||
err_t (*free) (ppp_pcb *pcb, void *ctx);
|
||||
/* Write a pbuf to a ppp link, only used from PPP functions to send PPP packets. */
|
||||
err_t (*write)(ppp_pcb *pcb, void *ctx, struct pbuf *p);
|
||||
/* Send a packet from lwIP core (IPv4 or IPv6) */
|
||||
err_t (*netif_output)(ppp_pcb *pcb, void *ctx, struct pbuf *p, u_short protocol);
|
||||
/* configure the transmit-side characteristics of the PPP interface */
|
||||
void (*send_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp);
|
||||
/* confire the receive-side characteristics of the PPP interface */
|
||||
void (*recv_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp);
|
||||
};
|
||||
|
||||
/*
|
||||
* What to do with network protocol (NP) packets.
|
||||
*/
|
||||
enum NPmode {
|
||||
NPMODE_PASS, /* pass the packet through */
|
||||
NPMODE_DROP, /* silently drop the packet */
|
||||
NPMODE_ERROR, /* return an error */
|
||||
NPMODE_QUEUE /* save it up for later. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Statistics.
|
||||
*/
|
||||
#if PPP_STATS_SUPPORT
|
||||
struct pppstat {
|
||||
unsigned int ppp_ibytes; /* bytes received */
|
||||
unsigned int ppp_ipackets; /* packets received */
|
||||
unsigned int ppp_ierrors; /* receive errors */
|
||||
unsigned int ppp_obytes; /* bytes sent */
|
||||
unsigned int ppp_opackets; /* packets sent */
|
||||
unsigned int ppp_oerrors; /* transmit errors */
|
||||
};
|
||||
|
||||
#if VJ_SUPPORT
|
||||
struct vjstat {
|
||||
unsigned int vjs_packets; /* outbound packets */
|
||||
unsigned int vjs_compressed; /* outbound compressed packets */
|
||||
unsigned int vjs_searches; /* searches for connection state */
|
||||
unsigned int vjs_misses; /* times couldn't find conn. state */
|
||||
unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
|
||||
unsigned int vjs_compressedin; /* inbound compressed packets */
|
||||
unsigned int vjs_errorin; /* inbound unknown type packets */
|
||||
unsigned int vjs_tossed; /* inbound packets tossed because of error */
|
||||
};
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
struct ppp_stats {
|
||||
struct pppstat p; /* basic PPP statistics */
|
||||
#if VJ_SUPPORT
|
||||
struct vjstat vj; /* VJ header compression statistics */
|
||||
#endif /* VJ_SUPPORT */
|
||||
};
|
||||
|
||||
#if CCP_SUPPORT
|
||||
struct compstat {
|
||||
unsigned int unc_bytes; /* total uncompressed bytes */
|
||||
unsigned int unc_packets; /* total uncompressed packets */
|
||||
unsigned int comp_bytes; /* compressed bytes */
|
||||
unsigned int comp_packets; /* compressed packets */
|
||||
unsigned int inc_bytes; /* incompressible bytes */
|
||||
unsigned int inc_packets; /* incompressible packets */
|
||||
unsigned int ratio; /* recent compression ratio << 8 */
|
||||
};
|
||||
|
||||
struct ppp_comp_stats {
|
||||
struct compstat c; /* packet compression statistics */
|
||||
struct compstat d; /* packet decompression statistics */
|
||||
};
|
||||
#endif /* CCP_SUPPORT */
|
||||
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
#if PPP_IDLETIMELIMIT
|
||||
/*
|
||||
* The following structure records the time in seconds since
|
||||
* the last NP packet was sent or received.
|
||||
*/
|
||||
struct ppp_idle {
|
||||
time_t xmit_idle; /* time since last NP packet sent */
|
||||
time_t recv_idle; /* time since last NP packet received */
|
||||
};
|
||||
#endif /* PPP_IDLETIMELIMIT */
|
||||
|
||||
/* values for epdisc.class */
|
||||
#define EPD_NULL 0 /* null discriminator, no data */
|
||||
#define EPD_LOCAL 1
|
||||
#define EPD_IP 2
|
||||
#define EPD_MAC 3
|
||||
#define EPD_MAGIC 4
|
||||
#define EPD_PHONENUM 5
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
#ifdef HAVE_MULTILINK
|
||||
extern u8_t multilink; /* enable multilink operation */
|
||||
extern u8_t doing_multilink;
|
||||
extern u8_t multilink_master;
|
||||
extern u8_t bundle_eof;
|
||||
extern u8_t bundle_terminating;
|
||||
#endif
|
||||
|
||||
#ifdef MAXOCTETS
|
||||
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
|
||||
extern int maxoctets_dir; /* Direction :
|
||||
0 - in+out (default)
|
||||
1 - in
|
||||
2 - out
|
||||
3 - max(in,out) */
|
||||
extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
||||
#define PPP_OCTETS_DIRECTION_SUM 0
|
||||
#define PPP_OCTETS_DIRECTION_IN 1
|
||||
#define PPP_OCTETS_DIRECTION_OUT 2
|
||||
#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
|
||||
/* same as previos, but little different on RADIUS side */
|
||||
#define PPP_OCTETS_DIRECTION_MAXSESSION 4
|
||||
#endif
|
||||
|
||||
/* Data input may be used by CCP and ECP, remove this entry
|
||||
* from struct protent to save some flash
|
||||
*/
|
||||
#define PPP_DATAINPUT 0
|
||||
|
||||
/*
|
||||
* The following struct gives the addresses of procedures to call
|
||||
* for a particular protocol.
|
||||
*/
|
||||
struct protent {
|
||||
u_short protocol; /* PPP protocol number */
|
||||
/* Initialization procedure */
|
||||
void (*init) (ppp_pcb *pcb);
|
||||
/* Process a received packet */
|
||||
void (*input) (ppp_pcb *pcb, u_char *pkt, int len);
|
||||
/* Process a received protocol-reject */
|
||||
void (*protrej) (ppp_pcb *pcb);
|
||||
/* Lower layer has come up */
|
||||
void (*lowerup) (ppp_pcb *pcb);
|
||||
/* Lower layer has gone down */
|
||||
void (*lowerdown) (ppp_pcb *pcb);
|
||||
/* Open the protocol */
|
||||
void (*open) (ppp_pcb *pcb);
|
||||
/* Close the protocol */
|
||||
void (*close) (ppp_pcb *pcb, const char *reason);
|
||||
#if PRINTPKT_SUPPORT
|
||||
/* Print a packet in readable form */
|
||||
int (*printpkt) (const u_char *pkt, int len,
|
||||
void (*printer) (void *, const char *, ...),
|
||||
void *arg);
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
#if PPP_DATAINPUT
|
||||
/* Process a received data packet */
|
||||
void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len);
|
||||
#endif /* PPP_DATAINPUT */
|
||||
#if PRINTPKT_SUPPORT
|
||||
const char *name; /* Text name of protocol */
|
||||
const char *data_name; /* Text name of corresponding data protocol */
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
#if PPP_OPTIONS
|
||||
option_t *options; /* List of command-line options */
|
||||
/* Check requested options, assign defaults */
|
||||
void (*check_options) (void);
|
||||
#endif /* PPP_OPTIONS */
|
||||
#if DEMAND_SUPPORT
|
||||
/* Configure interface for demand-dial */
|
||||
int (*demand_conf) (int unit);
|
||||
/* Say whether to bring up link for this pkt */
|
||||
int (*active_pkt) (u_char *pkt, int len);
|
||||
#endif /* DEMAND_SUPPORT */
|
||||
};
|
||||
|
||||
/* Table of pointers to supported protocols */
|
||||
extern const struct protent* const protocols[];
|
||||
|
||||
|
||||
/* Values for auth_pending, auth_done */
|
||||
#if PAP_SUPPORT
|
||||
#define PAP_WITHPEER 0x1
|
||||
#define PAP_PEER 0x2
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
#define CHAP_WITHPEER 0x4
|
||||
#define CHAP_PEER 0x8
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
#define EAP_WITHPEER 0x10
|
||||
#define EAP_PEER 0x20
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
/* Values for auth_done only */
|
||||
#if CHAP_SUPPORT
|
||||
#define CHAP_MD5_WITHPEER 0x40
|
||||
#define CHAP_MD5_PEER 0x80
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
|
||||
#define CHAP_MS_WITHPEER 0x100
|
||||
#define CHAP_MS_PEER 0x200
|
||||
#define CHAP_MS2_WITHPEER 0x400
|
||||
#define CHAP_MS2_PEER 0x800
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
/* Supported CHAP protocols */
|
||||
#if CHAP_SUPPORT
|
||||
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
|
||||
#else /* MSCHAP_SUPPORT */
|
||||
#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MD5)
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
#else /* CHAP_SUPPORT */
|
||||
#define CHAP_MDTYPE_SUPPORTED (MDTYPE_NONE)
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
/*
|
||||
* PPP statistics structure
|
||||
*/
|
||||
struct pppd_stats {
|
||||
unsigned int bytes_in;
|
||||
unsigned int bytes_out;
|
||||
unsigned int pkts_in;
|
||||
unsigned int pkts_out;
|
||||
};
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
|
||||
/*
|
||||
* PPP private functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Functions called from lwIP core.
|
||||
*/
|
||||
|
||||
/* initialize the PPP subsystem */
|
||||
int ppp_init(void);
|
||||
|
||||
|
||||
/*
|
||||
* Functions called from PPP link protocols.
|
||||
*/
|
||||
|
||||
/* Create a new PPP control block */
|
||||
ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, void *link_ctx_cb,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
|
||||
/* Set a PPP PCB to its initial state */
|
||||
void ppp_clear(ppp_pcb *pcb);
|
||||
|
||||
/* Initiate LCP open request */
|
||||
void ppp_start(ppp_pcb *pcb);
|
||||
|
||||
/* Called when link failed to setup */
|
||||
void ppp_link_failed(ppp_pcb *pcb);
|
||||
|
||||
/* Called when link is normally down (i.e. it was asked to end) */
|
||||
void ppp_link_end(ppp_pcb *pcb);
|
||||
|
||||
/* function called to process input packet */
|
||||
void ppp_input(ppp_pcb *pcb, struct pbuf *pb);
|
||||
|
||||
/* helper function, merge a pbuf chain into one pbuf */
|
||||
struct pbuf *ppp_singlebuf(struct pbuf *p);
|
||||
|
||||
|
||||
/*
|
||||
* Functions called by PPP protocols.
|
||||
*/
|
||||
|
||||
/* function called by all PPP subsystems to send packets */
|
||||
err_t ppp_write(ppp_pcb *pcb, struct pbuf *p);
|
||||
|
||||
/* functions called by auth.c link_terminated() */
|
||||
void ppp_link_terminated(ppp_pcb *pcb);
|
||||
|
||||
void new_phase(ppp_pcb *pcb, int p);
|
||||
|
||||
int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp);
|
||||
int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp);
|
||||
|
||||
#if PPP_IPV4_SUPPORT
|
||||
int sifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr, u32_t netmask);
|
||||
int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr);
|
||||
#if 0 /* UNUSED - PROXY ARP */
|
||||
int sifproxyarp(ppp_pcb *pcb, u32_t his_adr);
|
||||
int cifproxyarp(ppp_pcb *pcb, u32_t his_adr);
|
||||
#endif /* UNUSED - PROXY ARP */
|
||||
#if LWIP_DNS
|
||||
int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
|
||||
int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
|
||||
#endif /* LWIP_DNS */
|
||||
#if VJ_SUPPORT
|
||||
int sifvjcomp(ppp_pcb *pcb, int vjcomp, int cidcomp, int maxcid);
|
||||
#endif /* VJ_SUPPORT */
|
||||
int sifup(ppp_pcb *pcb);
|
||||
int sifdown (ppp_pcb *pcb);
|
||||
u32_t get_mask(u32_t addr);
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
|
||||
#if PPP_IPV6_SUPPORT
|
||||
int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
|
||||
int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
|
||||
int sif6up(ppp_pcb *pcb);
|
||||
int sif6down (ppp_pcb *pcb);
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
|
||||
#if DEMAND_SUPPORT
|
||||
int sifnpmode(ppp_pcb *pcb, int proto, enum NPmode mode);
|
||||
#endif /* DEMAND_SUPPORt */
|
||||
|
||||
void netif_set_mtu(ppp_pcb *pcb, int mtu);
|
||||
int netif_get_mtu(ppp_pcb *pcb);
|
||||
|
||||
#if CCP_SUPPORT
|
||||
#if 0 /* unused */
|
||||
int ccp_test(ppp_pcb *pcb, u_char *opt_ptr, int opt_len, int for_transmit);
|
||||
#endif /* unused */
|
||||
void ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method);
|
||||
void ccp_reset_comp(ppp_pcb *pcb);
|
||||
void ccp_reset_decomp(ppp_pcb *pcb);
|
||||
#if 0 /* unused */
|
||||
int ccp_fatal_error(ppp_pcb *pcb);
|
||||
#endif /* unused */
|
||||
#endif /* CCP_SUPPORT */
|
||||
|
||||
#if PPP_IDLETIMELIMIT
|
||||
int get_idle_time(ppp_pcb *pcb, struct ppp_idle *ip);
|
||||
#endif /* PPP_IDLETIMELIMIT */
|
||||
|
||||
#if DEMAND_SUPPORT
|
||||
int get_loop_output(void);
|
||||
#endif /* DEMAND_SUPPORT */
|
||||
|
||||
/* Optional protocol names list, to make our messages a little more informative. */
|
||||
#if PPP_PROTOCOLNAME
|
||||
const char * protocol_name(int proto);
|
||||
#endif /* PPP_PROTOCOLNAME */
|
||||
|
||||
/* Optional stats support, to get some statistics on the PPP interface */
|
||||
#if PPP_STATS_SUPPORT
|
||||
void print_link_stats(void); /* Print stats, if available */
|
||||
void reset_link_stats(int u); /* Reset (init) stats when link goes up */
|
||||
void update_link_stats(int u); /* Get stats at link termination */
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Inline versions of get/put char/short/long.
|
||||
* Pointer is advanced; we assume that both arguments
|
||||
* are lvalues and will already be in registers.
|
||||
* cp MUST be u_char *.
|
||||
*/
|
||||
#define GETCHAR(c, cp) { \
|
||||
(c) = *(cp)++; \
|
||||
}
|
||||
#define PUTCHAR(c, cp) { \
|
||||
*(cp)++ = (u_char) (c); \
|
||||
}
|
||||
#define GETSHORT(s, cp) { \
|
||||
(s) = *(cp)++ << 8; \
|
||||
(s) |= *(cp)++; \
|
||||
}
|
||||
#define PUTSHORT(s, cp) { \
|
||||
*(cp)++ = (u_char) ((s) >> 8); \
|
||||
*(cp)++ = (u_char) (s); \
|
||||
}
|
||||
#define GETLONG(l, cp) { \
|
||||
(l) = *(cp)++ << 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; \
|
||||
}
|
||||
#define PUTLONG(l, cp) { \
|
||||
*(cp)++ = (u_char) ((l) >> 24); \
|
||||
*(cp)++ = (u_char) ((l) >> 16); \
|
||||
*(cp)++ = (u_char) ((l) >> 8); \
|
||||
*(cp)++ = (u_char) (l); \
|
||||
}
|
||||
|
||||
#define INCPTR(n, cp) ((cp) += (n))
|
||||
#define DECPTR(n, cp) ((cp) -= (n))
|
||||
|
||||
/*
|
||||
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
||||
*/
|
||||
#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
|
||||
#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
|
||||
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
|
||||
|
||||
#define BZERO(s, n) memset(s, 0, n)
|
||||
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
|
||||
|
||||
#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); }
|
||||
|
||||
/*
|
||||
* MAKEHEADER - Add Header fields to a packet.
|
||||
*/
|
||||
#define MAKEHEADER(p, t) { \
|
||||
PUTCHAR(PPP_ALLSTATIONS, p); \
|
||||
PUTCHAR(PPP_UI, p); \
|
||||
PUTSHORT(t, p); }
|
||||
|
||||
/* Procedures exported from auth.c */
|
||||
void link_required(ppp_pcb *pcb); /* we are starting to use the link */
|
||||
void link_terminated(ppp_pcb *pcb); /* we are finished with the link */
|
||||
void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */
|
||||
void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */
|
||||
void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */
|
||||
void start_networks(ppp_pcb *pcb); /* start all the network control protos */
|
||||
void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos */
|
||||
#if PPP_AUTH_SUPPORT
|
||||
#if PPP_SERVER
|
||||
int auth_check_passwd(ppp_pcb *pcb, char *auser, int userlen, char *apasswd, int passwdlen, const char **msg, int *msglen);
|
||||
/* check the user name and passwd against configuration */
|
||||
void auth_peer_fail(ppp_pcb *pcb, int protocol);
|
||||
/* peer failed to authenticate itself */
|
||||
void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char *name, int namelen);
|
||||
/* peer successfully authenticated itself */
|
||||
#endif /* PPP_SERVER */
|
||||
void auth_withpeer_fail(ppp_pcb *pcb, int protocol);
|
||||
/* we failed to authenticate ourselves */
|
||||
void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor);
|
||||
/* we successfully authenticated ourselves */
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */
|
||||
void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */
|
||||
void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */
|
||||
#if PPP_AUTH_SUPPORT
|
||||
int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secret, int *secret_len, int am_server);
|
||||
/* get "secret" for chap */
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
/* Procedures exported from ipcp.c */
|
||||
/* int parse_dotted_ip (char *, u32_t *); */
|
||||
|
||||
/* Procedures exported from demand.c */
|
||||
#if DEMAND_SUPPORT
|
||||
void demand_conf (void); /* config interface(s) for demand-dial */
|
||||
void demand_block (void); /* set all NPs to queue up packets */
|
||||
void demand_unblock (void); /* set all NPs to pass packets */
|
||||
void demand_discard (void); /* set all NPs to discard packets */
|
||||
void demand_rexmit (int, u32_t); /* retransmit saved frames for an NP*/
|
||||
int loop_chars (unsigned char *, int); /* process chars from loopback */
|
||||
int loop_frame (unsigned char *, int); /* should we bring link up? */
|
||||
#endif /* DEMAND_SUPPORT */
|
||||
|
||||
/* Procedures exported from multilink.c */
|
||||
#ifdef HAVE_MULTILINK
|
||||
void mp_check_options (void); /* Check multilink-related options */
|
||||
int mp_join_bundle (void); /* join our link to an appropriate bundle */
|
||||
void mp_exit_bundle (void); /* have disconnected our link from bundle */
|
||||
void mp_bundle_terminated (void);
|
||||
char *epdisc_to_str (struct epdisc *); /* string from endpoint discrim. */
|
||||
int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */
|
||||
#else
|
||||
#define mp_bundle_terminated() /* nothing */
|
||||
#define mp_exit_bundle() /* nothing */
|
||||
#define doing_multilink 0
|
||||
#define multilink_master 0
|
||||
#endif
|
||||
|
||||
/* Procedures exported from utils.c. */
|
||||
void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const char *, ...), void *arg); /* Format a string for output */
|
||||
int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */
|
||||
int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args); /* vsprintf++ */
|
||||
size_t ppp_strlcpy(char *dest, const char *src, size_t len); /* safe strcpy */
|
||||
size_t ppp_strlcat(char *dest, const char *src, size_t len); /* safe strncpy */
|
||||
void ppp_dbglog(const char *fmt, ...); /* log a debug message */
|
||||
void ppp_info(const char *fmt, ...); /* log an informational message */
|
||||
void ppp_notice(const char *fmt, ...); /* log a notice-level message */
|
||||
void ppp_warn(const char *fmt, ...); /* log a warning message */
|
||||
void ppp_error(const char *fmt, ...); /* log an error message */
|
||||
void ppp_fatal(const char *fmt, ...); /* log an error message and die(1) */
|
||||
#if PRINTPKT_SUPPORT
|
||||
void ppp_dump_packet(const char *tag, unsigned char *p, int len);
|
||||
/* dump packet to debug log if interesting */
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
#endif /* LWIP_HDR_PPP_IMPL_H */
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1
|
||||
*
|
||||
* Extracted from chap_ms.c by James Carlson.
|
||||
*
|
||||
* Copyright (c) 1995 Eric Rosenquist. 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(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPCRYPT_H
|
||||
#define PPPCRYPT_H
|
||||
|
||||
void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key);
|
||||
|
||||
#endif /* PPPCRYPT_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */
|
||||
@@ -1,80 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* pppdebug.h - System debugging utilities.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* portions Copyright (c) 1998 Global Election Systems Inc.
|
||||
* portions Copyright (c) 2001 by Cognizant Pty Ltd.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE 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 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.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY (please don't use tabs!)
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 98-07-29 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
|
||||
* Original.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPDEBUG_H
|
||||
#define PPPDEBUG_H
|
||||
|
||||
/* Trace levels. */
|
||||
#define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE)
|
||||
#define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE)
|
||||
#define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING)
|
||||
#define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING)
|
||||
#define LOG_INFO (PPP_DEBUG)
|
||||
#define LOG_DETAIL (PPP_DEBUG)
|
||||
#define LOG_DEBUG (PPP_DEBUG)
|
||||
|
||||
#if PPP_DEBUG
|
||||
|
||||
#define MAINDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define SYSDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define FSMDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define LCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define IPCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define IPV6CPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define UPAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define CHAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define PPPDEBUG(a, b) LWIP_DEBUGF(a, b)
|
||||
|
||||
#else /* PPP_DEBUG */
|
||||
|
||||
#define MAINDEBUG(a)
|
||||
#define SYSDEBUG(a)
|
||||
#define FSMDEBUG(a)
|
||||
#define LCPDEBUG(a)
|
||||
#define IPCPDEBUG(a)
|
||||
#define IPV6CPDEBUG(a)
|
||||
#define UPAPDEBUG(a)
|
||||
#define CHAPDEBUG(a)
|
||||
#define PPPDEBUG(a, b)
|
||||
|
||||
#endif /* PPP_DEBUG */
|
||||
|
||||
#endif /* PPPDEBUG_H */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
@@ -1,179 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* pppoe.h - PPP Over Ethernet implementation for lwIP.
|
||||
*
|
||||
* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE 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 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.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 06-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Martin Husemann <martin@NetBSD.org>.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_OE_H
|
||||
#define PPP_OE_H
|
||||
|
||||
#include "ppp.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct pppoehdr {
|
||||
PACK_STRUCT_FLD_8(u8_t vertype);
|
||||
PACK_STRUCT_FLD_8(u8_t code);
|
||||
PACK_STRUCT_FIELD(u16_t session);
|
||||
PACK_STRUCT_FIELD(u16_t plen);
|
||||
} 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
|
||||
struct pppoetag {
|
||||
PACK_STRUCT_FIELD(u16_t tag);
|
||||
PACK_STRUCT_FIELD(u16_t len);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define PPPOE_STATE_INITIAL 0
|
||||
#define PPPOE_STATE_PADI_SENT 1
|
||||
#define PPPOE_STATE_PADR_SENT 2
|
||||
#define PPPOE_STATE_SESSION 3
|
||||
/* passive */
|
||||
#define PPPOE_STATE_PADO_SENT 1
|
||||
|
||||
#define PPPOE_HEADERLEN sizeof(struct pppoehdr)
|
||||
#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */
|
||||
|
||||
#define PPPOE_TAG_EOL 0x0000 /* end of list */
|
||||
#define PPPOE_TAG_SNAME 0x0101 /* service name */
|
||||
#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */
|
||||
#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */
|
||||
#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */
|
||||
#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */
|
||||
#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */
|
||||
#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */
|
||||
#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */
|
||||
#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */
|
||||
|
||||
#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */
|
||||
#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */
|
||||
#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */
|
||||
#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */
|
||||
#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */
|
||||
|
||||
#ifndef PPPOE_MAX_AC_COOKIE_LEN
|
||||
#define PPPOE_MAX_AC_COOKIE_LEN 64
|
||||
#endif
|
||||
|
||||
struct pppoe_softc {
|
||||
struct pppoe_softc *next;
|
||||
struct netif *sc_ethif; /* ethernet interface we are using */
|
||||
ppp_pcb *pcb; /* PPP PCB */
|
||||
|
||||
struct eth_addr sc_dest; /* hardware address of concentrator */
|
||||
u16_t sc_session; /* PPPoE session id */
|
||||
u8_t sc_state; /* discovery phase or session connected */
|
||||
|
||||
#ifdef PPPOE_TODO
|
||||
u8_t *sc_service_name; /* if != NULL: requested name of service */
|
||||
u8_t *sc_concentrator_name; /* if != NULL: requested concentrator id */
|
||||
#endif /* PPPOE_TODO */
|
||||
u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
|
||||
u8_t sc_ac_cookie_len; /* length of cookie data */
|
||||
#ifdef PPPOE_SERVER
|
||||
u8_t *sc_hunique; /* content of host unique we must echo back */
|
||||
u8_t sc_hunique_len; /* length of host unique */
|
||||
#endif
|
||||
u8_t sc_padi_retried; /* number of PADI retries already done */
|
||||
u8_t sc_padr_retried; /* number of PADR retries already done */
|
||||
};
|
||||
|
||||
|
||||
#define pppoe_init() /* compatibility define, no initialization needed */
|
||||
|
||||
ppp_pcb *pppoe_create(struct netif *pppif,
|
||||
struct netif *ethif,
|
||||
const char *service_name, const char *concentrator_name,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
|
||||
/*
|
||||
* Functions called from lwIP
|
||||
* DO NOT CALL FROM lwIP USER APPLICATION.
|
||||
*/
|
||||
void pppoe_disc_input(struct netif *netif, struct pbuf *p);
|
||||
void pppoe_data_input(struct netif *netif, struct pbuf *p);
|
||||
|
||||
#endif /* PPP_OE_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && PPPOE_SUPPORT */
|
||||
@@ -1,201 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* Network Point to Point Protocol over Layer 2 Tunneling Protocol header file.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPPOL2TP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPOL2TP_H_
|
||||
#define PPPOL2TP_H_
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/* Timeout */
|
||||
#define PPPOL2TP_CONTROL_TIMEOUT (5*1000) /* base for quick timeout calculation */
|
||||
#define PPPOL2TP_SLOW_RETRY (60*1000) /* persistent retry interval */
|
||||
|
||||
#define PPPOL2TP_MAXSCCRQ 4 /* retry SCCRQ four times (quickly) */
|
||||
#define PPPOL2TP_MAXICRQ 4 /* retry IRCQ four times */
|
||||
#define PPPOL2TP_MAXICCN 4 /* retry ICCN four times */
|
||||
|
||||
/* L2TP header flags */
|
||||
#define PPPOL2TP_HEADERFLAG_CONTROL 0x8000
|
||||
#define PPPOL2TP_HEADERFLAG_LENGTH 0x4000
|
||||
#define PPPOL2TP_HEADERFLAG_SEQUENCE 0x0800
|
||||
#define PPPOL2TP_HEADERFLAG_OFFSET 0x0200
|
||||
#define PPPOL2TP_HEADERFLAG_PRIORITY 0x0100
|
||||
#define PPPOL2TP_HEADERFLAG_VERSION 0x0002
|
||||
|
||||
/* Mandatory bits for control: Control, Length, Sequence, Version 2 */
|
||||
#define PPPOL2TP_HEADERFLAG_CONTROL_MANDATORY (PPPOL2TP_HEADERFLAG_CONTROL|PPPOL2TP_HEADERFLAG_LENGTH|PPPOL2TP_HEADERFLAG_SEQUENCE|PPPOL2TP_HEADERFLAG_VERSION)
|
||||
/* Forbidden bits for control: Offset, Priority */
|
||||
#define PPPOL2TP_HEADERFLAG_CONTROL_FORBIDDEN (PPPOL2TP_HEADERFLAG_OFFSET|PPPOL2TP_HEADERFLAG_PRIORITY)
|
||||
|
||||
/* Mandatory bits for data: Version 2 */
|
||||
#define PPPOL2TP_HEADERFLAG_DATA_MANDATORY (PPPOL2TP_HEADERFLAG_VERSION)
|
||||
|
||||
/* AVP (Attribute Value Pair) header */
|
||||
#define PPPOL2TP_AVPHEADERFLAG_MANDATORY 0x8000
|
||||
#define PPPOL2TP_AVPHEADERFLAG_HIDDEN 0x4000
|
||||
#define PPPOL2TP_AVPHEADERFLAG_LENGTHMASK 0x03ff
|
||||
|
||||
/* -- AVP - Message type */
|
||||
#define PPPOL2TP_AVPTYPE_MESSAGE 0 /* Message type */
|
||||
|
||||
/* Control Connection Management */
|
||||
#define PPPOL2TP_MESSAGETYPE_SCCRQ 1 /* Start Control Connection Request */
|
||||
#define PPPOL2TP_MESSAGETYPE_SCCRP 2 /* Start Control Connection Reply */
|
||||
#define PPPOL2TP_MESSAGETYPE_SCCCN 3 /* Start Control Connection Connected */
|
||||
#define PPPOL2TP_MESSAGETYPE_STOPCCN 4 /* Stop Control Connection Notification */
|
||||
#define PPPOL2TP_MESSAGETYPE_HELLO 6 /* Hello */
|
||||
/* Call Management */
|
||||
#define PPPOL2TP_MESSAGETYPE_OCRQ 7 /* Outgoing Call Request */
|
||||
#define PPPOL2TP_MESSAGETYPE_OCRP 8 /* Outgoing Call Reply */
|
||||
#define PPPOL2TP_MESSAGETYPE_OCCN 9 /* Outgoing Call Connected */
|
||||
#define PPPOL2TP_MESSAGETYPE_ICRQ 10 /* Incoming Call Request */
|
||||
#define PPPOL2TP_MESSAGETYPE_ICRP 11 /* Incoming Call Reply */
|
||||
#define PPPOL2TP_MESSAGETYPE_ICCN 12 /* Incoming Call Connected */
|
||||
#define PPPOL2TP_MESSAGETYPE_CDN 14 /* Call Disconnect Notify */
|
||||
/* Error reporting */
|
||||
#define PPPOL2TP_MESSAGETYPE_WEN 15 /* WAN Error Notify */
|
||||
/* PPP Session Control */
|
||||
#define PPPOL2TP_MESSAGETYPE_SLI 16 /* Set Link Info */
|
||||
|
||||
/* -- AVP - Result code */
|
||||
#define PPPOL2TP_AVPTYPE_RESULTCODE 1 /* Result code */
|
||||
#define PPPOL2TP_RESULTCODE 1 /* General request to clear control connection */
|
||||
|
||||
/* -- AVP - Protocol version (!= L2TP Header version) */
|
||||
#define PPPOL2TP_AVPTYPE_VERSION 2
|
||||
#define PPPOL2TP_VERSION 0x0100 /* L2TP Protocol version 1, revision 0 */
|
||||
|
||||
/* -- AVP - Framing capabilities */
|
||||
#define PPPOL2TP_AVPTYPE_FRAMINGCAPABILITIES 3 /* Bearer capabilities */
|
||||
#define PPPOL2TP_FRAMINGCAPABILITIES 0x00000003 /* Async + Sync framing */
|
||||
|
||||
/* -- AVP - Bearer capabilities */
|
||||
#define PPPOL2TP_AVPTYPE_BEARERCAPABILITIES 4 /* Bearer capabilities */
|
||||
#define PPPOL2TP_BEARERCAPABILITIES 0x00000003 /* Analog + Digital Access */
|
||||
|
||||
/* -- AVP - Tie breaker */
|
||||
#define PPPOL2TP_AVPTYPE_TIEBREAKER 5
|
||||
|
||||
/* -- AVP - Host name */
|
||||
#define PPPOL2TP_AVPTYPE_HOSTNAME 7 /* Host name */
|
||||
#define PPPOL2TP_HOSTNAME "lwIP" /* FIXME: make it configurable */
|
||||
|
||||
/* -- AVP - Vendor name */
|
||||
#define PPPOL2TP_AVPTYPE_VENDORNAME 8 /* Vendor name */
|
||||
#define PPPOL2TP_VENDORNAME "lwIP" /* FIXME: make it configurable */
|
||||
|
||||
/* -- AVP - Assign tunnel ID */
|
||||
#define PPPOL2TP_AVPTYPE_TUNNELID 9 /* Assign Tunnel ID */
|
||||
|
||||
/* -- AVP - Receive window size */
|
||||
#define PPPOL2TP_AVPTYPE_RECEIVEWINDOWSIZE 10 /* Receive window size */
|
||||
#define PPPOL2TP_RECEIVEWINDOWSIZE 8 /* FIXME: make it configurable */
|
||||
|
||||
/* -- AVP - Challenge */
|
||||
#define PPPOL2TP_AVPTYPE_CHALLENGE 11 /* Challenge */
|
||||
|
||||
/* -- AVP - Cause code */
|
||||
#define PPPOL2TP_AVPTYPE_CAUSECODE 12 /* Cause code*/
|
||||
|
||||
/* -- AVP - Challenge response */
|
||||
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE 13 /* Challenge response */
|
||||
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE 16
|
||||
|
||||
/* -- AVP - Assign session ID */
|
||||
#define PPPOL2TP_AVPTYPE_SESSIONID 14 /* Assign Session ID */
|
||||
|
||||
/* -- AVP - Call serial number */
|
||||
#define PPPOL2TP_AVPTYPE_CALLSERIALNUMBER 15 /* Call Serial Number */
|
||||
|
||||
/* -- AVP - Framing type */
|
||||
#define PPPOL2TP_AVPTYPE_FRAMINGTYPE 19 /* Framing Type */
|
||||
#define PPPOL2TP_FRAMINGTYPE 0x00000001 /* Sync framing */
|
||||
|
||||
/* -- AVP - TX Connect Speed */
|
||||
#define PPPOL2TP_AVPTYPE_TXCONNECTSPEED 24 /* TX Connect Speed */
|
||||
#define PPPOL2TP_TXCONNECTSPEED 100000000 /* Connect speed: 100 Mbits/s */
|
||||
|
||||
/* L2TP Session state */
|
||||
#define PPPOL2TP_STATE_INITIAL 0
|
||||
#define PPPOL2TP_STATE_SCCRQ_SENT 1
|
||||
#define PPPOL2TP_STATE_ICRQ_SENT 2
|
||||
#define PPPOL2TP_STATE_ICCN_SENT 3
|
||||
#define PPPOL2TP_STATE_DATA 4
|
||||
|
||||
#define PPPOL2TP_OUTPUT_DATA_HEADER_LEN 6 /* Our data header len */
|
||||
|
||||
/*
|
||||
* PPPoL2TP interface control block.
|
||||
*/
|
||||
typedef struct pppol2tp_pcb_s pppol2tp_pcb;
|
||||
struct pppol2tp_pcb_s {
|
||||
ppp_pcb *ppp; /* PPP PCB */
|
||||
u8_t phase; /* L2TP phase */
|
||||
struct udp_pcb *udp; /* UDP L2TP Socket */
|
||||
struct netif *netif; /* Output interface, used as a default route */
|
||||
ip_addr_t remote_ip; /* LNS IP Address */
|
||||
u16_t remote_port; /* LNS port */
|
||||
#if PPPOL2TP_AUTH_SUPPORT
|
||||
const u8_t *secret; /* Secret string */
|
||||
u8_t secret_len; /* Secret string length */
|
||||
u8_t secret_rv[16]; /* Random vector */
|
||||
u8_t challenge_hash[16]; /* Challenge response */
|
||||
u8_t send_challenge; /* Boolean whether the next sent packet should contains a challenge response */
|
||||
#endif /* PPPOL2TP_AUTH_SUPPORT */
|
||||
|
||||
u16_t tunnel_port; /* Tunnel port */
|
||||
u16_t our_ns; /* NS to peer */
|
||||
u16_t peer_nr; /* NR from peer */
|
||||
u16_t peer_ns; /* NS from peer */
|
||||
u16_t source_tunnel_id; /* Tunnel ID assigned by peer */
|
||||
u16_t remote_tunnel_id; /* Tunnel ID assigned to peer */
|
||||
u16_t source_session_id; /* Session ID assigned by peer */
|
||||
u16_t remote_session_id; /* Session ID assigned to peer */
|
||||
|
||||
u8_t sccrq_retried; /* number of SCCRQ retries already done */
|
||||
u8_t icrq_retried; /* number of ICRQ retries already done */
|
||||
u8_t iccn_retried; /* number of ICCN retries already done */
|
||||
};
|
||||
|
||||
|
||||
/* Create a new L2TP session. */
|
||||
ppp_pcb *pppol2tp_create(struct netif *pppif,
|
||||
struct netif *netif, ip_addr_t *ipaddr, u16_t port,
|
||||
const u8_t *secret, u8_t secret_len,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
|
||||
#endif /* PPPOL2TP_H_ */
|
||||
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
|
||||
@@ -1,119 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* Network Point to Point Protocol over Serial header file.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPOS_H
|
||||
#define PPPOS_H
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/sio.h"
|
||||
|
||||
#include "ppp.h"
|
||||
#include "vj.h"
|
||||
|
||||
/* PPP packet parser states. Current state indicates operation yet to be
|
||||
* completed. */
|
||||
enum {
|
||||
PDIDLE = 0, /* Idle state - waiting. */
|
||||
PDSTART, /* Process start flag. */
|
||||
PDADDRESS, /* Process address field. */
|
||||
PDCONTROL, /* Process control field. */
|
||||
PDPROTOCOL1, /* Process protocol field 1. */
|
||||
PDPROTOCOL2, /* Process protocol field 2. */
|
||||
PDDATA /* Process data byte. */
|
||||
};
|
||||
|
||||
/* PPPoS serial output callback function prototype */
|
||||
typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx);
|
||||
|
||||
/*
|
||||
* Extended asyncmap - allows any character to be escaped.
|
||||
*/
|
||||
typedef u8_t ext_accm[32];
|
||||
|
||||
/*
|
||||
* PPPoS interface control block.
|
||||
*/
|
||||
typedef struct pppos_pcb_s pppos_pcb;
|
||||
struct pppos_pcb_s {
|
||||
/* -- below are data that will NOT be cleared between two sessions */
|
||||
ppp_pcb *ppp; /* PPP PCB */
|
||||
pppos_output_cb_fn output_cb; /* PPP serial output callback */
|
||||
|
||||
/* -- below are data that will be cleared between two sessions
|
||||
*
|
||||
* last_xmit must be the first member of cleared members, because it is
|
||||
* used to know which part must not be cleared.
|
||||
*/
|
||||
u32_t last_xmit; /* Time of last transmission. */
|
||||
ext_accm out_accm; /* Async-Ctl-Char-Map for output. */
|
||||
|
||||
/* flags */
|
||||
unsigned int open :1; /* Set if PPPoS is open */
|
||||
unsigned int pcomp :1; /* Does peer accept protocol compression? */
|
||||
unsigned int accomp :1; /* Does peer accept addr/ctl compression? */
|
||||
|
||||
/* PPPoS rx */
|
||||
ext_accm in_accm; /* Async-Ctl-Char-Map for input. */
|
||||
struct pbuf *in_head, *in_tail; /* The input packet. */
|
||||
u16_t in_protocol; /* The input protocol code. */
|
||||
u16_t in_fcs; /* Input Frame Check Sequence value. */
|
||||
u8_t in_state; /* The input process state. */
|
||||
u8_t in_escaped; /* Escape next character. */
|
||||
};
|
||||
|
||||
/* Create a new PPPoS session. */
|
||||
ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
|
||||
#if !NO_SYS && !PPP_INPROC_IRQ_SAFE
|
||||
/* Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. */
|
||||
err_t pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l);
|
||||
#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
|
||||
|
||||
/* PPP over Serial: this is the input function to be called for received data. */
|
||||
void pppos_input(ppp_pcb *ppp, u8_t* data, int len);
|
||||
|
||||
|
||||
/*
|
||||
* Functions called from lwIP
|
||||
* DO NOT CALL FROM lwIP USER APPLICATION.
|
||||
*/
|
||||
#if !NO_SYS && !PPP_INPROC_IRQ_SAFE
|
||||
err_t pppos_input_sys(struct pbuf *p, struct netif *inp);
|
||||
#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
|
||||
|
||||
#endif /* PPPOS_H */
|
||||
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* upap.h - User/Password Authentication Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: upap.h,v 1.8 2002/12/04 23:03:33 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef UPAP_H
|
||||
#define UPAP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define UPAP_HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* UPAP codes.
|
||||
*/
|
||||
#define UPAP_AUTHREQ 1 /* Authenticate-Request */
|
||||
#define UPAP_AUTHACK 2 /* Authenticate-Ack */
|
||||
#define UPAP_AUTHNAK 3 /* Authenticate-Nak */
|
||||
|
||||
|
||||
/*
|
||||
* Client states.
|
||||
*/
|
||||
#define UPAPCS_INITIAL 0 /* Connection down */
|
||||
#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */
|
||||
#define UPAPCS_PENDING 2 /* Connection down, have requested auth */
|
||||
#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */
|
||||
#define UPAPCS_OPEN 4 /* We've received an Ack */
|
||||
#define UPAPCS_BADAUTH 5 /* We've received a Nak */
|
||||
|
||||
/*
|
||||
* Server states.
|
||||
*/
|
||||
#define UPAPSS_INITIAL 0 /* Connection down */
|
||||
#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */
|
||||
#define UPAPSS_PENDING 2 /* Connection down, have requested auth */
|
||||
#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */
|
||||
#define UPAPSS_OPEN 4 /* We've sent an Ack */
|
||||
#define UPAPSS_BADAUTH 5 /* We've sent a Nak */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#if 0 /* moved to opt.h */
|
||||
#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */
|
||||
#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
/*
|
||||
* Each interface is described by upap structure.
|
||||
*/
|
||||
#if PAP_SUPPORT
|
||||
typedef struct upap_state {
|
||||
const char *us_user; /* User */
|
||||
u8_t us_userlen; /* User length */
|
||||
const char *us_passwd; /* Password */
|
||||
u8_t us_passwdlen; /* Password length */
|
||||
u8_t us_clientstate; /* Client state */
|
||||
#if PPP_SERVER
|
||||
u8_t us_serverstate; /* Server state */
|
||||
#endif /* PPP_SERVER */
|
||||
u8_t us_id; /* Current id */
|
||||
u8_t us_transmits; /* Number of auth-reqs sent */
|
||||
} upap_state;
|
||||
#endif /* PAP_SUPPORT */
|
||||
|
||||
|
||||
void upap_authwithpeer(ppp_pcb *pcb, const char *user, const char *password);
|
||||
#if PPP_SERVER
|
||||
void upap_authpeer(ppp_pcb *pcb);
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
extern const struct protent pap_protent;
|
||||
|
||||
#endif /* UPAP_H */
|
||||
#endif /* PPP_SUPPORT && PAP_SUPPORT */
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Definitions for tcp compression routines.
|
||||
*
|
||||
* $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $
|
||||
*
|
||||
* Copyright (c) 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && VJ_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef VJ_H
|
||||
#define VJ_H
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
|
||||
#define MAX_SLOTS 16 /* must be > 2 and < 256 */
|
||||
#define MAX_HDR 128
|
||||
|
||||
/*
|
||||
* Compressed packet format:
|
||||
*
|
||||
* The first octet contains the packet type (top 3 bits), TCP
|
||||
* 'push' bit, and flags that indicate which of the 4 TCP sequence
|
||||
* numbers have changed (bottom 5 bits). The next octet is a
|
||||
* conversation number that associates a saved IP/TCP header with
|
||||
* the compressed packet. The next two octets are the TCP checksum
|
||||
* from the original datagram. The next 0 to 15 octets are
|
||||
* sequence number changes, one change per bit set in the header
|
||||
* (there may be no changes and there are two special cases where
|
||||
* the receiver implicitly knows what changed -- see below).
|
||||
*
|
||||
* There are 5 numbers which can change (they are always inserted
|
||||
* in the following order): TCP urgent pointer, window,
|
||||
* acknowlegement, sequence number and IP ID. (The urgent pointer
|
||||
* is different from the others in that its value is sent, not the
|
||||
* change in value.) Since typical use of SLIP links is biased
|
||||
* toward small packets (see comments on MTU/MSS below), changes
|
||||
* use a variable length coding with one octet for numbers in the
|
||||
* range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
|
||||
* range 256 - 65535 or 0. (If the change in sequence number or
|
||||
* ack is more than 65535, an uncompressed packet is sent.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet types (must not conflict with IP protocol version)
|
||||
*
|
||||
* The top nibble of the first octet is the packet type. There are
|
||||
* three possible types: IP (not proto TCP or tcp with one of the
|
||||
* control flags set); uncompressed TCP (a normal IP/TCP packet but
|
||||
* with the 8-bit protocol field replaced by an 8-bit connection id --
|
||||
* this type of packet syncs the sender & receiver); and compressed
|
||||
* TCP (described above).
|
||||
*
|
||||
* LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
|
||||
* is logically part of the 4-bit "changes" field that follows. Top
|
||||
* three bits are actual packet type. For backward compatibility
|
||||
* and in the interest of conserving bits, numbers are chosen so the
|
||||
* IP protocol version number (4) which normally appears in this nibble
|
||||
* means "IP packet".
|
||||
*/
|
||||
|
||||
/* packet types */
|
||||
#define TYPE_IP 0x40
|
||||
#define TYPE_UNCOMPRESSED_TCP 0x70
|
||||
#define TYPE_COMPRESSED_TCP 0x80
|
||||
#define TYPE_ERROR 0x00
|
||||
|
||||
/* Bits in first octet of compressed packet */
|
||||
#define NEW_C 0x40 /* flag bits for what changed in a packet */
|
||||
#define NEW_I 0x20
|
||||
#define NEW_S 0x08
|
||||
#define NEW_A 0x04
|
||||
#define NEW_W 0x02
|
||||
#define NEW_U 0x01
|
||||
|
||||
/* reserved, special-case values of above */
|
||||
#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
|
||||
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
|
||||
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
|
||||
|
||||
#define TCP_PUSH_BIT 0x10
|
||||
|
||||
|
||||
/*
|
||||
* "state" data for each active tcp conversation on the wire. This is
|
||||
* basically a copy of the entire IP/TCP header from the last packet
|
||||
* we saw from the conversation together with a small identifier
|
||||
* the transmit & receive ends of the line use to locate saved header.
|
||||
*/
|
||||
struct cstate {
|
||||
struct cstate *cs_next; /* next most recently used state (xmit only) */
|
||||
u16_t cs_hlen; /* size of hdr (receive only) */
|
||||
u8_t cs_id; /* connection # associated with this state */
|
||||
u8_t cs_filler;
|
||||
union {
|
||||
char csu_hdr[MAX_HDR];
|
||||
struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */
|
||||
} vjcs_u;
|
||||
};
|
||||
#define cs_ip vjcs_u.csu_ip
|
||||
#define cs_hdr vjcs_u.csu_hdr
|
||||
|
||||
|
||||
struct vjstat {
|
||||
u32_t vjs_packets; /* outbound packets */
|
||||
u32_t vjs_compressed; /* outbound compressed packets */
|
||||
u32_t vjs_searches; /* searches for connection state */
|
||||
u32_t vjs_misses; /* times couldn't find conn. state */
|
||||
u32_t vjs_uncompressedin; /* inbound uncompressed packets */
|
||||
u32_t vjs_compressedin; /* inbound compressed packets */
|
||||
u32_t vjs_errorin; /* inbound unknown type packets */
|
||||
u32_t vjs_tossed; /* inbound packets tossed because of error */
|
||||
};
|
||||
|
||||
/*
|
||||
* all the state data for one serial line (we need one of these per line).
|
||||
*/
|
||||
struct vjcompress {
|
||||
struct cstate *last_cs; /* most recently used tstate */
|
||||
u8_t last_recv; /* last rcvd conn. id */
|
||||
u8_t last_xmit; /* last sent conn. id */
|
||||
u16_t flags;
|
||||
u8_t maxSlotIndex;
|
||||
u8_t compressSlot; /* Flag indicating OK to compress slot ID. */
|
||||
#if LINK_STATS
|
||||
struct vjstat stats;
|
||||
#endif
|
||||
struct cstate tstate[MAX_SLOTS]; /* xmit connection states */
|
||||
struct cstate rstate[MAX_SLOTS]; /* receive connection states */
|
||||
};
|
||||
|
||||
/* flag values */
|
||||
#define VJF_TOSS 1U /* tossing rcvd frames because of input err */
|
||||
|
||||
extern void vj_compress_init (struct vjcompress *comp);
|
||||
extern u8_t vj_compress_tcp (struct vjcompress *comp, struct pbuf **pb);
|
||||
extern void vj_uncompress_err (struct vjcompress *comp);
|
||||
extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp);
|
||||
extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp);
|
||||
|
||||
#endif /* VJ_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && VJ_SUPPORT */
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* 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 LWIP_HDR_NETIF_SLIPIF_H
|
||||
#define LWIP_HDR_NETIF_SLIPIF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
/** Set this to 1 to start a thread that blocks reading on the serial line
|
||||
* (using sio_read()).
|
||||
*/
|
||||
#ifndef SLIP_USE_RX_THREAD
|
||||
#define SLIP_USE_RX_THREAD !NO_SYS
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to enable functions to pass in RX bytes from ISR context.
|
||||
* If enabled, slipif_received_byte[s]() process incoming bytes and put assembled
|
||||
* packets on a queue, which is fed into lwIP from slipif_poll().
|
||||
* If disabled, slipif_poll() polls the serial line (using sio_tryread()).
|
||||
*/
|
||||
#ifndef SLIP_RX_FROM_ISR
|
||||
#define SLIP_RX_FROM_ISR 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets
|
||||
* received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available.
|
||||
* If disabled, packets will be dropped if more than one packet is received.
|
||||
*/
|
||||
#ifndef SLIP_RX_QUEUE
|
||||
#define SLIP_RX_QUEUE SLIP_RX_FROM_ISR
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
err_t slipif_init(struct netif * netif);
|
||||
void slipif_poll(struct netif *netif);
|
||||
#if SLIP_RX_FROM_ISR
|
||||
void slipif_process_rxqueue(struct netif *netif);
|
||||
void slipif_received_byte(struct netif *netif, u8_t data);
|
||||
void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len);
|
||||
#endif /* SLIP_RX_FROM_ISR */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_NETIF_SLIPIF_H */
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* 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,40 +0,0 @@
|
||||
/*
|
||||
* 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 __PERF_H__
|
||||
#define __PERF_H__
|
||||
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
|
||||
#endif /* __PERF_H__ */
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
typedef struct sys_mbox_s {
|
||||
xQueueHandle os_mbox;
|
||||
sys_mutex_t lock;
|
||||
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 )
|
||||
|
||||
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
|
||||
|
||||
#endif /* __SYS_ARCH_H__ */
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright 2017 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.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void esp_vfs_lwip_sockets_register();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright 2015-2016 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 INET_H_
|
||||
#define INET_H_
|
||||
|
||||
#include "lwip/inet.h"
|
||||
|
||||
#endif /* INET_H_ */
|
||||
@@ -1,812 +0,0 @@
|
||||
/*
|
||||
* 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: Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
#include "esp_task.h"
|
||||
#include "esp_system.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
/* Enable all Espressif-only options */
|
||||
|
||||
/*
|
||||
-----------------------------------------------
|
||||
---------- Platform specific locking ----------
|
||||
-----------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
|
||||
* critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
/**
|
||||
* MEMCPY: override this if you have a faster implementation at hand than the
|
||||
* one included in your C library
|
||||
*/
|
||||
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
|
||||
|
||||
/**
|
||||
* SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a
|
||||
* call to memcpy() if the length is known at compile time and is small.
|
||||
*/
|
||||
#define SMEMCPY(dst,src,len) memcpy(dst,src,len)
|
||||
|
||||
#define LWIP_RAND esp_random
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- Memory options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/**
|
||||
* MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
|
||||
* instead of the lwip internal allocator. Can save code size if you
|
||||
* already use it.
|
||||
*/
|
||||
#define MEM_LIBC_MALLOC 1
|
||||
|
||||
/**
|
||||
* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.
|
||||
* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution
|
||||
* speed and usage from interrupts!
|
||||
*/
|
||||
#define MEMP_MEM_MALLOC 1
|
||||
|
||||
/**
|
||||
* MEM_ALIGNMENT: should be set to the alignment of the CPU
|
||||
* 4 byte alignment -> #define MEM_ALIGNMENT 4
|
||||
* 2 byte alignment -> #define MEM_ALIGNMENT 2
|
||||
*/
|
||||
#define MEM_ALIGNMENT 4
|
||||
|
||||
/*
|
||||
------------------------------------------------
|
||||
---------- Internal Memory Pool Sizes ----------
|
||||
------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* MEMP_NUM_NETCONN: the number of struct netconns.
|
||||
* (only needed if you use the sequential API, like api_lib.c)
|
||||
*/
|
||||
#define MEMP_NUM_NETCONN CONFIG_LWIP_MAX_SOCKETS
|
||||
|
||||
/**
|
||||
* MEMP_NUM_RAW_PCB: Number of raw connection PCBs
|
||||
* (requires the LWIP_RAW option)
|
||||
*/
|
||||
#define MEMP_NUM_RAW_PCB CONFIG_LWIP_MAX_RAW_PCBS
|
||||
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB: the number of simultaneously active TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB CONFIG_LWIP_MAX_ACTIVE_TCP
|
||||
|
||||
/**
|
||||
* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
|
||||
* (requires the LWIP_TCP option)
|
||||
*/
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN CONFIG_LWIP_MAX_LISTENING_TCP
|
||||
|
||||
/**
|
||||
* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
* per active UDP "connection".
|
||||
* (requires the LWIP_UDP option)
|
||||
*/
|
||||
#define MEMP_NUM_UDP_PCB CONFIG_LWIP_MAX_UDP_PCBS
|
||||
|
||||
/*
|
||||
--------------------------------
|
||||
---------- ARP options -------
|
||||
--------------------------------
|
||||
*/
|
||||
/**
|
||||
* ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address
|
||||
* resolution. By default, only the most recent packet is queued per IP address.
|
||||
* This is sufficient for most protocols and mainly reduces TCP connection
|
||||
* startup time. Set this to 1 if you know your application sends more than one
|
||||
* packet in a row to an IP address that is not in the ARP cache.
|
||||
*/
|
||||
#define ARP_QUEUEING 1
|
||||
|
||||
/*
|
||||
--------------------------------
|
||||
---------- IP options ----------
|
||||
--------------------------------
|
||||
*/
|
||||
/**
|
||||
* IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that
|
||||
* this option does not affect outgoing packet sizes, which can be controlled
|
||||
* via IP_FRAG.
|
||||
*/
|
||||
#define IP_REASSEMBLY CONFIG_LWIP_IP_REASSEMBLY
|
||||
|
||||
/**
|
||||
* IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note
|
||||
* that this option does not affect incoming packet sizes, which can be
|
||||
* controlled via IP_REASSEMBLY.
|
||||
*/
|
||||
#define IP_FRAG CONFIG_LWIP_IP_FRAG
|
||||
|
||||
/**
|
||||
* IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
|
||||
* a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
|
||||
* in this time, the whole packet is discarded.
|
||||
*/
|
||||
#define IP_REASS_MAXAGE 3
|
||||
|
||||
/**
|
||||
* IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
|
||||
* Since the received pbufs are enqueued, be sure to configure
|
||||
* PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
|
||||
* packets even if the maximum amount of fragments is enqueued for reassembly!
|
||||
*/
|
||||
#define IP_REASS_MAX_PBUFS 10
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- ICMP options ----------
|
||||
----------------------------------
|
||||
*/
|
||||
|
||||
#define LWIP_BROADCAST_PING CONFIG_LWIP_BROADCAST_PING
|
||||
|
||||
#define LWIP_MULTICAST_PING CONFIG_LWIP_MULTICAST_PING
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- RAW options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
|
||||
*/
|
||||
#define LWIP_RAW 1
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- DHCP options ----------
|
||||
----------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_DHCP==1: Enable DHCP module.
|
||||
*/
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
#define DHCP_MAXRTX 0
|
||||
|
||||
/**
|
||||
* DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
|
||||
*/
|
||||
#define DHCP_DOES_ARP_CHECK CONFIG_LWIP_DHCP_DOES_ARP_CHECK
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- AUTOIP options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
#ifdef CONFIG_LWIP_AUTOIP
|
||||
#define LWIP_AUTOIP 1
|
||||
|
||||
/**
|
||||
* LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on
|
||||
* the same interface at the same time.
|
||||
*/
|
||||
#define LWIP_DHCP_AUTOIP_COOP 1
|
||||
|
||||
/**
|
||||
* LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes
|
||||
* that should be sent before falling back on AUTOIP. This can be set
|
||||
* as low as 1 to get an AutoIP address very quickly, but you should
|
||||
* be prepared to handle a changing IP address when DHCP overrides
|
||||
* AutoIP.
|
||||
*/
|
||||
#define LWIP_DHCP_AUTOIP_COOP_TRIES CONFIG_LWIP_AUTOIP_TRIES
|
||||
|
||||
#define LWIP_AUTOIP_MAX_CONFLICTS CONFIG_LWIP_AUTOIP_MAX_CONFLICTS
|
||||
|
||||
#define LWIP_AUTOIP_RATE_LIMIT_INTERVAL CONFIG_LWIP_AUTOIP_RATE_LIMIT_INTERVAL
|
||||
|
||||
#endif /* CONFIG_LWIP_AUTOIP */
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- SNMP options ----------
|
||||
----------------------------------
|
||||
*/
|
||||
/*
|
||||
----------------------------------
|
||||
---------- IGMP options ----------
|
||||
----------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_IGMP==1: Turn on IGMP module.
|
||||
*/
|
||||
#define LWIP_IGMP 1
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- DNS options -----------
|
||||
----------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
|
||||
* transport.
|
||||
*/
|
||||
#define LWIP_DNS 1
|
||||
|
||||
#define DNS_MAX_SERVERS 3
|
||||
#define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1)
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- UDP options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
/*
|
||||
---------------------------------
|
||||
---------- TCP options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order.
|
||||
* Define to 0 if your device is low on memory.
|
||||
*/
|
||||
#define TCP_QUEUE_OOSEQ CONFIG_TCP_QUEUE_OOSEQ
|
||||
|
||||
/**
|
||||
* ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES==1: Keep TCP connection when IP changed
|
||||
* scenario happens: 192.168.0.2 -> 0.0.0.0 -> 192.168.0.2 or 192.168.0.2 -> 0.0.0.0
|
||||
*/
|
||||
|
||||
#define ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES
|
||||
/*
|
||||
* LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all
|
||||
* events (accept, sent, etc) that happen in the system.
|
||||
* LWIP_CALLBACK_API==1: The PCB callback function is called directly
|
||||
* for the event. This is the default.
|
||||
*/
|
||||
#define TCP_MSS CONFIG_TCP_MSS
|
||||
|
||||
/**
|
||||
* TCP_MSL: The maximum segment lifetime in milliseconds
|
||||
*/
|
||||
#define TCP_MSL CONFIG_TCP_MSL
|
||||
|
||||
/**
|
||||
* TCP_MAXRTX: Maximum number of retransmissions of data segments.
|
||||
*/
|
||||
#define TCP_MAXRTX CONFIG_TCP_MAXRTX
|
||||
|
||||
/**
|
||||
* TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments.
|
||||
*/
|
||||
#define TCP_SYNMAXRTX CONFIG_TCP_SYNMAXRTX
|
||||
|
||||
/**
|
||||
* TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb.
|
||||
*/
|
||||
#define TCP_LISTEN_BACKLOG 1
|
||||
|
||||
|
||||
/**
|
||||
* TCP_OVERSIZE: The maximum number of bytes that tcp_write may
|
||||
* allocate ahead of time
|
||||
*/
|
||||
#ifdef CONFIG_TCP_OVERSIZE_MSS
|
||||
#define TCP_OVERSIZE TCP_MSS
|
||||
#endif
|
||||
#ifdef CONFIG_TCP_OVERSIZE_QUARTER_MSS
|
||||
#define TCP_OVERSIZE (TCP_MSS/4)
|
||||
#endif
|
||||
#ifdef CONFIG_TCP_OVERSIZE_DISABLE
|
||||
#define TCP_OVERSIZE 0
|
||||
#endif
|
||||
#ifndef TCP_OVERSIZE
|
||||
#error "One of CONFIG_TCP_OVERSIZE_xxx options should be set by sdkconfig"
|
||||
#endif
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- Pbuf options ----------
|
||||
----------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
------------------------------------------------
|
||||
---------- Network Interfaces options ----------
|
||||
------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
|
||||
* field.
|
||||
*/
|
||||
#define LWIP_NETIF_HOSTNAME 1
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data
|
||||
* to be sent into one single pbuf. This is for compatibility with DMA-enabled
|
||||
* MACs that do not support scatter-gather.
|
||||
* Beware that this might involve CPU-memcpy before transmitting that would not
|
||||
* be needed without this flag! Use this only if you need to!
|
||||
*
|
||||
* @todo: TCP and IP-frag do not work with this, yet:
|
||||
*/
|
||||
#define LWIP_NETIF_TX_SINGLE_PBUF 1
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- LOOPIF options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
#ifdef CONFIG_LWIP_NETIF_LOOPBACK
|
||||
/**
|
||||
* LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP
|
||||
* address equal to the netif IP address, looping them back up the stack.
|
||||
*/
|
||||
#define LWIP_NETIF_LOOPBACK 1
|
||||
|
||||
/**
|
||||
* LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback
|
||||
* sending for each netif (0 = disabled)
|
||||
*/
|
||||
#define LWIP_LOOPBACK_MAX_PBUFS CONFIG_LWIP_LOOPBACK_MAX_PBUFS
|
||||
#endif
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- SLIPIF options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- Thread options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/**
|
||||
* TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
|
||||
*/
|
||||
#define TCPIP_THREAD_NAME "tiT"
|
||||
|
||||
/**
|
||||
* TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
|
||||
* The stack size value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define TCPIP_THREAD_STACKSIZE ESP_TASK_TCPIP_STACK
|
||||
|
||||
/**
|
||||
* TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
|
||||
* The priority value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define TCPIP_THREAD_PRIO ESP_TASK_TCPIP_PRIO
|
||||
|
||||
/**
|
||||
* TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
|
||||
* The queue size value itself is platform-dependent, but is passed to
|
||||
* sys_mbox_new() when tcpip_init is called.
|
||||
*/
|
||||
#define TCPIP_MBOX_SIZE CONFIG_TCPIP_RECVMBOX_SIZE
|
||||
|
||||
/**
|
||||
* DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE CONFIG_UDP_RECVMBOX_SIZE
|
||||
|
||||
/**
|
||||
* DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE CONFIG_TCP_RECVMBOX_SIZE
|
||||
|
||||
/**
|
||||
* DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
|
||||
* The queue size value itself is platform-dependent, but is passed to
|
||||
* sys_mbox_new() when the acceptmbox is created.
|
||||
*/
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 6
|
||||
|
||||
/**
|
||||
* DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread.
|
||||
* The stack size value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define DEFAULT_THREAD_STACKSIZE TCPIP_THREAD_STACKSIZE
|
||||
|
||||
/**
|
||||
* DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread.
|
||||
* The priority value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define DEFAULT_THREAD_PRIO TCPIP_THREAD_PRIO
|
||||
|
||||
/**
|
||||
* DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_RAW. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_RAW_RECVMBOX_SIZE 6
|
||||
|
||||
/*
|
||||
----------------------------------------------
|
||||
---------- Sequential layer options ----------
|
||||
----------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!)
|
||||
* Don't use it if you're not an active lwIP project member
|
||||
*/
|
||||
#define LWIP_TCPIP_CORE_LOCKING 0
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- Socket options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and
|
||||
* SO_SNDTIMEO processing.
|
||||
*/
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
/**
|
||||
* LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and
|
||||
* SO_RCVTIMEO processing.
|
||||
*/
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
|
||||
/**
|
||||
* LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
|
||||
* options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
|
||||
* in seconds. (does not require sockets.c, and will affect tcp.c)
|
||||
*/
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
/**
|
||||
* LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
|
||||
*/
|
||||
#define LWIP_SO_RCVBUF CONFIG_LWIP_SO_RCVBUF
|
||||
|
||||
/**
|
||||
* SO_REUSE==1: Enable SO_REUSEADDR option.
|
||||
* This option is set via menuconfig.
|
||||
*/
|
||||
#define SO_REUSE CONFIG_LWIP_SO_REUSE
|
||||
|
||||
/**
|
||||
* SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets
|
||||
* to all local matches if SO_REUSEADDR is turned on.
|
||||
* WARNING: Adds a memcpy for every packet if passing to more than one pcb!
|
||||
*/
|
||||
#define SO_REUSE_RXTOALL CONFIG_LWIP_SO_REUSE_RXTOALL
|
||||
|
||||
/*
|
||||
----------------------------------------
|
||||
---------- Statistics options ----------
|
||||
----------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_STATS==1: Enable statistics collection in lwip_stats.
|
||||
*/
|
||||
#define LWIP_STATS CONFIG_LWIP_STATS
|
||||
|
||||
#if LWIP_STATS
|
||||
|
||||
/**
|
||||
* LWIP_STATS_DISPLAY==1: Compile in the statistics output functions.
|
||||
*/
|
||||
#define LWIP_STATS_DISPLAY CONFIG_LWIP_STATS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- PPP options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* PPP_SUPPORT==1: Enable PPP.
|
||||
*/
|
||||
#define PPP_SUPPORT CONFIG_PPP_SUPPORT
|
||||
|
||||
#if PPP_SUPPORT
|
||||
|
||||
/**
|
||||
* PAP_SUPPORT==1: Support PAP.
|
||||
*/
|
||||
#define PAP_SUPPORT CONFIG_PPP_PAP_SUPPORT
|
||||
|
||||
/**
|
||||
* CHAP_SUPPORT==1: Support CHAP.
|
||||
*/
|
||||
#define CHAP_SUPPORT CONFIG_PPP_CHAP_SUPPORT
|
||||
|
||||
/**
|
||||
* MSCHAP_SUPPORT==1: Support MSCHAP.
|
||||
*/
|
||||
#define MSCHAP_SUPPORT CONFIG_PPP_MSCHAP_SUPPORT
|
||||
|
||||
/**
|
||||
* CCP_SUPPORT==1: Support CCP.
|
||||
*/
|
||||
#define MPPE_SUPPORT CONFIG_PPP_MPPE_SUPPORT
|
||||
|
||||
/**
|
||||
* PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char.
|
||||
* TODO: If PPP_MAXIDLEFLAG > 0 and next package is send during PPP_MAXIDLEFLAG time,
|
||||
* then 0x7E is not added at the begining of PPP package but 0x7E termination
|
||||
* is always at the end. This behaviour brokes PPP dial with GSM (PPPoS).
|
||||
* The PPP package should always start and end with 0x7E.
|
||||
*/
|
||||
|
||||
#define PPP_MAXIDLEFLAG 0
|
||||
|
||||
/**
|
||||
* PPP_DEBUG: Enable debugging for PPP.
|
||||
*/
|
||||
#define PPP_DEBUG_ON CONFIG_PPP_DEBUG_ON
|
||||
|
||||
#if PPP_DEBUG_ON
|
||||
#define PPP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define PPP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
--------------------------------------
|
||||
---------- Checksum options ----------
|
||||
--------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
---------------------------------------
|
||||
---------- IPv6 options ---------------
|
||||
---------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_IPV6==1: Enable IPv6
|
||||
*/
|
||||
#define LWIP_IPV6 1
|
||||
|
||||
/*
|
||||
---------------------------------------
|
||||
---------- Hook options ---------------
|
||||
---------------------------------------
|
||||
*/
|
||||
#define LWIP_HOOK_IP4_ROUTE_SRC ip4_route_src_hook
|
||||
|
||||
/*
|
||||
---------------------------------------
|
||||
---------- Debugging options ----------
|
||||
---------------------------------------
|
||||
*/
|
||||
/**
|
||||
* ETHARP_DEBUG: Enable debugging in etharp.c.
|
||||
*/
|
||||
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* NETIF_DEBUG: Enable debugging in netif.c.
|
||||
*/
|
||||
#define NETIF_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* PBUF_DEBUG: Enable debugging in pbuf.c.
|
||||
*/
|
||||
#define PBUF_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* API_LIB_DEBUG: Enable debugging in api_lib.c.
|
||||
*/
|
||||
#define API_LIB_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* SOCKETS_DEBUG: Enable debugging in sockets.c.
|
||||
*/
|
||||
#define SOCKETS_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* ICMP_DEBUG: Enable debugging in icmp.c.
|
||||
*/
|
||||
#define ICMP_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* IP_DEBUG: Enable debugging for IP.
|
||||
*/
|
||||
#define IP_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* MEMP_DEBUG: Enable debugging in memp.c.
|
||||
*/
|
||||
#define MEMP_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug.
|
||||
*/
|
||||
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions.
|
||||
*/
|
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* TCPIP_DEBUG: Enable debugging in tcpip.c.
|
||||
*/
|
||||
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||
|
||||
/**
|
||||
* ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be
|
||||
* updated with the source MAC and IP addresses supplied in the packet.
|
||||
* You may want to disable this if you do not trust LAN peers to have the
|
||||
* correct addresses, or as a limited approach to attempt to handle
|
||||
* spoofing. If disabled, lwIP will need to make a new ARP request if
|
||||
* the peer is not already in the ARP table, adding a little latency.
|
||||
* The peer *is* in the ARP table if it requested our address before.
|
||||
* Also notice that this slows down input processing of every IP packet!
|
||||
*/
|
||||
#define ETHARP_TRUST_IP_MAC CONFIG_LWIP_ETHARP_TRUST_IP_MAC
|
||||
|
||||
|
||||
/**
|
||||
* POSIX I/O functions are mapped to LWIP via the VFS layer
|
||||
* (see port/vfs_lwip.c)
|
||||
*/
|
||||
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
||||
|
||||
/**
|
||||
* FD_SETSIZE from sys/types.h is the maximum number of supported file
|
||||
* descriptors and CONFIG_LWIP_MAX_SOCKETS defines the number of sockets;
|
||||
* LWIP_SOCKET_OFFSET is configured to use the largest numbers of file
|
||||
* descriptors for sockets. File descriptors from 0 to LWIP_SOCKET_OFFSET-1
|
||||
* are non-socket descriptors and from LWIP_SOCKET_OFFSET to FD_SETSIZE are
|
||||
* socket descriptors.
|
||||
*/
|
||||
#define LWIP_SOCKET_OFFSET (FD_SETSIZE - CONFIG_LWIP_MAX_SOCKETS)
|
||||
|
||||
/* Enable all Espressif-only options */
|
||||
|
||||
#define ESP_LWIP 1
|
||||
#define ESP_LWIP_ARP 1
|
||||
#define ESP_PER_SOC_TCP_WND 1
|
||||
#define ESP_THREAD_SAFE 1
|
||||
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF
|
||||
#define ESP_DHCP 1
|
||||
#define ESP_DNS 1
|
||||
#define ESP_IPV6_AUTOCONFIG 1
|
||||
#define ESP_PERF 0
|
||||
#define ESP_RANDOM_TCP_PORT 1
|
||||
#define ESP_IP4_ATON 1
|
||||
#define ESP_LIGHT_SLEEP 1
|
||||
#define ESP_L2_TO_L3_COPY CONFIG_L2_TO_L3_COPY
|
||||
#define ESP_STATS_MEM CONFIG_LWIP_STATS
|
||||
#define ESP_STATS_DROP CONFIG_LWIP_STATS
|
||||
#define ESP_STATS_TCP 0
|
||||
#define ESP_DHCP_TIMER 1
|
||||
#define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__)
|
||||
#define ESP_PING 1
|
||||
#define ESP_HAS_SELECT 1
|
||||
|
||||
#if CONFIG_LWIP_IRAM_OPTIMIZATION
|
||||
#define ESP_IRAM_ATTR IRAM_ATTR
|
||||
#else
|
||||
#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
|
||||
|
||||
enum {
|
||||
DBG_PERF_DIR_RX = 0,
|
||||
DBG_PERF_DIR_TX,
|
||||
};
|
||||
|
||||
enum {
|
||||
DBG_PERF_POINT_INT = 0,
|
||||
DBG_PERF_POINT_WIFI_IN = 1,
|
||||
DBG_PERF_POINT_WIFI_OUT = 2,
|
||||
DBG_PERF_POINT_LWIP_IN = 3,
|
||||
DBG_PERF_POINT_LWIP_OUT = 4,
|
||||
DBG_PERF_POINT_SOC_IN = 5,
|
||||
DBG_PERF_POINT_SOC_OUT = 6,
|
||||
};
|
||||
|
||||
#else
|
||||
#define DBG_PERF_PATH_SET(dir, point)
|
||||
#define DBG_PERF_FILTER_LEN 1000
|
||||
#endif
|
||||
|
||||
#if ESP_PER_SOC_TCP_WND
|
||||
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
|
||||
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DHCP_DEBUG: Enable debugging in dhcp.c.
|
||||
*/
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
#define LWIP_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_DEBUG LWIP_DBG_OFF
|
||||
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
#define CHECKSUM_CHECK_IP 0
|
||||
|
||||
#define LWIP_NETCONN_FULLDUPLEX 1
|
||||
#define LWIP_NETCONN_SEM_PER_THREAD 1
|
||||
|
||||
#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
|
||||
#define SNTP_SET_SYSTEM_TIME_US(sec, us) \
|
||||
do { \
|
||||
struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \
|
||||
settimeofday(&tv, NULL); \
|
||||
} while (0);
|
||||
|
||||
#define SNTP_GET_SYSTEM_TIME(sec, us) \
|
||||
do { \
|
||||
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; \
|
||||
gettimeofday(&tv, NULL); \
|
||||
(sec) = tv.tv_sec; \
|
||||
(us) = tv.tv_usec; \
|
||||
} while (0);
|
||||
|
||||
#define SOC_SEND_LOG //printf
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright 2015-2016 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 _ETH_LWIP_IF_H_
|
||||
#define _ETH_LWIP_IF_H_
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
err_t ethernetif_init(struct netif *netif);
|
||||
|
||||
void ethernetif_input(struct netif *netif, void *buffer, u16_t len);
|
||||
|
||||
void netif_reg_addr_change_cb(void* cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ETH_LWIP_IF_H_ */
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright 2015-2016 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 _WLAN_LWIP_IF_H_
|
||||
#define _WLAN_LWIP_IF_H_
|
||||
|
||||
#include "esp_wifi.h"
|
||||
|
||||
#include "esp_wifi_internal.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
err_t wlanif_init_ap(struct netif *netif);
|
||||
err_t wlanif_init_sta(struct netif *netif);
|
||||
|
||||
void wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb);
|
||||
|
||||
wifi_interface_t wifi_get_interface(void *dev);
|
||||
|
||||
void netif_reg_addr_change_cb(void* cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _WLAN_LWIP_IF_H_ */
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright 2015-2016 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 IN_H_
|
||||
#define IN_H_
|
||||
|
||||
#include "lwip/inet.h"
|
||||
|
||||
#define IN6_IS_ADDR_MULTICAST(a) IN_MULTICAST(a)
|
||||
|
||||
#endif /* IN_H_ */
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* This file is a posix wrapper for lwip/sockets.h.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/sockets.h"
|
||||
Reference in New Issue
Block a user