NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
DIS.c
1/************************************************************************************
2* Copyright (C) 2023 *
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
20void rpl_dis_pdu_send()
21{
22 NETSIM_ID d = pstruEventDetails->nDeviceId;
23 double time = pstruEventDetails->dEventTime;
24 PRPL_NODE rpl = GET_RPL_NODE(d);
25
26 //schedule the next dis
27 pstruEventDetails->dEventTime += rpl->DISInterval;
28 fnpAddEvent(pstruEventDetails);
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
40void rpl_process_dis_msg()
41{
42 NETSIM_ID d = pstruEventDetails->nDeviceId;
43 double t = pstruEventDetails->dEventTime;
44
45 NetSim_PACKET* dio_pdu = create_current_dio_message(d, t, TRUE);
46
47 if (dio_pdu != NULL)
48 rpl_node_send_msg(d, dio_pdu);
49}
50
51void rpl_dis_msg_destroy(NetSim_PACKET* packet)
52{
53 PRPL_CTRL_MSG rpl = packet->pstruNetworkData->Packet_RoutingProtocol;
54 PRPL_DIS_BASE b = rpl->Base;
55 free(b);
56 UINT i;
57 for (i = 0; i < rpl->option_count; i++)
58 rpl_option_destroy(rpl->options[i]);
59 free(rpl);
60}
61
62void rpl_dis_msg_copy(const NetSim_PACKET* destPacket, const NetSim_PACKET* srcPacket)
63{
64 PRPL_CTRL_MSG srpl = srcPacket->pstruNetworkData->Packet_RoutingProtocol;
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}