summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorOlivier Dufour2013-03-14 15:20:30 +0100
committerOlivier Dufour2013-03-21 11:20:15 +0100
commit8cdcbf05fabf797231f98c2224b6ee6f299fca91 (patch)
tree3b085cb265d1564e618a7b267e14645e62832b7b /common
parentf3394a1965588a5977bc5fab6e4f079bd9390a53 (diff)
common/lib/scammer: handle MME answer, closes #3821
We need to define answers method to allow scapy send/receive functions to detect MME answer. A REQ/IND MME is not an answer, a CNF/RSP MME is an answer if the sent packet has the corresponding REQ/IND mmtype. If the criteria ans.mmtype == req.mmtype + 1 is not enough, the answers method in the MMEPayload child class can be implemented.
Diffstat (limited to 'common')
-rw-r--r--common/lib/scammer/scammer.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/lib/scammer/scammer.py b/common/lib/scammer/scammer.py
index c4ebdb42be..cff1e0078b 100644
--- a/common/lib/scammer/scammer.py
+++ b/common/lib/scammer/scammer.py
@@ -29,6 +29,16 @@ class MME (Packet):
ConditionalField (XByteField("fmsn", 0), lambda p:p.mmv==0x1),
]
+ def answers(self, other):
+ # Only CNF or RSP MME can be answers.
+ mmsubtype = self.mmtype & 0x03
+ if mmsubtype == 0x01 or mmsubtype == 0x03:
+ # If other is the REQ/IND corresponding to the CNF/RSP, ask the
+ # payload for further information.
+ if self.mmtype == (other.mmtype + 1):
+ return self.payload.answers(other.payload)
+ return 0
+
bind_layers (Ether, MME, type = ETHER_TYPES['HPAV'])
class MMEPayload (Packet):
@@ -39,6 +49,11 @@ class MMEPayload (Packet):
if cls.__name__ in HPAV_MMTYPES:
bind_layers (MME, cls, mmtype = HPAV_MMTYPES[cls.__name__])
+ # Called by MME.answers. Default behavior is always true, override it for
+ # specific MME needs.
+ def answers(self, other):
+ return 1
+
def get_sniffed_mme (mme):
"""Get the MME embedded in the VS_SNIFFER.IND."""
assert mme.mmtype == HPAV_MMTYPES['VS_SNIFFER_IND']