NetSim Source Code Help
Loading...
Searching...
No Matches
RPL_Message.h
Go to the documentation of this file.
1#pragma once
2/************************************************************************************
3* Copyright (C) 2020 *
4* TETCOS, Bangalore. India *
5* *
6* Tetcos owns the intellectual property rights in the Product and its content. *
7* The copying, redistribution, reselling or publication of any or all of the *
8* Product or its content without express prior written consent of Tetcos is *
9* prohibited. Ownership and / or any other right relating to the software and all *
10* intellectual property rights therein shall remain at all times with Tetcos. *
11* *
12* Author: Shashi Kant Suman *
13* *
14* ---------------------------------------------------------------------------------*/
15
16/************************************************************************************
17https://tools.ietf.org/html/rfc6550
18************************************************************************************/
19
20#define ICMP_TYPE_RPL 0x9B
21
22typedef enum
23{
34
35#define GET_RPL_CTRL_PACKET_TYPE(code) (NW_PROTOCOL_RPL*100+code)
36#define GET_RPL_CTRL_MSG_CODE(packet) (packet->nControlDataType%100)
37
38
40{
49typedef struct stru_rpl_option
50{
52 void* option;
54
55/* 6. ICMPv6 RPL Control Message
56
570 1 2 3
580 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
59+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60| Type | Code | Checksum |
61+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62| |
63. Base .
64. .
65+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66| |
67. Option(s) .
68. .
69+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70
71Figure 6: RPL Control Message
72*/
73
75{
79 void* Base;
83#define GET_PRPL_CTRL_MSG(packet) ((PRPL_CTRL_MSG)(PACKET_NWDATA(packet)->Packet_RoutingProtocol))
84#define SET_BASE_IN_MSG(packet,b) (GET_PRPL_CTRL_MSG(packet)->Base = b)
85#define GET_BASE_FROM_MSG(packet) (GET_PRPL_CTRL_MSG(packet)->Base)
86#define RPL_CTRL_MSG_SIZE_FIXED 4 //Bytes
87
88
89/*
906.2.1. Format of the DIS Base Object
91
920 1 2
930 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
94+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95| Flags | Reserved | Option(s)...
96+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97
98Figure 13: The DIS Base Object
99*/
100typedef struct stru_rpl_DIS_Base
101{
105#define RPL_DIS_BASE_SIZE 2 //Bytes
106
107
108/*
1096.3.1. Format of the DIO Base Object
110
1110 1 2 3
1120 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
113+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
114| RPLInstanceID |Version Number | Rank |
115+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116|G|0| MOP | Prf | DTSN | Flags | Reserved |
117+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
118| |
119+ +
120| |
121+ DODAGID +
122| |
123+ +
124| |
125+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126| Option(s)...
127+-+-+-+-+-+-+-+-+
128
129Figure 14: The DIO Base Object
130*/
131typedef struct stru_rpl_dio_base
132{
136 UINT G : 1;
145#define RPL_DIO_BASE_SIZE 24 //Bytes
146
147/*
1486.4.1. Format of the DAO Base Object
149
1500 1 2 3
1510 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
152+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
153| RPLInstanceID |K|D| Flags | Reserved | DAOSequence |
154+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
155| |
156+ +
157| |
158+ DODAGID* +
159| |
160+ +
161| |
162+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
163| Option(s)...
164+-+-+-+-+-+-+-+-+
165*/
166typedef struct stru_rpl_dao_base
167{
169 UINT K : 1;
170 UINT D : 1;
176#define RPL_DAO_BASE_SIZE 20 //Bytes
177
178/*
1796.5.1. Format of the DAO-ACK Base Object
180
1810 1 2 3
1820 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
183+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
184| RPLInstanceID |D| Reserved | DAOSequence | Status |
185+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
186| |
187+ +
188| |
189+ DODAGID* +
190| |
191+ +
192| |
193+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
194| Option(s)...
195+-+-+-+-+-+-+-+-+
196*/
198{
200 UINT D : 1;
206#define RPL_DAOACK_BASE_SIZE 20 //Bytes
207
208
209/*
2106.6.1. Format of the CC Base Object
211
212 0 1 2 3
213 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215 | RPLInstanceID |R| Flags | CC Nonce |
216 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
217 | |
218 + +
219 | |
220 + DODAGID +
221 | |
222 + +
223 | |
224 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
225 | Destination Counter |
226 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
227 | Option(s)...
228 +-+-+-+-+-+-+-+-+
229
230 Figure 18: The CC Base Object
231*/
232typedef struct stru_rpl_cc_base
233{
235 UINT R : 1;
241
242/*
243The DODAG Configuration option MAY be present in DIO messages, and
244its format is as follows:
245
2460 1 2 3
2470 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
248+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
249| Type = 0x04 |Opt Length = 14| Flags |A| PCS | DIOIntDoubl. |
250+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
251| DIOIntMin. | DIORedun. | MaxRankIncrease |
252+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
253| MinHopRankIncrease | OCP |
254+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
255| Reserved | Def. Lifetime | Lifetime Unit |
256+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257
258Figure 24: Format of the DODAG Configuration Option
259*/
260
262{
266 UINT A : 1;
278#define RPL_DODAG_CONFIG_OPTION_SIZE 16 //Bytes
279
280/*
2816.7.7. RPL Target
282
283The RPL Target option MAY be present in DAO messages, and its format
284is as follows:
285
2860 1 2 3
2870 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
288+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
289| Type = 0x05 | Option Length | Flags | Prefix Length |
290+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
291| |
292+ +
293| Target Prefix (Variable Length) |
294. .
295. .
296+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
297
298Figure 25: Format of the RPL Target Option
299*/
300typedef struct stru_rpl_target
301{
#define UINT
Definition: Linux.h:38
#define UINT16
Definition: Linux.h:33
#define UINT8
Definition: Linux.h:31
struct stru_rpl_option * PRPL_OPTION
RPL_CTRL_MSG_CODE
Definition: RPL_Message.h:23
@ Consistency_Check
Definition: RPL_Message.h:32
@ Secure_Destination_Advertisement_Object
Definition: RPL_Message.h:30
@ Destination_Advertisement_Object_Acknowledgment
Definition: RPL_Message.h:27
@ DODAG_Information_Object
Definition: RPL_Message.h:25
@ DODAG_Information_Solicitation
Definition: RPL_Message.h:24
@ Destination_Advertisement_Object
Definition: RPL_Message.h:26
@ Secure_DODAG_Information_Solicitation
Definition: RPL_Message.h:28
@ Secure_DODAG_Information_Object
Definition: RPL_Message.h:29
@ Secure_Destination_Advertisement_Object_Acknowledgment
Definition: RPL_Message.h:31
struct stru_rpl_option RPL_OPTION
struct stru_rpl_dao_base RPL_DAO_BASE
enum_rpl_option_type
Definition: RPL_Message.h:40
@ RPLOPTION_DODAGConfiguration
Definition: RPL_Message.h:45
@ RPLOPTION_DAGMetricsContainer
Definition: RPL_Message.h:43
@ RPLOPTION_RoutingInformation
Definition: RPL_Message.h:44
@ RPLOPTION_PadN
Definition: RPL_Message.h:42
@ RPLOPTION_PrefixInformation
Definition: RPL_Message.h:47
@ RPLOPTION_RPLTARGET
Definition: RPL_Message.h:46
@ RPLOPTION_Pad1
Definition: RPL_Message.h:41
struct stru_rpl_DIS_Base * PRPL_DIS_BASE
struct stru_rpl_target * PRPL_TARGET_OPTION
struct stru_rpl_dio_base * PRPL_DIO_BASE
struct stru_rpl_ctrl_message RPL_CTRL_MSG
struct stru_rpl_ctrl_message * PRPL_CTRL_MSG
struct stru_rpl_dao_base * PRPL_DAO_BASE
struct stru_dodag_config_option RPL_DODAG_CONFIG_OPTION
struct stru_dodag_config_option * PRPL_DODAG_CONFIG_OPTION
struct stru_rpl_cc_base * PRPL_CC_BASE
struct stru_rpl_dio_base RPL_DIO_BASE
struct stru_rpl_target RPL_TARGET_OPTION
struct stru_rpl_dao_ack_base RPL_DAOACK_BASE
struct stru_rpl_dao_ack_base * PRPL_DAOACK_BASE
enum enum_rpl_option_type RPL_OPTION_TYPE
struct stru_rpl_cc_base RPL_CC_BASE
struct stru_rpl_DIS_Base RPL_DIS_BASE
PRPL_OPTION * options
Definition: RPL_Message.h:80
NETSIM_IPAddress DODAGID
Definition: RPL_Message.h:174
NETSIM_IPAddress DODAGID
Definition: RPL_Message.h:143
RPL_OPTION_TYPE type
Definition: RPL_Message.h:51
NETSIM_IPAddress Traget_Prefix
Definition: RPL_Message.h:306