[lwip] add lwIP 2.2.1 as a selectable version alongside 1.4.1/2.0.3/2.1.2

- Kconfig: RT_USING_LWIP221 choice, RT_USING_LWIP_VER_NUM=0x20201
  - SConscript for lwip-2.2.1 (acd.c, mdns split files, tftp.c)
  - replay RTT patch set from lwip-2.1.2 onto 2.2.1
  - import RTT ping.c and tftp_port.c (adapted to 2.2.x TFTP API)
  - SAL: version-gated netconn socket accessor (callback_arg union >= 2.2.0)
  - lwipopts: DHCP ACD (RFC 5227) and MEMP_NUM_SYS_TIMEOUT version gates
This commit is contained in:
Tim Wang
2026-10-03 12:59:43 +08:00
committed by Bernard Xiong
parent 4422241f09
commit f1cc628cf2
22 changed files with 933 additions and 60 deletions
+2 -1
View File
@@ -7,4 +7,5 @@
/lwip-1.4.1/
/lwip-2.0.3/
/lwip-2.1.2/
/lwip-2.1.2/
/lwip-2.2.1/
+5 -1
View File
@@ -28,6 +28,9 @@ if RT_USING_LWIP
config RT_USING_LWIP212
bool "lwIP v2.1.2"
config RT_USING_LWIP221
bool "lwIP v2.2.1"
# online version
if !RT_USING_LWIP_LOCAL_VERSION
config RT_USING_LWIP_LATEST
@@ -39,6 +42,7 @@ if RT_USING_LWIP
config RT_USING_LWIP_VER_NUM
hex
default 0x99999 if RT_USING_LWIP_LATEST
default 0x20201 if RT_USING_LWIP221
default 0x20102 if RT_USING_LWIP212
default 0x20003 if RT_USING_LWIP203
default 0x10401 if RT_USING_LWIP141
@@ -48,7 +52,7 @@ if RT_USING_LWIP
bool "IPV6 protocol"
default n
select NETDEV_USING_IPV6
select NETDEV_IPV6_SCOPES if RT_USING_LWIP212
select NETDEV_IPV6_SCOPES if RT_USING_LWIP212 || RT_USING_LWIP221
endif
config RT_LWIP_MEM_ALIGNMENT
File diff suppressed because it is too large Load Diff
@@ -508,6 +508,25 @@ tryget_socket(int fd)
return NULL;
}
/**
* Same as tryget_socket but a global routine.
*
* @param fd externally used socket index
* @return struct lwip_sock for the socket or NULL if not found
*/
struct lwip_sock *
lwip_tryget_socket(int fd)
{
struct lwip_sock *sock = tryget_socket_unconn(fd);
if (sock != NULL) {
if (sock->conn) {
return sock;
}
done_socket(sock);
}
return NULL;
}
/**
* Map a externally used socket index to the internal socket representation.
*
@@ -569,6 +588,9 @@ alloc_socket(struct netconn *newconn, int accepted)
sockets[i].sendevent = (NETCONNTYPE_GROUP(newconn->type) == NETCONN_TCP ? (accepted != 0) : 1);
sockets[i].errevent = 0;
#endif /* LWIP_SOCKET_SELECT || LWIP_SOCKET_POLL */
#ifdef SAL_USING_POSIX
rt_wqueue_init(&sockets[i].wait_head);
#endif
return i + LWIP_SOCKET_OFFSET;
}
SYS_ARCH_UNPROTECT(lev);
@@ -838,7 +838,11 @@ altcp_tls_create_config(int is_server, u8_t cert_count, u8_t pkey_count, int hav
altcp_mbedtls_free_config(conf);
return NULL;
}
mbedtls_ssl_conf_authmode(&conf->conf, ALTCP_MBEDTLS_AUTHMODE);
if (!is_server && have_ca) {
mbedtls_ssl_conf_authmode(&conf->conf, MBEDTLS_SSL_VERIFY_REQUIRED);
} else {
mbedtls_ssl_conf_authmode(&conf->conf, ALTCP_MBEDTLS_AUTHMODE);
}
mbedtls_ssl_conf_rng(&conf->conf, mbedtls_ctr_drbg_random, &altcp_tls_entropy_rng->ctr_drbg);
#if ALTCP_MBEDTLS_LIB_DEBUG != LWIP_DBG_OFF
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017-08-17 armink first version.
*/
#include <rtthread.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <lwip/apps/tftp_server.h>
static struct tftp_context ctx;
/* lwIP 2.2.x: tftp.c invokes ctx->error without NULL-check; the callback
* is effectively mandatory (see tftp.c recv error path). */
static void tftp_error(void* handle, int err, const char* msg, int size)
{
LWIP_UNUSED_ARG(handle);
rt_kprintf("TFTP error: %d, %.*s\n", err, size, msg);
}
static void* tftp_open(const char* fname, const char* mode, u8_t write)
{
int fd = -1;
if (!rt_strcmp(mode, "octet"))
{
if (write)
{
fd = open(fname, O_WRONLY | O_CREAT, 0);
}
else
{
fd = open(fname, O_RDONLY, 0);
}
}
else
{
rt_kprintf("tftp: No support this mode(%s).", mode);
}
return (void *) fd;
}
static int tftp_write(void* handle, struct pbuf* p)
{
int fd = (int) handle;
return write(fd, p->payload, p->len);
}
#if defined(RT_USING_FINSH)
#include <finsh.h>
static void tftp_server(uint8_t argc, char **argv)
{
ctx.open = tftp_open;
ctx.close = (void (*)(void *)) close;
ctx.read = (int (*)(void *, void *, int)) read;
ctx.write = tftp_write;
ctx.error = tftp_error; /* lwIP 2.2.x 新增,必填 */
if (tftp_init_server(&ctx) == ERR_OK) /* lwIP 2.2.x: tftp_init → tftp_init_server */
{
rt_kprintf("TFTP server start successfully.\n");
}
else
{
rt_kprintf("TFTP server start failed.\n");
}
}
FINSH_FUNCTION_EXPORT(tftp_server, start tftp server.);
MSH_CMD_EXPORT(tftp_server, start tftp server.);
#endif /* defined(RT_USING_FINSH) */
+65 -6
View File
@@ -97,6 +97,12 @@
#include <string.h>
#include <rtthread.h>
#ifdef RT_USING_NETDEV
#include "netdev.h"
#endif
/** Random generator function to create random TXIDs and source ports for queries */
#ifndef DNS_RAND_TXID
#if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_XID) != 0)
@@ -298,7 +304,9 @@ static u8_t dns_last_pcb_idx;
static u8_t dns_seqno;
static struct dns_table_entry dns_table[DNS_TABLE_SIZE];
static struct dns_req_entry dns_requests[DNS_MAX_REQUESTS];
#ifndef RT_USING_NETDEV
static ip_addr_t dns_servers[DNS_MAX_SERVERS];
#endif
#if LWIP_IPV4
const ip_addr_t dns_mquery_v4group = DNS_MQUERY_IPV4_GROUP_INIT;
@@ -362,9 +370,25 @@ dns_setserver(u8_t numdns, const ip_addr_t *dnsserver)
{
if (numdns < DNS_MAX_SERVERS) {
if (dnsserver != NULL) {
#ifdef RT_USING_NETDEV
struct netif *netif = NULL;
/* set network interface device DNS server address */
for (netif = netif_list; netif != NULL; netif = netif->next) {
netdev_set_dns_server(netdev_get_by_name(netif->name), numdns, dnsserver);
}
#else
dns_servers[numdns] = (*dnsserver);
#endif /* RT_USING_NETDEV */
} else {
#ifdef RT_USING_NETDEV
struct netif *netif = NULL;
for (netif = netif_list; netif != NULL; netif = netif->next) {
netdev_set_dns_server(netdev_get_by_name(netif->name), numdns, IP_ADDR_ANY);
}
#else
dns_servers[numdns] = *IP_ADDR_ANY;
#endif
}
}
}
@@ -381,7 +405,11 @@ const ip_addr_t *
dns_getserver(u8_t numdns)
{
if (numdns < DNS_MAX_SERVERS) {
#ifdef RT_USING_NETDEV
return &netdev_default->dns_servers[numdns];
#else
return &dns_servers[numdns];
#endif
} else {
return IP_ADDR_ANY;
}
@@ -775,11 +803,19 @@ dns_send(u8_t idx)
u8_t n;
u8_t pcb_idx;
struct dns_table_entry *entry = &dns_table[idx];
const ip_addr_t *dns_addr;
LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n",
(u16_t)(entry->server_idx), entry->name));
LWIP_ASSERT("dns server out of array", entry->server_idx < DNS_MAX_SERVERS);
if (ip_addr_isany_val(dns_servers[entry->server_idx])
#ifdef RT_USING_NETDEV
dns_addr = &netdev_default->dns_servers[entry->server_idx];
#else
dns_addr = &dns_servers[entry->server_idx];
#endif
if (ip_addr_isany(dns_addr)
#if LWIP_DNS_SUPPORT_MDNS_QUERIES
&& !entry->is_mdns
#endif
@@ -864,7 +900,11 @@ dns_send(u8_t idx)
#endif /* LWIP_DNS_SUPPORT_MDNS_QUERIES */
{
dst_port = DNS_SERVER_PORT;
dst = &dns_servers[entry->server_idx];
dst = dns_addr;
#ifdef RT_USING_NETDEV
/* set netif index for this pcb, specify the network interface corresponding to the DNS server */
dns_pcbs[pcb_idx]->netif_idx = netif_get_index((struct netif *)netdev_default->user_data);
#endif
}
err = udp_sendto(dns_pcbs[pcb_idx], p, dst, dst_port);
@@ -1045,8 +1085,15 @@ dns_backupserver_available(struct dns_table_entry *pentry)
u8_t ret = 0;
if (pentry) {
if ((pentry->server_idx + 1 < DNS_MAX_SERVERS) && !ip_addr_isany_val(dns_servers[pentry->server_idx + 1])) {
ret = 1;
if ((pentry->server_idx + 1 < DNS_MAX_SERVERS)) {
#ifdef RT_USING_NETDEV
const ip_addr_t *dns_addr = &netdev_default->dns_servers[pentry->server_idx + 1];
#else
const ip_addr_t *dns_addr = &dns_servers[pentry->server_idx + 1];
#endif
if (!ip_addr_isany(dns_addr)) {
ret = 1;
}
}
}
@@ -1235,9 +1282,16 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
if (!entry->is_mdns)
#endif /* LWIP_DNS_SUPPORT_MDNS_QUERIES */
{
#ifdef RT_USING_NETDEV
const ip_addr_t *dns_addr = &netdev_default->dns_servers[entry->server_idx];
#else
const ip_addr_t *dns_addr = &dns_servers[entry->server_idx];
#endif
/* Check whether response comes from the same network address to which the
question was sent. (RFC 5452) */
if (!ip_addr_eq(addr, &dns_servers[entry->server_idx])) {
/* RT-Thread: compare against the per-device server selected above
* (ip_addr_eq is upstream 2.2.1's renamed ip_addr_cmp). */
if (!ip_addr_eq(addr, dns_addr)) {
goto ignore_packet; /* ignore this packet */
}
}
@@ -1643,8 +1697,13 @@ dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, dns_found_call
if (!is_mdns)
#endif /* LWIP_DNS_SUPPORT_MDNS_QUERIES */
{
#ifdef RT_USING_NETDEV
const ip_addr_t *dns_addr = &netdev_default->dns_servers[0];
#else
const ip_addr_t *dns_addr = &dns_servers[0];
#endif
/* prevent calling found callback if no server is set, return error instead */
if (ip_addr_isany_val(dns_servers[0])) {
if (ip_addr_isany(dns_addr)) {
return ERR_VAL;
}
}
@@ -740,7 +740,16 @@ dhcp_handle_ack(struct netif *netif, struct dhcp_msg *msg_in)
for (n = 0; (n < LWIP_DHCP_PROVIDE_DNS_SERVERS) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n); n++) {
ip_addr_t dns_addr;
ip_addr_set_ip4_u32_val(dns_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n)));
#ifdef RT_USING_NETDEV
extern struct netdev *netdev_get_by_name(const char *name);
extern void netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_t *dns_server);
/* Here we only need to set the dns server of the corresponding network device,
* but do not need to configure all network devices.
*/
netdev_set_dns_server(netdev_get_by_name(netif->name), n, &dns_addr);
#else
dns_setserver(n, &dns_addr);
#endif
}
#endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */
}
@@ -547,7 +547,16 @@ dhcp6_handle_config_reply(struct netif *netif, struct pbuf *p_msg_in)
}
ip6_addr_assign_zone(dns_addr6, IP6_UNKNOWN, netif);
/* @todo: do we need a different offset than DHCP(v4)? */
#ifdef RT_USING_NETDEV
extern struct netdev *netdev_get_by_name(const char *name);
extern void netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_t *dns_server);
/* Here we only need to set the dns server of the corresponding network device,
* but do not need to configure all network devices.
*/
netdev_set_dns_server(netdev_get_by_name(netif->name), n, &dns_addr);
#else
dns_setserver(n, &dns_addr);
#endif
}
}
/* @ todo: parse and set Domain Search List */
@@ -791,14 +791,37 @@ nd6_input(struct pbuf *p, struct netif *inp)
if (htonl(rdnss_opt->lifetime) > 0) {
/* TODO implement Lifetime > 0 */
#ifdef RT_USING_NETDEV
extern struct netdev *netdev_get_by_name(const char *name);
extern void netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_t *dns_server);
/* Here we only need to set the dns server of the corresponding network device,
* but do not need to configure all network devices.
*/
netdev_set_dns_server(netdev_get_by_name(inp->name), rdnss_server_idx++, &rdnss_address);
#else
dns_setserver(rdnss_server_idx++, &rdnss_address);
#endif
} else {
/* TODO implement DNS removal in dns.c */
u8_t s;
for (s = 0; s < DNS_MAX_SERVERS; s++) {
const ip_addr_t *addr = dns_getserver(s);
/* RT-Thread: clear only the matching server of this device
* (ip_addr_eq is upstream 2.2.1's renamed ip_addr_cmp). */
if(ip_addr_eq(addr, &rdnss_address)) {
#ifdef RT_USING_NETDEV
extern struct netdev *netdev_get_by_name(const char *name);
extern void netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_t *dns_server);
/* Here we only need to set the dns server of the corresponding network device,
* but do not need to configure all network devices.
*/
netdev_set_dns_server(netdev_get_by_name(inp->name), s, IP_ADDR_ANY);
#else
/* RT-Thread: RT 2.1.2 wrote IP_ADDR_ANY here; upstream 2.2.1 passes NULL.
* dns_setserver() maps a NULL server back to IP_ADDR_ANY (core/dns.c),
* so both forms clear the server — kept the upstream form. */
dns_setserver(s, NULL);
#endif
}
}
}
@@ -93,6 +93,13 @@
#include "lwip/nd6.h"
#endif
#include <rtthread.h>
#ifdef RT_USING_NETDEV
#include "lwip/netdb.h"
#include <netdev.h>
#endif /* RT_USING_NETDEV */
#if LWIP_NETIF_STATUS_CALLBACK
#define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0)
#else
@@ -502,6 +509,12 @@ netif_do_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr, ip_addr_t *ol
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4);
NETIF_STATUS_CALLBACK(netif);
#ifdef RT_USING_NETDEV
/* rt-thread sal network interface device set IP address operations */
netdev_low_level_set_ipaddr(netdev_get_by_name(netif->name), &netif->ip_addr);
#endif /* RT_USING_NETDEV */
return 1; /* address changed */
}
return 0; /* address unchanged */
@@ -562,6 +575,12 @@ netif_do_set_netmask(struct netif *netif, const ip4_addr_t *netmask, ip_addr_t *
ip4_addr2_16(netif_ip4_netmask(netif)),
ip4_addr3_16(netif_ip4_netmask(netif)),
ip4_addr4_16(netif_ip4_netmask(netif))));
#ifdef RT_USING_NETDEV
/* rt-thread network interface device set netmask address */
netdev_low_level_set_netmask(netdev_get_by_name(netif->name), &netif->netmask);
#endif /* RT_USING_NETDEV */
return 1; /* netmask changed */
}
return 0; /* netmask unchanged */
@@ -624,6 +643,12 @@ netif_do_set_gw(struct netif *netif, const ip4_addr_t *gw, ip_addr_t *old_gw)
ip4_addr2_16(netif_ip4_gw(netif)),
ip4_addr3_16(netif_ip4_gw(netif)),
ip4_addr4_16(netif_ip4_gw(netif))));
#ifdef RT_USING_NETDEV
/* rt_thread network interface device set gateway address */
netdev_low_level_set_gw(netdev_get_by_name(netif->name), &netif->gw);
#endif /* RT_USING_NETDEV */
return 1; /* gateway changed */
}
return 0; /* gateway unchanged */
@@ -893,6 +918,11 @@ netif_set_up(struct netif *netif)
#if LWIP_IPV6
nd6_restart_netif(netif);
#endif /* LWIP_IPV6 */
#ifdef RT_USING_NETDEV
/* rt-thread network interface device set up status */
netdev_low_level_set_status(netdev_get_by_name(netif->name), RT_TRUE);
#endif /* RT_USING_NETDEV */
}
}
@@ -975,6 +1005,11 @@ netif_set_down(struct netif *netif)
#endif /* LWIP_IPV6 */
NETIF_STATUS_CALLBACK(netif);
#ifdef RT_USING_NETDEV
/* rt-thread network interface device set down status */
netdev_low_level_set_status(netdev_get_by_name(netif->name), RT_FALSE);
#endif /* RT_USING_NETDEV */
}
}
@@ -1045,6 +1080,11 @@ netif_set_link_up(struct netif *netif)
netif_invoke_ext_callback(netif, LWIP_NSC_LINK_CHANGED, &args);
}
#endif
#ifdef RT_USING_NETDEV
/* rt-thread network interface device set link up status */
netdev_low_level_set_link_status(netdev_get_by_name(netif->name), RT_TRUE);
#endif /* RT_USING_NETDEV */
}
}
@@ -1082,6 +1122,11 @@ netif_set_link_down(struct netif *netif)
netif_invoke_ext_callback(netif, LWIP_NSC_LINK_CHANGED, &args);
}
#endif
#ifdef RT_USING_NETDEV
/* rt-thread network interface device set link down status */
netdev_low_level_set_link_status(netdev_get_by_name(netif->name), RT_FALSE);
#endif /* RT_USING_NETDEV */
}
}
@@ -1595,6 +1640,11 @@ netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
* zone field, so this should not create any compatibility problems. */
ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[0]), IP6_UNICAST, netif);
#ifdef RT_USING_NETDEV
/* rt-thread network interface device set ipv6 address */
ip_addr_copy(netdev_get_by_name(netif->name)->ip6_addr[0], netif->ip6_addr[0]);
#endif /* RT_USING_NETDEV */
/* Set address state. */
#if LWIP_IPV6_DUP_DETECT_ATTEMPTS
/* Will perform duplicate address detection (DAD). */
@@ -1638,6 +1688,10 @@ netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chos
for (i = ip6_addr_islinklocal(ip6addr) ? 0 : 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
ip_addr_copy_from_ip6(netif->ip6_addr[i], *ip6addr);
#ifdef RT_USING_NETDEV
/* rt-thread network interface device set ipv6 address */
ip_addr_copy(netdev_get_by_name(netif->name)->ip6_addr[i], netif->ip6_addr[i]);
#endif /* RT_USING_NETDEV */
ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[i]), IP6_UNICAST, netif);
netif_ip6_addr_set_state(netif, i, IP6_ADDR_TENTATIVE);
if (chosen_idx != NULL) {
@@ -1763,8 +1817,12 @@ netif_find(const char *name)
return NULL;
}
num = (u8_t)atoi(&name[2]);
if (!num && (name[2] != '0')) {
/* RT-Thread netif names are "e0", "e1" ... (2 chars, see NETIF_NAMESIZE),
* not upstream's "en0" style where the number starts at name[2].
* Keep RT's &name[1] offset; upstream 2.2.1 added an atoi-failure check
* which is adapted here for the 2-char naming convention. */
num = (u8_t)atoi(&name[1]);
if (!num && (name[1] != '0')) {
/* this means atoi has failed */
return NULL;
}
@@ -196,7 +196,9 @@ typedef uintptr_t mem_ptr_t;
#define LWIP_NO_UNISTD_H 0
#endif
#if !LWIP_NO_UNISTD_H
#include <unistd.h>
#include "sys/types.h"
#else
typedef int ssize_t;
#endif
#else /* SSIZE_MAX */
typedef int ssize_t;
@@ -461,6 +461,8 @@ extern const ip_addr_t ip6_addr_any;
#define IP_ANY_TYPE IP_ADDR_ANY
#endif
struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src);
#ifdef __cplusplus
}
#endif
@@ -67,7 +67,9 @@ extern "C" {
* netif can be identified by in APIs. Composed of
* 2 chars, 3 (max) digits, and 1 \0
*/
#ifndef NETIF_NAMESIZE
#define NETIF_NAMESIZE 6
#endif
/**
* @defgroup netif_flags Flags
@@ -353,7 +355,9 @@ struct netif {
/** flags (@see @ref netif_flags) */
u8_t flags;
/** descriptive abbreviation */
char name[2];
/* RT-Thread: widened from upstream's char name[2] to NETIF_NAMESIZE so the
* full "e0"-style name can be stored (consumed by ethernetif.c rt_strncpy). */
char name[NETIF_NAMESIZE];
/** number of this interface. Used for @ref if_api and @ref netifapi_netif,
* as well as for IPv6 zones */
u8_t num;
@@ -63,6 +63,11 @@ union lwip_sock_lastdata {
struct pbuf *pbuf;
};
#include <rtthread.h>
#ifdef SAL_USING_POSIX
#include <ipc/waitqueue.h>
#endif
/** Contains all internal pointers and states used for a socket */
struct lwip_sock {
/** sockets currently are built on netconns, each socket has one netconn */
@@ -89,6 +94,10 @@ struct lwip_sock {
#define LWIP_SOCK_FD_FREE_TCP 1
#define LWIP_SOCK_FD_FREE_FREE 2
#endif
#ifdef SAL_USING_POSIX
rt_wqueue_t wait_head;
#endif
};
#ifndef set_errno
@@ -68,6 +68,8 @@ enum lwip_ieee_eth_type {
ETHTYPE_PPPOE = 0x8864U,
/** Jumbo Frames */
ETHTYPE_JUMBO = 0x8870U,
/** EAPOL, EAP over LAN */
ETHTYPE_EAPOL = 0x888EU,
/** Process field network */
ETHTYPE_PROFINET = 0x8892U,
/** Ethernet for control automation technology */
@@ -436,6 +436,8 @@ typedef struct ipv6_mreq {
#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 */
#endif
#ifndef SIOCATMARK
#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
#endif
@@ -498,9 +500,22 @@ typedef struct fd_set
#define LWIP_SELECT_MAXNFDS FD_SETSIZE
#endif /* FD_SET */
#if LWIP_SOCKET_SELECT
/* poll-related defines and types */
/* @todo: find a better way to guard the definition of these defines and types if already defined */
#if !defined(POLLIN) && !defined(POLLOUT)
#ifdef RT_USING_MUSLLIBC
#define POLLIN 0x001 /**< There is data to read. */
#define POLLPRI 0x002 /**< There is urgent data to read. */
#define POLLOUT 0x004 /**< Writing is now possible. */
#define POLLERR 0x008 /**< Error condition. */
#define POLLHUP 0x010 /**< Hang up. */
#define POLLNVAL 0x020 /**< Invalid polling request. */
#define POLLRDNORM 0x040 /**< Normal data may be read. */
#define POLLRDBAND 0x080 /**< Priority data may be read. */
#define POLLWRNORM 0x100 /**< Writing normal data is possible. */
#define POLLWRBAND 0x200 /**< Writing priority data is possible. */
#else
#define POLLIN 0x1
#define POLLOUT 0x2
#define POLLERR 0x4
@@ -512,6 +527,7 @@ typedef struct fd_set
#define POLLWRNORM 0x80
#define POLLWRBAND 0x100
#define POLLHUP 0x200
#endif /* RT_USING_MUSLLIBC */
typedef unsigned int nfds_t;
struct pollfd
{
@@ -520,6 +536,7 @@ struct pollfd
short revents;
};
#endif
#endif
/** 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 */
@@ -50,7 +50,7 @@
#include "netif/lowpan6.h"
#if LWIP_IPV6
#if LWIP_IPV6 && LWIP_6LOWPAN
#include "lwip/ip.h"
#include "lwip/pbuf.h"
@@ -24,7 +24,8 @@
*
******************************************************************************
* REVISION HISTORY
*
* 24-09-12 Evlers <1425295900@qq.com>
* add support for independent dns services for multiple network devices
* 03-01-01 Marc Boucher <marc@mbsi.ca>
* Ported to lwIP.
* 97-11-05 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
@@ -134,6 +135,9 @@
#if PPP_IPV6_SUPPORT
#include "netif/ppp/ipv6cp.h"
#endif /* PPP_IPV6_SUPPORT */
#ifdef RT_USING_NETDEV
#include "netdev.h"
#endif /* RT_USING_NETDEV */
/*************************/
/*** LOCAL DEFINITIONS ***/
@@ -469,8 +473,7 @@ static void ppp_do_connect(void *arg) {
* ppp_netif_init_cb - netif init callback
*/
static err_t ppp_netif_init_cb(struct netif *netif) {
netif->name[0] = 'p';
netif->name[1] = 'p';
rt_strncpy(netif->name, "pp", sizeof(netif->name));
#if PPP_IPV4_SUPPORT
netif->output = ppp_netif_output_ip4;
#endif /* PPP_IPV4_SUPPORT */
@@ -1123,9 +1126,20 @@ int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) {
LWIP_UNUSED_ARG(pcb);
ip_addr_set_ip4_u32_val(ns, ns1);
#ifdef RT_USING_NETDEV
/* Here we only need to set the dns server of the corresponding network device,
* but do not need to configure all network cards.
*/
netdev_set_dns_server(netdev_get_by_name(pcb->netif->name), 0, &ns);
#else
dns_setserver(0, &ns);
#endif
ip_addr_set_ip4_u32_val(ns, ns2);
#ifdef RT_USING_NETDEV
netdev_set_dns_server(netdev_get_by_name(pcb->netif->name), 1, &ns);
#else
dns_setserver(1, &ns);
#endif
return 1;
}
@@ -1140,13 +1154,23 @@ int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) {
nsa = dns_getserver(0);
ip_addr_set_ip4_u32_val(nsb, ns1);
/* RT-Thread: clear the DNS server of the device owning this PCB
* (ip_addr_eq is upstream 2.2.1's renamed ip_addr_cmp). */
if (ip_addr_eq(nsa, &nsb)) {
#ifdef RT_USING_NETDEV
netdev_set_dns_server(netdev_get_by_name(pcb->netif->name), 0, IP_ADDR_ANY);
#else
dns_setserver(0, IP_ADDR_ANY);
#endif
}
nsa = dns_getserver(1);
ip_addr_set_ip4_u32_val(nsb, ns2);
if (ip_addr_eq(nsa, &nsb)) {
#ifdef RT_USING_NETDEV
netdev_set_dns_server(netdev_get_by_name(pcb->netif->name), 1, IP_ADDR_ANY);
#else
dns_setserver(1, IP_ADDR_ANY);
#endif
}
return 1;
}
+19 -3
View File
@@ -464,9 +464,18 @@
#define LWIP_DHCP 0
#endif
/* 1 if you want to do an ARP check on the offered address
(recommended). */
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
/* 2.2.0 replaces DHCP_DOES_ARP_CHECK with ACD (RFC 5227 address conflict
* detection). The legacy macro is silently unused in 2.2.x, so map the
* intent onto the new option by version. This also makes the behavior
* explicit against upstream default drift: the 2.2.1 release default for
* LWIP_DHCP_DOES_ACD_CHECK is (LWIP_DHCP) (opt.h), i.e. same intent as
* RT's 2.1.2 DHCP_DOES_ARP_CHECK. Requires acd.c in the build
* (see lwip-2.2.1/SConscript). */
#if RT_USING_LWIP_VER_NUM >= 0x20200
#define LWIP_DHCP_DOES_ACD_CHECK (LWIP_DHCP)
#else
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
#endif
/* ---------- AUTOIP options ------- */
#define LWIP_AUTOIP 0
@@ -595,11 +604,18 @@
#endif
/* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts. */
#if RT_USING_LWIP_VER_NUM >= 0x20200
/* lwIP 2.2.x changed the pool formula (LWIP_ACD, LWIP_IPV6_DHCP6,
* PPP_NUM_TIMEOUTS_PER_PCB). Do not derive it here; fall back to the
* upstream opt.h default (MEMP_NUM_SYS_TIMEOUT == LWIP_NUM_SYS_TIMEOUT_INTERNAL,
* opt.h:527 in 2.2.1) which always matches its own code. */
#else
#if RT_USING_LWIP_VER_NUM == 0x20102
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD)))
#else
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + (2*LWIP_IPV6)) : 0))
#endif
#endif
/*
* LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names.
File diff suppressed because it is too large Load Diff