From 25e07b7d239a21fc1ddbc1561ca2d22bf6325c95 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:21:37 -0800 Subject: [PATCH] Routing API: added ext_header_hbh_update --- os/net/ipv6/uip6.c | 5 +---- os/net/routing/nullrouting/nullrouting.c | 7 +++++++ os/net/routing/routing.h | 10 ++++++++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl-ext-header.h | 5 +++-- os/net/routing/rpl-lite/rpl.c | 1 + 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index edc037468..aa6b8a537 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -875,13 +875,10 @@ ext_hdr_options_process(void) * Using this fix, the header is ignored, and the next header (if * present) is processed. */ -#if UIP_CONF_IPV6_RPL - LOG_DBG("Processing RPL option\n"); - if(!rpl_ext_header_hbh_update(uip_ext_opt_offset)) { + if(!NETSTACK_ROUTING.ext_header_hbh_update(uip_ext_opt_offset)) { LOG_ERR("RPL Option Error: Dropping Packet\n"); return 1; } -#endif /* UIP_CONF_IPV6_RPL */ uip_ext_opt_offset += (UIP_EXT_HDR_OPT_BUF->len) + 2; return 0; default: diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index d7b643b5b..3f7c2487f 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -81,6 +81,12 @@ ext_header_update(void) } /*---------------------------------------------------------------------------*/ static int +ext_header_hbh_update(int uip_ext_opt_offset) +{ + return 1; +} +/*---------------------------------------------------------------------------*/ +static int ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) { return 0; @@ -95,6 +101,7 @@ const struct routing_driver nullrouting_driver = { local_repair, ext_header_remove, ext_header_update, + ext_header_hbh_update, ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index bfa639f1c..2edf50b40 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -87,6 +87,16 @@ struct routing_driver { * \return 1 in case of success, 0 otherwise */ int (* ext_header_update)(void); + /** + * Process and update the routing protocol hob-by-hop + * extention headers of the current uIP packet. + * + * \param uip_ext_opt_offset The offset within the uIP packet where + * extension headers start + * \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 uip_ext_opt_offset); /** * Look for next hop from SRH of current uIP packet. * diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 2b1dc81fd..ffc46ea9d 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -380,6 +380,7 @@ const struct routing_driver rpl_classic_driver = { local_repair, rpl_ext_header_remove, rpl_ext_header_update, + rpl_ext_header_hbh_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl-ext-header.h b/os/net/routing/rpl-lite/rpl-ext-header.h index 59d637b1c..df61bc325 100644 --- a/os/net/routing/rpl-lite/rpl-ext-header.h +++ b/os/net/routing/rpl-lite/rpl-ext-header.h @@ -60,7 +60,8 @@ int rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr); int rpl_ext_header_srh_update(void); /** -* Process and update the RPL extension headers of the current uIP packet. +* Process and update the RPL hop-by-hop extension headers of +* the current uIP packet. * * \param uip_ext_opt_offset The offset within the uIP packet where * extension headers start @@ -70,7 +71,7 @@ int rpl_ext_header_srh_update(void); int rpl_ext_header_hbh_update(int uip_ext_opt_offset); /** - * Adds/updates RPL extension headers to current uIP packet. + * Adds/updates all RPL extension headers to current uIP packet. * * \return 1 in case of success, 0 otherwise */ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index cb677eedd..ab67d8be0 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -202,6 +202,7 @@ const struct routing_driver rpl_lite_driver = { rpl_local_repair, rpl_ext_header_remove, rpl_ext_header_update, + rpl_ext_header_hbh_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/