Implement multicast engine hooks in the uIPv6 core

- init()
  - process incoming multicast datagram
  - Pass ICMPv6 trickle messages to the engine
This commit is contained in:
George Oikonomou 2011-11-11 12:08:29 +00:00 committed by George Oikonomou
parent 151533b9bc
commit 226701b098
2 changed files with 46 additions and 0 deletions

View file

@ -42,6 +42,7 @@
extern uint16_t uip_slen;
#include "net/ip/uip-udp-packet.h"
#include "net/ipv6/multicast/uip-mcast6.h"
#include <string.h>
@ -57,6 +58,14 @@ uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len)
len > UIP_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN?
UIP_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN: len);
uip_process(UIP_UDP_SEND_CONN);
#if UIP_CONF_IPV6_MULTICAST
/* Let the multicast engine process the datagram before we send it */
if(uip_is_addr_mcast_routable(&uip_udp_conn->ripaddr)) {
UIP_MCAST6.out();
}
#endif /* UIP_IPV6_MULTICAST */
#if UIP_CONF_IPV6
tcpip_ipv6_output();
#else

View file

@ -75,6 +75,7 @@
#include "net/ipv6/uip-icmp6.h"
#include "net/ipv6/uip-nd6.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ipv6/multicast/uip-mcast6.h"
#include <string.h>
@ -429,6 +430,10 @@ uip_init(void)
uip_udp_conns[c].lport = 0;
}
#endif /* UIP_UDP */
#if UIP_CONF_IPV6_MULTICAST
UIP_MCAST6.init();
#endif
}
/*---------------------------------------------------------------------------*/
#if UIP_TCP && UIP_ACTIVE_OPEN
@ -1151,6 +1156,28 @@ uip_process(uint8_t flag)
}
}
/*
* Process Packets with a routable multicast destination:
* - We invoke the multicast engine and let it do its thing
* (cache, forward etc).
* - We never execute the datagram forwarding logic in this file here. When
* the engine returns, forwarding has been handled if and as required.
* - Depending on the return value, we either discard or deliver up the stack
*
* All multicast engines must hook in here. After this function returns, we
* expect UIP_BUF to be unmodified
*/
#if UIP_CONF_IPV6_MULTICAST
if(uip_is_addr_mcast_routable(&UIP_IP_BUF->destipaddr)) {
if(UIP_MCAST6.in() == UIP_MCAST6_ACCEPT) {
/* Deliver up the stack */
goto process;
} else {
/* Don't deliver up the stack */
goto drop;
}
}
#endif /* UIP_IPV6_CONF_MULTICAST */
/* TBD Some Parameter problem messages */
if(!uip_ds6_is_my_addr(&UIP_IP_BUF->destipaddr) &&
@ -1220,6 +1247,10 @@ uip_process(uint8_t flag)
uip_ext_bitmap = 0;
#endif /* UIP_CONF_ROUTER */
#if UIP_CONF_IPV6_MULTICAST
process:
#endif
while(1) {
switch(*uip_next_hdr){
#if UIP_TCP
@ -1437,6 +1468,12 @@ uip_process(uint8_t flag)
UIP_STAT(++uip_stat.icmp.recv);
uip_len = 0;
break;
#if UIP_CONF_IPV6_ROLL_TM
case ICMP6_ROLL_TM:
roll_tm_icmp_input();
uip_len = 0;
break;
#endif
default:
PRINTF("Unknown icmp6 message type %d\n", UIP_ICMP_BUF->type);
UIP_STAT(++uip_stat.icmp.drop);