aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-09-29 22:17:33 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-09-29 22:23:01 +0700
commit8a8b422dcfebbafbfab1ddedf29b56f7da826369 (patch)
tree428b2f5611c70f0eb9a70efa2a6bb3c527a055f2
parent61a1ecc988394bcae36056bbb477cb984163a3ef (diff)
mncc_sock.py: simplify msg_type matching
-rw-r--r--mncc_sock.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/mncc_sock.py b/mncc_sock.py
index 9887471..1c4f6be 100644
--- a/mncc_sock.py
+++ b/mncc_sock.py
@@ -22,6 +22,11 @@ class mncc_msg_common:
fit = min(len(bytes), ctypes.sizeof(self))
ctypes.memmove(ctypes.addressof(self), bytes, fit)
+ # Message type matching
+ def is_rtp(self):
+ return self.msg_type in (mncc.MNCC_RTP_CREATE,
+ mncc.MNCC_RTP_CONNECT, mncc.MNCC_RTP_FREE)
+
class mncc_msg(mncc.gsm_mncc, mncc_msg_common):
def __str__(self):
return 'mncc_msg(type=0x%04x, callref=%u, fields=0x%04x)' % (self.msg_type, self.callref, self.fields)
@@ -75,7 +80,7 @@ class MnccSocketBase(object):
data = self.sock.recv(1500)
ms = mncc_msg()
ms.receive(data)
- if ms.msg_type == mncc.MNCC_RTP_CREATE or ms.msg_type == mncc.MNCC_RTP_CONNECT or ms.msg_type == mncc.MNCC_RTP_FREE:
+ if ms.is_rtp():
ms = mncc_rtp_msg()
ms.receive(data)
elif ms.msg_type == mncc.MNCC_SOCKET_HELLO: