fix bug in get_destination

This commit is contained in:
Stefan Lankes 2011-10-20 04:51:34 -07:00
parent fcbc567c71
commit 844acb30b9

View file

@ -417,7 +417,6 @@ static uint8_t mmnif_get_destination(struct netif *netif, struct pbuf *p)
{
struct ip_hdr *iphdr;
ip_addr_p_t ip;
uint8_t core;
/* grab the destination ip address out of the ip header
* for internal routing the last ocet is interpreted as core ID.
@ -425,19 +424,7 @@ static uint8_t mmnif_get_destination(struct netif *netif, struct pbuf *p)
iphdr = (struct ip_hdr *)(p->payload);
ip = iphdr->dest;
/* check if the ip address is in the Local Area Network of the 48 cores */
/* if it's not the same network the router core is addressed
* Note: the router core is core 1
*/
if (ip_addr_netcmp(&ip, &netif->ip_addr, &netif->netmask))
return 1;
core = ip4_addr4(&ip);
/* check if the address is legitimata else return router core again */
if ((core) < 1 || (core > MMNIF_CORES))
core = 1;
return core;
return ip4_addr4(&ip);
}
/* mmnif_rxbuff_alloc():
@ -622,6 +609,12 @@ static err_t mmnif_tx(struct netif *netif, struct pbuf *p)
goto drop_packet;
}
/* check destination ip */
if (BUILTIN_EXPECT((dest_ip < 1) || (dest_ip > MMNIF_CORES), 0)) {
DEBUGPRINTF("mmnif_tx: invalid destination IP %d => drop\n", dest_ip);
goto drop_packet;
}
/* allocate memory for the packet in the remote buffer */
realloc:
write_address = mmnif_rxbuff_alloc(dest_ip, p->tot_len);