Rework rpl-ext-header.c
This commit is contained in:
parent
8456c544d8
commit
6c11da58d8
@ -849,7 +849,7 @@ ext_hdr_options_process(int ext_offset)
|
||||
* present) is processed.
|
||||
*/
|
||||
LOG_DBG("Processing RPL option\n");
|
||||
if(!NETSTACK_ROUTING.ext_header_hbh_update(ext_offset, opt_offset)) {
|
||||
if(!NETSTACK_ROUTING.ext_header_hbh_update(UIP_IP_PAYLOAD(ext_offset), opt_offset)) {
|
||||
LOG_ERR("RPL Option Error: Dropping Packet\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ ext_header_update(void)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
ext_header_hbh_update(uint8_t *ext_buf, int opt_offset)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -131,14 +131,13 @@ struct routing_driver {
|
||||
* Process and update the routing protocol hob-by-hop
|
||||
* extention headers of the current uIP packet.
|
||||
*
|
||||
* \param ext_offset The offset within the uIP packet where
|
||||
* extension headers start
|
||||
* \param ext_buf A pointer to the ext header buffer
|
||||
* \param opt_offset The offset within the extension header where
|
||||
* the option starts
|
||||
* \return 1 in case the packet is valid and to be processed further,
|
||||
* 0 in case the packet must be dropped.
|
||||
*/
|
||||
int (* ext_header_hbh_update)(int ext_offset, int opt_offset);
|
||||
int (* ext_header_hbh_update)(uint8_t *ext_buf, int opt_offset);
|
||||
/**
|
||||
* Process and update SRH in-place,
|
||||
* i.e. internal address swapping as per RFC6554
|
||||
|
@ -62,34 +62,33 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset)
|
||||
{
|
||||
rpl_instance_t *instance;
|
||||
int down;
|
||||
uint16_t sender_rank;
|
||||
uint8_t sender_closer;
|
||||
uip_ds6_route_t *route;
|
||||
rpl_parent_t *sender = NULL;
|
||||
rpl_parent_t *sender;
|
||||
struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)ext_buf;
|
||||
struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(ext_buf + opt_offset);
|
||||
|
||||
if(UIP_HBHO_BUF(ext_offset)->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->opt_type != UIP_EXT_HDR_OPT_RPL
|
||||
|| UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->opt_len != RPL_HDR_OPT_LEN) {
|
||||
if(hbh_hdr->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| rpl_opt->opt_type != UIP_EXT_HDR_OPT_RPL
|
||||
|| rpl_opt->opt_len != RPL_HDR_OPT_LEN) {
|
||||
|
||||
LOG_ERR("Hop-by-hop extension header has wrong size or type (%u %u %u)\n",
|
||||
UIP_HBHO_BUF(ext_offset)->len,
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->opt_type,
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->opt_len);
|
||||
hbh_hdr->len, rpl_opt->opt_type, rpl_opt->opt_len);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
instance = rpl_get_instance(UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->instance);
|
||||
instance = rpl_get_instance(rpl_opt->instance);
|
||||
if(instance == NULL) {
|
||||
LOG_ERR("Unknown instance: %u\n",
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->instance);
|
||||
LOG_ERR("Unknown instance: %u\n", rpl_opt->instance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags & RPL_HDR_OPT_FWD_ERR) {
|
||||
if(rpl_opt->flags & RPL_HDR_OPT_FWD_ERR) {
|
||||
LOG_ERR("Forward error!\n");
|
||||
/* We should try to repair it by removing the neighbor that caused
|
||||
the packet to be forwareded in the first place. We drop any
|
||||
@ -113,14 +112,14 @@ rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
return 0;
|
||||
}
|
||||
down = 0;
|
||||
if(UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags & RPL_HDR_OPT_DOWN) {
|
||||
if(rpl_opt->flags & RPL_HDR_OPT_DOWN) {
|
||||
down = 1;
|
||||
}
|
||||
|
||||
sender_rank = UIP_HTONS(UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->senderrank);
|
||||
sender_rank = UIP_HTONS(rpl_opt->senderrank);
|
||||
sender = nbr_table_get_from_lladdr(rpl_parents, packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
|
||||
if(sender != NULL && (UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags & RPL_HDR_OPT_RANK_ERR)) {
|
||||
if(sender != NULL && (rpl_opt->flags & RPL_HDR_OPT_RANK_ERR)) {
|
||||
/* A rank error was signalled, attempt to repair it by updating
|
||||
* the sender's rank from ext header */
|
||||
sender->rank = sender_rank;
|
||||
@ -150,7 +149,7 @@ rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
instance->unicast_dio_target = sender;
|
||||
rpl_schedule_unicast_dio_immediately(instance);
|
||||
}
|
||||
if(UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags & RPL_HDR_OPT_RANK_ERR) {
|
||||
if(rpl_opt->flags & RPL_HDR_OPT_RANK_ERR) {
|
||||
RPL_STAT(rpl_stats.loop_errors++);
|
||||
LOG_ERR(" Rank error signalled in RPL option!\n");
|
||||
/* Packet must be dropped and dio trickle timer reset, see RFC6550 - 11.2.2.2 */
|
||||
@ -159,7 +158,7 @@ rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
}
|
||||
LOG_WARN("Single error tolerated\n");
|
||||
RPL_STAT(rpl_stats.loop_warnings++);
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags |= RPL_HDR_OPT_RANK_ERR;
|
||||
rpl_opt->flags |= RPL_HDR_OPT_RANK_ERR;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -414,18 +413,18 @@ update_hbh_header(void)
|
||||
{
|
||||
rpl_instance_t *instance;
|
||||
rpl_parent_t *parent;
|
||||
int opt_offset = 2;
|
||||
struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)UIP_IP_PAYLOAD(0);
|
||||
struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(UIP_IP_PAYLOAD(0) + 2);
|
||||
|
||||
if(UIP_IP_BUF->proto == UIP_PROTO_HBHO && UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_type == UIP_EXT_HDR_OPT_RPL) {
|
||||
if(UIP_HBHO_BUF(0)->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_len != RPL_HDR_OPT_LEN) {
|
||||
if(UIP_IP_BUF->proto == UIP_PROTO_HBHO && rpl_opt->opt_type == UIP_EXT_HDR_OPT_RPL) {
|
||||
if(hbh_hdr->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| rpl_opt->opt_len != RPL_HDR_OPT_LEN) {
|
||||
|
||||
LOG_ERR("Hop-by-hop extension header has wrong size (%u)\n",
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_len);
|
||||
LOG_ERR("Hop-by-hop extension header has wrong size (%u)\n", rpl_opt->opt_len);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
instance = rpl_get_instance(UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->instance);
|
||||
instance = rpl_get_instance(rpl_opt->instance);
|
||||
if(instance == NULL || !instance->used || !instance->current_dag->joined) {
|
||||
LOG_ERR("Unable to add/update hop-by-hop extension header: incorrect instance\n");
|
||||
return 0; /* Drop */
|
||||
@ -433,17 +432,17 @@ update_hbh_header(void)
|
||||
|
||||
LOG_INFO("Updating RPL option\n");
|
||||
/* Update sender rank and instance, will update flags next */
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->senderrank = UIP_HTONS(instance->current_dag->rank);
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->instance = instance->instance_id;
|
||||
rpl_opt->senderrank = UIP_HTONS(instance->current_dag->rank);
|
||||
rpl_opt->instance = instance->instance_id;
|
||||
|
||||
if(RPL_IS_STORING(instance)) { /* In non-storing mode, downwards traffic does not have the HBH option */
|
||||
/* Check the direction of the down flag, as per Section 11.2.2.3,
|
||||
which states that if a packet is going down it should in
|
||||
general not go back up again. If this happens, a
|
||||
RPL_HDR_OPT_FWD_ERR should be flagged. */
|
||||
if((UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->flags & RPL_HDR_OPT_DOWN)) {
|
||||
if((rpl_opt->flags & RPL_HDR_OPT_DOWN)) {
|
||||
if(uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr) == NULL) {
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->flags |= RPL_HDR_OPT_FWD_ERR;
|
||||
rpl_opt->flags |= RPL_HDR_OPT_FWD_ERR;
|
||||
LOG_WARN("RPL forwarding error\n");
|
||||
/* We should send back the packet to the originating parent,
|
||||
but it is not feasible yet, so we send a No-Path DAO instead */
|
||||
@ -462,11 +461,11 @@ update_hbh_header(void)
|
||||
if(uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr) == NULL) {
|
||||
/* No route was found, so this packet will go towards the RPL
|
||||
root. If so, we should not set the down flag. */
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->flags &= ~RPL_HDR_OPT_DOWN;
|
||||
rpl_opt->flags &= ~RPL_HDR_OPT_DOWN;
|
||||
LOG_DBG("RPL option going up\n");
|
||||
} else {
|
||||
/* A DAO route was found so we set the down flag. */
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->flags |= RPL_HDR_OPT_DOWN;
|
||||
rpl_opt->flags |= RPL_HDR_OPT_DOWN;
|
||||
LOG_DBG("RPL option going down\n");
|
||||
}
|
||||
}
|
||||
@ -479,7 +478,8 @@ update_hbh_header(void)
|
||||
static int
|
||||
insert_hbh_header(const rpl_instance_t *instance)
|
||||
{
|
||||
int opt_offset = 2;
|
||||
struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)UIP_IP_PAYLOAD(0);
|
||||
struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(UIP_IP_PAYLOAD(2));
|
||||
|
||||
/* Insert hop-by-hop header */
|
||||
LOG_DBG("Creating hop-by-hop option\n");
|
||||
@ -493,16 +493,16 @@ insert_hbh_header(const rpl_instance_t *instance)
|
||||
memset(UIP_IP_PAYLOAD(0), 0, RPL_HOP_BY_HOP_LEN);
|
||||
|
||||
/* Insert HBH header (as first ext header) */
|
||||
UIP_HBHO_BUF(0)->next = UIP_IP_BUF->proto;
|
||||
hbh_hdr->next = UIP_IP_BUF->proto;
|
||||
UIP_IP_BUF->proto = UIP_PROTO_HBHO;
|
||||
|
||||
/* Initialize HBH option */
|
||||
UIP_HBHO_BUF(0)->len = (RPL_HOP_BY_HOP_LEN - 8) / 8;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_type = UIP_EXT_HDR_OPT_RPL;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_len = RPL_HDR_OPT_LEN;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->flags = 0;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->senderrank = UIP_HTONS(instance->current_dag->rank);
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->instance = instance->instance_id;
|
||||
hbh_hdr->len = (RPL_HOP_BY_HOP_LEN - 8) / 8;
|
||||
rpl_opt->opt_type = UIP_EXT_HDR_OPT_RPL;
|
||||
rpl_opt->opt_len = RPL_HDR_OPT_LEN;
|
||||
rpl_opt->flags = 0;
|
||||
rpl_opt->senderrank = UIP_HTONS(instance->current_dag->rank);
|
||||
rpl_opt->instance = instance->instance_id;
|
||||
|
||||
uipbuf_add_ext_hdr(RPL_HOP_BY_HOP_LEN);
|
||||
uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN);
|
||||
|
@ -275,7 +275,7 @@ rpl_dag_t *rpl_get_dag(const uip_ipaddr_t *addr);
|
||||
rpl_dag_t *rpl_get_any_dag(void);
|
||||
rpl_instance_t *rpl_get_instance(uint8_t instance_id);
|
||||
int rpl_ext_header_update(void);
|
||||
int rpl_ext_header_hbh_update(int, int);
|
||||
int rpl_ext_header_hbh_update(uint8_t *, int);
|
||||
void rpl_insert_header(void);
|
||||
void rpl_ext_header_remove(void);
|
||||
const struct link_stats *rpl_get_parent_link_stats(rpl_parent_t *p);
|
||||
|
@ -299,7 +299,7 @@ insert_srh_header(void)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset)
|
||||
{
|
||||
int down;
|
||||
int rank_error_signaled;
|
||||
@ -307,32 +307,31 @@ rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
uint16_t sender_rank;
|
||||
uint8_t sender_closer;
|
||||
rpl_nbr_t *sender;
|
||||
uint8_t opt_type = UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->opt_type;
|
||||
uint8_t opt_len = UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->opt_len;
|
||||
struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)ext_buf;
|
||||
struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(ext_buf + opt_offset);
|
||||
|
||||
if(UIP_HBHO_BUF(ext_offset)->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| opt_type != UIP_EXT_HDR_OPT_RPL
|
||||
|| opt_len != RPL_HDR_OPT_LEN) {
|
||||
if(hbh_hdr->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| rpl_opt->opt_type != UIP_EXT_HDR_OPT_RPL
|
||||
|| rpl_opt->opt_len != RPL_HDR_OPT_LEN) {
|
||||
LOG_ERR("hop-by-hop extension header has wrong size or type (%u %u %u)\n",
|
||||
UIP_HBHO_BUF(ext_offset)->len, opt_type, opt_len);
|
||||
hbh_hdr->len, rpl_opt->opt_type, rpl_opt->opt_len);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
if(!curr_instance.used || curr_instance.instance_id != UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->instance) {
|
||||
LOG_ERR("unknown instance: %u\n",
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->instance);
|
||||
if(!curr_instance.used || curr_instance.instance_id != rpl_opt->instance) {
|
||||
LOG_ERR("unknown instance: %u\n", rpl_opt->instance);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
if(UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags & RPL_HDR_OPT_FWD_ERR) {
|
||||
if(rpl_opt->flags & RPL_HDR_OPT_FWD_ERR) {
|
||||
LOG_ERR("forward error!\n");
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
down = (UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags & RPL_HDR_OPT_DOWN) ? 1 : 0;
|
||||
sender_rank = UIP_HTONS(UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->senderrank);
|
||||
down = (rpl_opt->flags & RPL_HDR_OPT_DOWN) ? 1 : 0;
|
||||
sender_rank = UIP_HTONS(rpl_opt->senderrank);
|
||||
sender = nbr_table_get_from_lladdr(rpl_neighbors, packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
rank_error_signaled = (UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags & RPL_HDR_OPT_RANK_ERR) ? 1 : 0;
|
||||
rank_error_signaled = (rpl_opt->flags & RPL_HDR_OPT_RANK_ERR) ? 1 : 0;
|
||||
sender_closer = sender_rank < curr_instance.dag.rank;
|
||||
loop_detected = (down && !sender_closer) || (!down && sender_closer);
|
||||
|
||||
@ -346,7 +345,7 @@ rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
|
||||
if(loop_detected) {
|
||||
/* Set forward error flag */
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(ext_offset, opt_offset)->flags |= RPL_HDR_OPT_RANK_ERR;
|
||||
rpl_opt->flags |= RPL_HDR_OPT_RANK_ERR;
|
||||
}
|
||||
|
||||
return rpl_process_hbh(sender, sender_rank, loop_detected, rank_error_signaled);
|
||||
@ -358,25 +357,25 @@ rpl_ext_header_hbh_update(int ext_offset, int opt_offset)
|
||||
static int
|
||||
update_hbh_header(void)
|
||||
{
|
||||
int opt_offset = 2;
|
||||
struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)UIP_IP_PAYLOAD(0);
|
||||
struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(UIP_IP_PAYLOAD(2));
|
||||
|
||||
if(UIP_IP_BUF->proto == UIP_PROTO_HBHO && UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_type == UIP_EXT_HDR_OPT_RPL) {
|
||||
if(UIP_HBHO_BUF(0)->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_len != RPL_HDR_OPT_LEN) {
|
||||
if(UIP_IP_BUF->proto == UIP_PROTO_HBHO && rpl_opt->opt_type == UIP_EXT_HDR_OPT_RPL) {
|
||||
if(hbh_hdr->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| rpl_opt->opt_len != RPL_HDR_OPT_LEN) {
|
||||
|
||||
LOG_ERR("hop-by-hop extension header has wrong size (%u)\n",
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_len);
|
||||
LOG_ERR("hop-by-hop extension header has wrong size (%u)\n", rpl_opt->opt_len);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
if(!curr_instance.used || curr_instance.instance_id != UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->instance) {
|
||||
if(!curr_instance.used || curr_instance.instance_id != rpl_opt->instance) {
|
||||
LOG_ERR("unable to add/update hop-by-hop extension header: incorrect instance\n");
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
/* Update sender rank and instance, will update flags next */
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->senderrank = UIP_HTONS(curr_instance.dag.rank);
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->instance = curr_instance.instance_id;
|
||||
rpl_opt->senderrank = UIP_HTONS(curr_instance.dag.rank);
|
||||
rpl_opt->instance = curr_instance.instance_id;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -389,7 +388,8 @@ update_hbh_header(void)
|
||||
static int
|
||||
insert_hbh_header(void)
|
||||
{
|
||||
int opt_offset = 2;
|
||||
struct uip_hbho_hdr *hbh_hdr = (struct uip_hbho_hdr *)UIP_IP_PAYLOAD(0);
|
||||
struct uip_ext_hdr_opt_rpl *rpl_opt = (struct uip_ext_hdr_opt_rpl *)(UIP_IP_PAYLOAD(2));
|
||||
|
||||
/* Insert hop-by-hop header */
|
||||
LOG_INFO("creating hop-by-hop option\n");
|
||||
@ -403,16 +403,16 @@ insert_hbh_header(void)
|
||||
memset(UIP_IP_PAYLOAD(0), 0, RPL_HOP_BY_HOP_LEN);
|
||||
|
||||
/* Insert HBH header (as first ext header) */
|
||||
UIP_HBHO_BUF(0)->next = UIP_IP_BUF->proto;
|
||||
hbh_hdr->next = UIP_IP_BUF->proto;
|
||||
UIP_IP_BUF->proto = UIP_PROTO_HBHO;
|
||||
|
||||
/* Initialize HBH option */
|
||||
UIP_HBHO_BUF(0)->len = (RPL_HOP_BY_HOP_LEN - 8) / 8;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_type = UIP_EXT_HDR_OPT_RPL;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->opt_len = RPL_HDR_OPT_LEN;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->flags = 0;
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->senderrank = UIP_HTONS(curr_instance.dag.rank);
|
||||
UIP_EXT_HDR_OPT_RPL_BUF(0, opt_offset)->instance = curr_instance.instance_id;
|
||||
hbh_hdr->len = (RPL_HOP_BY_HOP_LEN - 8) / 8;
|
||||
rpl_opt->opt_type = UIP_EXT_HDR_OPT_RPL;
|
||||
rpl_opt->opt_len = RPL_HDR_OPT_LEN;
|
||||
rpl_opt->flags = 0;
|
||||
rpl_opt->senderrank = UIP_HTONS(curr_instance.dag.rank);
|
||||
rpl_opt->instance = curr_instance.instance_id;
|
||||
|
||||
uipbuf_add_ext_hdr(RPL_HOP_BY_HOP_LEN);
|
||||
uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN);
|
||||
|
@ -63,14 +63,13 @@ int rpl_ext_header_srh_update(void);
|
||||
* Process and update the RPL hop-by-hop extension headers of
|
||||
* the current uIP packet.
|
||||
*
|
||||
* \param ext_offset The offset within the uIP packet where
|
||||
* extension headers start
|
||||
* \param ext_buf A pointer to the ext header buffer
|
||||
* \param opt_offset The offset within the extension header where
|
||||
* the option starts
|
||||
* \return 1 in case the packet is valid and to be processed further,
|
||||
* 0 in case the packet must be dropped.
|
||||
*/
|
||||
int rpl_ext_header_hbh_update(int ext_offset, int opt_offset);
|
||||
int rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset);
|
||||
|
||||
/**
|
||||
* Adds/updates all RPL extension headers to current uIP packet.
|
||||
|
Loading…
Reference in New Issue
Block a user