Skip to content

Commit e5db29f

Browse files
authored
Merge pull request #924 from gokulkumar792/print_meshid
IEEE 802.11: include the "Mesh ID" field while printing management frames
2 parents dcae3b0 + 34f0181 commit e5db29f

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

print-802_11.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ struct tim_t {
236236
uint8_tbitmap[251];
237237
};
238238

239+
struct meshid_t {
240+
u_intlength;
241+
u_charmeshid[33]; /* 32 + 1 for null */
242+
};
243+
239244
#defineE_SSID0
240245
#defineE_RATES1
241246
#defineE_FH2
@@ -260,6 +265,7 @@ struct tim_t {
260265
/* reserved 19 */
261266
/* reserved 16 */
262267
/* reserved 16 */
268+
#define E_MESHID114
263269

264270

265271
struct mgmt_body_t {
@@ -287,6 +293,8 @@ struct mgmt_body_t {
287293
struct fh_tfh;
288294
inttim_present;
289295
struct tim_ttim;
296+
intmeshid_present;
297+
struct meshid_tmeshid;
290298
};
291299

292300
struct ctrl_control_wrapper_hdr_t {
@@ -420,6 +428,13 @@ struct meshcntl_t {
420428
ND_PRINT("%s", \
421429
CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "");
422430

431+
#define PRINT_MESHID(p) \
432+
if (p.meshid_present) { \
433+
ND_PRINT(" (MESHID: "); \
434+
fn_print_str(ndo, p.meshid.meshid); \
435+
ND_PRINT(")"); \
436+
}
437+
423438
#define MAX_MCS_INDEX76
424439

425440
/*
@@ -1138,6 +1153,7 @@ parse_elements(netdissect_options *ndo,
11381153
struct ds_t ds;
11391154
struct cf_t cf;
11401155
struct tim_t tim;
1156+
struct meshid_t meshid;
11411157

11421158
/*
11431159
* We haven't seen any elements yet.
@@ -1148,6 +1164,7 @@ parse_elements(netdissect_options *ndo,
11481164
pbody->ds_present = 0;
11491165
pbody->cf_present = 0;
11501166
pbody->tim_present = 0;
1167+
pbody->meshid_present = 0;
11511168

11521169
while (length != 0) {
11531170
/* Make sure we at least have the element ID and length. */
@@ -1336,6 +1353,30 @@ parse_elements(netdissect_options *ndo,
13361353
pbody->tim_present = 1;
13371354
}
13381355
break;
1356+
case E_MESHID:
1357+
meshid.length = elementlen;
1358+
offset += 2;
1359+
length -= 2;
1360+
if (meshid.length != 0) {
1361+
if (meshid.length > sizeof(meshid.meshid) - 1)
1362+
return 0;
1363+
memcpy(&meshid.meshid, p + offset, meshid.length);
1364+
offset += meshid.length;
1365+
length -= meshid.length;
1366+
}
1367+
meshid.meshid[meshid.length] = '\0';
1368+
/*
1369+
* Present and not truncated.
1370+
*
1371+
* If we haven't already seen a MESHID IE,
1372+
* copy this one, otherwise ignore this one,
1373+
* so we later report the first one we saw.
1374+
*/
1375+
if (!pbody->meshid_present) {
1376+
pbody->meshid = meshid;
1377+
pbody->meshid_present = 1;
1378+
}
1379+
break;
13391380
default:
13401381
#if 0
13411382
ND_PRINT("(1) unhandled element_id (%u) ",
@@ -1389,6 +1430,7 @@ handle_beacon(netdissect_options *ndo,
13891430
ND_PRINT(" %s",
13901431
CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS");
13911432
PRINT_DS_CHANNEL(pbody);
1433+
PRINT_MESHID(pbody);
13921434

13931435
return ret;
13941436
trunc:
@@ -1553,6 +1595,7 @@ handle_probe_response(netdissect_options *ndo,
15531595
PRINT_SSID(pbody);
15541596
PRINT_RATES(pbody);
15551597
PRINT_DS_CHANNEL(pbody);
1598+
PRINT_MESHID(pbody);
15561599

15571600
return ret;
15581601
trunc:

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ scps_invalid scps_invalid.pcap scps_invalid.out
270270
# IEEE 802.11 tests
271271
802.11_exthdr ieee802.11_exthdr.pcap ieee802.11_exthdr.out -v
272272
802.11_rx-stbc ieee802.11_rx-stbc.pcap ieee802.11_rx-stbc.out
273+
802.11_meshid ieee802.11_meshid.pcap ieee802.11_meshid.out
273274

274275
# OpenFlow tests
275276
of10_p3295-vv of10_p3295.pcap of10_p3295-vv.out -vv

tests/ieee802.11_meshid.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1 12:20:37.867811 9526800862us tsft 6.0 Mb/s 5745 MHz 11a -34dBm signal [bit 22] Beacon () [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] IBSS CH: 149, PRIVACY (MESHID: 11s-mesh-network)
2+
2 12:20:38.357687 9527290733us tsft 6.0 Mb/s 5745 MHz 11a -38dBm signal [bit 22] Probe Request () [6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit]
3+
3 12:20:38.358276 9527291378us tsft 6.0 Mb/s 5745 MHz 11a -34dBm signal [bit 22] Probe Response () [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] CH: 149, PRIVACY (MESHID: 11s-mesh-network)

tests/ieee802.11_meshid.pcap

823 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)