Merge branch 'master' into ppp-new

This commit is contained in:
Sylvain Rochet 2014-01-19 03:41:01 +01:00
commit 03a3412e62
19 changed files with 431 additions and 315 deletions

View File

@ -6,6 +6,10 @@ HISTORY
++ New features: ++ New features:
2014-01-17: Jiri Engelthaler
* icmp, icmp6, opt.h: patch #8027: Completed HW checksuming for IPv4 and
IPv6 ICMP's
2012-08-22: Sylvain Rochet 2012-08-22: Sylvain Rochet
* New PPP stack for lwIP, developed in ppp-new branch. * New PPP stack for lwIP, developed in ppp-new branch.
Based from pppd 2.4.5, released 2009-11-17, with huge changes to match Based from pppd 2.4.5, released 2009-11-17, with huge changes to match
@ -145,6 +149,17 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2014-01-08: Stathis Voukelatos
* memp_std.h: patch #7928 Fixed size calculation in MALLOC memory pool
creation macro
2014-01-18: Brian Fahs
* tcp_out.c: patch #8237: tcp_rexmit_rto fails to update pcb->unsent_oversize
when necessary
2014-01-17: Grant Erickson, Jay Logue, Simon Goldschmidt
* ipv6.c, netif.c: patch #7913 Enable Support for IPv6 Loopback
2014-01-16: Stathis Voukelatos 2014-01-16: Stathis Voukelatos
* netif.c: patch #7902 Fixed netif_poll() operation when LWIP_LOOPBACK_MAX_PBUFS > 0 * netif.c: patch #7902 Fixed netif_poll() operation when LWIP_LOOPBACK_MAX_PBUFS > 0

View File

@ -133,6 +133,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
goto lenerr; goto lenerr;
} }
#if CHECKSUM_CHECK_ICMP
if (inet_chksum_pbuf(p) != 0) { if (inet_chksum_pbuf(p) != 0) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
pbuf_free(p); pbuf_free(p);
@ -140,6 +141,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
snmp_inc_icmpinerrors(); snmp_inc_icmpinerrors();
return; return;
} }
#endif
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN #if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) { if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) {
/* p is not big enough to contain link headers /* p is not big enough to contain link headers
@ -324,7 +326,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
/* calculate checksum */ /* calculate checksum */
icmphdr->chksum = 0; icmphdr->chksum = 0;
#if CHECKSUM_GEN_ICMP
icmphdr->chksum = inet_chksum(icmphdr, q->len); icmphdr->chksum = inet_chksum(icmphdr, q->len);
#endif
ICMP_STATS_INC(icmp.xmit); ICMP_STATS_INC(icmp.xmit);
/* increase number of messages attempted to send */ /* increase number of messages attempted to send */
snmp_inc_icmpoutmsgs(); snmp_inc_icmpoutmsgs();

View File

@ -772,11 +772,11 @@ err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
if (ip_addr_cmp(dest, &netif->ip_addr)) { if (ip_addr_cmp(dest, &netif->ip_addr)) {
/* Packet to self, enqueue it for loopback */ /* Packet to self, enqueue it for loopback */
LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()")); LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()"));
return netif_loop_output(netif, p, dest); return netif_loop_output(netif, p);
} }
#if LWIP_IGMP #if LWIP_IGMP
if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) { if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) {
netif_loop_output(netif, p, dest); netif_loop_output(netif, p);
} }
#endif /* LWIP_IGMP */ #endif /* LWIP_IGMP */
#endif /* ENABLE_LOOPBACK */ #endif /* ENABLE_LOOPBACK */

View File

@ -578,7 +578,9 @@ ip_reass(struct pbuf *p)
IPH_OFFSET_SET(fraghdr, 0); IPH_OFFSET_SET(fraghdr, 0);
IPH_CHKSUM_SET(fraghdr, 0); IPH_CHKSUM_SET(fraghdr, 0);
/* @todo: do we need to set calculate the correct checksum? */ /* @todo: do we need to set calculate the correct checksum? */
#if CHECKSUM_GEN_IP
IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN)); IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN));
#endif /* CHECKSUM_GEN_IP */
p = ipr->p; p = ipr->p;
@ -818,7 +820,9 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
IPH_OFFSET_SET(iphdr, htons(tmp)); IPH_OFFSET_SET(iphdr, htons(tmp));
IPH_LEN_SET(iphdr, htons(cop + IP_HLEN)); IPH_LEN_SET(iphdr, htons(cop + IP_HLEN));
IPH_CHKSUM_SET(iphdr, 0); IPH_CHKSUM_SET(iphdr, 0);
#if CHECKSUM_GEN_IP
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
#endif /* CHECKSUM_GEN_IP */
#if IP_FRAG_USES_STATIC_BUF #if IP_FRAG_USES_STATIC_BUF
if (last) { if (last) {

View File

@ -96,7 +96,7 @@ icmp6_input(struct pbuf *p, struct netif *inp)
icmp6hdr = (struct icmp6_hdr *)p->payload; icmp6hdr = (struct icmp6_hdr *)p->payload;
#if LWIP_ICMP6_CHECKSUM_CHECK #if CHECKSUM_CHECK_ICMP6
if (ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->tot_len, ip6_current_src_addr(), if (ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->tot_len, ip6_current_src_addr(),
ip6_current_dest_addr()) != 0) { ip6_current_dest_addr()) != 0) {
/* Checksum failed */ /* Checksum failed */
@ -105,7 +105,7 @@ icmp6_input(struct pbuf *p, struct netif *inp)
ICMP6_STATS_INC(icmp6.drop); ICMP6_STATS_INC(icmp6.drop);
return; return;
} }
#endif /* LWIP_ICMP6_CHECKSUM_CHECK */ #endif /* CHECKSUM_CHECK_ICMP6 */
switch (icmp6hdr->type) { switch (icmp6hdr->type) {
case ICMP6_TYPE_NA: /* Neighbor advertisement */ case ICMP6_TYPE_NA: /* Neighbor advertisement */
@ -179,8 +179,10 @@ icmp6_input(struct pbuf *p, struct netif *inp)
/* Set fields in reply. */ /* Set fields in reply. */
((struct icmp6_echo_hdr *)(r->payload))->type = ICMP6_TYPE_EREP; ((struct icmp6_echo_hdr *)(r->payload))->type = ICMP6_TYPE_EREP;
((struct icmp6_echo_hdr *)(r->payload))->chksum = 0; ((struct icmp6_echo_hdr *)(r->payload))->chksum = 0;
#if CHECKSUM_GEN_ICMP6
((struct icmp6_echo_hdr *)(r->payload))->chksum = ip6_chksum_pseudo(r, ((struct icmp6_echo_hdr *)(r->payload))->chksum = ip6_chksum_pseudo(r,
IP6_NEXTH_ICMP6, r->tot_len, reply_src, ip6_current_src_addr()); IP6_NEXTH_ICMP6, r->tot_len, reply_src, ip6_current_src_addr());
#endif /* CHECKSUM_GEN_ICMP6 */
/* Send reply. */ /* Send reply. */
ICMP6_STATS_INC(icmp6.xmit); ICMP6_STATS_INC(icmp6.xmit);
@ -327,8 +329,10 @@ icmp6_send_response(struct pbuf *p, u8_t code, u32_t data, u8_t type)
/* calculate checksum */ /* calculate checksum */
icmp6hdr->chksum = 0; icmp6hdr->chksum = 0;
#if CHECKSUM_GEN_ICMP6
icmp6hdr->chksum = ip6_chksum_pseudo(q, IP6_NEXTH_ICMP6, q->tot_len, icmp6hdr->chksum = ip6_chksum_pseudo(q, IP6_NEXTH_ICMP6, q->tot_len,
reply_src, reply_dest); reply_src, reply_dest);
#endif /* CHECKSUM_GEN_ICMP6 */
ICMP6_STATS_INC(icmp6.xmit); ICMP6_STATS_INC(icmp6.xmit);
ip6_output_if(q, reply_src, reply_dest, LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif); ip6_output_if(q, reply_src, reply_dest, LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif);

View File

@ -802,10 +802,17 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
ip6_debug_print(p); ip6_debug_print(p);
#if ENABLE_LOOPBACK #if ENABLE_LOOPBACK
/* TODO implement loopback for v6 {
if (ip6_addr_cmp(dest, netif_ip6_addr(0))) { int i;
return netif_loop_output(netif, p, dest); for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
}*/ if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_cmp(dest, netif_ip6_addr(netif, i))) {
/* Packet to self, enqueue it for loopback */
LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n"));
return netif_loop_output(netif, p);
}
}
}
#endif /* ENABLE_LOOPBACK */ #endif /* ENABLE_LOOPBACK */
#if LWIP_IPV6_FRAG #if LWIP_IPV6_FRAG
/* don't fragment if interface has mtu set to 0 [loopif] */ /* don't fragment if interface has mtu set to 0 [loopif] */
@ -814,7 +821,7 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
} }
#endif /* LWIP_IPV6_FRAG */ #endif /* LWIP_IPV6_FRAG */
LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()")); LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()\n"));
return netif->output_ip6(netif, p, dest); return netif->output_ip6(netif, p, dest);
} }

View File

@ -563,8 +563,10 @@ mld6_send(struct mld_group *group, u8_t type)
mld_hdr->reserved = 0; mld_hdr->reserved = 0;
ip6_addr_set(&(mld_hdr->multicast_address), &(group->group_address)); ip6_addr_set(&(mld_hdr->multicast_address), &(group->group_address));
#if CHECKSUM_GEN_ICMP6
mld_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, mld_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len,
src_addr, &(group->group_address)); src_addr, &(group->group_address));
#endif /* CHECKSUM_GEN_ICMP6 */
/* Add hop-by-hop headers options: router alert with MLD value. */ /* Add hop-by-hop headers options: router alert with MLD value. */
ip6_options_add_hbh_ra(p, IP6_NEXTH_ICMP6, IP6_ROUTER_ALERT_VALUE_MLD); ip6_options_add_hbh_ra(p, IP6_NEXTH_ICMP6, IP6_ROUTER_ALERT_VALUE_MLD);

View File

@ -838,8 +838,10 @@ nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags)
target_addr = &multicast_address; target_addr = &multicast_address;
} }
#if CHECKSUM_GEN_ICMP6
ns_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr, ns_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
target_addr); target_addr);
#endif /* CHECKSUM_GEN_ICMP6 */
/* Send the packet out. */ /* Send the packet out. */
ND6_STATS_INC(nd6.xmit); ND6_STATS_INC(nd6.xmit);
@ -910,8 +912,10 @@ nd6_send_na(struct netif * netif, ip6_addr_t * target_addr, u8_t flags)
dest_addr = ip6_current_src_addr(); dest_addr = ip6_current_src_addr();
} }
#if CHECKSUM_GEN_ICMP6
na_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr, na_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
dest_addr); dest_addr);
#endif /* CHECKSUM_GEN_ICMP6 */
/* Send the packet out. */ /* Send the packet out. */
ND6_STATS_INC(nd6.xmit); ND6_STATS_INC(nd6.xmit);
@ -977,8 +981,10 @@ nd6_send_rs(struct netif * netif)
SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len); SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len);
} }
#if CHECKSUM_GEN_ICMP6
rs_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr, rs_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
&multicast_address); &multicast_address);
#endif /* CHECKSUM_GEN_ICMP6 */
/* Send the packet out. */ /* Send the packet out. */
ND6_STATS_INC(nd6.xmit); ND6_STATS_INC(nd6.xmit);

View File

@ -88,7 +88,19 @@ static u8_t netif_num;
static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr); static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr);
#endif /* LWIP_IPV6 */ #endif /* LWIP_IPV6 */
#if LWIP_IPV6
#define ipX_input(in, netif) (IP6H_V((const struct ip6_hdr *)in->payload) == 6) ? ip6_input(in, netif) : ip_input(in, netif)
#else
#define ipX_input(in, netif) ip_input(in, netif)
#endif
#if LWIP_HAVE_LOOPIF #if LWIP_HAVE_LOOPIF
static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr);
#if LWIP_IPV6
static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr);
#endif
static struct netif loop_netif; static struct netif loop_netif;
/** /**
@ -108,7 +120,10 @@ netif_loopif_init(struct netif *netif)
netif->name[0] = 'l'; netif->name[0] = 'l';
netif->name[1] = 'o'; netif->name[1] = 'o';
netif->output = netif_loop_output; netif->output = netif_loop_output_ipv4;
#if LWIP_IPV6
netif->output_ip6 = netif_loop_output_ipv6;
#endif
return ERR_OK; return ERR_OK;
} }
#endif /* LWIP_HAVE_LOOPIF */ #endif /* LWIP_HAVE_LOOPIF */
@ -127,6 +142,15 @@ netif_init(void)
#else /* NO_SYS */ #else /* NO_SYS */
netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input); netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input);
#endif /* NO_SYS */ #endif /* NO_SYS */
#if LWIP_IPV6
loop_netif.ip6_addr[0].addr[0] = 0;
loop_netif.ip6_addr[0].addr[1] = 0;
loop_netif.ip6_addr[0].addr[2] = 0;
loop_netif.ip6_addr[0].addr[3] = PP_HTONL(0x00000001UL);
loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
#endif /* LWIP_IPV6 */
netif_set_up(&loop_netif); netif_set_up(&loop_netif);
#endif /* LWIP_HAVE_LOOPIF */ #endif /* LWIP_HAVE_LOOPIF */
@ -655,13 +679,11 @@ void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_
* *
* @param netif the lwip network interface structure * @param netif the lwip network interface structure
* @param p the (IP) packet to 'send' * @param p the (IP) packet to 'send'
* @param ipaddr the ip address to send the packet to (not used)
* @return ERR_OK if the packet has been sent * @return ERR_OK if the packet has been sent
* ERR_MEM if the pbuf used to copy the packet couldn't be allocated * ERR_MEM if the pbuf used to copy the packet couldn't be allocated
*/ */
err_t err_t
netif_loop_output(struct netif *netif, struct pbuf *p, netif_loop_output(struct netif *netif, struct pbuf *p)
ip_addr_t *ipaddr)
{ {
struct pbuf *r; struct pbuf *r;
err_t err; err_t err;
@ -679,7 +701,6 @@ netif_loop_output(struct netif *netif, struct pbuf *p,
#endif /* LWIP_HAVE_LOOPIF */ #endif /* LWIP_HAVE_LOOPIF */
#endif /* LWIP_SNMP */ #endif /* LWIP_SNMP */
SYS_ARCH_DECL_PROTECT(lev); SYS_ARCH_DECL_PROTECT(lev);
LWIP_UNUSED_ARG(ipaddr);
/* Allocate a new pbuf */ /* Allocate a new pbuf */
r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
@ -741,6 +762,23 @@ netif_loop_output(struct netif *netif, struct pbuf *p,
return ERR_OK; return ERR_OK;
} }
static err_t
netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr)
{
LWIP_UNUSED_ARG(addr);
return netif_loop_output(netif, p);
}
#if LWIP_IPV6
static err_t
netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr)
{
LWIP_UNUSED_ARG(addr);
return netif_loop_output(netif, p);
}
#endif
/** /**
* Call netif_poll() in the main loop of your application. This is to prevent * Call netif_poll() in the main loop of your application. This is to prevent
* reentering non-reentrant functions like tcp_input(). Packets passed to * reentering non-reentrant functions like tcp_input(). Packets passed to
@ -804,7 +842,7 @@ netif_poll(struct netif *netif)
snmp_add_ifinoctets(stats_if, in->tot_len); snmp_add_ifinoctets(stats_if, in->tot_len);
snmp_inc_ifinucastpkts(stats_if); snmp_inc_ifinucastpkts(stats_if);
/* loopback packets are always IP packets! */ /* loopback packets are always IP packets! */
if (ip_input(in, netif) != ERR_OK) { if (ipX_input(in, netif) != ERR_OK) {
pbuf_free(in); pbuf_free(in);
} }
/* Don't reference the packet any more! */ /* Don't reference the packet any more! */

View File

@ -86,7 +86,7 @@ stats_display_proto(struct stats_proto *proto, const char *name)
LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
} }
#if IGMP_STATS #if IGMP_STATS || MLD6_STATS
void void
stats_display_igmp(struct stats_igmp *igmp, const char *name) stats_display_igmp(struct stats_igmp *igmp, const char *name)
{ {
@ -106,7 +106,7 @@ stats_display_igmp(struct stats_igmp *igmp, const char *name)
LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave));
LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report));
} }
#endif /* IGMP_STATS */ #endif /* IGMP_STATS || MLD6_STATS */
#if MEM_STATS || MEMP_STATS #if MEM_STATS || MEMP_STATS
void void

View File

@ -1261,11 +1261,16 @@ tcp_rexmit_rto(struct tcp_pcb *pcb)
for (seg = pcb->unacked; seg->next != NULL; seg = seg->next); for (seg = pcb->unacked; seg->next != NULL; seg = seg->next);
/* concatenate unsent queue after unacked queue */ /* concatenate unsent queue after unacked queue */
seg->next = pcb->unsent; seg->next = pcb->unsent;
#if TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK
/* if last unsent changed, we need to update unsent_oversize */
if (pcb->unsent == NULL) {
pcb->unsent_oversize = seg->oversize_left;
}
#endif /* TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK*/
/* unsent queue is the concatenated queue (of unacked, unsent) */ /* unsent queue is the concatenated queue (of unacked, unsent) */
pcb->unsent = pcb->unacked; pcb->unsent = pcb->unacked;
/* unacked queue is now empty */ /* unacked queue is now empty */
pcb->unacked = NULL; pcb->unacked = NULL;
/* last unsent hasn't changed, no need to reset unsent_oversize */
/* increment number of retransmissions */ /* increment number of retransmissions */
++pcb->nrtx; ++pcb->nrtx;

View File

@ -94,6 +94,9 @@ struct autoip
/** Set a struct autoip allocated by the application to work with */ /** Set a struct autoip allocated by the application to work with */
void autoip_set_struct(struct netif *netif, struct autoip *autoip); 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 */ /** Start AutoIP client */
err_t autoip_start(struct netif *netif); err_t autoip_start(struct netif *netif);

View File

@ -94,6 +94,15 @@ struct in_addr {
#define IN_LOOPBACKNET IP_LOOPBACKNET #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
#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) #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)) #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! */ /* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */

View File

@ -210,7 +210,7 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL)) #define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
#define ip_addr_debug_print(debug, ipaddr) \ #define ip_addr_debug_print(debug, ipaddr) \
LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \ LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, \
ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \ ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \
ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \ ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \
ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \ ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \
@ -228,6 +228,9 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) #define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(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 */ /** For backwards compatibility */
#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) #define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr)

View File

@ -1,290 +1,289 @@
/** /**
* @file * @file
* *
* IPv6 addresses. * IPv6 addresses.
*/ */
/* /*
* Copyright (c) 2010 Inico Technologies Ltd. * Copyright (c) 2010 Inico Technologies Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * 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 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Ivan Delamer <delamer@inicotech.com> * Author: Ivan Delamer <delamer@inicotech.com>
* *
* Structs and macros for handling IPv6 addresses. * Structs and macros for handling IPv6 addresses.
* *
* Please coordinate changes and requests with Ivan Delamer * Please coordinate changes and requests with Ivan Delamer
* <delamer@inicotech.com> * <delamer@inicotech.com>
*/ */
#ifndef __LWIP_IP6_ADDR_H__ #ifndef __LWIP_IP6_ADDR_H__
#define __LWIP_IP6_ADDR_H__ #define __LWIP_IP6_ADDR_H__
#include "lwip/opt.h" #include "lwip/opt.h"
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* This is the aligned version of ip6_addr_t, /* This is the aligned version of ip6_addr_t,
used as local variable, on the stack, etc. */ used as local variable, on the stack, etc. */
struct ip6_addr { struct ip6_addr {
u32_t addr[4]; u32_t addr[4];
}; };
/* This is the packed version of ip6_addr_t, /* This is the packed version of ip6_addr_t,
used in network headers that are itself packed */ used in network headers that are itself packed */
#ifdef PACK_STRUCT_USE_INCLUDES #ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h" # include "arch/bpstruct.h"
#endif #endif
PACK_STRUCT_BEGIN PACK_STRUCT_BEGIN
struct ip6_addr_packed { struct ip6_addr_packed {
PACK_STRUCT_FIELD(u32_t addr[4]); PACK_STRUCT_FIELD(u32_t addr[4]);
} PACK_STRUCT_STRUCT; } PACK_STRUCT_STRUCT;
PACK_STRUCT_END PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES #ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h" # include "arch/epstruct.h"
#endif #endif
/** ip6_addr_t uses a struct for convenience only, so that the same defines can /** ip6_addr_t uses a struct for convenience only, so that the same defines can
* operate both on ip6_addr_t as well as on ip6_addr_p_t. */ * operate both on ip6_addr_t as well as on ip6_addr_p_t. */
typedef struct ip6_addr ip6_addr_t; typedef struct ip6_addr ip6_addr_t;
typedef struct ip6_addr_packed ip6_addr_p_t; typedef struct ip6_addr_packed ip6_addr_p_t;
/** IP6_ADDR_ANY can be used as a fixed IPv6 address /** IP6_ADDR_ANY can be used as a fixed IPv6 address
* for the wildcard * for the wildcard
*/ */
extern const ip6_addr_t ip6_addr_any; extern const ip6_addr_t ip6_addr_any;
#define IP6_ADDR_ANY ((ip6_addr_t *)&ip6_addr_any) #define IP6_ADDR_ANY ((ip6_addr_t *)&ip6_addr_any)
#if BYTE_ORDER == BIG_ENDIAN
/** Set an IPv6 partial address given by byte-parts. */
#if BYTE_ORDER == BIG_ENDIAN #define IP6_ADDR(ip6addr, index, a,b,c,d) \
/** Set an IPv6 partial address given by byte-parts. */ (ip6addr)->addr[index] = ((u32_t)((a) & 0xff) << 24) | \
#define IP6_ADDR(ip6addr, index, a,b,c,d) \ ((u32_t)((b) & 0xff) << 16) | \
(ip6addr)->addr[index] = ((u32_t)((a) & 0xff) << 24) | \ ((u32_t)((c) & 0xff) << 8) | \
((u32_t)((b) & 0xff) << 16) | \ (u32_t)((d) & 0xff)
((u32_t)((c) & 0xff) << 8) | \ #else
(u32_t)((d) & 0xff) /** Set an IPv6 partial address given by byte-parts.
#else Little-endian version, stored in network order (no htonl). */
/** Set an IPv6 partial address given by byte-parts. #define IP6_ADDR(ip6addr, index, a,b,c,d) \
Little-endian version, stored in network order (no htonl). */ (ip6addr)->addr[index] = ((u32_t)((d) & 0xff) << 24) | \
#define IP6_ADDR(ip6addr, index, a,b,c,d) \ ((u32_t)((c) & 0xff) << 16) | \
(ip6addr)->addr[index] = ((u32_t)((d) & 0xff) << 24) | \ ((u32_t)((b) & 0xff) << 8) | \
((u32_t)((c) & 0xff) << 16) | \ (u32_t)((a) & 0xff)
((u32_t)((b) & 0xff) << 8) | \ #endif
(u32_t)((a) & 0xff)
#endif /** Access address in 16-bit block */
#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0]) >> 16) & 0xffff)
/** Access address in 16-bit block */ #define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0])) & 0xffff)
#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0]) >> 16) & 0xffff) #define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1]) >> 16) & 0xffff)
#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0])) & 0xffff) #define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1])) & 0xffff)
#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1]) >> 16) & 0xffff) #define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2]) >> 16) & 0xffff)
#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1])) & 0xffff) #define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2])) & 0xffff)
#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2]) >> 16) & 0xffff) #define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)(htonl((ip6addr)->addr[3]) >> 16) & 0xffff)
#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2])) & 0xffff) #define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)(htonl((ip6addr)->addr[3])) & 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]; \
/** Copy IPv6 address - faster than ip6_addr_set: no NULL check */ (dest).addr[1] = (src).addr[1]; \
#define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \ (dest).addr[2] = (src).addr[2]; \
(dest).addr[1] = (src).addr[1]; \ (dest).addr[3] = (src).addr[3];}while(0)
(dest).addr[2] = (src).addr[2]; \ /** Safely copy one IPv6 address to another (src may be NULL) */
(dest).addr[3] = (src).addr[3];}while(0) #define ip6_addr_set(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \
/** Safely copy one IPv6 address to another (src may be NULL) */ (dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \
#define ip6_addr_set(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \ (dest)->addr[2] = (src) == NULL ? 0 : (src)->addr[2]; \
(dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \ (dest)->addr[3] = (src) == NULL ? 0 : (src)->addr[3];}while(0)
(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; \
/** Set complete address to zero */ (ip6addr)->addr[1] = 0; \
#define ip6_addr_set_zero(ip6addr) do{(ip6addr)->addr[0] = 0; \ (ip6addr)->addr[2] = 0; \
(ip6addr)->addr[1] = 0; \ (ip6addr)->addr[3] = 0;}while(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 'any' (no need for htonl()) */ /** Set address to ipv6 loopback address */
#define ip6_addr_set_any(ip6addr) ip6_addr_set_zero(ip6addr) #define ip6_addr_set_loopback(ip6addr) do{(ip6addr)->addr[0] = 0; \
/** Set address to ipv6 loopback address */ (ip6addr)->addr[1] = 0; \
#define ip6_addr_set_loopback(ip6addr) do{(ip6addr)->addr[0] = 0; \ (ip6addr)->addr[2] = 0; \
(ip6addr)->addr[1] = 0; \ (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0)
(ip6addr)->addr[2] = 0; \ /** Safely copy one IPv6 address to another and change byte order
(ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) * from host- to network-order. */
/** Safely copy one IPv6 address to another and change byte order #define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : htonl((src)->addr[0]); \
* from host- to network-order. */ (dest)->addr[1] = (src) == NULL ? 0 : htonl((src)->addr[1]); \
#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : htonl((src)->addr[0]); \ (dest)->addr[2] = (src) == NULL ? 0 : htonl((src)->addr[2]); \
(dest)->addr[1] = (src) == NULL ? 0 : htonl((src)->addr[1]); \ (dest)->addr[3] = (src) == NULL ? 0 : htonl((src)->addr[3]);}while(0)
(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
* Determine if two IPv6 address are on the same network. * @arg addr2 IPv6 address 2
* * @return !0 if the network identifiers of both address match
* @arg addr1 IPv6 address 1 */
* @arg addr2 IPv6 address 2 #define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
* @return !0 if the network identifiers of both address match ((addr1)->addr[1] == (addr2)->addr[1]))
*/
#define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ #define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
((addr1)->addr[1] == (addr2)->addr[1])) ((addr1)->addr[1] == (addr2)->addr[1]) && \
((addr1)->addr[2] == (addr2)->addr[2]) && \
#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ ((addr1)->addr[3] == (addr2)->addr[3]))
((addr1)->addr[1] == (addr2)->addr[1]) && \
((addr1)->addr[2] == (addr2)->addr[2]) && \ #define ip6_get_subnet_id(ip6addr) (htonl((ip6addr)->addr[2]) & 0x0000ffffUL)
((addr1)->addr[3] == (addr2)->addr[3]))
#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || \
#define ip6_get_subnet_id(ip6addr) (htonl((ip6addr)->addr[2]) & 0x0000ffffUL) (((ip6addr)->addr[0] == 0) && \
((ip6addr)->addr[1] == 0) && \
#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || \ ((ip6addr)->addr[2] == 0) && \
(((ip6addr)->addr[0] == 0) && \ ((ip6addr)->addr[3] == 0)))
((ip6addr)->addr[1] == 0) && \
((ip6addr)->addr[2] == 0) && \
((ip6addr)->addr[3] == 0)))
#define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \ #define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \
((ip6addr)->addr[1] == 0UL) && \ ((ip6addr)->addr[1] == 0UL) && \
((ip6addr)->addr[2] == 0UL) && \ ((ip6addr)->addr[2] == 0UL) && \
((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
#define ip6_addr_isglobal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xe0000000UL)) == PP_HTONL(0x20000000UL)) #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_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_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_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_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_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_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_rendezvous_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00400000UL))
#define ip6_addr_multicast_scope(ip6addr) ((htonl((ip6addr)->addr[0]) >> 16) & 0xf) #define ip6_addr_multicast_scope(ip6addr) ((htonl((ip6addr)->addr[0]) >> 16) & 0xf)
#define IP6_MULTICAST_SCOPE_RESERVED 0x0 #define IP6_MULTICAST_SCOPE_RESERVED 0x0
#define IP6_MULTICAST_SCOPE_RESERVED0 0x0 #define IP6_MULTICAST_SCOPE_RESERVED0 0x0
#define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1 #define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1
#define IP6_MULTICAST_SCOPE_LINK_LOCAL 0x2 #define IP6_MULTICAST_SCOPE_LINK_LOCAL 0x2
#define IP6_MULTICAST_SCOPE_RESERVED3 0x3 #define IP6_MULTICAST_SCOPE_RESERVED3 0x3
#define IP6_MULTICAST_SCOPE_ADMIN_LOCAL 0x4 #define IP6_MULTICAST_SCOPE_ADMIN_LOCAL 0x4
#define IP6_MULTICAST_SCOPE_SITE_LOCAL 0x5 #define IP6_MULTICAST_SCOPE_SITE_LOCAL 0x5
#define IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL 0x8 #define IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL 0x8
#define IP6_MULTICAST_SCOPE_GLOBAL 0xe #define IP6_MULTICAST_SCOPE_GLOBAL 0xe
#define IP6_MULTICAST_SCOPE_RESERVEDF 0xf #define IP6_MULTICAST_SCOPE_RESERVEDF 0xf
#define ip6_addr_ismulticast_iflocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff010000UL)) #define ip6_addr_ismulticast_iflocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff010000UL))
#define ip6_addr_ismulticast_linklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff020000UL)) #define ip6_addr_ismulticast_linklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff020000UL))
#define ip6_addr_ismulticast_adminlocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff040000UL)) #define ip6_addr_ismulticast_adminlocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff040000UL))
#define ip6_addr_ismulticast_sitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff050000UL)) #define ip6_addr_ismulticast_sitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff050000UL))
#define ip6_addr_ismulticast_orglocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff080000UL)) #define ip6_addr_ismulticast_orglocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff080000UL))
#define ip6_addr_ismulticast_global(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff0e0000UL)) #define ip6_addr_ismulticast_global(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff0e0000UL))
/* TODO define get/set for well-know multicast addresses, e.g. ff02::1 */ /* TODO define get/set for well-know multicast addresses, e.g. ff02::1 */
#define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \ #define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \
((ip6addr)->addr[1] == 0UL) && \ ((ip6addr)->addr[1] == 0UL) && \
((ip6addr)->addr[2] == 0UL) && \ ((ip6addr)->addr[2] == 0UL) && \
((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
#define ip6_addr_isallnodes_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ #define ip6_addr_isallnodes_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
((ip6addr)->addr[1] == 0UL) && \ ((ip6addr)->addr[1] == 0UL) && \
((ip6addr)->addr[2] == 0UL) && \ ((ip6addr)->addr[2] == 0UL) && \
((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
#define ip6_addr_set_allnodes_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ #define ip6_addr_set_allnodes_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
(ip6addr)->addr[1] = 0; \ (ip6addr)->addr[1] = 0; \
(ip6addr)->addr[2] = 0; \ (ip6addr)->addr[2] = 0; \
(ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0)
#define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ #define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
((ip6addr)->addr[1] == 0UL) && \ ((ip6addr)->addr[1] == 0UL) && \
((ip6addr)->addr[2] == 0UL) && \ ((ip6addr)->addr[2] == 0UL) && \
((ip6addr)->addr[3] == PP_HTONL(0x00000002UL))) ((ip6addr)->addr[3] == PP_HTONL(0x00000002UL)))
#define ip6_addr_set_allrouters_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ #define ip6_addr_set_allrouters_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
(ip6addr)->addr[1] = 0; \ (ip6addr)->addr[1] = 0; \
(ip6addr)->addr[2] = 0; \ (ip6addr)->addr[2] = 0; \
(ip6addr)->addr[3] = PP_HTONL(0x00000002UL);}while(0) (ip6addr)->addr[3] = PP_HTONL(0x00000002UL);}while(0)
#define ip6_addr_issolicitednode(ip6addr) ( ((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ #define ip6_addr_issolicitednode(ip6addr) ( ((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
(((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) ) (((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) )
#define ip6_addr_set_solicitednode(ip6addr, if_id) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ #define ip6_addr_set_solicitednode(ip6addr, if_id) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
(ip6addr)->addr[1] = 0; \ (ip6addr)->addr[1] = 0; \
(ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \ (ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \
(ip6addr)->addr[3] = htonl(0xff000000UL | (htonl(if_id) & 0x00ffffffUL));}while(0) (ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id));}while(0)
#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ #define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
((ip6addr)->addr[1] == 0) && \ ((ip6addr)->addr[1] == 0) && \
((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
((ip6addr)->addr[3] == htonl(0xff000000UL | (htonl((sn_addr)->addr[3]) & 0x00ffffffUL)))) ((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3])))
/* IPv6 address states. */ /* IPv6 address states. */
#define IP6_ADDR_INVALID 0x00 #define IP6_ADDR_INVALID 0x00
#define IP6_ADDR_TENTATIVE 0x08 #define IP6_ADDR_TENTATIVE 0x08
#define IP6_ADDR_TENTATIVE_1 0x09 /* 1 probe sent */ #define IP6_ADDR_TENTATIVE_1 0x09 /* 1 probe sent */
#define IP6_ADDR_TENTATIVE_2 0x0a /* 2 probes sent */ #define IP6_ADDR_TENTATIVE_2 0x0a /* 2 probes sent */
#define IP6_ADDR_TENTATIVE_3 0x0b /* 3 probes sent */ #define IP6_ADDR_TENTATIVE_3 0x0b /* 3 probes sent */
#define IP6_ADDR_TENTATIVE_4 0x0c /* 4 probes sent */ #define IP6_ADDR_TENTATIVE_4 0x0c /* 4 probes sent */
#define IP6_ADDR_TENTATIVE_5 0x0d /* 5 probes sent */ #define IP6_ADDR_TENTATIVE_5 0x0d /* 5 probes sent */
#define IP6_ADDR_TENTATIVE_6 0x0e /* 6 probes sent */ #define IP6_ADDR_TENTATIVE_6 0x0e /* 6 probes sent */
#define IP6_ADDR_TENTATIVE_7 0x0f /* 7 probes sent */ #define IP6_ADDR_TENTATIVE_7 0x0f /* 7 probes sent */
#define IP6_ADDR_VALID 0x10 #define IP6_ADDR_VALID 0x10
#define IP6_ADDR_PREFERRED 0x30 #define IP6_ADDR_PREFERRED 0x30
#define IP6_ADDR_DEPRECATED 0x50 #define IP6_ADDR_DEPRECATED 0x50
#define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID) #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_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_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_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED)
#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED) #define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED)
#define ip6_addr_debug_print(debug, ipaddr) \ #define ip6_addr_debug_print(debug, ipaddr) \
LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \ LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
ipaddr != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0, \ ipaddr != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0)) ipaddr != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0))
int ip6addr_aton(const char *cp, ip6_addr_t *addr); #define IP6ADDR_STRLEN_MAX 46
/** returns ptr to static buffer; not reentrant! */
char *ip6addr_ntoa(const ip6_addr_t *addr); int ip6addr_aton(const char *cp, ip6_addr_t *addr);
char *ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen); /** 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 #ifdef __cplusplus
}
#endif /* LWIP_IPV6 */ #endif
#endif /* __LWIP_IP6_ADDR_H__ */ #endif /* LWIP_IPV6 */
#endif /* __LWIP_IP6_ADDR_H__ */

View File

@ -12,7 +12,7 @@
#ifndef LWIP_MALLOC_MEMPOOL #ifndef LWIP_MALLOC_MEMPOOL
/* This treats "malloc pools" just like any other pool. /* This treats "malloc pools" just like any other pool.
The pools are a little bigger to provide 'size' as the amount of user data. */ 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 + sizeof(struct memp_malloc_helper)), "MALLOC_"#size) #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_START
#define LWIP_MALLOC_MEMPOOL_END #define LWIP_MALLOC_MEMPOOL_END
#endif /* LWIP_MALLOC_MEMPOOL */ #endif /* LWIP_MALLOC_MEMPOOL */

View File

@ -359,7 +359,7 @@ void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_
#endif /* LWIP_IGMP */ #endif /* LWIP_IGMP */
#if ENABLE_LOOPBACK #if ENABLE_LOOPBACK
err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip); err_t netif_loop_output(struct netif *netif, struct pbuf *p);
void netif_poll(struct netif *netif); void netif_poll(struct netif *netif);
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING #if !LWIP_NETIF_LOOPBACK_MULTITHREADING
void netif_poll_all(void); void netif_poll_all(void);

View File

@ -96,6 +96,9 @@ err_t netifapi_netif_common ( struct netif *netif,
#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, 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_start(n) netifapi_netif_common(n, NULL, dhcp_start)
#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) #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_start(n) netifapi_netif_common(n, NULL, autoip_start)
#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)

View File

@ -2012,6 +2012,13 @@
#define CHECKSUM_GEN_ICMP 1 #define CHECKSUM_GEN_ICMP 1
#endif #endif
/**
* CHECKSUM_GEN_ICMP6==1: Generate checksums in software for outgoing ICMP6 packets.
*/
#ifndef CHECKSUM_GEN_ICMP6
#define CHECKSUM_GEN_ICMP6 1
#endif
/** /**
* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.
*/ */
@ -2033,6 +2040,20 @@
#define CHECKSUM_CHECK_TCP 1 #define CHECKSUM_CHECK_TCP 1
#endif #endif
/**
* CHECKSUM_CHECK_ICMP==1: Check checksums in software for incoming ICMP packets.
*/
#ifndef CHECKSUM_CHECK_ICMP
#define CHECKSUM_CHECK_ICMP 1
#endif
/**
* CHECKSUM_CHECK_ICMP6==1: Check checksums in software for incoming ICMPv6 packets
*/
#ifndef CHECKSUM_CHECK_ICMP6
#define CHECKSUM_CHECK_ICMP6 1
#endif
/** /**
* LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from * LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from
* application buffers to pbufs. * application buffers to pbufs.
@ -2089,13 +2110,6 @@
#define LWIP_ICMP6_HL 255 #define LWIP_ICMP6_HL 255
#endif #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. * LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol.
*/ */