]> The Tcpdump Group git mirrors - tcpdump/blob - rpl.h
added RPL decode for DAO and DAOACK, refactor out option printer
[tcpdump] / rpl.h
1 #ifndef _RPL_H_
2
3 /*
4 * NOTE: the contents of this file are an interpretation of RFC6550.
5 * no copyright is asserted on this file, as it transcribes
6 * a public specification.
7 *
8 */
9
10 #define PACKED __attribute__((packed))
11
12 /*
13 * DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
14 */
15
16 #define ND_RPL_MESSAGE 155 /* 0x9B */
17
18 enum ND_RPL_CODE {
19 ND_RPL_DAG_IS=0x00,
20 ND_RPL_DAG_IO=0x01,
21 ND_RPL_DAO =0x02,
22 ND_RPL_DAO_ACK=0x03,
23 ND_RPL_SEC_DAG_IS = 0x80,
24 ND_RPL_SEC_DAG_IO = 0x81,
25 ND_RPL_SEC_DAG = 0x82,
26 ND_RPL_SEC_DAG_ACK= 0x83,
27 ND_RPL_SEC_CONSIST= 0x84,
28 };
29
30 enum ND_RPL_DIO_FLAGS {
31 ND_RPL_DIO_GROUNDED = 0x80,
32 ND_RPL_DIO_DATRIG = 0x40,
33 ND_RPL_DIO_DASUPPORT= 0x20,
34 ND_RPL_DIO_RES4 = 0x10,
35 ND_RPL_DIO_RES3 = 0x08,
36 ND_RPL_DIO_PRF_MASK = 0x07, /* 3-bit preference */
37 };
38
39 #define DAGID_LEN 16
40
41 /* section 6 of draft-ietf-roll-rpl-19 */
42 struct nd_rpl_security {
43 u_int8_t rpl_sec_t_reserved; /* bit 7 is T-bit */
44 u_int8_t rpl_sec_algo;
45 u_int16_t rpl_sec_kim_lvl_flags; /* bit 15/14, KIM */
46 /* bit 10-8, LVL, bit 7-0 flags */
47 u_int32_t rpl_sec_counter;
48 u_int8_t rpl_sec_ki[0]; /* depends upon kim */
49 } PACKED;
50
51 /* section 6.2.1, DODAG Information Solication (DIS_IS) */
52 struct nd_rpl_dis_is {
53 u_int8_t rpl_dis_flags;
54 u_int8_t rpl_dis_reserved;
55 u_int8_t rpl_dis_options[0];
56 } PACKED;
57
58 /* section 6.3.1, DODAG Information Object (DIO) */
59 struct nd_rpl_dio {
60 u_int8_t rpl_instanceid;
61 u_int8_t rpl_version;
62 u_int16_t rpl_dagrank;
63 u_int8_t rpl_mopprf; /* bit 7=G, 5-3=MOP, 2-0=PRF */
64 u_int8_t rpl_dtsn; /* Dest. Advertisement Trigger Sequence Number */
65 u_int8_t rpl_flags; /* no flags defined yet */
66 u_int8_t rpl_resv1;
67 u_int8_t rpl_dagid[DAGID_LEN];
68 } PACKED;
69 #define RPL_DIO_GROUND_FLAG 0x80
70 #define RPL_DIO_MOP_SHIFT 3
71 #define RPL_DIO_MOP_MASK (7 << RPL_DIO_MOP_SHIFT)
72 #define RPL_DIO_PRF_SHIFT 0
73 #define RPL_DIO_PRF_MASK (7 << RPL_DIO_PRF_SHIFT)
74 #define RPL_DIO_GROUNDED(X) ((X)&RPL_DIO_GROUND_FLAG)
75 #define RPL_DIO_MOP(X) (enum RPL_DIO_MOP)(((X)&RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT)
76 #define RPL_DIO_PRF(X) (((X)&RPL_DIO_PRF_MASK) >> RPL_DIO_PRF_SHIFT)
77
78 enum RPL_DIO_MOP {
79 RPL_DIO_NONSTORING= 0x0,
80 RPL_DIO_STORING = 0x1,
81 RPL_DIO_NONSTORING_MULTICAST = 0x2,
82 RPL_DIO_STORING_MULTICAST = 0x3,
83 };
84
85 enum RPL_SUBOPT {
86 RPL_OPT_PAD0 = 0,
87 RPL_OPT_PADN = 1,
88 RPL_DIO_METRICS = 2,
89 RPL_DIO_ROUTINGINFO = 3,
90 RPL_DIO_CONFIG = 4,
91 RPL_DAO_RPLTARGET = 5,
92 RPL_DAO_TRANSITINFO = 6,
93 RPL_DIO_DESTPREFIX = 8,
94 RPL_DAO_RPLTARGET_DESC=9,
95 };
96
97 struct rpl_dio_genoption {
98 u_int8_t rpl_dio_type;
99 u_int8_t rpl_dio_len; /* suboption length, not including type/len */
100 u_int8_t rpl_dio_data[0];
101 } PACKED;
102
103 #define RPL_DIO_LIFETIME_INFINITE 0xffffffff
104 #define RPL_DIO_LIFETIME_DISCONNECT 0
105
106 struct rpl_dio_destprefix {
107 u_int8_t rpl_dio_type;
108 u_int8_t rpl_dio_len;
109 u_int8_t rpl_dio_prefixlen; /* in bits */
110 u_int8_t rpl_dio_prf; /* flags, including Route Preference */
111 u_int32_t rpl_dio_prefixlifetime; /* in seconds */
112 u_int8_t rpl_dio_prefix[0]; /* variables number of bytes */
113 } PACKED;
114
115 /* section 6.4.1, DODAG Information Object (DIO) */
116 struct nd_rpl_dao {
117 u_int8_t rpl_instanceid;
118 u_int8_t rpl_flags; /* bit 7=K, 6=D */
119 u_int8_t rpl_resv;
120 u_int8_t rpl_daoseq;
121 u_int8_t rpl_dagid[0]; /* [DAGID_LEN] present when D set. */
122 } PACKED;
123
124 /* indicates if this DAO is to be acK'ed */
125 #define RPL_DAO_K_SHIFT 7
126 #define RPL_DAO_K_MASK (1 << RPL_DAO_K_SHIFT)
127 #define RPL_DAO_K(X) (((X)&RPL_DAO_K_MASK) >> RPL_DAO_K_SHIFT)
128
129 /* indicates if the DAGID is present */
130 #define RPL_DAO_D_SHIFT 6
131 #define RPL_DAO_D_MASK (1 << RPL_DAO_D_SHIFT)
132 #define RPL_DAO_D(X) (((X)&RPL_DAO_D_MASK) >> RPL_DAO_D_SHIFT)
133
134 struct rpl_dao_target {
135 u_int8_t rpl_dao_type;
136 u_int8_t rpl_dao_len;
137 u_int8_t rpl_dao_flags; /* unused */
138 u_int8_t rpl_dao_prefixlen; /* in bits */
139 u_int8_t rpl_dao_prefix[0]; /* variables number of bytes */
140 } PACKED;
141
142 /* section 6.5.1, Destination Advertisement Object Acknowledgement (DAO-ACK) */
143 struct nd_rpl_daoack {
144 u_int8_t rpl_instanceid;
145 u_int8_t rpl_flags; /* bit 7=D */
146 u_int8_t rpl_daoseq;
147 u_int8_t rpl_status;
148 u_int8_t rpl_dagid[0]; /* [DAGID_LEN] present when D set. */
149 } PACKED;
150 /* indicates if the DAGID is present */
151 #define RPL_DAOACK_D_SHIFT 7
152 #define RPL_DAOACK_D_MASK (1 << RPL_DAOACK_D_SHIFT)
153 #define RPL_DAOACK_D(X) (((X)&RPL_DAOACK_D_MASK) >> RPL_DAOACK_D_SHIFT)
154
155
156
157 #define _RPL_H_
158 #endif /* _RPL_H_ */
159
160 /*
161 * Local Variables:
162 * c-basic-offset:4
163 * c-style: whitesmith
164 * End:
165 */
166