rpl-private.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef RPL_PRIVATE_H
00035 #define RPL_PRIVATE_H
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "net/rpl/rpl.h"
00048
00049 #include "lib/list.h"
00050 #include "net/uip.h"
00051 #include "sys/clock.h"
00052 #include "sys/ctimer.h"
00053 #include "net/uip-ds6.h"
00054
00055
00056
00057 #define uip_is_addr_linklocal_rplnodes_mcast(a) \
00058 ((((a)->u8[0]) == 0xff) && \
00059 (((a)->u8[1]) == 0x02) && \
00060 (((a)->u16[1]) == 0) && \
00061 (((a)->u16[2]) == 0) && \
00062 (((a)->u16[3]) == 0) && \
00063 (((a)->u16[4]) == 0) && \
00064 (((a)->u16[5]) == 0) && \
00065 (((a)->u16[6]) == 0) && \
00066 (((a)->u8[14]) == 0) && \
00067 (((a)->u8[15]) == 0x1a))
00068
00069
00070 #define uip_create_linklocal_rplnodes_mcast(a) uip_ip6addr(a, 0xff02, 0, 0, 0, 0, 0, 0, 0x001a)
00071
00072
00073 #define RPL_CODE_DIS 0x00
00074 #define RPL_CODE_DIO 0x01
00075 #define RPL_CODE_DAO 0x02
00076 #define RPL_CODE_DAO_ACK 0x03
00077 #define RPL_CODE_SEC_DIS 0x80
00078 #define RPL_CODE_SEC_DIO 0x81
00079 #define RPL_CODE_SEC_DAO 0x82
00080 #define RPL_CODE_SEC_DAO_ACK 0x83
00081
00082
00083 #define RPL_DIO_SUBOPT_PAD1 0
00084 #define RPL_DIO_SUBOPT_PADN 1
00085 #define RPL_DIO_SUBOPT_DAG_METRIC_CONTAINER 2
00086 #define RPL_DIO_SUBOPT_ROUTE_INFO 3
00087 #define RPL_DIO_SUBOPT_DAG_CONF 4
00088 #define RPL_DIO_SUBOPT_TARGET 5
00089 #define RPL_DIO_SUBOPT_TRANSIT 6
00090 #define RPL_DIO_SUBOPT_SOLICITED_INFO 7
00091 #define RPL_DIO_SUBOPT_PREFIX_INFO 8
00092
00093 #define RPL_DAO_K_FLAG 0x80
00094 #define RPL_DAO_D_FLAG 0x40
00095
00096
00097
00098
00099 #define DEFAULT_DAO_LATENCY (CLOCK_SECOND * 8)
00100
00101
00102 #define ZERO_LIFETIME 0
00103
00104
00105 #define INFINITE_LIFETIME 0xffffffff
00106
00107
00108 #define DEFAULT_ROUTE_LIFETIME INFINITE_LIFETIME
00109
00110 #define DEFAULT_RPL_LIFETIME_UNIT 0xffff
00111 #define DEFAULT_RPL_DEF_LIFETIME 0xff
00112
00113 #ifndef RPL_CONF_MIN_HOPRANKINC
00114 #define DEFAULT_MIN_HOPRANKINC 256
00115 #else
00116 #define DEFAULT_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
00117 #endif
00118 #define DEFAULT_MAX_RANKINC (3 * DEFAULT_MIN_HOPRANKINC)
00119
00120 #define DAG_RANK(fixpt_rank, dag) ((fixpt_rank) / (dag)->min_hoprankinc)
00121
00122
00123 #define BASE_RANK 0
00124
00125
00126 #define ROOT_RANK(dag) (dag)->min_hoprankinc
00127
00128 #define INFINITE_RANK 0xffff
00129
00130 #define INITIAL_LINK_METRIC NEIGHBOR_INFO_ETX2FIX(5)
00131
00132
00133
00134
00135
00136 #ifdef RPL_CONF_DIO_INTERVAL_MIN
00137 #define DEFAULT_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
00138 #else
00139 #define DEFAULT_DIO_INTERVAL_MIN 12
00140 #endif
00141
00142
00143 #ifdef RPL_CONF_DIO_INTERVAL_DOUBLINGS
00144 #define DEFAULT_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
00145 #else
00146 #define DEFAULT_DIO_INTERVAL_DOUBLINGS 8
00147 #endif
00148
00149
00150 #ifdef RPL_CONF_DIO_REDUNDANCY
00151 #define DEFAULT_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
00152 #else
00153 #define DEFAULT_DIO_REDUNDANCY 10
00154 #endif
00155
00156
00157 #define DAO_EXPIRATION_TIMEOUT 60
00158
00159 #define RPL_INSTANCE_LOCAL_FLAG 0x80
00160 #define RPL_INSTANCE_D_FLAG 0x40
00161
00162
00163 #define RPL_ROUTE_FROM_INTERNAL 0
00164 #define RPL_ROUTE_FROM_UNICAST_DAO 1
00165 #define RPL_ROUTE_FROM_MULTICAST_DAO 2
00166 #define RPL_ROUTE_FROM_DIO 3
00167
00168
00169 #define RPL_MOP_NO_DOWNWARD_ROUTES 0
00170 #define RPL_MOP_NON_STORING 1
00171 #define RPL_MOP_STORING_NO_MULTICAST 2
00172 #define RPL_MOP_STORING_MULTICAST 3
00173
00174 #ifdef RPL_CONF_MOP
00175 #define RPL_MOP_DEFAULT RPL_CONF_MOP
00176 #else
00177 #define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
00178 #endif
00179
00180
00181
00182
00183
00184
00185 #define RPL_DAG_MC_ETX_DIVISOR 128
00186
00187
00188 #define RPL_DIS_SEND 1
00189 #ifdef RPL_DIS_INTERVAL_CONF
00190 #define RPL_DIS_INTERVAL RPL_DIS_INTERVAL_CONF
00191 #else
00192 #define RPL_DIS_INTERVAL 60
00193 #endif
00194 #define RPL_DIS_START_DELAY 5
00195
00196
00197 struct rpl_dio {
00198 uip_ipaddr_t dag_id;
00199 rpl_ocp_t ocp;
00200 rpl_rank_t rank;
00201 uint8_t grounded;
00202 uint8_t mop;
00203 uint8_t preference;
00204 uint8_t version;
00205 uint8_t instance_id;
00206 uint8_t dtsn;
00207 uint8_t dag_intdoubl;
00208 uint8_t dag_intmin;
00209 uint8_t dag_redund;
00210 uint8_t default_lifetime;
00211 uint16_t lifetime_unit;
00212 rpl_rank_t dag_max_rankinc;
00213 rpl_rank_t dag_min_hoprankinc;
00214 rpl_prefix_t destination_prefix;
00215 rpl_prefix_t prefix_info;
00216 struct rpl_metric_container mc;
00217 };
00218 typedef struct rpl_dio rpl_dio_t;
00219
00220 #if RPL_CONF_STATS
00221
00222 struct rpl_stats {
00223 uint16_t mem_overflows;
00224 uint16_t local_repairs;
00225 uint16_t global_repairs;
00226 uint16_t malformed_msgs;
00227 uint16_t resets;
00228 uint16_t parent_switch;
00229 };
00230 typedef struct rpl_stats rpl_stats_t;
00231
00232 extern rpl_stats_t rpl_stats;
00233 #endif
00234
00235
00236
00237 #if RPL_CONF_STATS
00238 #define RPL_STAT(code) (code)
00239 #else
00240 #define RPL_STAT(code)
00241 #endif
00242
00243
00244 void dis_output(uip_ipaddr_t *addr);
00245 void dio_output(rpl_dag_t *, uip_ipaddr_t *uc_addr);
00246 void dao_output(rpl_parent_t *, uint32_t lifetime);
00247 void dao_ack_output(rpl_dag_t *, uip_ipaddr_t *, uint8_t);
00248 void uip_rpl_input(void);
00249
00250
00251 void rpl_join_dag(rpl_dag_t *);
00252 void rpl_local_repair(rpl_dag_t *dag);
00253 int rpl_set_default_route(rpl_dag_t *dag, uip_ipaddr_t *from);
00254 void rpl_process_dio(uip_ipaddr_t *, rpl_dio_t *);
00255 int rpl_process_parent_event(rpl_dag_t *, rpl_parent_t *);
00256
00257
00258 rpl_dag_t *rpl_alloc_dag(uint8_t);
00259 void rpl_free_dag(rpl_dag_t *);
00260
00261
00262 rpl_parent_t *rpl_add_parent(rpl_dag_t *, rpl_dio_t *dio, uip_ipaddr_t *);
00263 rpl_parent_t *rpl_find_parent(rpl_dag_t *, uip_ipaddr_t *);
00264 int rpl_remove_parent(rpl_dag_t *, rpl_parent_t *);
00265 rpl_parent_t *rpl_select_parent(rpl_dag_t *dag);
00266 void rpl_recalculate_ranks(void);
00267
00268
00269 void rpl_remove_routes(rpl_dag_t *dag);
00270 uip_ds6_route_t *rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix,
00271 int prefix_len, uip_ipaddr_t *next_hop);
00272 void rpl_purge_routes(void);
00273
00274
00275 rpl_of_t *rpl_find_of(rpl_ocp_t);
00276
00277
00278 void rpl_schedule_dao(rpl_dag_t *);
00279 void rpl_reset_dio_timer(rpl_dag_t *, uint8_t);
00280 void rpl_reset_periodic_timer(void);
00281
00282
00283 void rpl_poison_routes(rpl_dag_t *, rpl_parent_t *);
00284
00285 #endif