Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-instance support, DIO DAG metric container enhancement, .. (see… #2463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion core/net/ip/tcpip.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,22 @@ tcpip_ipv6_output(void)
/* No route was found - we send to the default route instead. */
if(route == NULL) {
PRINTF("tcpip_ipv6_output: no route found, using default route\n");
nexthop = uip_ds6_defrt_choose();
#if UIP_CONF_IPV6_RPL && RPL_MAX_INSTANCES > 1
rpl_instance_t *instance;
instance = rpl_hbh_get_instance();
if(instance->current_dag->preferred_parent == NULL){
instance=rpl_get_default_instance(&UIP_IP_BUF->destipaddr);
rpl_hbh_set_instance(instance);
}
printf("tcpip : instance used is %d\n", instance->instance_id);
nexthop = rpl_get_parent_ipaddr(instance->current_dag->preferred_parent);
if(nexthop == NULL){
/* No default route found, so using ds6 function */
nexthop = uip_ds6_defrt_choose();
}
#else
nexthop = uip_ds6_defrt_choose();
#endif /* UIP_CONF_IPV6_RPL && RPL_MAX_INSTANCES > 1 */
if(nexthop == NULL) {
#ifdef UIP_FALLBACK_INTERFACE
PRINTF("FALLBACK: removing ext hdrs & setting proto %d %d\n",
Expand Down
3 changes: 3 additions & 0 deletions core/net/ip/uip.h
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,9 @@ struct uip_udp_conn {
uint16_t lport; /**< The local port number in network byte order. */
uint16_t rport; /**< The remote port number in network byte order. */
uint8_t ttl; /**< Default time-to-live. */
#if UIP_CONF_IPV6_RPL
uint8_t rpl_instance_id;
#endif /* UIP_CONF_IPV6_RPL*/

/** The application state. */
uip_udp_appstate_t appstate;
Expand Down
3 changes: 3 additions & 0 deletions core/net/ipv6/uip-ds6-nbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ typedef struct uip_ds6_nbr {
struct stimer sendns;
uint8_t nscount;
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA */
#if UIP_CONF_IPV6_RPL && RPL_LB == RPL_LB_MIN_NOACK
uint8_t noack_count;
#endif /* UIP_CONF_IPV6_RPL */
#if UIP_CONF_IPV6_QUEUE_PKT
struct uip_packetqueue_handle packethandle;
#define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
Expand Down
6 changes: 3 additions & 3 deletions core/net/ipv6/uip-icmp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ echo_request_input(void)

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

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

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

UIP_STAT(++uip_stat.icmp.sent);
Expand Down Expand Up @@ -302,7 +302,7 @@ uip_icmp6_send(const uip_ipaddr_t *dest, int type, int code, int payload_len)
UIP_STAT(++uip_stat.ip.sent);

#if UIP_CONF_IPV6_RPL
rpl_insert_header();
rpl_insert_header(0);
#endif /* UIP_CONF_IPV6_RPL */
tcpip_ipv6_output();
}
Expand Down
4 changes: 2 additions & 2 deletions core/net/ipv6/uip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ uip_process(uint8_t flag)
}

#if UIP_CONF_IPV6_RPL
if(!rpl_update_header()) {
if(rpl_update_header()) {
/* Packet can not be forwarded */
PRINTF("RPL header update error\n");
goto drop;
Expand Down Expand Up @@ -1583,7 +1583,7 @@ uip_process(uint8_t flag)
#endif /* UIP_UDP_CHECKSUMS */

#if UIP_CONF_IPV6_RPL
rpl_insert_header();
rpl_insert_header(uip_udp_conn->rpl_instance_id);
#endif /* UIP_CONF_IPV6_RPL */

UIP_STAT(++uip_stat.udp.sent);
Expand Down
85 changes: 82 additions & 3 deletions core/net/rpl/rpl-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
#define RPL_CONF_STATS 0
#endif /* RPL_CONF_STATS */

/*
* Specify which metric types are supported/enabled in the Metric container.
* If a DIO contains a unsupported metric type, control packet is dropped.
*/
#ifdef RPL_CONF_DAG_MC_SUPPORTED_METRICS
#define RPL_DAG_MC_SUPPORTED_METRICS RPL_CONF_DAG_MC_SUPPORTED_METRICS
#else
#define RPL_DAG_MC_SUPPORTED_METRICS (RPL_DAG_MC_BITMAP(RPL_DAG_MC_ETX) | RPL_DAG_MC_BITMAP(RPL_DAG_MC_HOPCOUNT) | RPL_DAG_MC_BITMAP(RPL_DAG_MC_ENERGY))
#endif /* RPL_CONF_DAG_MC_SUPPORTED_METRICS */

/*
* The objective function (OF) used by a RPL root is configurable through
* the RPL_CONF_OF_OCP parameter. This is defined as the objective code
Expand All @@ -67,9 +77,16 @@
#ifdef RPL_CONF_SUPPORTED_OFS
#define RPL_SUPPORTED_OFS RPL_CONF_SUPPORTED_OFS
#else /* RPL_CONF_SUPPORTED_OFS */
#define RPL_SUPPORTED_OFS {&rpl_mrhof}
#define RPL_SUPPORTED_OFS {&rpl_mrhof, &rpl_of0}
#endif /* RPL_CONF_SUPPORTED_OFS */

/*
* Functions used to simplify manipulation of MC metric types.
*/
#define RPL_DAG_MC_BITMAP(type) 1 << (type-1)
#define RPL_IS_METRIC_SUPPORTED(type) RPL_DAG_MC_SUPPORTED_METRICS & RPL_DAG_MC_BITMAP(type)
#define RPL_IS_OF_ENABLED(of_name) RPL_OF_ENABLED & of_name

/*
* Enable/disable RPL Metric Containers (MC). The actual MC in use
* for a given DODAG is decided at runtime, when joining. Note that
Expand All @@ -81,23 +98,85 @@
#ifdef RPL_CONF_WITH_MC
#define RPL_WITH_MC RPL_CONF_WITH_MC
#else /* RPL_CONF_WITH_MC */
#define RPL_WITH_MC 0
#define RPL_WITH_MC (RPL_DAG_MC_SUPPORTED_METRICS != RPL_DAG_MC_NONE)
#endif /* RPL_CONF_WITH_MC */

/* The MC advertised in DIOs and propagating from the root */
/* The MC advertised in DIOs and propagating from the root */
#ifdef RPL_CONF_DAG_MC
#define RPL_DAG_MC RPL_CONF_DAG_MC
#else
#define RPL_DAG_MC RPL_DAG_MC_NONE
#endif /* RPL_CONF_DAG_MC */

/*
* Maximum of Metric/Constraint object in a DAG Metric Container
*/
#ifdef RPL_CONF_MAX_DAG_MC_OBJECTS
#define RPL_MAX_DAG_MC_OBJECTS RPL_CONF_MAX_DAG_MC_OBJECTS
#else
#define RPL_MAX_DAG_MC_OBJECTS 1
#endif /* RPL_CONF_MAX_DAG_MC_OBJECTS */

/*
* Maximum of Type-Length-Value field in a DAG Metric Container Object.
*/

#ifdef RPL_CONF_MAX_DAG_MC_TLV
#define RPL_MAX_DAG_MC_TLV RPL_CONF_MAX_DAG_MC_TLV
#else
#define RPL_MAX_DAG_MC_TLV 0
#endif /* RPL_CONF_MAX_DAG_MC_TLV */

/*
* Energy type to be used in DAG MC energy object. Also used when checking
* advertized constraints.
* If not defined, energy type will be based on DODAG Rank :
* - RPL_DAG_MC_ENERGY_TYPE_MAINS for a DODAG root,
* - RPL_DAG_MC_ENERGY_TYPE_BATTERY for other nodes
*/
#ifdef RPL_CONF_DAG_MC_ENERGY_TYPE
#define RPL_DAG_MC_ENERGY_TYPE RPL_CONF_DAG_MC_ENERGY_TYPE
#endif /* RPL_CONF_DAG_MC_ENERGY_TYPE */

/*
* The default objective function used by RPL is configurable through the
* RPL_CONF_DEFAULT_OF parameter. This should be defined to be the name of an
* rpl_of object linked into the system image, e.g., rpl_of0.
*/
#ifdef RPL_CONF_DEFAULT_OF
#define RPL_DEFAULT_OF RPL_CONF_DEFAULT_OF

#endif /* RPL_CONF_DEFAULT_OF */

/* This value decides which DAG instance we should participate in by default. */
#ifdef RPL_CONF_DEFAULT_INSTANCE
#define RPL_DEFAULT_INSTANCE RPL_CONF_DEFAULT_INSTANCE
#else
#define RPL_DEFAULT_INSTANCE 0x1e
#endif /* RPL_CONF_DEFAULT_INSTANCE */

/* Enable DIO filter based on constraints found and authorized instance IDs */
#ifdef RPL_CONF_FILTER_DIO
#define RPL_FILTER_DIO RPL_CONF_FILTER_DIO
#else
#define RPL_FILTER_DIO 1
#endif /* RPL_CONF_FILTER_DIO */


/* Load balancing mechanism, RPL_LB_NONE to set no mechanism*/
#ifdef RPL_CONF_LB
#define RPL_LB RPL_CONF_LB
#else
#define RPL_LB RPL_LB_NONE
#endif /* RPL_CONF_LB */

/* Authorized instances array. "{0}" results in authorizing all instances */
#ifdef RPL_CONF_AUTHORIZED_INSTANCES
#define RPL_AUTHORIZED_INSTANCES RPL_CONF_AUTHORIZED_INSTANCES
#else
#define RPL_AUTHORIZED_INSTANCES {0}
#endif /* RPL_CONF_AUTHORIZED_INSTANCES */

/*
* This value decides if this node must stay as a leaf or not
* as allowed by draft-ietf-roll-rpl-19#section-8.5
Expand Down
2 changes: 1 addition & 1 deletion core/net/rpl/rpl-dag-root.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ rpl_dag_root_is_root(void)
{
rpl_instance_t *instance;

instance = rpl_get_default_instance();
instance = last_joined_instance;

if(instance == NULL) {
return 0;
Expand Down
Loading