mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-09 09:03:49 +08:00
task #12722 (improve IPv4/v6 address handling): renamed ip_addr_t to ip4_addr_t, renamed ipX_addr_t to ip_addr_t and added IP version;
ip_addr_t is used for all generic IP addresses for the API, ip(4/6)_addr_t are only used internally or when initializing netifs or when calling version-related functions
This commit is contained in:
@@ -64,10 +64,10 @@
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
|
||||
#if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/udp.h"
|
||||
//#include "lwip/udp.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/autoip.h"
|
||||
@@ -108,7 +108,7 @@
|
||||
static void autoip_handle_arp_conflict(struct netif *netif);
|
||||
|
||||
/* creates a pseudo random LL IP-Address for a network interface */
|
||||
static void autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr);
|
||||
static void autoip_create_addr(struct netif *netif, ip4_addr_t *ipaddr);
|
||||
|
||||
/* sends an ARP probe */
|
||||
static err_t autoip_arp_probe(struct netif *netif);
|
||||
@@ -193,7 +193,7 @@ autoip_handle_arp_conflict(struct netif *netif)
|
||||
* @param ipaddr ip address to initialize
|
||||
*/
|
||||
static void
|
||||
autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr)
|
||||
autoip_create_addr(struct netif *netif, ip4_addr_t *ipaddr)
|
||||
{
|
||||
/* Here we create an IP-Address out of range 169.254.1.0 to 169.254.254.255
|
||||
* compliant to RFC 3927 Section 2.1
|
||||
@@ -229,7 +229,7 @@ static err_t
|
||||
autoip_arp_probe(struct netif *netif)
|
||||
{
|
||||
return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast,
|
||||
(struct eth_addr *)netif->hwaddr, IP_ADDR_ANY, ðzero,
|
||||
(struct eth_addr *)netif->hwaddr, IP4_ADDR_ANY, ðzero,
|
||||
&netif->autoip->llipaddr, ARP_REQUEST);
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ static err_t
|
||||
autoip_bind(struct netif *netif)
|
||||
{
|
||||
struct autoip *autoip = netif->autoip;
|
||||
ip_addr_t sn_mask, gw_addr;
|
||||
ip4_addr_t sn_mask, gw_addr;
|
||||
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
|
||||
("autoip_bind(netif=%p) %c%c%"U16_F" %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
@@ -288,7 +288,7 @@ autoip_start(struct netif *netif)
|
||||
/* Set IP-Address, Netmask and Gateway to 0 to make sure that
|
||||
* ARP Packets are formed correctly
|
||||
*/
|
||||
netif_set_addr(netif, IP_ADDR_ANY, IP_ADDR_ANY, IP_ADDR_ANY);
|
||||
netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY);
|
||||
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
|
||||
("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0],
|
||||
@@ -311,7 +311,7 @@ autoip_start(struct netif *netif)
|
||||
autoip->state = AUTOIP_STATE_OFF;
|
||||
autoip->ttw = 0;
|
||||
autoip->sent_num = 0;
|
||||
ip_addr_set_zero(&autoip->llipaddr);
|
||||
ip4_addr_set_zero(&autoip->llipaddr);
|
||||
autoip->lastconflict = 0;
|
||||
}
|
||||
|
||||
@@ -373,8 +373,8 @@ autoip_stop(struct netif *netif)
|
||||
{
|
||||
if (netif->autoip) {
|
||||
netif->autoip->state = AUTOIP_STATE_OFF;
|
||||
if (ip_addr_islinklocal(&netif->ip_addr)) {
|
||||
netif_set_addr(netif, IP_ADDR_ANY, IP_ADDR_ANY, IP_ADDR_ANY);
|
||||
if (ip4_addr_islinklocal(&netif->ip_addr)) {
|
||||
netif_set_addr(netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY);
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
@@ -479,11 +479,11 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
|
||||
* when probing ip.dst == llipaddr && hw.src != netif->hwaddr
|
||||
* we have a conflict and must solve it
|
||||
*/
|
||||
ip_addr_t sipaddr, dipaddr;
|
||||
ip4_addr_t sipaddr, dipaddr;
|
||||
struct eth_addr netifaddr;
|
||||
ETHADDR16_COPY(netifaddr.addr, netif->hwaddr);
|
||||
|
||||
/* Copy struct ip_addr2 to aligned ip_addr, to support compilers without
|
||||
/* Copy struct ip4_addr2 to aligned ip4_addr, to support compilers without
|
||||
* structure packing (not using structure copy which breaks strict-aliasing rules).
|
||||
*/
|
||||
IPADDR2_COPY(&sipaddr, &hdr->sipaddr);
|
||||
@@ -498,8 +498,8 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
|
||||
* ip.src == llipaddr OR
|
||||
* ip.dst == llipaddr && hw.src != own hwaddr
|
||||
*/
|
||||
if ((ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr)) ||
|
||||
(ip_addr_cmp(&dipaddr, &netif->autoip->llipaddr) &&
|
||||
if ((ip4_addr_cmp(&sipaddr, &netif->autoip->llipaddr)) ||
|
||||
(ip4_addr_cmp(&dipaddr, &netif->autoip->llipaddr) &&
|
||||
!eth_addr_cmp(&netifaddr, &hdr->shwaddr))) {
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING,
|
||||
("autoip_arp_reply(): Probe Conflict detected\n"));
|
||||
@@ -510,7 +510,7 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
|
||||
* in any state we have a conflict if
|
||||
* ip.src == llipaddr && hw.src != own hwaddr
|
||||
*/
|
||||
if (ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr) &&
|
||||
if (ip4_addr_cmp(&sipaddr, &netif->autoip->llipaddr) &&
|
||||
!eth_addr_cmp(&netifaddr, &hdr->shwaddr)) {
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING,
|
||||
("autoip_arp_reply(): Conflicting ARP-Packet detected\n"));
|
||||
@@ -520,4 +520,4 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LWIP_AUTOIP */
|
||||
#endif /* LWIP_IPV4 && LWIP_AUTOIP */
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
|
||||
#if LWIP_IPV4 && LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/icmp.h"
|
||||
#include "lwip/inet_chksum.h"
|
||||
@@ -87,7 +87,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
ICMP_STATS_INC(icmp.recv);
|
||||
snmp_inc_icmpinmsgs();
|
||||
|
||||
iphdr = (struct ip_hdr *)ip_current_header();
|
||||
iphdr = (struct ip_hdr *)ip4_current_header();
|
||||
hlen = IPH_HL(iphdr) * 4;
|
||||
if (p->len < sizeof(u16_t)*2) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len));
|
||||
@@ -185,8 +185,8 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
/* We generate an answer by switching the dest and src ip addresses,
|
||||
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
|
||||
iecho = (struct icmp_echo_hdr *)p->payload;
|
||||
ip_addr_copy(iphdr->src, inp->ip_addr);
|
||||
ip_addr_copy(iphdr->dest, *ip_current_src_addr());
|
||||
ip4_addr_copy(iphdr->src, inp->ip_addr);
|
||||
ip4_addr_copy(iphdr->dest, *ip4_current_src_addr());
|
||||
ICMPH_TYPE_SET(iecho, ICMP_ER);
|
||||
#if CHECKSUM_GEN_ICMP
|
||||
/* adjust the checksum */
|
||||
@@ -217,7 +217,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
} else {
|
||||
err_t ret;
|
||||
/* send an ICMP packet, src addr is the dest addr of the current packet */
|
||||
ret = ip_output_if(p, ip_current_dest_addr(), IP_HDRINCL,
|
||||
ret = ip4_output_if(p, ip4_current_dest_addr(), IP_HDRINCL,
|
||||
ICMP_TTL, 0, IP_PROTO_ICMP, inp);
|
||||
if (ret != ERR_OK) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret));
|
||||
@@ -292,7 +292,7 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
||||
struct ip_hdr *iphdr;
|
||||
/* we can use the echo header here */
|
||||
struct icmp_echo_hdr *icmphdr;
|
||||
ip_addr_t iphdr_src;
|
||||
ip4_addr_t iphdr_src;
|
||||
|
||||
/* ICMP header + IP header + 8 bytes of data */
|
||||
q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE,
|
||||
@@ -306,9 +306,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
||||
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src));
|
||||
ip4_addr_debug_print(ICMP_DEBUG, &(iphdr->src));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, (" to "));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest));
|
||||
ip4_addr_debug_print(ICMP_DEBUG, &(iphdr->dest));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("\n"));
|
||||
|
||||
icmphdr = (struct icmp_echo_hdr *)q->payload;
|
||||
@@ -331,9 +331,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
||||
snmp_inc_icmpoutmsgs();
|
||||
/* increase number of destination unreachable messages attempted to send */
|
||||
snmp_inc_icmpouttimeexcds();
|
||||
ip_addr_copy(iphdr_src, iphdr->src);
|
||||
ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);
|
||||
ip4_addr_copy(iphdr_src, iphdr->src);
|
||||
ip4_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
#endif /* LWIP_ICMP */
|
||||
#endif /* LWIP_IPV4 && LWIP_ICMP */
|
||||
|
||||
@@ -79,7 +79,7 @@ Steve Reynolds
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
|
||||
#if LWIP_IPV4 && LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/debug.h"
|
||||
@@ -124,10 +124,10 @@ Steve Reynolds
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct igmp_msg {
|
||||
PACK_STRUCT_FLD_8(u8_t igmp_msgtype);
|
||||
PACK_STRUCT_FLD_8(u8_t igmp_maxresp);
|
||||
PACK_STRUCT_FIELD(u16_t igmp_checksum);
|
||||
PACK_STRUCT_FLD_S(ip_addr_p_t igmp_group_address);
|
||||
PACK_STRUCT_FLD_8(u8_t igmp_msgtype);
|
||||
PACK_STRUCT_FLD_8(u8_t igmp_maxresp);
|
||||
PACK_STRUCT_FIELD(u16_t igmp_checksum);
|
||||
PACK_STRUCT_FLD_S(ip4_addr_p_t igmp_group_address);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
@@ -135,18 +135,18 @@ PACK_STRUCT_END
|
||||
#endif
|
||||
|
||||
|
||||
static struct igmp_group *igmp_lookup_group(struct netif *ifp, const ip_addr_t *addr);
|
||||
static struct igmp_group *igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr);
|
||||
static err_t igmp_remove_group(struct igmp_group *group);
|
||||
static void igmp_timeout( struct igmp_group *group);
|
||||
static void igmp_start_timer(struct igmp_group *group, u8_t max_time);
|
||||
static void igmp_delaying_member(struct igmp_group *group, u8_t maxresp);
|
||||
static err_t igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, struct netif *netif);
|
||||
static err_t igmp_ip_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, struct netif *netif);
|
||||
static void igmp_send(struct igmp_group *group, u8_t type);
|
||||
|
||||
|
||||
static struct igmp_group* igmp_group_list;
|
||||
static ip_addr_t allsystems;
|
||||
static ip_addr_t allrouters;
|
||||
static ip4_addr_t allsystems;
|
||||
static ip4_addr_t allrouters;
|
||||
|
||||
|
||||
/**
|
||||
@@ -172,7 +172,7 @@ igmp_dump_group_list()
|
||||
|
||||
while (group != NULL) {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_dump_group_list: [%"U32_F"] ", (u32_t)(group->group_state)));
|
||||
ip_addr_debug_print(IGMP_DEBUG, &group->group_address);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, &group->group_address);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif));
|
||||
group = group->next;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ igmp_start(struct netif *netif)
|
||||
/* Allow the igmp messages at the MAC level */
|
||||
if (netif->igmp_mac_filter != NULL) {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, &allsystems);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, &allsystems);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
|
||||
netif->igmp_mac_filter(netif, &allsystems, IGMP_ADD_MAC_FILTER);
|
||||
}
|
||||
@@ -242,7 +242,7 @@ igmp_stop(struct netif *netif)
|
||||
/* disable the group at the MAC level */
|
||||
if (netif->igmp_mac_filter != NULL) {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, &group->group_address);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, &group->group_address);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
|
||||
netif->igmp_mac_filter(netif, &(group->group_address), IGMP_DEL_MAC_FILTER);
|
||||
}
|
||||
@@ -271,7 +271,7 @@ igmp_report_groups(struct netif *netif)
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", netif));
|
||||
|
||||
while (group != NULL) {
|
||||
if ((group->netif == netif) && (!(ip_addr_cmp(&(group->group_address), &allsystems)))) {
|
||||
if ((group->netif == netif) && (!(ip4_addr_cmp(&(group->group_address), &allsystems)))) {
|
||||
igmp_delaying_member(group, IGMP_JOIN_DELAYING_MEMBER_TMR);
|
||||
}
|
||||
group = group->next;
|
||||
@@ -287,12 +287,12 @@ igmp_report_groups(struct netif *netif)
|
||||
* NULL if the group wasn't found.
|
||||
*/
|
||||
struct igmp_group *
|
||||
igmp_lookfor_group(struct netif *ifp, const ip_addr_t *addr)
|
||||
igmp_lookfor_group(struct netif *ifp, const ip4_addr_t *addr)
|
||||
{
|
||||
struct igmp_group *group = igmp_group_list;
|
||||
|
||||
while (group != NULL) {
|
||||
if ((group->netif == ifp) && (ip_addr_cmp(&(group->group_address), addr))) {
|
||||
if ((group->netif == ifp) && (ip4_addr_cmp(&(group->group_address), addr))) {
|
||||
return group;
|
||||
}
|
||||
group = group->next;
|
||||
@@ -313,7 +313,7 @@ igmp_lookfor_group(struct netif *ifp, const ip_addr_t *addr)
|
||||
* NULL on memory error.
|
||||
*/
|
||||
struct igmp_group *
|
||||
igmp_lookup_group(struct netif *ifp, const ip_addr_t *addr)
|
||||
igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr)
|
||||
{
|
||||
struct igmp_group *group = igmp_group_list;
|
||||
|
||||
@@ -328,7 +328,7 @@ igmp_lookup_group(struct netif *ifp, const ip_addr_t *addr)
|
||||
group = (struct igmp_group *)memp_malloc(MEMP_IGMP_GROUP);
|
||||
if (group != NULL) {
|
||||
group->netif = ifp;
|
||||
ip_addr_set(&(group->group_address), addr);
|
||||
ip4_addr_set(&(group->group_address), addr);
|
||||
group->timer = 0; /* Not running */
|
||||
group->group_state = IGMP_GROUP_NON_MEMBER;
|
||||
group->last_reporter_flag = 0;
|
||||
@@ -339,7 +339,7 @@ igmp_lookup_group(struct netif *ifp, const ip_addr_t *addr)
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: %sallocated a new group with address ", (group?"":"impossible to ")));
|
||||
ip_addr_debug_print(IGMP_DEBUG, addr);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, addr);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", ifp));
|
||||
|
||||
return group;
|
||||
@@ -386,7 +386,7 @@ igmp_remove_group(struct igmp_group *group)
|
||||
* @param dest destination ip address of the igmp packet
|
||||
*/
|
||||
void
|
||||
igmp_input(struct pbuf *p, struct netif *inp, const ip_addr_t *dest)
|
||||
igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
|
||||
{
|
||||
struct igmp_msg* igmp;
|
||||
struct igmp_group* group;
|
||||
@@ -403,9 +403,9 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip_addr_t *dest)
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: message from "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, &(ip_current_header()->src));
|
||||
ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->src));
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (" to address "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, &(ip_current_header()->dest));
|
||||
ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->dest));
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", inp));
|
||||
|
||||
/* Now calculate and check the checksum */
|
||||
@@ -432,7 +432,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip_addr_t *dest)
|
||||
switch (igmp->igmp_msgtype) {
|
||||
case IGMP_MEMB_QUERY: {
|
||||
/* IGMP_MEMB_QUERY to the "all systems" address ? */
|
||||
if ((ip_addr_cmp(dest, &allsystems)) && ip_addr_isany(&igmp->igmp_group_address)) {
|
||||
if ((ip4_addr_cmp(dest, &allsystems)) && ip4_addr_isany(&igmp->igmp_group_address)) {
|
||||
/* THIS IS THE GENERAL QUERY */
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: General IGMP_MEMB_QUERY on \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp)));
|
||||
|
||||
@@ -447,21 +447,21 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip_addr_t *dest)
|
||||
groupref = igmp_group_list;
|
||||
while (groupref) {
|
||||
/* Do not send messages on the all systems group address! */
|
||||
if ((groupref->netif == inp) && (!(ip_addr_cmp(&(groupref->group_address), &allsystems)))) {
|
||||
if ((groupref->netif == inp) && (!(ip4_addr_cmp(&(groupref->group_address), &allsystems)))) {
|
||||
igmp_delaying_member(groupref, igmp->igmp_maxresp);
|
||||
}
|
||||
groupref = groupref->next;
|
||||
}
|
||||
} else {
|
||||
/* IGMP_MEMB_QUERY to a specific group ? */
|
||||
if (!ip_addr_isany(&igmp->igmp_group_address)) {
|
||||
if (!ip4_addr_isany(&igmp->igmp_group_address)) {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_MEMB_QUERY to a specific group "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, &igmp->igmp_group_address);
|
||||
if (ip_addr_cmp(dest, &allsystems)) {
|
||||
ip_addr_t groupaddr;
|
||||
ip4_addr_debug_print(IGMP_DEBUG, &igmp->igmp_group_address);
|
||||
if (ip4_addr_cmp(dest, &allsystems)) {
|
||||
ip4_addr_t groupaddr;
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (" using \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp)));
|
||||
/* we first need to re-look for the group since we used dest last time */
|
||||
ip_addr_copy(groupaddr, igmp->igmp_group_address);
|
||||
ip4_addr_copy(groupaddr, igmp->igmp_group_address);
|
||||
group = igmp_lookfor_group(inp, &groupaddr);
|
||||
} else {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (" with the group address as destination [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp)));
|
||||
@@ -510,21 +510,21 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip_addr_t *dest)
|
||||
* @return ERR_OK if group was joined on the netif(s), an err_t otherwise
|
||||
*/
|
||||
err_t
|
||||
igmp_joingroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr)
|
||||
igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
|
||||
{
|
||||
err_t err = ERR_VAL; /* no matching interface */
|
||||
struct igmp_group *group;
|
||||
struct netif *netif;
|
||||
|
||||
/* make sure it is multicast address */
|
||||
LWIP_ERROR("igmp_joingroup: attempt to join non-multicast address", ip_addr_ismulticast(groupaddr), return ERR_VAL;);
|
||||
LWIP_ERROR("igmp_joingroup: attempt to join allsystems address", (!ip_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;);
|
||||
LWIP_ERROR("igmp_joingroup: attempt to join non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;);
|
||||
LWIP_ERROR("igmp_joingroup: attempt to join allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;);
|
||||
|
||||
/* loop through netif's */
|
||||
netif = netif_list;
|
||||
while (netif != NULL) {
|
||||
/* Should we join this interface ? */
|
||||
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip_addr_isany(ifaddr) || ip_addr_cmp(&(netif->ip_addr), ifaddr)))) {
|
||||
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_cmp(&(netif->ip_addr), ifaddr)))) {
|
||||
/* find group or create a new one if not found */
|
||||
group = igmp_lookup_group(netif, groupaddr);
|
||||
|
||||
@@ -535,13 +535,13 @@ igmp_joingroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr)
|
||||
} else {
|
||||
/* OK - it was new group */
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: join to new group: "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("\n"));
|
||||
|
||||
/* If first use of the group, allow the group at the MAC level */
|
||||
if ((group->use==0) && (netif->igmp_mac_filter != NULL)) {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: igmp_mac_filter(ADD "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
|
||||
netif->igmp_mac_filter(netif, groupaddr, IGMP_ADD_MAC_FILTER);
|
||||
}
|
||||
@@ -580,28 +580,28 @@ igmp_joingroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr)
|
||||
* @return ERR_OK if group was left on the netif(s), an err_t otherwise
|
||||
*/
|
||||
err_t
|
||||
igmp_leavegroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr)
|
||||
igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
|
||||
{
|
||||
err_t err = ERR_VAL; /* no matching interface */
|
||||
struct igmp_group *group;
|
||||
struct netif *netif;
|
||||
|
||||
/* make sure it is multicast address */
|
||||
LWIP_ERROR("igmp_leavegroup: attempt to leave non-multicast address", ip_addr_ismulticast(groupaddr), return ERR_VAL;);
|
||||
LWIP_ERROR("igmp_leavegroup: attempt to leave allsystems address", (!ip_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;);
|
||||
LWIP_ERROR("igmp_leavegroup: attempt to leave non-multicast address", ip4_addr_ismulticast(groupaddr), return ERR_VAL;);
|
||||
LWIP_ERROR("igmp_leavegroup: attempt to leave allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;);
|
||||
|
||||
/* loop through netif's */
|
||||
netif = netif_list;
|
||||
while (netif != NULL) {
|
||||
/* Should we leave this interface ? */
|
||||
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip_addr_isany(ifaddr) || ip_addr_cmp(&(netif->ip_addr), ifaddr)))) {
|
||||
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_cmp(&(netif->ip_addr), ifaddr)))) {
|
||||
/* find group */
|
||||
group = igmp_lookfor_group(netif, groupaddr);
|
||||
|
||||
if (group != NULL) {
|
||||
/* Only send a leave if the flag is set according to the state diagram */
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: Leaving group: "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("\n"));
|
||||
|
||||
/* If there is no other use of the group */
|
||||
@@ -612,19 +612,19 @@ igmp_leavegroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr)
|
||||
IGMP_STATS_INC(igmp.tx_leave);
|
||||
igmp_send(group, IGMP_LEAVE_GROUP);
|
||||
}
|
||||
|
||||
|
||||
/* Disable the group at the MAC level */
|
||||
if (netif->igmp_mac_filter != NULL) {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: igmp_mac_filter(DEL "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
|
||||
netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER);
|
||||
}
|
||||
|
||||
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: remove group: "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("\n"));
|
||||
|
||||
ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("\n"));
|
||||
|
||||
/* Free the group */
|
||||
igmp_remove_group(group);
|
||||
} else {
|
||||
@@ -677,9 +677,9 @@ igmp_timeout(struct igmp_group *group)
|
||||
/* If the state is IGMP_GROUP_DELAYING_MEMBER then we send a report for this group
|
||||
(unless it is the allsystems group) */
|
||||
if ((group->group_state == IGMP_GROUP_DELAYING_MEMBER) &&
|
||||
(!(ip_addr_cmp(&(group->group_address), &allsystems)))) {
|
||||
(!(ip4_addr_cmp(&(group->group_address), &allsystems)))) {
|
||||
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address "));
|
||||
ip_addr_debug_print(IGMP_DEBUG, &(group->group_address));
|
||||
ip4_addr_debug_print(IGMP_DEBUG, &(group->group_address));
|
||||
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif));
|
||||
|
||||
IGMP_STATS_INC(igmp.tx_report);
|
||||
@@ -753,14 +753,14 @@ igmp_delaying_member(struct igmp_group *group, u8_t maxresp)
|
||||
* returns errors returned by netif->output
|
||||
*/
|
||||
static err_t
|
||||
igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, struct netif *netif)
|
||||
igmp_ip_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, struct netif *netif)
|
||||
{
|
||||
/* This is the "router alert" option */
|
||||
u16_t ra[2];
|
||||
ra[0] = PP_HTONS(ROUTER_ALERT);
|
||||
ra[1] = 0x0000; /* Router shall examine packet */
|
||||
IGMP_STATS_INC(igmp.xmit);
|
||||
return ip_output_if_opt(p, src, dest, IGMP_TTL, 0, IP_PROTO_IGMP, netif, ra, ROUTER_ALERTLEN);
|
||||
return ip4_output_if_opt(p, src, dest, IGMP_TTL, 0, IP_PROTO_IGMP, netif, ra, ROUTER_ALERTLEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -774,8 +774,8 @@ igmp_send(struct igmp_group *group, u8_t type)
|
||||
{
|
||||
struct pbuf* p = NULL;
|
||||
struct igmp_msg* igmp = NULL;
|
||||
ip_addr_t src = *IP_ADDR_ANY;
|
||||
ip_addr_t* dest = NULL;
|
||||
ip4_addr_t src = *IP4_ADDR_ANY;
|
||||
ip4_addr_t* dest = NULL;
|
||||
|
||||
/* IP header + "router alert" option + IGMP header */
|
||||
p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM);
|
||||
@@ -784,16 +784,16 @@ igmp_send(struct igmp_group *group, u8_t type)
|
||||
igmp = (struct igmp_msg *)p->payload;
|
||||
LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg",
|
||||
(p->len >= sizeof(struct igmp_msg)));
|
||||
ip_addr_copy(src, group->netif->ip_addr);
|
||||
ip4_addr_copy(src, group->netif->ip_addr);
|
||||
|
||||
if (type == IGMP_V2_MEMB_REPORT) {
|
||||
dest = &(group->group_address);
|
||||
ip_addr_copy(igmp->igmp_group_address, group->group_address);
|
||||
ip4_addr_copy(igmp->igmp_group_address, group->group_address);
|
||||
group->last_reporter_flag = 1; /* Remember we were the last to report */
|
||||
} else {
|
||||
if (type == IGMP_LEAVE_GROUP) {
|
||||
dest = &allrouters;
|
||||
ip_addr_copy(igmp->igmp_group_address, group->group_address);
|
||||
ip4_addr_copy(igmp->igmp_group_address, group->group_address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,4 +813,4 @@ igmp_send(struct igmp_group *group, u8_t type)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LWIP_IGMP */
|
||||
#endif /* LWIP_IPV4 && LWIP_IGMP */
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
@@ -73,7 +76,7 @@
|
||||
|
||||
/** Some defines for DHCP to let link-layer-addressed packets through while the
|
||||
* netif is down.
|
||||
* To use this in your own application/protocol, define LWIP_IP_ACCEPT_UDP_PORT
|
||||
* To use this in your own application/protocol, define LWIP_IP_ACCEPT_UDP_PORT(port)
|
||||
* to return 1 if the port is accepted and 0 if the port is not accepted.
|
||||
*/
|
||||
#if LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT)
|
||||
@@ -100,13 +103,13 @@ static u16_t ip_id;
|
||||
|
||||
#if LWIP_IGMP
|
||||
/** The default netif used for multicast */
|
||||
static struct netif* ip_default_multicast_netif;
|
||||
static struct netif* ip4_default_multicast_netif;
|
||||
|
||||
/** Set a default netif for IPv4 multicast. */
|
||||
void
|
||||
ip_set_default_multicast_netif(struct netif* default_multicast_netif)
|
||||
ip4_set_default_multicast_netif(struct netif* default_multicast_netif)
|
||||
{
|
||||
ip_default_multicast_netif = default_multicast_netif;
|
||||
ip4_default_multicast_netif = default_multicast_netif;
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
@@ -120,7 +123,7 @@ ip_set_default_multicast_netif(struct netif* default_multicast_netif)
|
||||
* @return the netif on which to send to reach dest
|
||||
*/
|
||||
struct netif *
|
||||
ip_route(const ip_addr_t *dest)
|
||||
ip4_route(const ip4_addr_t *dest)
|
||||
{
|
||||
struct netif *netif;
|
||||
|
||||
@@ -133,17 +136,17 @@ ip_route(const ip_addr_t *dest)
|
||||
|
||||
#if LWIP_IGMP
|
||||
/* Use administratively selected interface for multicast by default */
|
||||
if (ip_addr_ismulticast(dest) && ip_default_multicast_netif) {
|
||||
return ip_default_multicast_netif;
|
||||
if (ip4_addr_ismulticast(dest) && ip4_default_multicast_netif) {
|
||||
return ip4_default_multicast_netif;
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
/* iterate through netifs */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
/* is the netif up, does it have a link and a valid address? */
|
||||
if (netif_is_up(netif) && netif_is_link_up(netif) && !ip_addr_isany(&(netif->ip_addr))) {
|
||||
if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany(&(netif->ip_addr))) {
|
||||
/* network mask matches? */
|
||||
if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
|
||||
if (ip4_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
|
||||
/* return netif on which to forward IP packet */
|
||||
return netif;
|
||||
}
|
||||
@@ -151,7 +154,7 @@ ip_route(const ip_addr_t *dest)
|
||||
}
|
||||
|
||||
if ((netif_default == NULL) || !netif_is_up(netif_default) || !netif_is_link_up(netif_default) ||
|
||||
ip_addr_isany(&netif_default->ip_addr)) {
|
||||
ip4_addr_isany(&netif_default->ip_addr)) {
|
||||
/* No matching netif found an default netif is not usable.
|
||||
If this is not good enough for you, use LWIP_HOOK_IP4_ROUTE() */
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_route: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
@@ -163,7 +166,7 @@ ip_route(const ip_addr_t *dest)
|
||||
|
||||
#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
|
||||
/* loopif is disabled, looopback traffic is passed through any netif */
|
||||
if (ip_addr_isloopback(dest)) {
|
||||
if (ip4_addr_isloopback(dest)) {
|
||||
/* don't check for link on loopback traffic */
|
||||
if (netif_is_up(netif_default)) {
|
||||
return netif_default;
|
||||
@@ -195,9 +198,9 @@ ip_route(const ip_addr_t *dest)
|
||||
* @return 1: can forward 0: discard
|
||||
*/
|
||||
static int
|
||||
ip_canforward(struct pbuf *p)
|
||||
ip4_canforward(struct pbuf *p)
|
||||
{
|
||||
u32_t addr = htonl(ip4_addr_get_u32(ip_current_dest_addr()));
|
||||
u32_t addr = htonl(ip4_addr_get_u32(ip4_current_dest_addr()));
|
||||
|
||||
if (p->flags & PBUF_FLAG_LLBCAST) {
|
||||
/* don't route link-layer broadcasts */
|
||||
@@ -231,18 +234,18 @@ ip_canforward(struct pbuf *p)
|
||||
* @param inp the netif on which this packet was received
|
||||
*/
|
||||
static void
|
||||
ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
{
|
||||
struct netif *netif;
|
||||
|
||||
PERF_START;
|
||||
|
||||
if (!ip_canforward(p)) {
|
||||
if (!ip4_canforward(p)) {
|
||||
goto return_noroute;
|
||||
}
|
||||
|
||||
/* RFC3927 2.7: do not forward link-local addresses */
|
||||
if (ip_addr_islinklocal(ip_current_dest_addr())) {
|
||||
if (ip4_addr_islinklocal(ip4_current_dest_addr())) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not forwarding LLA %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()),
|
||||
ip4_addr3_16(ip_current_dest_addr()), ip4_addr4_16(ip_current_dest_addr())));
|
||||
@@ -250,7 +253,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
}
|
||||
|
||||
/* Find network interface where to forward this IP packet to. */
|
||||
netif = ip_route(ip_current_dest_addr());
|
||||
netif = ip4_route(ip4_current_dest_addr());
|
||||
if (netif == NULL) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for %"U16_F".%"U16_F".%"U16_F".%"U16_F" found\n",
|
||||
ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()),
|
||||
@@ -301,7 +304,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
if (netif->mtu && (p->tot_len > netif->mtu)) {
|
||||
if ((IPH_OFFSET(iphdr) & PP_NTOHS(IP_DF)) == 0) {
|
||||
#if IP_FRAG
|
||||
ip_frag(p, netif, ip_current_dest_addr());
|
||||
ip4_frag(p, netif, ip4_current_dest_addr());
|
||||
#else /* IP_FRAG */
|
||||
/* @todo: send ICMP Destination Unreachable code 13 "Communication administratively prohibited"? */
|
||||
#endif /* IP_FRAG */
|
||||
@@ -312,13 +315,30 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
return;
|
||||
}
|
||||
/* transmit pbuf on chosen interface */
|
||||
netif->output(netif, p, ip_current_dest_addr());
|
||||
netif->output(netif, p, ip4_current_dest_addr());
|
||||
return;
|
||||
return_noroute:
|
||||
snmp_inc_ipoutnoroutes();
|
||||
}
|
||||
#endif /* IP_FORWARD */
|
||||
|
||||
#if LWIP_IPV6
|
||||
/* If both IP versions are enabled, this function can dispatch packets to the correct one.
|
||||
* May be used as netif input function.
|
||||
*/
|
||||
err_t
|
||||
ip_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
if (p != NULL) {
|
||||
if (IP_HDR_GET_VERSION(p->payload) == 6) {
|
||||
return ip6_input(p, inp);
|
||||
}
|
||||
return ip4_input(p, inp);
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function is called by the network interface device driver when
|
||||
* an IP packet is received. The function does the basic checks of the
|
||||
@@ -334,7 +354,7 @@ return_noroute:
|
||||
* processed, but currently always returns ERR_OK)
|
||||
*/
|
||||
err_t
|
||||
ip_input(struct pbuf *p, struct netif *inp)
|
||||
ip4_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
struct ip_hdr *iphdr;
|
||||
struct netif *netif;
|
||||
@@ -351,7 +371,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
if (IPH_V(iphdr) != 4) {
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IP packet dropped due to bad version number %"U16_F"\n", IPH_V(iphdr)));
|
||||
ip_debug_print(p);
|
||||
ip4_debug_print(p);
|
||||
pbuf_free(p);
|
||||
IP_STATS_INC(ip.err);
|
||||
IP_STATS_INC(ip.drop);
|
||||
@@ -404,7 +424,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("Checksum (0x%"X16_F") failed, IP packet dropped.\n", inet_chksum(iphdr, iphdr_hlen)));
|
||||
ip_debug_print(p);
|
||||
ip4_debug_print(p);
|
||||
pbuf_free(p);
|
||||
IP_STATS_INC(ip.chkerr);
|
||||
IP_STATS_INC(ip.drop);
|
||||
@@ -414,17 +434,17 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
#endif
|
||||
|
||||
/* copy IP addresses to aligned ip_addr_t */
|
||||
ip_addr_copy(*ipX_2_ip(&ip_data.current_iphdr_dest), iphdr->dest);
|
||||
ip_addr_copy(*ipX_2_ip(&ip_data.current_iphdr_src), iphdr->src);
|
||||
ip_addr_copy_from_ip4(ip_data.current_iphdr_dest, iphdr->dest);
|
||||
ip_addr_copy_from_ip4(ip_data.current_iphdr_src, iphdr->src);
|
||||
|
||||
/* match packet against an interface, i.e. is this packet for us? */
|
||||
#if LWIP_IGMP
|
||||
if (ip_addr_ismulticast(ip_current_dest_addr())) {
|
||||
if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, ip_current_dest_addr()))) {
|
||||
if (ip4_addr_ismulticast(ip4_current_dest_addr())) {
|
||||
if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, ip4_current_dest_addr()))) {
|
||||
/* IGMP snooping switches need 0.0.0.0 to be allowed as source address (RFC 4541) */
|
||||
ip_addr_t allsystems;
|
||||
ip4_addr_t allsystems;
|
||||
IP4_ADDR(&allsystems, 224, 0, 0, 1);
|
||||
if (ip_addr_cmp(ip_current_dest_addr(), &allsystems) &&
|
||||
if (ip4_addr_cmp(ip4_current_dest_addr(), &allsystems) &&
|
||||
ip_addr_isany(ip_current_src_addr())) {
|
||||
check_ip_src = 0;
|
||||
}
|
||||
@@ -448,13 +468,13 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
ip4_addr_get_u32(&iphdr->dest) & ~ip4_addr_get_u32(&netif->netmask)));
|
||||
|
||||
/* interface is up and configured? */
|
||||
if ((netif_is_up(netif)) && (!ip_addr_isany(&(netif->ip_addr)))) {
|
||||
if ((netif_is_up(netif)) && (!ip4_addr_isany(&(netif->ip_addr)))) {
|
||||
/* unicast to this interface address? */
|
||||
if (ip_addr_cmp(ip_current_dest_addr(), &(netif->ip_addr)) ||
|
||||
if (ip4_addr_cmp(ip4_current_dest_addr(), &(netif->ip_addr)) ||
|
||||
/* or broadcast on this interface network address? */
|
||||
ip_addr_isbroadcast(ip_current_dest_addr(), netif)
|
||||
#if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF
|
||||
|| (ip4_addr_get_u32(ip_current_dest_addr()) == PP_HTONL(IPADDR_LOOPBACK))
|
||||
|| (ip4_addr_get_u32(ip4_current_dest_addr()) == PP_HTONL(IPADDR_LOOPBACK))
|
||||
#endif /* LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF */
|
||||
) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
|
||||
@@ -466,7 +486,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
/* connections to link-local addresses must persist after changing
|
||||
the netif's address (RFC3927 ch. 1.9) */
|
||||
if ((netif->autoip != NULL) &&
|
||||
ip_addr_cmp(ip_current_dest_addr(), &(netif->autoip->llipaddr))) {
|
||||
ip4_addr_cmp(ip4_current_dest_addr(), &(netif->autoip->llipaddr))) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: LLA packet accepted on interface %c%c\n",
|
||||
netif->name[0], netif->name[1]));
|
||||
/* break out of for loop */
|
||||
@@ -541,7 +561,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
/* non-broadcast packet? */
|
||||
if (!ip_addr_isbroadcast(ip_current_dest_addr(), inp)) {
|
||||
/* try to forward IP packet on (other) interfaces */
|
||||
ip_forward(p, iphdr, inp);
|
||||
ip4_forward(p, iphdr, inp);
|
||||
} else
|
||||
#endif /* IP_FORWARD */
|
||||
{
|
||||
@@ -557,7 +577,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip_reass()\n",
|
||||
ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8));
|
||||
/* reassemble the packet*/
|
||||
p = ip_reass(p);
|
||||
p = ip4_reass(p);
|
||||
/* packet not fully reassembled yet? */
|
||||
if (p == NULL) {
|
||||
return ERR_OK;
|
||||
@@ -595,7 +615,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
/* send to upper layers */
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n"));
|
||||
ip_debug_print(p);
|
||||
ip4_debug_print(p);
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len));
|
||||
|
||||
ip_data.current_netif = netif;
|
||||
@@ -634,7 +654,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
#endif /* LWIP_ICMP */
|
||||
#if LWIP_IGMP
|
||||
case IP_PROTO_IGMP:
|
||||
igmp_input(p, inp, ip_current_dest_addr());
|
||||
igmp_input(p, inp, ip4_current_dest_addr());
|
||||
break;
|
||||
#endif /* LWIP_IGMP */
|
||||
default:
|
||||
@@ -662,8 +682,8 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
ip_data.current_input_netif = NULL;
|
||||
ip_data.current_ip4_header = NULL;
|
||||
ip_data.current_ip_header_tot_len = 0;
|
||||
ip_addr_set_any(ip_current_src_addr());
|
||||
ip_addr_set_any(ip_current_dest_addr());
|
||||
ip4_addr_set_any(ip4_current_src_addr());
|
||||
ip4_addr_set_any(ip4_current_dest_addr());
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -694,12 +714,12 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
* unique identifiers independent of destination"
|
||||
*/
|
||||
err_t
|
||||
ip_output_if(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
ip4_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos,
|
||||
u8_t proto, struct netif *netif)
|
||||
{
|
||||
#if IP_OPTIONS_SEND
|
||||
return ip_output_if_opt(p, src, dest, ttl, tos, proto, netif, NULL, 0);
|
||||
return ip4_output_if_opt(p, src, dest, ttl, tos, proto, netif, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -708,23 +728,23 @@ ip_output_if(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
* @ param ip_options pointer to the IP options, copied into the IP header
|
||||
* @ param optlen length of ip_options
|
||||
*/
|
||||
err_t ip_output_if_opt(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
err_t ip4_output_if_opt(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
|
||||
u16_t optlen)
|
||||
{
|
||||
#endif /* IP_OPTIONS_SEND */
|
||||
const ip_addr_t *src_used = src;
|
||||
const ip4_addr_t *src_used = src;
|
||||
if (dest != IP_HDRINCL) {
|
||||
if (ip_addr_isany(src)) {
|
||||
if (ip4_addr_isany(src)) {
|
||||
src_used = &netif->ip_addr;
|
||||
}
|
||||
}
|
||||
|
||||
#if IP_OPTIONS_SEND
|
||||
return ip_output_if_opt_src(p, src_used, dest, ttl, tos, proto, netif,
|
||||
return ip4_output_if_opt_src(p, src_used, dest, ttl, tos, proto, netif,
|
||||
ip_options, optlen);
|
||||
#else /* IP_OPTIONS_SEND */
|
||||
return ip_output_if_src(p, src_used, dest, ttl, tos, proto, netif);
|
||||
return ip4_output_if_src(p, src_used, dest, ttl, tos, proto, netif);
|
||||
#endif /* IP_OPTIONS_SEND */
|
||||
}
|
||||
|
||||
@@ -733,25 +753,25 @@ err_t ip_output_if_opt(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *de
|
||||
* when it is 'any'.
|
||||
*/
|
||||
err_t
|
||||
ip_output_if_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
ip4_output_if_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos,
|
||||
u8_t proto, struct netif *netif)
|
||||
{
|
||||
#if IP_OPTIONS_SEND
|
||||
return ip_output_if_opt_src(p, src, dest, ttl, tos, proto, netif, NULL, 0);
|
||||
return ip4_output_if_opt_src(p, src, dest, ttl, tos, proto, netif, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as ip_output_if_opt() but 'src' address is not replaced by netif address
|
||||
* when it is 'any'.
|
||||
*/
|
||||
err_t ip_output_if_opt_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
|
||||
u16_t optlen)
|
||||
{
|
||||
#endif /* IP_OPTIONS_SEND */
|
||||
struct ip_hdr *iphdr;
|
||||
ip_addr_t dest_addr;
|
||||
ip4_addr_t dest_addr;
|
||||
#if CHECKSUM_GEN_IP_INLINE
|
||||
u32_t chk_sum = 0;
|
||||
#endif /* CHECKSUM_GEN_IP_INLINE */
|
||||
@@ -811,7 +831,7 @@ err_t ip_output_if_opt_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t
|
||||
#endif /* CHECKSUM_GEN_IP_INLINE */
|
||||
|
||||
/* dest cannot be NULL here */
|
||||
ip_addr_copy(iphdr->dest, *dest);
|
||||
ip4_addr_copy(iphdr->dest, *dest);
|
||||
#if CHECKSUM_GEN_IP_INLINE
|
||||
chk_sum += ip4_addr_get_u32(&iphdr->dest) & 0xFFFF;
|
||||
chk_sum += ip4_addr_get_u32(&iphdr->dest) >> 16;
|
||||
@@ -834,10 +854,10 @@ err_t ip_output_if_opt_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t
|
||||
++ip_id;
|
||||
|
||||
if (src == NULL) {
|
||||
ip_addr_copy(iphdr->src, ip_addr_any);
|
||||
ip4_addr_copy(iphdr->src, *IP4_ADDR_ANY);
|
||||
} else {
|
||||
/* src cannot be NULL here */
|
||||
ip_addr_copy(iphdr->src, *src);
|
||||
ip4_addr_copy(iphdr->src, *src);
|
||||
}
|
||||
|
||||
#if CHECKSUM_GEN_IP_INLINE
|
||||
@@ -856,19 +876,19 @@ err_t ip_output_if_opt_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t
|
||||
} else {
|
||||
/* IP header already included in p */
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
ip_addr_copy(dest_addr, iphdr->dest);
|
||||
ip4_addr_copy(dest_addr, iphdr->dest);
|
||||
dest = &dest_addr;
|
||||
}
|
||||
|
||||
IP_STATS_INC(ip.xmit);
|
||||
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], netif->num));
|
||||
ip_debug_print(p);
|
||||
ip4_debug_print(p);
|
||||
|
||||
#if ENABLE_LOOPBACK
|
||||
if (ip_addr_cmp(dest, &netif->ip_addr)
|
||||
if (ip4_addr_cmp(dest, &netif->ip_addr)
|
||||
#if !LWIP_HAVE_LOOPIF
|
||||
|| ip_addr_isloopback(dest)
|
||||
|| ip4_addr_isloopback(dest)
|
||||
#endif /* !LWIP_HAVE_LOOPIF */
|
||||
) {
|
||||
/* Packet to self, enqueue it for loopback */
|
||||
@@ -884,7 +904,7 @@ err_t ip_output_if_opt_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t
|
||||
#if IP_FRAG
|
||||
/* don't fragment if interface has mtu set to 0 [loopif] */
|
||||
if (netif->mtu && (p->tot_len > netif->mtu)) {
|
||||
return ip_frag(p, netif, dest);
|
||||
return ip4_frag(p, netif, dest);
|
||||
}
|
||||
#endif /* IP_FRAG */
|
||||
|
||||
@@ -910,21 +930,21 @@ err_t ip_output_if_opt_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t
|
||||
* see ip_output_if() for more return values
|
||||
*/
|
||||
err_t
|
||||
ip_output(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto)
|
||||
{
|
||||
struct netif *netif;
|
||||
|
||||
LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p);
|
||||
|
||||
if ((netif = ip_route(dest)) == NULL) {
|
||||
if ((netif = ip4_route(dest)) == NULL) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest)));
|
||||
IP_STATS_INC(ip.rterr);
|
||||
return ERR_RTE;
|
||||
}
|
||||
|
||||
return ip_output_if(p, src, dest, ttl, tos, proto, netif);
|
||||
return ip4_output_if(p, src, dest, ttl, tos, proto, netif);
|
||||
}
|
||||
|
||||
#if LWIP_NETIF_HWADDRHINT
|
||||
@@ -947,7 +967,7 @@ ip_output(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
* see ip_output_if() for more return values
|
||||
*/
|
||||
err_t
|
||||
ip_output_hinted(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
ip4_output_hinted(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint)
|
||||
{
|
||||
struct netif *netif;
|
||||
@@ -955,7 +975,7 @@ ip_output_hinted(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
|
||||
LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p);
|
||||
|
||||
if ((netif = ip_route(dest)) == NULL) {
|
||||
if ((netif = ip4_route(dest)) == NULL) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
|
||||
ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest)));
|
||||
IP_STATS_INC(ip.rterr);
|
||||
@@ -963,7 +983,7 @@ ip_output_hinted(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
}
|
||||
|
||||
NETIF_SET_HWADDRHINT(netif, addr_hint);
|
||||
err = ip_output_if(p, src, dest, ttl, tos, proto, netif);
|
||||
err = ip4_output_if(p, src, dest, ttl, tos, proto, netif);
|
||||
NETIF_SET_HWADDRHINT(netif, NULL);
|
||||
|
||||
return err;
|
||||
@@ -975,7 +995,7 @@ ip_output_hinted(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
|
||||
* @param p an IP packet, p->payload pointing to the IP header
|
||||
*/
|
||||
void
|
||||
ip_debug_print(struct pbuf *p)
|
||||
ip4_debug_print(struct pbuf *p)
|
||||
{
|
||||
struct ip_hdr *iphdr = (struct ip_hdr *)p->payload;
|
||||
|
||||
@@ -1013,3 +1033,5 @@ ip_debug_print(struct pbuf *p)
|
||||
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||
}
|
||||
#endif /* IP_DEBUG */
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
@@ -37,12 +37,31 @@
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */
|
||||
const ip_addr_t ip_addr_any = { IPADDR_ANY };
|
||||
const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST };
|
||||
const ip_addr_t ip_addr_any = {
|
||||
#if LWIP_IPV6
|
||||
{
|
||||
#endif
|
||||
IPADDR_ANY
|
||||
#if LWIP_IPV6
|
||||
}, IPADDR_TYPE_V4
|
||||
#endif
|
||||
};
|
||||
const ip_addr_t ip_addr_broadcast = {
|
||||
#if LWIP_IPV6
|
||||
{
|
||||
#endif
|
||||
IPADDR_BROADCAST
|
||||
#if LWIP_IPV6
|
||||
}, IPADDR_TYPE_V4
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine if an address is a broadcast address on a network interface
|
||||
@@ -52,9 +71,9 @@ const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST };
|
||||
* @return returns non-zero if the address is a broadcast address
|
||||
*/
|
||||
u8_t
|
||||
ip4_addr_isbroadcast(u32_t addr, const struct netif *netif)
|
||||
ip4_addr_isbroadcast_u32(u32_t addr, const struct netif *netif)
|
||||
{
|
||||
ip_addr_t ipaddr;
|
||||
ip4_addr_t ipaddr;
|
||||
ip4_addr_set_u32(&ipaddr, addr);
|
||||
|
||||
/* all ones (broadcast) or all zeroes (old skool broadcast) */
|
||||
@@ -70,7 +89,7 @@ ip4_addr_isbroadcast(u32_t addr, const struct netif *netif)
|
||||
} else if (addr == ip4_addr_get_u32(&netif->ip_addr)) {
|
||||
return 0;
|
||||
/* on the same (sub) network... */
|
||||
} else if (ip_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask))
|
||||
} else if (ip4_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask))
|
||||
/* ...and host identifier bits are all ones? =>... */
|
||||
&& ((addr & ~ip4_addr_get_u32(&netif->netmask)) ==
|
||||
(IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) {
|
||||
@@ -129,9 +148,9 @@ ip4_addr_netmask_valid(u32_t netmask)
|
||||
u32_t
|
||||
ipaddr_addr(const char *cp)
|
||||
{
|
||||
ip_addr_t val;
|
||||
ip4_addr_t val;
|
||||
|
||||
if (ipaddr_aton(cp, &val)) {
|
||||
if (ip4addr_aton(cp, &val)) {
|
||||
return ip4_addr_get_u32(&val);
|
||||
}
|
||||
return (IPADDR_NONE);
|
||||
@@ -149,7 +168,7 @@ ipaddr_addr(const char *cp)
|
||||
* @return 1 if cp could be converted to addr, 0 on failure
|
||||
*/
|
||||
int
|
||||
ipaddr_aton(const char *cp, ip_addr_t *addr)
|
||||
ip4addr_aton(const char *cp, ip4_addr_t *addr)
|
||||
{
|
||||
u32_t val;
|
||||
u8_t base;
|
||||
@@ -257,11 +276,11 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
|
||||
* @return pointer to a global static (!) buffer that holds the ASCII
|
||||
* representation of addr
|
||||
*/
|
||||
char *
|
||||
ipaddr_ntoa(const ip_addr_t *addr)
|
||||
char*
|
||||
ip4addr_ntoa(const ip4_addr_t *addr)
|
||||
{
|
||||
static char str[16];
|
||||
return ipaddr_ntoa_r(addr, str, 16);
|
||||
static char str[IP4ADDR_STRLEN_MAX];
|
||||
return ip4addr_ntoa_r(addr, str, IP4ADDR_STRLEN_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +292,8 @@ ipaddr_ntoa(const ip_addr_t *addr)
|
||||
* @return either pointer to buf which now holds the ASCII
|
||||
* representation of addr or NULL if buf was too small
|
||||
*/
|
||||
char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen)
|
||||
char*
|
||||
ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen)
|
||||
{
|
||||
u32_t s_addr;
|
||||
char inv[3];
|
||||
@@ -310,3 +330,21 @@ char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen)
|
||||
*--rp = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** Convert IPv4 address to generic IP address.
|
||||
* Since source types do not contain the type field, a target storage need to be supplied.
|
||||
*/
|
||||
ip_addr_t*
|
||||
ip4_2_ip(const ip4_addr_t *ip4addr, ip_addr_t* storage)
|
||||
{
|
||||
if ((ip4addr == NULL) || (storage == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
ip4_addr_copy(storage->addr.ip4, *ip4addr);
|
||||
IP_SET_TYPE_L(storage, IPADDR_TYPE_V4);
|
||||
return storage;
|
||||
}
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_IPV4
|
||||
|
||||
#include "lwip/ip_frag.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/inet_chksum.h"
|
||||
@@ -100,8 +103,8 @@ PACK_STRUCT_END
|
||||
#endif
|
||||
|
||||
#define IP_ADDRESSES_AND_ID_MATCH(iphdrA, iphdrB) \
|
||||
(ip_addr_cmp(&(iphdrA)->src, &(iphdrB)->src) && \
|
||||
ip_addr_cmp(&(iphdrA)->dest, &(iphdrB)->dest) && \
|
||||
(ip4_addr_cmp(&(iphdrA)->src, &(iphdrB)->src) && \
|
||||
ip4_addr_cmp(&(iphdrA)->dest, &(iphdrB)->dest) && \
|
||||
IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0
|
||||
|
||||
/* global variables */
|
||||
@@ -476,7 +479,7 @@ freepbuf:
|
||||
* @return NULL if reassembly is incomplete, ? otherwise
|
||||
*/
|
||||
struct pbuf *
|
||||
ip_reass(struct pbuf *p)
|
||||
ip4_reass(struct pbuf *p)
|
||||
{
|
||||
struct pbuf *r;
|
||||
struct ip_hdr *fraghdr;
|
||||
@@ -679,8 +682,8 @@ ipfrag_free_pbuf_custom(struct pbuf *p)
|
||||
*
|
||||
* @return ERR_OK if sent successfully, err_t otherwise
|
||||
*/
|
||||
err_t
|
||||
ip_frag(struct pbuf *p, struct netif *netif, const ip_addr_t *dest)
|
||||
err_t
|
||||
ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
|
||||
{
|
||||
struct pbuf *rambuf;
|
||||
#if IP_FRAG_USES_STATIC_BUF
|
||||
@@ -879,3 +882,5 @@ ip_frag(struct pbuf *p, struct netif *netif, const ip_addr_t *dest)
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* IP_FRAG */
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
Reference in New Issue
Block a user