Rework ext_hdr_options_process
This commit is contained in:
parent
6c11da58d8
commit
6c583efa37
|
@ -95,8 +95,6 @@
|
||||||
* Direct access to extension header options, with explicit ext header and option offset
|
* Direct access to extension header options, with explicit ext header and option offset
|
||||||
*/
|
*/
|
||||||
#define UIP_EXT_HDR_OPT_BUF(ext, opt) ((struct uip_ext_hdr_opt *)(UIP_IP_PAYLOAD(ext) + (opt)))
|
#define UIP_EXT_HDR_OPT_BUF(ext, opt) ((struct uip_ext_hdr_opt *)(UIP_IP_PAYLOAD(ext) + (opt)))
|
||||||
#define UIP_EXT_HDR_OPT_PADN_BUF(ext, opt) ((struct uip_ext_hdr_opt_padn *)(UIP_IP_PAYLOAD(ext) + (opt)))
|
|
||||||
#define UIP_EXT_HDR_OPT_RPL_BUF(ext, opt) ((struct uip_ext_hdr_opt_rpl *)(UIP_IP_PAYLOAD(ext) + (opt)))
|
|
||||||
|
|
||||||
#include "net/ipv6/uipopt.h"
|
#include "net/ipv6/uipopt.h"
|
||||||
#include "net/ipv6/uipbuf.h"
|
#include "net/ipv6/uipbuf.h"
|
||||||
|
|
|
@ -816,7 +816,7 @@ uip_add_rcv_nxt(uint16_t n)
|
||||||
* \brief Process the options in Destination and Hop By Hop extension headers
|
* \brief Process the options in Destination and Hop By Hop extension headers
|
||||||
*/
|
*/
|
||||||
static uint8_t
|
static uint8_t
|
||||||
ext_hdr_options_process(int ext_offset)
|
ext_hdr_options_process(uint8_t *ext_buf)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Length field in the extension header: length of the header in units of
|
* Length field in the extension header: length of the header in units of
|
||||||
|
@ -824,8 +824,10 @@ ext_hdr_options_process(int ext_offset)
|
||||||
* length field in an option : the length of data in the option
|
* length field in an option : the length of data in the option
|
||||||
*/
|
*/
|
||||||
uint8_t opt_offset = 2;
|
uint8_t opt_offset = 2;
|
||||||
while(opt_offset < ((UIP_EXT_BUF(ext_offset)->len << 3) + 8)) {
|
struct uip_hbho_hdr *ext_hdr = (struct uip_hbho_hdr *)ext_buf;
|
||||||
switch(UIP_EXT_HDR_OPT_BUF(ext_offset, opt_offset)->type) {
|
while(opt_offset < ((ext_hdr->len << 3) + 8)) {
|
||||||
|
struct uip_ext_hdr_opt *opt_hdr = (struct uip_ext_hdr_opt *)(ext_buf + opt_offset);
|
||||||
|
switch(opt_hdr->type) {
|
||||||
/*
|
/*
|
||||||
* for now we do not support any options except padding ones
|
* for now we do not support any options except padding ones
|
||||||
* PAD1 does not make sense as the header must be 8bytes aligned,
|
* PAD1 does not make sense as the header must be 8bytes aligned,
|
||||||
|
@ -837,7 +839,7 @@ ext_hdr_options_process(int ext_offset)
|
||||||
break;
|
break;
|
||||||
case UIP_EXT_HDR_OPT_PADN:
|
case UIP_EXT_HDR_OPT_PADN:
|
||||||
LOG_DBG("Processing PADN option\n");
|
LOG_DBG("Processing PADN option\n");
|
||||||
opt_offset += UIP_EXT_HDR_OPT_PADN_BUF(ext_offset, opt_offset)->opt_len + 2;
|
opt_offset += ((struct uip_ext_hdr_opt_padn *)opt_hdr)->opt_len + 2;
|
||||||
break;
|
break;
|
||||||
case UIP_EXT_HDR_OPT_RPL:
|
case UIP_EXT_HDR_OPT_RPL:
|
||||||
/* Fixes situation when a node that is not using RPL
|
/* Fixes situation when a node that is not using RPL
|
||||||
|
@ -849,11 +851,11 @@ ext_hdr_options_process(int ext_offset)
|
||||||
* present) is processed.
|
* present) is processed.
|
||||||
*/
|
*/
|
||||||
LOG_DBG("Processing RPL option\n");
|
LOG_DBG("Processing RPL option\n");
|
||||||
if(!NETSTACK_ROUTING.ext_header_hbh_update(UIP_IP_PAYLOAD(ext_offset), opt_offset)) {
|
if(!NETSTACK_ROUTING.ext_header_hbh_update(ext_buf, opt_offset)) {
|
||||||
LOG_ERR("RPL Option Error: Dropping Packet\n");
|
LOG_ERR("RPL Option Error: Dropping Packet\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
opt_offset += (UIP_EXT_HDR_OPT_BUF(ext_offset, opt_offset)->len) + 2;
|
opt_offset += opt_hdr->len + 2;
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
/*
|
/*
|
||||||
|
@ -869,8 +871,8 @@ ext_hdr_options_process(int ext_offset)
|
||||||
* Problem, Code 2, message to the packet's Source Address,
|
* Problem, Code 2, message to the packet's Source Address,
|
||||||
* pointing to the unrecognized Option Type.
|
* pointing to the unrecognized Option Type.
|
||||||
*/
|
*/
|
||||||
LOG_DBG("Unrecognized option, MSB 0x%x\n", UIP_EXT_HDR_OPT_BUF(ext_offset, opt_offset)->type);
|
LOG_DBG("Unrecognized option, MSB 0x%x\n", opt_hdr->type);
|
||||||
switch(UIP_EXT_HDR_OPT_BUF(ext_offset, opt_offset)->type & 0xC0) {
|
switch(opt_hdr->type & 0xC0) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 0x40:
|
case 0x40:
|
||||||
|
@ -881,11 +883,11 @@ ext_hdr_options_process(int ext_offset)
|
||||||
}
|
}
|
||||||
case 0x80:
|
case 0x80:
|
||||||
uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION,
|
uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION,
|
||||||
(uint32_t)UIP_IPH_LEN + ext_offset + opt_offset);
|
(ext_buf + opt_offset) - uip_buf);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* in the cases were we did not discard, update ext_opt* */
|
/* in the cases were we did not discard, update ext_opt* */
|
||||||
opt_offset += UIP_EXT_HDR_OPT_BUF(ext_offset, opt_offset)->len + 2;
|
opt_offset += opt_hdr->len + 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1161,7 +1163,7 @@ uip_process(uint8_t flag)
|
||||||
|
|
||||||
next_header = uipbuf_get_next_header(uip_buf, uip_len, &protocol, true);
|
next_header = uipbuf_get_next_header(uip_buf, uip_len, &protocol, true);
|
||||||
if(next_header != NULL && protocol == UIP_PROTO_HBHO) {
|
if(next_header != NULL && protocol == UIP_PROTO_HBHO) {
|
||||||
switch(ext_hdr_options_process(next_header - UIP_IP_PAYLOAD(0))) {
|
switch(ext_hdr_options_process(next_header)) {
|
||||||
case 0:
|
case 0:
|
||||||
break; /* done */
|
break; /* done */
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1263,7 +1265,7 @@ uip_process(uint8_t flag)
|
||||||
uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_HBHO;
|
uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_HBHO;
|
||||||
}
|
}
|
||||||
#endif /*UIP_CONF_IPV6_CHECKS*/
|
#endif /*UIP_CONF_IPV6_CHECKS*/
|
||||||
switch(ext_hdr_options_process(next_header - UIP_IP_PAYLOAD(0))) {
|
switch(ext_hdr_options_process(next_header)) {
|
||||||
case 0:
|
case 0:
|
||||||
break; /* done */
|
break; /* done */
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1287,7 +1289,7 @@ uip_process(uint8_t flag)
|
||||||
uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_DESTO1;
|
uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_DESTO1;
|
||||||
}
|
}
|
||||||
#endif /*UIP_CONF_IPV6_CHECKS*/
|
#endif /*UIP_CONF_IPV6_CHECKS*/
|
||||||
switch(ext_hdr_options_process(next_header - UIP_IP_PAYLOAD(0))) {
|
switch(ext_hdr_options_process(next_header)) {
|
||||||
case 0:
|
case 0:
|
||||||
break; /* done */
|
break; /* done */
|
||||||
case 1:
|
case 1:
|
||||||
|
|
Loading…
Reference in New Issue