Skip to content

Commit

Permalink
Merge pull request contiki-os#1493 from simonduq/pr/add-missing-ext-hdr
Browse files Browse the repository at this point in the history
Insert RPL ext header before sending ICMP, UDP and TCP messages
  • Loading branch information
simonduq authored Jul 25, 2016
2 parents ff5a475 + 7a15768 commit 21387b9
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 191 deletions.
15 changes: 9 additions & 6 deletions core/net/ip/tcpip.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,15 @@ tcpip_ipv6_output(void)
return;
}

#if UIP_CONF_IPV6_RPL
if(!rpl_update_header()) {
/* Packet can not be forwarded */
PRINTF("tcpip_ipv6_output: RPL header update error\n");
uip_clear_buf();
return;
}
#endif /* UIP_CONF_IPV6_RPL */

if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
/* Next hop determination */

Expand Down Expand Up @@ -651,12 +660,6 @@ tcpip_ipv6_output(void)

/* End of next hop determination */

#if UIP_CONF_IPV6_RPL
if(!rpl_finalize_header(nexthop)) {
uip_clear_buf();
return;
}
#endif /* UIP_CONF_IPV6_RPL */
nbr = uip_ds6_nbr_lookup(nexthop);
if(nbr == NULL) {
#if UIP_ND6_SEND_NA
Expand Down
12 changes: 0 additions & 12 deletions core/net/ipv6/uip-icmp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ echo_request_input(void)
uip_ext_len = 0;
}

/* Insert RPL extension headers */
#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */

/* Below is important for the correctness of UIP_ICMP_BUF and the
* checksum
*/
Expand Down Expand Up @@ -260,10 +255,6 @@ uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param) {
UIP_ICMP_BUF->icmpchksum = 0;
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();

#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */

UIP_STAT(++uip_stat.icmp.sent);

PRINTF("Sending ICMPv6 ERROR message type %d code %d to ", type, code);
Expand Down Expand Up @@ -301,9 +292,6 @@ uip_icmp6_send(const uip_ipaddr_t *dest, int type, int code, int payload_len)
UIP_STAT(++uip_stat.icmp.sent);
UIP_STAT(++uip_stat.ip.sent);

#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */
tcpip_ipv6_output();
}
/*---------------------------------------------------------------------------*/
Expand Down
14 changes: 1 addition & 13 deletions core/net/ipv6/uip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ ext_hdr_options_process(void)
*/
#if UIP_CONF_IPV6_RPL
PRINTF("Processing RPL option\n");
if(rpl_verify_hbh_header(uip_ext_opt_offset)) {
if(!rpl_verify_hbh_header(uip_ext_opt_offset)) {
PRINTF("RPL Option Error: Dropping Packet\n");
return 1;
}
Expand Down Expand Up @@ -1228,14 +1228,6 @@ uip_process(uint8_t flag)
goto send;
}

#if UIP_CONF_IPV6_RPL
if(!rpl_update_header()) {
/* Packet can not be forwarded */
PRINTF("RPL header update error\n");
goto drop;
}
#endif /* UIP_CONF_IPV6_RPL */

UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1;
PRINTF("Forwarding packet to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
Expand Down Expand Up @@ -1582,10 +1574,6 @@ uip_process(uint8_t flag)
}
#endif /* UIP_UDP_CHECKSUMS */

#if UIP_CONF_IPV6_RPL
rpl_insert_header();
#endif /* UIP_CONF_IPV6_RPL */

UIP_STAT(++uip_stat.udp.sent);
goto ip_send_nolen;
#endif /* UIP_UDP */
Expand Down
Loading

0 comments on commit 21387b9

Please sign in to comment.