... and finally, we got a first working version of a dual-stack lwIP runnin IPv4 and IPv6 in parallel - big thanks to Ivan Delamer! (this is work in progress, so please beware, test a lot and report problems!)

This commit is contained in:
goldsimon
2011-05-17 19:35:14 +00:00
parent f3c1686a40
commit 4bfbe7ebeb
40 changed files with 3930 additions and 978 deletions

View File

@@ -37,6 +37,7 @@
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/ip6_addr.h"
#include "lwip/err.h"
#include "lwip/netif.h"
@@ -69,14 +70,29 @@ extern "C" {
#define IP_PCB_ADDRHINT
#endif /* LWIP_NETIF_HWADDRHINT */
#if LWIP_IPV6
#define IP_PCB_ISIPV6 u8_t isipv6;
#define IP_PCB_IP6 ip6_addr_t ip6;
#else
#define IP_PCB_ISIPV6
#define IP_PCB_IP6
#endif /* LWIP_IPV6 */
/* 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_PCB_ISIPV6 \
/* ip addresses in network byte order */ \
ip_addr_t local_ip; \
ip_addr_t remote_ip; \
union { \
ip_addr_t ip4; \
IP_PCB_IP6 \
} local_ip; \
union { \
ip_addr_t ip4; \
IP_PCB_IP6 \
} remote_ip; \
/* Socket options */ \
u8_t so_options; \
/* Type Of Service */ \

View File

@@ -70,12 +70,15 @@ struct pbuf * ip_reass(struct pbuf *p);
/** 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__
#define __LWIP_PBUF_CUSTOM_REF__
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__ */
#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest);

View File

@@ -76,20 +76,35 @@ extern "C" {
/* Helpers to process several netconn_types by the same code */
#define NETCONNTYPE_GROUP(t) (t&0xF0)
#define NETCONNTYPE_DATAGRAM(t) (t&0xE0)
#define NETCONNTYPE_GROUP(t) ((t)&0xF0)
#define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0)
#define NETCONNTYPE_ISIPV6(t) ((t)&0x08)
#define NETCONNTYPE_ISUDPLITE(t)(((t)&0xF7) == NETCONN_UDPLITE)
#define NETCONNTYPE_ISUDPNOCHKSUM(t)(((t)&0xF7) == NETCONN_UDPNOCHKSUM)
/** 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 = 0x18,
#endif /* LWIP_IPV6 */
/* NETCONN_UDP Group */
NETCONN_UDP = 0x20,
NETCONN_UDPLITE = 0x21,
NETCONN_UDPNOCHKSUM= 0x22,
#if LWIP_IPV6
NETCONN_UDP_IPV6 = 0x28,
NETCONN_UDPLITE_IPV6 = 0x29,
NETCONN_UDPNOCHKSUM_IPV6= 0x2a,
#endif /* LWIP_IPV6 */
/* NETCONN_RAW Group */
NETCONN_RAW = 0x40
#if LWIP_IPV6
,
NETCONN_RAW_IPV6 = 0x48
#endif /* LWIP_IPV6 */
};
/** Current state of the netconn. Non-TCP netconns are always
@@ -111,13 +126,13 @@ enum netconn_evt {
NETCONN_EVT_ERROR
};
#if LWIP_IGMP
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
/** Used for netconn_join_leave_group() */
enum netconn_igmp {
NETCONN_JOIN,
NETCONN_LEAVE
};
#endif /* LWIP_IGMP */
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
/* forward-declare some structs to avoid to include their headers */
struct ip_pcb;
@@ -235,13 +250,25 @@ err_t netconn_write(struct netconn *conn, const void *dataptr, size_t size,
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
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
err_t netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr,
ip_addr_t *netif_addr, enum netconn_igmp join_or_leave);
#endif /* LWIP_IGMP */
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
#if LWIP_DNS
err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
#endif /* LWIP_DNS */
#if LWIP_IPV6
#define netconn_bind_ip6(conn, ip6addr, port) \
netconn_bind(conn, (ip_addr_t*) ip6addr, port)
#define netconn_connect_ip6(conn, ip6addr, port) \
netconn_connect(conn, (ip_addr_t*) ip6addr, port)
#define netconn_sendto_ip6(conn, buf, ip6addr, port) \
netconn_sendto(conn, buf, (ip_addr_t*) ip6addr, port)
#if LWIP_IPV6_MLD
#define netconn_join_leave_group_ip6(conn, multiaddr, srcaddr, join_or_leave) \
netconn_join_leave_group(conn, (ip_addr_t*)multiaddr, (ip_addr_t*)srcaddr, join_or_leave)
#endif /* LWIP_IPV6_MLD*/
#endif /* LWIP_IPV6 */
#define netconn_err(conn) ((conn)->last_err)
#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)

View File

@@ -98,14 +98,14 @@ struct api_msg_msg {
struct {
u8_t shut;
} sd;
#if LWIP_IGMP
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
/** used for do_join_leave_group */
struct {
ip_addr_t *multiaddr;
ip_addr_t *netif_addr;
enum netconn_igmp join_or_leave;
} jl;
#endif /* LWIP_IGMP */
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
#if TCP_LISTEN_BACKLOG
struct {
u8_t backlog;
@@ -154,9 +154,9 @@ void do_write ( struct api_msg_msg *msg);
void do_getaddr ( struct api_msg_msg *msg);
void do_close ( struct api_msg_msg *msg);
void do_shutdown ( struct api_msg_msg *msg);
#if LWIP_IGMP
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
void do_join_leave_group( struct api_msg_msg *msg);
#endif /* LWIP_IGMP */
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
#if LWIP_DNS
void do_gethostbyname(void *arg);

View File

@@ -47,7 +47,7 @@ LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg),
#if IP_REASSEMBLY
LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
#endif /* IP_REASSEMBLY */
#if IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
#if (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) || 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 */
@@ -91,6 +91,19 @@ LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE,
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
#endif /* PPP_SUPPORT && PPPOE_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.
*

View File

@@ -35,6 +35,7 @@
#include "lwip/opt.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/ip6_addr.h"
#ifdef __cplusplus
extern "C" {
@@ -45,9 +46,18 @@ extern "C" {
/** This netbuf includes a checksum */
#define NETBUF_FLAG_CHKSUM 0x02
#if LWIP_IPV6
#define NETBUF_IP6 ip6_addr_t ip6;
#else
#define NETBUF_IP6
#endif /* LWIP_IPV6 */
struct netbuf {
struct pbuf *p, *ptr;
ip_addr_t addr;
union {
ip_addr_t ip4;
NETBUF_IP6
} addr;
u16_t port;
#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
#if LWIP_CHECKSUM_ON_COPY
@@ -55,7 +65,10 @@ struct netbuf {
#endif /* LWIP_CHECKSUM_ON_COPY */
u16_t toport_chksum;
#if LWIP_NETBUF_RECVINFO
ip_addr_t toaddr;
union {
ip_addr_t ip4;
NETBUF_IP6
} toaddr;
#endif /* LWIP_NETBUF_RECVINFO */
#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */
};
@@ -81,12 +94,12 @@ void netbuf_first (struct netbuf *buf);
#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_fromaddr(buf) (&((buf)->addr.ip4))
#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr.ip4), 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)->addr), destaddr)
#define netbuf_destaddr(buf) (&((buf)->toaddr.ip4))
#define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->toaddr.ip4), destaddr)
#define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
#endif /* LWIP_NETBUF_RECVINFO */
#if LWIP_CHECKSUM_ON_COPY
@@ -94,6 +107,13 @@ void netbuf_first (struct netbuf *buf);
(buf)->toport_chksum = chksum; } while(0)
#endif /* LWIP_CHECKSUM_ON_COPY */
#if LWIP_IPV6
#define netbuf_fromaddr_ip6(buf) (&((buf)->addr.ip6))
#define netbuf_set_fromaddr_ip6(buf, fromaddr) ip6_addr_set((&(buf)->addr.ip6), fromaddr)
#define netbuf_destaddr_ip6(buf) (&((buf)->toaddr.ip6))
#define netbuf_set_destaddr_ip6(buf, destaddr) ip6_addr_set((&(buf)->toaddr.ip6), destaddr)
#endif /* LWIP_IPV6 */
#ifdef __cplusplus
}
#endif

View File

@@ -39,6 +39,7 @@
#include "lwip/err.h"
#include "lwip/ip_addr.h"
#include "lwip/ip6_addr.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
@@ -48,6 +49,9 @@ struct dhcp;
#if LWIP_AUTOIP
struct autoip;
#endif
#if LWIP_IPV6_DHCP6
#include "lwip/dhcp6.h"
#endif /* LWIP_IPV6_DHCP6 */
#ifdef __cplusplus
extern "C" {
@@ -117,6 +121,18 @@ typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp);
*/
typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p,
ip_addr_t *ipaddr);
#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 'nd_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,
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.
*
@@ -129,6 +145,11 @@ typedef void (*netif_status_callback_fn)(struct netif *netif);
/** Function prototype for netif igmp_mac_filter functions */
typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif,
ip_addr_t *group, u8_t action);
#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,
ip6_addr_t *group, u8_t action);
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
/** Generic data structure used for all lwIP network interfaces.
* The following fields should be filled in by the initialization
@@ -142,6 +163,13 @@ struct netif {
ip_addr_t netmask;
ip_addr_t gw;
#if LWIP_IPV6
/** Array of IPv6 addresses for this netif. */
ip6_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];
#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;
@@ -153,6 +181,12 @@ struct netif {
* 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
*/
@@ -174,6 +208,18 @@ struct netif {
/** 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 */
char* hostname;
@@ -208,10 +254,15 @@ struct netif {
u32_t ifoutdiscards;
#endif /* LWIP_SNMP */
#if LWIP_IGMP
/** This function could be called to add or delete a entry in the multicast
/** 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_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 */
@@ -308,6 +359,15 @@ void netif_poll_all(void);
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
#endif /* ENABLE_LOOPBACK */
#if LWIP_IPV6
#define netif_ip6_addr(netif, i) (&(netif->ip6_addr[(i)]))
#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_matches_ip6_addr(struct netif * netif, ip6_addr_t * ip6addr);
void netif_create_ip6_linklocal_address(struct netif * netif, u8_t from_mac_48bit);
#endif /* LWIP_IPV6 */
#ifdef __cplusplus
}
#endif

View File

@@ -1544,6 +1544,41 @@
#define SYS_STATS (NO_SYS == 0)
#endif
/**
* IP6_STATS==1: Enable IPv6 stats.
*/
#ifndef IP6_STATS
#define IP6_STATS (LWIP_IPV6)
#endif
/**
* ICMP6_STATS==1: Enable ICMP for IPv6 stats.
*/
#ifndef ICMP6_STATS
#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
#endif
/**
* IP6_FRAG_STATS==1: Enable IPv6 fragmentation stats.
*/
#ifndef IP6_FRAG_STATS
#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
#endif
/**
* MLD6_STATS==1: Enable MLD for IPv6 stats.
*/
#ifndef MLD6_STATS
#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
#endif
/**
* ND6_STATS==1: Enable Neighbor discovery for IPv6 stats.
*/
#ifndef ND6_STATS
#define ND6_STATS (LWIP_IPV6)
#endif
#else
#define LINK_STATS 0
@@ -1557,6 +1592,11 @@
#define MEMP_STATS 0
#define SYS_STATS 0
#define LWIP_STATS_DISPLAY 0
#define IP6_STATS 0
#define ICMP6_STATS 0
#define IP6_FRAG_STATS 0
#define MLD6_STATS 0
#define ND6_STATS 0
#endif /* LWIP_STATS */
@@ -1779,6 +1819,231 @@
#define LWIP_CHECKSUM_ON_COPY 0
#endif
/*
---------------------------------------
---------- IPv6 options ---------------
---------------------------------------
*/
/**
* LWIP_IPV6==1: Enable IPv6
*/
#ifndef LWIP_IPV6
#define LWIP_IPV6 0
#endif
/**
* LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif.
*/
#ifndef LWIP_IPV6_NUM_ADDRESSES
#define LWIP_IPV6_NUM_ADDRESSES 3
#endif
/**
* LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs
*/
#ifndef LWIP_IPV6_FORWARD
#define LWIP_IPV6_FORWARD 0
#endif
/**
* LWIP_ICMP6==1: Enable ICMPv6 (mandatory per RFC)
*/
#ifndef LWIP_ICMP6
#define LWIP_ICMP6 (LWIP_IPV6)
#endif
/**
* LWIP_ICMP6_DATASIZE: bytes from original packet to send back in
* ICMPv6 error messages.
*/
#ifndef LWIP_ICMP6_DATASIZE
#define LWIP_ICMP6_DATASIZE 8
#endif
/**
* LWIP_ICMP6_HL: default hop limit for ICMPv6 messages
*/
#ifndef LWIP_ICMP6_HL
#define LWIP_ICMP6_HL 255
#endif
/**
* LWIP_ICMP6_CHECKSUM_CHECK==1: verify checksum on ICMPv6 packets
*/
#ifndef LWIP_ICMP6_CHECKSUM_CHECK
#define LWIP_ICMP6_CHECKSUM_CHECK 1
#endif
/**
* LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol.
*/
#ifndef LWIP_IPV6_MLD
#define LWIP_IPV6_MLD (LWIP_IPV6)
#endif
/**
* MEMP_NUM_MLD6_GROUP: Max number of IPv6 multicast that can be joined.
*/
#ifndef MEMP_NUM_MLD6_GROUP
#define MEMP_NUM_MLD6_GROUP 4
#endif
/**
* LWIP_IPV6_FRAG==1: Fragment outgoing IPv6 packets that are too big.
*/
#ifndef LWIP_IPV6_FRAG
#define LWIP_IPV6_FRAG 0
#endif
/**
* LWIP_IPV6_REASS==1: reassemble incoming IPv6 packets that fragmented
*/
#ifndef LWIP_IPV6_REASS
#define LWIP_IPV6_REASS (LWIP_IPV6)
#endif
/**
* LWIP_ND6_QUEUEING==1: queue outgoing IPv6 packets while MAC address
* is being resolved.
*/
#ifndef LWIP_ND6_QUEUEING
#define LWIP_ND6_QUEUEING (LWIP_IPV6)
#endif
/**
* MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC resolution.
*/
#ifndef MEMP_NUM_ND6_QUEUE
#define MEMP_NUM_ND6_QUEUE 20
#endif
/**
* LWIP_ND6_NUM_NEIGHBORS: Number of entries in IPv6 neighbor cache
*/
#ifndef LWIP_ND6_NUM_NEIGHBORS
#define LWIP_ND6_NUM_NEIGHBORS 10
#endif
/**
* LWIP_ND6_NUM_DESTINATIONS: number of entries in IPv6 destination cache
*/
#ifndef LWIP_ND6_NUM_DESTINATIONS
#define LWIP_ND6_NUM_DESTINATIONS 10
#endif
/**
* LWIP_ND6_NUM_PREFIXES: number of entries in IPv6 on-link prefixes cache
*/
#ifndef LWIP_ND6_NUM_PREFIXES
#define LWIP_ND6_NUM_PREFIXES 5
#endif
/**
* LWIP_ND6_NUM_ROUTERS: number of entries in IPv6 default router cache
*/
#ifndef LWIP_ND6_NUM_ROUTERS
#define LWIP_ND6_NUM_ROUTERS 3
#endif
/**
* LWIP_ND6_MAX_MULTICAST_SOLICIT: max number of multicast solicit messages to send
* (neighbor solicit and router solicit)
*/
#ifndef LWIP_ND6_MAX_MULTICAST_SOLICIT
#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
#endif
/**
* LWIP_ND6_MAX_UNICAST_SOLICIT: max number of unicast neighbor solicitation messages
* to send during neighbor reachability detection.
*/
#ifndef LWIP_ND6_MAX_UNICAST_SOLICIT
#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
#endif
/**
* Unused: See ND RFC (time in milliseconds).
*/
#ifndef LWIP_ND6_MAX_ANYCAST_DELAY_TIME
#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
#endif
/**
* Unused: See ND RFC
*/
#ifndef LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT
#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
#endif
/**
* LWIP_ND6_REACHABLE_TIME: default neighbor reachable time (in milliseconds).
* May be updated by router advertisement messages.
*/
#ifndef LWIP_ND6_REACHABLE_TIME
#define LWIP_ND6_REACHABLE_TIME 30000
#endif
/**
* LWIP_ND6_RETRANS_TIMER: default retransmission timer for solicitation messages
*/
#ifndef LWIP_ND6_RETRANS_TIMER
#define LWIP_ND6_RETRANS_TIMER 1000
#endif
/**
* LWIP_ND6_DELAY_FIRST_PROBE_TIME: Delay before first unicast neighbor solicitation
* message is sent, during neighbor reachability detection.
*/
#ifndef LWIP_ND6_DELAY_FIRST_PROBE_TIME
#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
#endif
/**
* LWIP_ND6_ALLOW_RA_UPDATES==1: Allow Router Advertisement messages to update
* Reachable time and retransmission timers, and netif MTU.
*/
#ifndef LWIP_ND6_ALLOW_RA_UPDATES
#define LWIP_ND6_ALLOW_RA_UPDATES 1
#endif
/**
* LWIP_IPV6_SEND_ROUTER_SOLICIT==1: Send router solicitation messages during
* network startup.
*/
#ifndef LWIP_IPV6_SEND_ROUTER_SOLICIT
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
#endif
/**
* LWIP_ND6_TCP_REACHABILITY_HINTS==1: Allow TCP to provide Neighbor Discovery
* with reachability hints for connected destinations. This helps avoid sending
* unicast neighbor solicitation messages.
*/
#ifndef LWIP_ND6_TCP_REACHABILITY_HINTS
#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
#endif
/**
* LWIP_IPV6_AUTOCONFIG==1: Enable stateless address autoconfiguration as per RFC 4862.
*/
#ifndef LWIP_IPV6_AUTOCONFIG
#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
#endif
/**
* LWIP_IPV6_DUP_DETECT_ATTEMPTS: Number of duplicate address detection attempts.
*/
#ifndef LWIP_IPV6_DUP_DETECT_ATTEMPTS
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#endif
/**
* LWIP_IPV6_DHCP6==1: enable DHCPv6 stateful address autoconfiguration.
*/
#ifndef LWIP_IPV6_DHCP6
#define LWIP_IPV6_DHCP6 0
#endif
/*
---------------------------------------
---------- Debugging options ----------
@@ -2040,4 +2305,11 @@
#define DNS_DEBUG LWIP_DBG_OFF
#endif
/**
* IP6_DEBUG: Enable debugging for IPv6.
*/
#ifndef IP6_DEBUG
#define IP6_DEBUG LWIP_DBG_ON
#endif
#endif /* __LWIP_OPT_H__ */

View File

@@ -45,7 +45,11 @@ extern "C" {
#define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF)
#define PBUF_TRANSPORT_HLEN 20
#if LWIP_IPV6
#define PBUF_IP_HLEN 40
#else
#define PBUF_IP_HLEN 20
#endif
typedef enum {
PBUF_TRANSPORT,

View File

@@ -40,6 +40,7 @@
#include "lwip/def.h"
#include "lwip/ip.h"
#include "lwip/ip_addr.h"
#include "lwip/ip6_addr.h"
#ifdef __cplusplus
extern "C" {
@@ -60,6 +61,27 @@ struct raw_pcb;
typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
ip_addr_t *addr);
#if LWIP_IPV6
/** Function prototype for raw pcb IPv6 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 IPv6 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_ip6_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
ip6_addr_t *addr);
#endif /* LWIP_IPV6 */
#if LWIP_IPV6
#define RAW_PCB_RECV_IP6 raw_recv_ip6_fn ip6;
#else
#define RAW_PCB_RECV_IP6
#endif /* LWIP_IPV6 */
struct raw_pcb {
/* Common members of all PCB types */
IP_PCB;
@@ -69,7 +91,10 @@ struct raw_pcb {
u8_t protocol;
/** receive callback function */
raw_recv_fn recv;
union {
raw_recv_fn ip4;
RAW_PCB_RECV_IP6
} recv;
/* user-supplied argument for the recv callback */
void *recv_arg;
};
@@ -85,6 +110,14 @@ void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *re
err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr);
err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
#if LWIP_IPV6
struct raw_pcb * raw_new_ip6 (u8_t proto);
#define raw_bind_ip6(pcb, ip6addr) raw_bind(pcb, (ip_addr_t *)ip6addr)
#define raw_connect_ip6(pcb, ip6addr) raw_connect(pcb, (ip_addr_t *)ip6addr)
#define raw_recv_ip6(pcb, recv_ip6_fn, recv_arg) raw_recv(pcb, (raw_recv_fn)recv_ip6_fn, recv_arg)
#define raw_sendto_ip6(pcb, pbuf, ip6addr) raw_sendto(pcb, pbuf, (ip_addr_t *)ip6addr)
#endif /* LWIP_IPV6 */
/* 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, not init needed. */

View File

@@ -42,6 +42,7 @@
#include "lwip/ip_addr.h"
#include "lwip/inet.h"
#include "lwip/inet6.h"
#ifdef __cplusplus
extern "C" {
@@ -56,10 +57,24 @@ struct sockaddr_in {
char sin_zero[8];
};
#if LWIP_IPV6
struct sockaddr_in6 {
u8_t sin6_len; /* length of this structure */
u8_t sin6_family; /* AF_INET6 */
u16_t sin6_port; /* Transport layer port # */
u32_t sin6_flowinfo; /* IPv6 flow information */
struct in6_addr sin6_addr; /* IPv6 address */
};
#endif /* LWIP_IPV6 */
struct sockaddr {
u8_t sa_len;
u8_t sa_family;
char sa_data[14];
#if LWIP_IPV6
u8_t sa_data[22];
#else /* LWIP_IPV6 */
u8_t sa_data[14];
#endif /* LWIP_IPV6 */
};
#ifndef socklen_t
@@ -118,7 +133,13 @@ struct linger {
#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

View File

@@ -144,6 +144,21 @@ struct stats_ {
#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
};
extern struct stats_ lwip_stats;
@@ -268,6 +283,46 @@ void stats_init(void);
#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_proto(&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
/* Display of statistics */
#if LWIP_STATS_DISPLAY
void stats_display(void);

View File

@@ -42,6 +42,8 @@
#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" {
@@ -367,6 +369,14 @@ err_t tcp_output (struct tcp_pcb *pcb);
const char* tcp_debug_state_str(enum tcp_state s);
#if LWIP_IPV6
struct tcp_pcb * tcp_new_ip6 (void);
#define tcp_bind_ip6(pcb, ip6addr, port) \
tcp_bind(pcb, (ip_addr_t *)ip6addr, port)
#define tcp_connect_ip6(pcb, ip6addr, port, connected) \
udp_connect(pcb, (ip_addr_t *)ip6addr, port, connected)
#endif /* LWIP_IPV6 */
#ifdef __cplusplus
}

View File

@@ -43,6 +43,8 @@
#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" {
@@ -429,6 +431,11 @@ void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
void tcp_rst(u32_t seqno, u32_t ackno,
ip_addr_t *local_ip, ip_addr_t *remote_ip,
u16_t local_port, u16_t remote_port);
#if LWIP_IPV6
void tcp_rst_ip6(u32_t seqno, u32_t ackno,
ip6_addr_t *local_ip6, ip6_addr_t *remote_ip6,
u16_t local_port, u16_t remote_port);
#endif /* LWIP_IPV6 */
u32_t tcp_next_iss(void);
@@ -437,6 +444,9 @@ void tcp_zero_window_probe(struct tcp_pcb *pcb);
#if TCP_CALCULATE_EFF_SEND_MSS
u16_t tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr);
#if LWIP_IPV6
u16_t tcp_eff_send_mss_ip6(u16_t sendmss, ip6_addr_t *src, ip6_addr_t *dest);
#endif /* LWIP_IPV6 */
#endif /* TCP_CALCULATE_EFF_SEND_MSS */
#if LWIP_CALLBACK_API

View File

@@ -40,6 +40,7 @@
#include "lwip/netif.h"
#include "lwip/ip_addr.h"
#include "lwip/ip.h"
#include "lwip/ip6_addr.h"
#ifdef __cplusplus
extern "C" {
@@ -87,6 +88,26 @@ struct udp_pcb;
typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
ip_addr_t *addr, u16_t port);
#if LWIP_IPV6
/** Function prototype for udp pcb IPv6 receive callback functions
* The callback is responsible for freeing the pbuf
* if it's not used any more.
*
* @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 IPv6 address from which the packet was received
* @param port the remote port from which the packet was received
*/
typedef void (*udp_recv_ip6_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
ip6_addr_t *addr, u16_t port);
#endif /* LWIP_IPV6 */
#if LWIP_IPV6
#define UDP_PCB_RECV_IP6 udp_recv_ip6_fn ip6;
#else
#define UDP_PCB_RECV_IP6
#endif /* LWIP_IPV6 */
struct udp_pcb {
/* Common members of all PCB types */
@@ -111,7 +132,10 @@ struct udp_pcb {
#endif /* LWIP_UDPLITE */
/** receive callback function */
udp_recv_fn recv;
union {
udp_recv_fn ip4;
UDP_PCB_RECV_IP6
}recv;
/** user-supplied argument for the recv callback */
void *recv_arg;
};
@@ -156,6 +180,26 @@ void udp_input (struct pbuf *p, struct netif *inp);
#define udp_init() /* Compatibility define, not init needed. */
#if LWIP_IPV6
struct udp_pcb * udp_new_ip6(void);
#define udp_bind_ip6(pcb, ip6addr, port) \
udp_bind(pcb, (ip_addr_t *)ip6addr, port)
#define udp_connect_ip6(pcb, ip6addr, port) \
udp_connect(pcb, (ip_addr_t *)ip6addr, port)
#define udp_recv_ip6(pcb, recv_ip6_fn, recv_arg) \
udp_recv(pcb, (udp_recv_fn)recv_ip6_fn, recv_arg)
#define udp_sendto_ip6(pcb, pbuf, ip6addr, port) \
udp_sendto(pcb, pbuf, (ip_addr_t *)ip6addr, port)
#define udp_sendto_if_ip6(pcb, pbuf, ip6addr, port, netif) \
udp_sendto_if(pcb, pbuf, (ip_addr_t *)ip6addr, port, netif)
#if LWIP_CHECKSUM_ON_COPY
#define udp_sendto_chksum_ip6(pcb, pbuf, ip6addr, port, have_chk, chksum) \
udp_sendto_chksum(pcb, pbuf, (ip_addr_t *)ip6addr, port, have_chk, chksum)
#define udp_sendto_if_chksum_ip6(pcb, pbuf, ip6addr, port, netif, have_chk, chksum) \
udp_sendto_if_chksum(pcb, pbuf, (ip_addr_t *)ip6addr, port, netif, have_chk, chksum)
#endif /*LWIP_CHECKSUM_ON_COPY */
#endif /* LWIP_IPV6 */
#if UDP_DEBUG
void udp_debug_print(struct udp_hdr *udphdr);
#else

View File

@@ -137,6 +137,7 @@ PACK_STRUCT_END
#define ETHTYPE_ARP 0x0806U
#define ETHTYPE_IP 0x0800U
#define ETHTYPE_VLAN 0x8100U
#define ETHTYPE_IPV6 0x86DDU
#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */
#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */