提交 fe4f74a6 编写于 作者: B Bernard Xiong

Merge pull request #330 from hduffddybz/ipv6

Add conditional compilation about IPv6 sources and headers, change code style
...@@ -7,7 +7,7 @@ objs = [] ...@@ -7,7 +7,7 @@ objs = []
list = os.listdir(os.path.join(RTT_ROOT, 'components', 'net')) list = os.listdir(os.path.join(RTT_ROOT, 'components', 'net'))
# the default version of LWIP is 1.4.1 # the default version of LWIP is 1.4.1
if not GetDepend('RT_USING_LWIP132') and not GetDepend('RT_USING_LWIP140'): if not GetDepend('RT_USING_LWIP132') and not GetDepend('RT_USING_LWIP140') and not GetDepend('RT_USING_LWIP_HEAD'):
AddDepend('RT_USING_LWIP141') AddDepend('RT_USING_LWIP141')
for d in list: for d in list:
......
...@@ -6,6 +6,10 @@ HISTORY ...@@ -6,6 +6,10 @@ HISTORY
++ New features: ++ New features:
2013-08-19: Simon Goldschmidt
* netif.h: bug #42998: made NETIF_MAX_HWADDR_LEN overridable for some special
networks
2013-03-17: Simon Goldschmidt (patch by Ghobad Emadi) 2013-03-17: Simon Goldschmidt (patch by Ghobad Emadi)
* opt.h, etharp.c: Added LWIP_HOOK_ETHARP_GET_GW to implement IPv4 routing with * opt.h, etharp.c: Added LWIP_HOOK_ETHARP_GET_GW to implement IPv4 routing with
multiple gateways multiple gateways
......
...@@ -29,12 +29,18 @@ src/core/tcp_out.c ...@@ -29,12 +29,18 @@ src/core/tcp_out.c
src/core/timers.c src/core/timers.c
src/core/udp.c src/core/udp.c
src/core/inet_chksum.c src/core/inet_chksum.c
src/netif/etharp.c
src/netif/ethernetif.c
src/netif/slipif.c
src/core/ipv4/autoip.c src/core/ipv4/autoip.c
src/core/ipv4/icmp.c src/core/ipv4/icmp.c
src/core/ipv4/igmp.c src/core/ipv4/igmp.c
src/core/ipv4/ip4.c src/core/ipv4/ip4.c
src/core/ipv4/ip4_addr.c src/core/ipv4/ip4_addr.c
src/core/ipv4/ip_frag.c src/core/ipv4/ip_frag.c
""")
ipv6_src = Split("""
src/core/ipv6/dhcp6.c src/core/ipv6/dhcp6.c
src/core/ipv6/ethip6.c src/core/ipv6/ethip6.c
src/core/ipv6/icmp6.c src/core/ipv6/icmp6.c
...@@ -44,9 +50,6 @@ src/core/ipv6/ip6.c ...@@ -44,9 +50,6 @@ src/core/ipv6/ip6.c
src/core/ipv6/ip6_frag.c src/core/ipv6/ip6_frag.c
src/core/ipv6/mld6.c src/core/ipv6/mld6.c
src/core/ipv6/nd6.c src/core/ipv6/nd6.c
src/netif/etharp.c
src/netif/ethernetif.c
src/netif/slipif.c
""") """)
snmp_src = Split(""" snmp_src = Split("""
...@@ -95,6 +98,9 @@ path = [GetCurrentDir() + '/src', ...@@ -95,6 +98,9 @@ path = [GetCurrentDir() + '/src',
GetCurrentDir() + '/src/arch/include', GetCurrentDir() + '/src/arch/include',
GetCurrentDir() + '/src/include/netif'] GetCurrentDir() + '/src/include/netif']
if GetDepend(['RT_LWIP_IPV6']):
src += ipv6_src
if GetDepend(['RT_LWIP_SNMP']): if GetDepend(['RT_LWIP_SNMP']):
src += snmp_src src += snmp_src
......
...@@ -97,13 +97,14 @@ static void tcpip_init_done_callback(void *arg) ...@@ -97,13 +97,14 @@ static void tcpip_init_done_callback(void *arg)
#ifdef LWIP_IPV6 #ifdef LWIP_IPV6
ethif->netif->output_ip6 = ethip6_output; ethif->netif->output_ip6 = ethip6_output;
netif_create_ip6_linklocal_address(ethif->netif, 1); netif_create_ip6_linklocal_address(ethif->netif, 1);
#ifdef LWIP_IPV6_AUTOCONFIG #ifdef LWIP_IPV6_AUTOCONFIG
ethif->netif->ip6_autoconfig_enabled = 1; ethif->netif->ip6_autoconfig_enabled = 1;
#endif #endif
#ifdef LWIP_IPV6_MLD #ifdef LWIP_IPV6_MLD
ethif->netif->mld_mac_filter = NULL; ethif->netif->mld_mac_filter = NULL;
#endif
#endif #endif
#endif
#if LWIP_DHCP #if LWIP_DHCP
if (ethif->flags & NETIF_FLAG_DHCP) if (ethif->flags & NETIF_FLAG_DHCP)
{ {
...@@ -175,14 +176,6 @@ int lwip_system_init(void) ...@@ -175,14 +176,6 @@ int lwip_system_init(void)
netifapi_netif_set_addr(netif_default, &ipaddr, &netmask, &gw); netifapi_netif_set_addr(netif_default, &ipaddr, &netmask, &gw);
} }
#endif #endif
/*#if LWIP_IPV6 && LWIP_IPV6_MLD
ip6_addr_t ip6addr_group;
IP6_ADDR(&ip6addr_group, 0, 0xfe, 0x80, 0x00, 0x00);
IP6_ADDR(&ip6addr_group, 0, 0x00, 0x00, 0x00, 0x00);
IP6_ADDR(&ip6addr_group, 0, 0x00, 0x00, 0x00, 0x00);
IP6_ADDR(&ip6addr_group, 0, 0x00, 0x00, 0x00, 0x01);
netif_mld_mac_filter_fn(netif_default, &ip6addr_group, 0);
#endif*/
rt_kprintf("lwIP-%d.%d.%d initialized!\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION); rt_kprintf("lwIP-%d.%d.%d initialized!\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION);
return 0; return 0;
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
#error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h" #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
#endif #endif
/* There must be sufficient timeouts, taking into account requirements of the subsystems. */ /* There must be sufficient timeouts, taking into account requirements of the subsystems. */
#if (LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)))) #if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)))
#error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
#endif #endif
#if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS)) #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
......
...@@ -60,9 +60,12 @@ extern "C" { ...@@ -60,9 +60,12 @@ extern "C" {
/* Throughout this file, IP addresses are expected to be in /* Throughout this file, IP addresses are expected to be in
* the same byte order as in IP_PCB. */ * the same byte order as in IP_PCB. */
/** must be the maximum of all used hardware address lengths /** Must be the maximum of all used hardware address lengths
across all types of interfaces in use */ 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 #define NETIF_MAX_HWADDR_LEN 6U
#endif
/** Whether the network interface is 'up'. This is /** Whether the network interface is 'up'. This is
* a software flag used to control whether this network * a software flag used to control whether this network
......
...@@ -14,12 +14,13 @@ ...@@ -14,12 +14,13 @@
//#define LWIP_IPV6_DHCP6 1 //#define LWIP_IPV6_DHCP6 1
#define LWIP_ICMP6 1 #define LWIP_ICMP6 1
#define LWIP_IPV6_NUM_ADDRESSES 3 #define LWIP_IPV6_NUM_ADDRESSES 3
#endif
#ifdef RT_LWIP_IPV6_AUTOCONFIG #ifdef RT_LWIP_IPV6_AUTOCONFIG
#define LWIP_IPV6_AUTOCONFIG 1 #define LWIP_IPV6_AUTOCONFIG 1
#endif #endif
#endif
#ifdef RT_LWIP_IPV6_MLD #ifdef RT_LWIP_IPV6_MLD
#define LWIP_IPV6_MLD 1 #define LWIP_IPV6_MLD 1
#endif #endif
......
...@@ -437,6 +437,7 @@ void set_if(char* netif_name, char* ip_addr, char* gw_addr, char* nm_addr) ...@@ -437,6 +437,7 @@ void set_if(char* netif_name, char* ip_addr, char* gw_addr, char* nm_addr)
} }
FINSH_FUNCTION_EXPORT(set_if, set network interface address); FINSH_FUNCTION_EXPORT(set_if, set network interface address);
#if LWIP_IPV6
void set_if6(char* netif_name, char* ip6_addr) void set_if6(char* netif_name, char* ip6_addr)
{ {
struct netif* netif = netif_list; struct netif* netif = netif_list;
...@@ -467,6 +468,7 @@ void set_if6(char* netif_name, char* ip6_addr) ...@@ -467,6 +468,7 @@ void set_if6(char* netif_name, char* ip6_addr)
} }
} }
FINSH_FUNCTION_EXPORT(set_if6, set ipv6 local address) FINSH_FUNCTION_EXPORT(set_if6, set ipv6 local address)
#endif
#if LWIP_DNS #if LWIP_DNS
#include <lwip/dns.h> #include <lwip/dns.h>
...@@ -514,11 +516,11 @@ void list_if(void) ...@@ -514,11 +516,11 @@ void list_if(void)
rt_kprintf("ip address: %s\n", ipaddr_ntoa(&(netif->ip_addr))); rt_kprintf("ip address: %s\n", ipaddr_ntoa(&(netif->ip_addr)));
rt_kprintf("gw address: %s\n", ipaddr_ntoa(&(netif->gw))); rt_kprintf("gw address: %s\n", ipaddr_ntoa(&(netif->gw)));
rt_kprintf("net mask : %s\n", ipaddr_ntoa(&(netif->netmask))); rt_kprintf("net mask : %s\n", ipaddr_ntoa(&(netif->netmask)));
#if LWIP_IPV6
rt_kprintf("link-local address: %s\n", ip6addr_ntoa(&(netif->ip6_addr[0]))); rt_kprintf("link-local address: %s\n", ip6addr_ntoa(&(netif->ip6_addr[0])));
rt_kprintf("ipv6[1] address: %s\n", ip6addr_ntoa(&(netif->ip6_addr[1]))); rt_kprintf("ipv6[1] address: %s\n", ip6addr_ntoa(&(netif->ip6_addr[1])));
rt_kprintf("\r\n"); rt_kprintf("\r\n");
#endif
netif = netif->next; netif = netif->next;
} }
...@@ -558,13 +560,13 @@ void list_tcps(void) ...@@ -558,13 +560,13 @@ void list_tcps(void)
rt_kprintf("Active PCB states:\n"); rt_kprintf("Active PCB states:\n");
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next)
{ {
#ifndef LWIP_IPV6 #ifndef LWIP_IPV6
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip))); strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip))); strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
#else #else
strcpy(local_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->local_ip))); strcpy(local_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->local_ip)));
strcpy(remote_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->remote_ip))); strcpy(remote_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->remote_ip)));
#endif #endif
rt_kprintf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ", rt_kprintf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ",
num++, num++,
local_ip_str, local_ip_str,
...@@ -588,13 +590,13 @@ void list_tcps(void) ...@@ -588,13 +590,13 @@ void list_tcps(void)
num = 0; num = 0;
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next)
{ {
#ifndef LWIP_IPV6 #ifndef LWIP_IPV6
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip))); strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip))); strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
#else #else
strcpy(local_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->local_ip))); strcpy(local_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->local_ip)));
strcpy(remote_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->remote_ip))); strcpy(remote_ip_str, ip6addr_ntoa((ip6_addr_t *)&(pcb->remote_ip)));
#endif #endif
rt_kprintf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ", rt_kprintf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ",
num++, num++,
......
...@@ -369,7 +369,6 @@ static err_t lwip_tx_func(struct netif *netif, struct pbuf *p) ...@@ -369,7 +369,6 @@ static err_t lwip_tx_func(struct netif *netif, struct pbuf *p)
case 3: case 3:
case 4: case 4:
case 5: case 5:
case 6:
{ {
const u8_t arpproto[] = { 0x08, 0x06 }; const u8_t arpproto[] = { 0x08, 0x06 };
...@@ -379,7 +378,7 @@ static err_t lwip_tx_func(struct netif *netif, struct pbuf *p) ...@@ -379,7 +378,7 @@ static err_t lwip_tx_func(struct netif *netif, struct pbuf *p)
check_pkt(p, 12, arpproto, sizeof(arpproto)); /* eth level proto: ip */ check_pkt(p, 12, arpproto, sizeof(arpproto)); /* eth level proto: ip */
break; break;
} }
case 7: case 6:
{ {
const u8_t fake_arp[6] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xab }; const u8_t fake_arp[6] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xab };
const u8_t ipproto[] = { 0x08, 0x00 }; const u8_t ipproto[] = { 0x08, 0x00 };
...@@ -773,13 +772,13 @@ START_TEST(test_dhcp_relayed) ...@@ -773,13 +772,13 @@ START_TEST(test_dhcp_relayed)
} }
fail_unless(netif_is_up(&net_test)); fail_unless(netif_is_up(&net_test));
fail_unless(txpacket == 6, "txpacket = %d", txpacket); fail_unless(txpacket == 5, "txpacket = %d", txpacket);
/* We need to send arp response here.. */ /* We need to send arp response here.. */
send_pkt(&net_test, arp_resp, sizeof(arp_resp)); send_pkt(&net_test, arp_resp, sizeof(arp_resp));
fail_unless(txpacket == 7, "txpacket = %d", txpacket); fail_unless(txpacket == 6, "txpacket = %d", txpacket);
fail_unless(netif_is_up(&net_test)); fail_unless(netif_is_up(&net_test));
xid = htonl(net_test.dhcp->xid); /* xid updated */ xid = htonl(net_test.dhcp->xid); /* xid updated */
...@@ -790,7 +789,7 @@ START_TEST(test_dhcp_relayed) ...@@ -790,7 +789,7 @@ START_TEST(test_dhcp_relayed)
tick_lwip(); tick_lwip();
} }
fail_unless(txpacket == 7, "txpacket = %d", txpacket); fail_unless(txpacket == 6, "txpacket = %d", txpacket);
netif_remove(&net_test); netif_remove(&net_test);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册