forked from osmocom/wireshark
802.11: clean up data frame handling.
Change
case DATA_FRAME:
if (condition) {
do stuff;
break;
}
do other stuff;
break;
to
case DATA_FRAME:
if (condition) {
do stuff;
} else {
do other stuff;
}
break;
to make it clearer that it's "do this if condition is true, else do
that".
(cherry picked from commit 258fb14821
)
This commit is contained in:
parent
d73b87e52a
commit
127f8e47ee
|
@ -26708,79 +26708,78 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo,
|
||||||
call_dissector(llc_handle, msdu_tvb, pinfo, subframe_tree);
|
call_dissector(llc_handle, msdu_tvb, pinfo, subframe_tree);
|
||||||
msdu_offset = roundup2(msdu_offset+msdu_length, 4);
|
msdu_offset = roundup2(msdu_offset+msdu_length, 4);
|
||||||
} while (tvb_reported_length_remaining(next_tvb, msdu_offset) > 14);
|
} while (tvb_reported_length_remaining(next_tvb, msdu_offset) > 14);
|
||||||
|
} else {
|
||||||
|
/* I guess some bridges take Netware Ethernet_802_3 frames,
|
||||||
|
which are 802.3 frames (with a length field rather than
|
||||||
|
a type field, but with no 802.2 header in the payload),
|
||||||
|
and just stick the payload into an 802.11 frame. I've seen
|
||||||
|
captures that show frames of that sort.
|
||||||
|
|
||||||
break;
|
We also handle some odd form of encapsulation in which a
|
||||||
}
|
complete Ethernet frame is encapsulated within an 802.11
|
||||||
/* I guess some bridges take Netware Ethernet_802_3 frames,
|
data frame, with no 802.2 header. This has been seen
|
||||||
which are 802.3 frames (with a length field rather than
|
from some hardware.
|
||||||
a type field, but with no 802.2 header in the payload),
|
|
||||||
and just stick the payload into an 802.11 frame. I've seen
|
|
||||||
captures that show frames of that sort.
|
|
||||||
|
|
||||||
We also handle some odd form of encapsulation in which a
|
On top of that, at least at some point it appeared that
|
||||||
complete Ethernet frame is encapsulated within an 802.11
|
the OLPC XO sent out frames with two bytes of 0 between
|
||||||
data frame, with no 802.2 header. This has been seen
|
the "end" of the 802.11 header and the beginning of
|
||||||
from some hardware.
|
the payload. Something similar has also been observed
|
||||||
|
with Atheros chipsets. There the sequence control field
|
||||||
|
seems repeated.
|
||||||
|
|
||||||
On top of that, at least at some point it appeared that
|
So, if the packet doesn't start with 0xaa 0xaa:
|
||||||
the OLPC XO sent out frames with two bytes of 0 between
|
|
||||||
the "end" of the 802.11 header and the beginning of
|
|
||||||
the payload. Something similar has also been observed
|
|
||||||
with Atheros chipsets. There the sequence control field
|
|
||||||
seems repeated.
|
|
||||||
|
|
||||||
So, if the packet doesn't start with 0xaa 0xaa:
|
we first use the same scheme that linux-wlan-ng does to detect
|
||||||
|
those encapsulated Ethernet frames, namely looking to see whether
|
||||||
|
the frame either starts with 6 octets that match the destination
|
||||||
|
address from the 802.11 header or has 6 octets that match the
|
||||||
|
source address from the 802.11 header following the first 6 octets,
|
||||||
|
and, if so, treat it as an encapsulated Ethernet frame;
|
||||||
|
|
||||||
we first use the same scheme that linux-wlan-ng does to detect
|
otherwise, we use the same scheme that we use in the Ethernet
|
||||||
those encapsulated Ethernet frames, namely looking to see whether
|
dissector to recognize Netware 802.3 frames, namely checking
|
||||||
the frame either starts with 6 octets that match the destination
|
whether the packet starts with 0xff 0xff and, if so, treat it
|
||||||
address from the 802.11 header or has 6 octets that match the
|
as an encapsulated IPX frame, and then check whether the
|
||||||
source address from the 802.11 header following the first 6 octets,
|
packet starts with 0x00 0x00 and, if so, treat it as an OLPC
|
||||||
and, if so, treat it as an encapsulated Ethernet frame;
|
frame, or check the packet starts with the repetition of the
|
||||||
|
sequence control field and, if so, treat it as an Atheros frame. */
|
||||||
otherwise, we use the same scheme that we use in the Ethernet
|
heur_dtbl_entry_t *hdtbl_entry;
|
||||||
dissector to recognize Netware 802.3 frames, namely checking
|
if (dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
|
||||||
whether the packet starts with 0xff 0xff and, if so, treat it
|
pinfo->fragmented = save_fragmented;
|
||||||
as an encapsulated IPX frame, and then check whether the
|
goto end_of_wlan; /* heuristics dissector handled it. */
|
||||||
packet starts with 0x00 0x00 and, if so, treat it as an OLPC
|
}
|
||||||
frame, or check the packet starts with the repetition of the
|
encap_type = ENCAP_802_2;
|
||||||
sequence control field and, if so, treat it as an Atheros frame. */
|
if (tvb_bytes_exist(next_tvb, 0, 2)) {
|
||||||
heur_dtbl_entry_t *hdtbl_entry;
|
octet1 = tvb_get_guint8(next_tvb, 0);
|
||||||
if (dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
|
octet2 = tvb_get_guint8(next_tvb, 1);
|
||||||
pinfo->fragmented = save_fragmented;
|
if ((octet1 != 0xaa) || (octet2 != 0xaa)) {
|
||||||
goto end_of_wlan; /* heuristics dissector handled it. */
|
if ((tvb_memeql(next_tvb, 6, (const guint8 *)pinfo->dl_src.data, 6) == 0) ||
|
||||||
}
|
(tvb_memeql(next_tvb, 0, (const guint8 *)pinfo->dl_dst.data, 6) == 0))
|
||||||
encap_type = ENCAP_802_2;
|
encap_type = ENCAP_ETHERNET;
|
||||||
if (tvb_bytes_exist(next_tvb, 0, 2)) {
|
else if ((octet1 == 0xff) && (octet2 == 0xff))
|
||||||
octet1 = tvb_get_guint8(next_tvb, 0);
|
encap_type = ENCAP_IPX;
|
||||||
octet2 = tvb_get_guint8(next_tvb, 1);
|
else if (((octet1 == 0x00) && (octet2 == 0x00)) ||
|
||||||
if ((octet1 != 0xaa) || (octet2 != 0xaa)) {
|
(((octet2 << 8) | octet1) == seq_control)) {
|
||||||
if ((tvb_memeql(next_tvb, 6, (const guint8 *)pinfo->dl_src.data, 6) == 0) ||
|
proto_tree_add_item(tree, hf_ieee80211_mysterious_olpc_stuff, next_tvb, 0, 2, ENC_NA);
|
||||||
(tvb_memeql(next_tvb, 0, (const guint8 *)pinfo->dl_dst.data, 6) == 0))
|
next_tvb = tvb_new_subset_remaining(next_tvb, 2);
|
||||||
encap_type = ENCAP_ETHERNET;
|
}
|
||||||
else if ((octet1 == 0xff) && (octet2 == 0xff))
|
|
||||||
encap_type = ENCAP_IPX;
|
|
||||||
else if (((octet1 == 0x00) && (octet2 == 0x00)) ||
|
|
||||||
(((octet2 << 8) | octet1) == seq_control)) {
|
|
||||||
proto_tree_add_item(tree, hf_ieee80211_mysterious_olpc_stuff, next_tvb, 0, 2, ENC_NA);
|
|
||||||
next_tvb = tvb_new_subset_remaining(next_tvb, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch (encap_type) {
|
switch (encap_type) {
|
||||||
|
|
||||||
case ENCAP_802_2:
|
case ENCAP_802_2:
|
||||||
call_dissector(llc_handle, next_tvb, pinfo, tree);
|
call_dissector(llc_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENCAP_ETHERNET:
|
case ENCAP_ETHERNET:
|
||||||
call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
|
call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENCAP_IPX:
|
case ENCAP_IPX:
|
||||||
call_dissector(ipx_handle, next_tvb, pinfo, tree);
|
call_dissector(ipx_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue