]> The Tcpdump Group git mirrors - tcpdump/blob - rpl.h
Use EXTRACT_nBITS even when just testing against zero.
[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 #if 0
49 u_int8_t rpl_sec_ki[0]; /* depends upon kim */
50 #endif
51 };
52
53 /* section 6.2.1, DODAG Information Solication (DIS_IS) */
54 struct nd_rpl_dis_is {
55 u_int8_t rpl_dis_flags;
56 u_int8_t rpl_dis_reserved;
57 #if 0
58 u_int8_t rpl_dis_options[0];
59 #endif
60 };
61
62 /* section 6.3.1, DODAG Information Object (DIO) */
63 struct nd_rpl_dio {
64 u_int8_t rpl_instanceid;
65 u_int8_t rpl_version;
66 u_int16_t rpl_dagrank;
67 u_int8_t rpl_mopprf; /* bit 7=G, 5-3=MOP, 2-0=PRF */
68 u_int8_t rpl_dtsn; /* Dest. Advertisement Trigger Sequence Number */
69 u_int8_t rpl_flags; /* no flags defined yet */
70 u_int8_t rpl_resv1;
71 u_int8_t rpl_dagid[DAGID_LEN];
72 };
73 #define RPL_DIO_GROUND_FLAG 0x80
74 #define RPL_DIO_MOP_SHIFT 3
75 #define RPL_DIO_MOP_MASK (7 << RPL_DIO_MOP_SHIFT)
76 #define RPL_DIO_PRF_SHIFT 0
77 #define RPL_DIO_PRF_MASK (7 << RPL_DIO_PRF_SHIFT)
78 #define RPL_DIO_GROUNDED(X) ((X)&RPL_DIO_GROUND_FLAG)
79 #define RPL_DIO_MOP(X) (enum RPL_DIO_MOP)(((X)&RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT)
80 #define RPL_DIO_PRF(X) (((X)&RPL_DIO_PRF_MASK) >> RPL_DIO_PRF_SHIFT)
81
82 enum RPL_DIO_MOP {
83 RPL_DIO_NONSTORING= 0x0,
84 RPL_DIO_STORING = 0x1,
85 RPL_DIO_NONSTORING_MULTICAST = 0x2,
86 RPL_DIO_STORING_MULTICAST = 0x3,
87 };
88
89 enum RPL_SUBOPT {
90 RPL_OPT_PAD0 = 0,
91 RPL_OPT_PADN = 1,
92 RPL_DIO_METRICS = 2,
93 RPL_DIO_ROUTINGINFO = 3,
94 RPL_DIO_CONFIG = 4,
95 RPL_DAO_RPLTARGET = 5,
96 RPL_DAO_TRANSITINFO = 6,
97 RPL_DIO_DESTPREFIX = 8,
98 RPL_DAO_RPLTARGET_DESC=9,
99 };
100
101 struct rpl_dio_genoption {
102 u_int8_t rpl_dio_type;
103 u_int8_t rpl_dio_len; /* suboption length, not including type/len */
104 };
105 #define RPL_DIO_GENOPTION_LEN 2
106
107 #define RPL_DIO_LIFETIME_INFINITE 0xffffffff
108 #define RPL_DIO_LIFETIME_DISCONNECT 0
109
110 struct rpl_dio_destprefix {
111 u_int8_t rpl_dio_type;
112 u_int8_t rpl_dio_len;
113 u_int8_t rpl_dio_prefixlen; /* in bits */
114 u_int8_t rpl_dio_prf; /* flags, including Route Preference */
115 u_int32_t rpl_dio_prefixlifetime; /* in seconds */
116 #if 0
117 u_int8_t rpl_dio_prefix[0]; /* variable number of bytes */
118 #endif
119 };
120
121 /* section 6.4.1, DODAG Information Object (DIO) */
122 struct nd_rpl_dao {
123 u_int8_t rpl_instanceid;
124 u_int8_t rpl_flags; /* bit 7=K, 6=D */
125 u_int8_t rpl_resv;
126 u_int8_t rpl_daoseq;
127 u_int8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
128 };
129 #define ND_RPL_DAO_MIN_LEN 4 /* length without DAGID */
130
131 /* indicates if this DAO is to be acK'ed */
132 #define RPL_DAO_K_SHIFT 7
133 #define RPL_DAO_K_MASK (1 << RPL_DAO_K_SHIFT)
134 #define RPL_DAO_K(X) (((X)&RPL_DAO_K_MASK) >> RPL_DAO_K_SHIFT)
135
136 /* indicates if the DAGID is present */
137 #define RPL_DAO_D_SHIFT 6
138 #define RPL_DAO_D_MASK (1 << RPL_DAO_D_SHIFT)
139 #define RPL_DAO_D(X) (((X)&RPL_DAO_D_MASK) >> RPL_DAO_D_SHIFT)
140
141 struct rpl_dao_target {
142 u_int8_t rpl_dao_type;
143 u_int8_t rpl_dao_len;
144 u_int8_t rpl_dao_flags; /* unused */
145 u_int8_t rpl_dao_prefixlen; /* in bits */
146 #if 0
147 u_int8_t rpl_dao_prefix[0]; /* variable number of bytes */
148 #endif
149 };
150
151 /* section 6.5.1, Destination Advertisement Object Acknowledgement (DAO-ACK) */
152 struct nd_rpl_daoack {
153 u_int8_t rpl_instanceid;
154 u_int8_t rpl_flags; /* bit 7=D */
155 u_int8_t rpl_daoseq;
156 u_int8_t rpl_status;
157 u_int8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
158 };
159 #define ND_RPL_DAOACK_MIN_LEN 4 /* length without DAGID */
160 /* indicates if the DAGID is present */
161 #define RPL_DAOACK_D_SHIFT 7
162 #define RPL_DAOACK_D_MASK (1 << RPL_DAOACK_D_SHIFT)
163 #define RPL_DAOACK_D(X) (((X)&RPL_DAOACK_D_MASK) >> RPL_DAOACK_D_SHIFT)
164
165
166
167 #define _RPL_H_
168 #endif /* _RPL_H_ */
169
170 /*
171 * Local Variables:
172 * c-basic-offset:4
173 * c-style: whitesmith
174 * End:
175 */
176