NetSim Source Code Help
Loading...
Searching...
No Matches
DIS.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "RPL.h"
16#include "RPL_Message.h"
17
18#define check_if_dis_needed(rpl) (rpl->joined_dodag == NULL)
19
21{
23 double time = pstruEventDetails->dEventTime;
24 PRPL_NODE rpl = GET_RPL_NODE(d);
25
26 //schedule the next dis
29
30 bool isdisneeded = check_if_dis_needed(rpl);
31
32 if (isdisneeded)
33 {
34 NetSim_PACKET* dis_pdu = create_dis_message(d, time);
35
36 rpl_node_send_msg(d, dis_pdu);
37 }
38}
39
41{
43 double t = pstruEventDetails->dEventTime;
44
46
47 if (dio_pdu != NULL)
48 rpl_node_send_msg(d, dio_pdu);
49}
50
52{
54 PRPL_DIS_BASE b = rpl->Base;
55 free(b);
56 UINT i;
57 for (i = 0; i < rpl->option_count; i++)
59 free(rpl);
60}
61
62void rpl_dis_msg_copy(const NetSim_PACKET* destPacket, const NetSim_PACKET* srcPacket)
63{
65 PRPL_CTRL_MSG drpl = (PRPL_CTRL_MSG)calloc(1, sizeof* drpl);
66 memcpy(drpl, srpl, sizeof* drpl);
67 destPacket->pstruNetworkData->Packet_RoutingProtocol = drpl;
68
69 PRPL_DIS_BASE b = srpl->Base;
70 PRPL_DIS_BASE db = (PRPL_DIS_BASE)calloc(1, sizeof* db);
71 memcpy(db, b, sizeof* db);
72 drpl->Base = db;
73
74 UINT i;
75 for (i = 0; i < srpl->option_count; i++)
76 drpl->options[i] = rpl_option_copy(srpl->options[i]);
77}
unsigned int NETSIM_ID
Definition: Animation.h:45
void rpl_dis_msg_copy(const NetSim_PACKET *destPacket, const NetSim_PACKET *srcPacket)
Definition: DIS.c:62
void rpl_process_dis_msg()
Definition: DIS.c:40
void rpl_dis_pdu_send()
Definition: DIS.c:20
void rpl_dis_msg_destroy(NetSim_PACKET *packet)
Definition: DIS.c:51
#define check_if_dis_needed(rpl)
Definition: DIS.c:18
#define UINT
Definition: Linux.h:38
#define TRUE
Definition: Linux.h:77
#define free(p)
Definition: Memory.h:31
#define calloc(c, s)
Definition: Memory.h:29
#define GET_RPL_NODE(d)
Definition: RPL.h:212
NetSim_PACKET * create_dis_message(NETSIM_ID ndevid, double time)
Definition: RPL_Message.c:408
NetSim_PACKET * create_current_dio_message(NETSIM_ID ndevId, double time, bool include_dodag_config)
Definition: RPL_Message.c:293
PRPL_OPTION rpl_option_copy(PRPL_OPTION option)
Definition: RPL_Message.c:114
void rpl_node_send_msg(NETSIM_ID ndevid, NetSim_PACKET *packet)
Definition: RPL_Message.c:418
void rpl_option_destroy(PRPL_OPTION option)
Definition: RPL_Message.c:96
struct stru_rpl_DIS_Base * PRPL_DIS_BASE
struct stru_rpl_ctrl_message * PRPL_CTRL_MSG
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
NETSIM_ID nDeviceId
Definition: Stack.h:750
struct stru_NetSim_Packet_NetworkLayer * pstruNetworkData
Definition: Packet.h:275
PRPL_OPTION * options
Definition: RPL_Message.h:80
double DISInterval
Definition: RPL.h:174