18char* GetStringRPL_Subevent(NETSIM_ID);
19int fn_NetSim_RPL_Init_F();
20int fn_NetSim_RPL_Finish_F();
21int fn_NetSim_RPL_Configure_F(
void** var);
22int fn_NetSim_RPL_FreePacket_F(NetSim_PACKET* packet);
23int fn_NetSim_RPL_CopyPacket_F(NetSim_PACKET* destPacket, NetSim_PACKET* srcPacket);
29 NetSim_EVENTDETAILS *pstruEventDetails_Formal,
30 char *pszAppPath_Formal,
31 char *pszWritePath_Formal,
35 return fn_NetSim_RPL_Init_F();
42_declspec (dllexport)
int fn_NetSim_RPL_Run()
44 switch (pstruEventDetails->nEventType)
46 case NETWORK_OUT_EVENT:
50 case NETWORK_IN_EVENT:
52 rpl_add_to_neighbor_list();
53 if (is_rpl_control_packet(pstruEventDetails->pPacket))
55 rpl_process_ctrl_msg();
56 fn_NetSim_Packet_FreePacket(pstruEventDetails->pPacket);
57 pstruEventDetails->pPacket = NULL;
63 switch (pstruEventDetails->nSubEventType)
65 case RPL_TRICKLE_T_TIMEOUT:
66 rpl_trickle_handle_t_timeout();
68 case RPL_TRICKLE_I_TIMEOUT:
69 rpl_trickle_handle_i_timeout();
74 case RPL_NEW_PREF_PARENT:
81 case RPL_DAO_ROUTE_TIMEOUT:
82 rpl_dao_route_timeout();
88 fnNetSimError(
"Unknown subevent %d for RPL.", pstruEventDetails->nSubEventType);
94 fnNetSimError(
"Unknow event %d for RPL protocol", pstruEventDetails->nEventType);
104_declspec(dllexport)
int fn_NetSim_RPL_Finish()
106 return fn_NetSim_RPL_Finish_F();
113_declspec (dllexport)
char* fn_NetSim_RPL_Trace(NETSIM_ID nSubEvent)
115 return GetStringRPL_Subevent(nSubEvent);
122_declspec(dllexport)
int fn_NetSim_RPL_Configure(
void** var)
124 return fn_NetSim_RPL_Configure_F(var);
130_declspec(dllexport)
int fn_NetSim_RPL_FreePacket(NetSim_PACKET* pstruPacket)
132 return fn_NetSim_RPL_FreePacket_F(pstruPacket);
139_declspec(dllexport)
int fn_NetSim_RPL_CopyPacket(NetSim_PACKET* pstruDestPacket, NetSim_PACKET* pstruSrcPacket)
141 return fn_NetSim_RPL_CopyPacket_F(pstruDestPacket, pstruSrcPacket);
147_declspec(dllexport)
int fn_NetSim_RPL_Metrics(PMETRICSWRITER metricsWriter)
155_declspec(dllexport)
char* fn_NetSim_RPL_ConfigPacketTrace()
163_declspec(dllexport)
char* fn_NetSim_RPL_WritePacketTrace(NetSim_PACKET* pstruPacket,
char** ppszTrace)
168static PRPL_ROOT rpl_root_info_create()
170 PRPL_ROOT root_info = calloc(1,
sizeof* root_info);
171 memcpy(root_info, get_global_root_info(),
sizeof* root_info);
173 root_info->dodag_id = NULL;
174 root_info->configured_dodag_id = NULL;
175 root_info->dodag_pref = RPL_DEFAULT_DAG_PREF;
176 root_info->grounded = FALSE;
177 root_info->min_hop_rank_inc = 1;
181void rpl_node_init(NETSIM_ID d)
183 PRPL_NODE r = GET_RPL_NODE(d);
184 r->root_info = rpl_root_info_create();
187 memset(pstruEventDetails, 0,
sizeof* pstruEventDetails);
188 pstruEventDetails->dEventTime = r->DISInitDelay;
189 pstruEventDetails->nDeviceId = d;
190 pstruEventDetails->nDeviceType = DEVICE_TYPE(d);
191 pstruEventDetails->nEventType = TIMER_EVENT;
192 pstruEventDetails->nProtocolId = NW_PROTOCOL_RPL;
193 pstruEventDetails->nSubEventType = RPL_SEND_DIS;
194 fnpAddEvent(pstruEventDetails);
197void start_as_root(NETSIM_ID d)
199 PRPL_NODE rpl = GET_RPL_NODE(d);
202 rpl_delete_all_route(d);
204 forget_neighbor_messages(rpl);
206 if (rpl->joined_dodag != NULL)
208 rpl_dodag_destroy(rpl->joined_dodag);
209 rpl->joined_dodag = NULL;
212 if (rpl->root_info->dodag_id == NULL)
214 if (rpl->root_info->configured_dodag_id == NULL)
216 rpl->root_info->dodag_id = IP_COPY(DEVICE_NWADDRESS(d, 1));
220 rpl->root_info->dodag_id = IP_COPY(rpl->root_info->configured_dodag_id);
223 rpl_trickle_reset(d);