Skip to content
Snippets Groups Projects
Commit e09ebb43 authored by Pierre Lorinquer's avatar Pierre Lorinquer
Browse files

Update following p-l- comments.

The conditions for the tls_data and data fields (in the EAP_TLS and
EAP_FAST classes) were written in a more concise manner.
parent 8bcf817b
No related branches found
No related tags found
No related merge requests found
...@@ -539,12 +539,11 @@ class EAP_MD5(EAP): ...@@ -539,12 +539,11 @@ class EAP_MD5(EAP):
ByteEnumField("code", 1, eap_codes), ByteEnumField("code", 1, eap_codes),
ByteField("id", 0), ByteField("id", 0),
FieldLenField("len", None, fmt="H", length_of="optional_name", FieldLenField("len", None, fmt="H", length_of="optional_name",
adjust=lambda p, x: (x + p.value_size + 6) if p.value_size is not None else 6), adjust=lambda p, x: x + 6 + (p.value_size or 0)),
ByteEnumField("type", 4, eap_types), ByteEnumField("type", 4, eap_types),
FieldLenField("value_size", None, fmt="B", length_of="value"), FieldLenField("value_size", None, fmt="B", length_of="value"),
XStrLenField("value", '', length_from=lambda p: p.value_size), XStrLenField("value", '', length_from=lambda p: p.value_size),
XStrLenField("optional_name", '', XStrLenField("optional_name", '', length_from=lambda p: 0 if p.len is None or p.value_size is None else (p.len - p.value_size - 6))
length_from=lambda p: (p.len - p.value_size - 6) if p.len is not None and p.value_size is not None else 0)
] ]
...@@ -565,8 +564,7 @@ class EAP_TLS(EAP): ...@@ -565,8 +564,7 @@ class EAP_TLS(EAP):
BitField('S', 0, 1), BitField('S', 0, 1),
BitField('reserved', 0, 5), BitField('reserved', 0, 5),
ConditionalField(IntField('tls_message_len', 0), lambda pkt: pkt.L == 1), ConditionalField(IntField('tls_message_len', 0), lambda pkt: pkt.L == 1),
XStrLenField('tls_data', '', XStrLenField('tls_data', '', length_from=lambda pkt: 0 if pkt.len is None else pkt.len - (6 + 4 * pkt.L))
length_from=lambda pkt: pkt.len - 10 if pkt.len is not None and pkt.L == 1 else pkt.len - 6 if pkt.len is not None else 0)
] ]
...@@ -589,8 +587,7 @@ class EAP_FAST(EAP): ...@@ -589,8 +587,7 @@ class EAP_FAST(EAP):
BitField('reserved', 0, 2), BitField('reserved', 0, 2),
BitField('version', 0, 3), BitField('version', 0, 3),
ConditionalField(IntField('message_len', 0), lambda pkt: pkt.L == 1), ConditionalField(IntField('message_len', 0), lambda pkt: pkt.L == 1),
XStrLenField('data', '', XStrLenField('data', '', length_from=lambda pkt: 0 if pkt.len is None else pkt.len - (6 + 4 * pkt.L))
length_from=lambda pkt: pkt.len - 10 if pkt.len is not None and pkt.L == 1 else pkt.len - 6 if pkt.len is not None else 0)
] ]
...@@ -1110,7 +1107,7 @@ bind_layers( CookedLinux, EAPOL, proto=34958) ...@@ -1110,7 +1107,7 @@ bind_layers( CookedLinux, EAPOL, proto=34958)
bind_layers( GRE, LLC, proto=122) bind_layers( GRE, LLC, proto=122)
bind_layers( GRE, Dot1Q, proto=33024) bind_layers( GRE, Dot1Q, proto=33024)
bind_layers( GRE, Dot1AD, type=0x88a8) bind_layers( GRE, Dot1AD, type=0x88a8)
bind_layers( GRE, Ether, proto=1) bind_layers( GRE, Ether, proto=0x6558)
bind_layers( GRE, ARP, proto=2054) bind_layers( GRE, ARP, proto=2054)
bind_layers( GRE, EAPOL, proto=34958) bind_layers( GRE, EAPOL, proto=34958)
bind_layers( GRE, GRErouting, { "routing_present" : 1 } ) bind_layers( GRE, GRErouting, { "routing_present" : 1 } )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment