aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-12-01 23:04:20 +0100
committerHarald Welte <laforge@gnumonks.org>2015-12-01 23:04:20 +0100
commit20523c7fd2477db2b526832690a11ef3db717e08 (patch)
treefd490f7a91ba2788ec67dcf790376e8b02b2f852
parent4f3762e7934aee623e210a52ae96099c688b5153 (diff)
add mncc_rtp_msg() class for RTP messages on MNCC interface
-rw-r--r--gsm_call_fsm.py2
-rw-r--r--mncc_sock.py15
2 files changed, 16 insertions, 1 deletions
diff --git a/gsm_call_fsm.py b/gsm_call_fsm.py
index 73c5978..267d2b4 100644
--- a/gsm_call_fsm.py
+++ b/gsm_call_fsm.py
@@ -5,7 +5,7 @@ import ctypes
import pykka
from fysom import Fysom
-from mncc_sock import mncc_msg, mncc_number
+from mncc_sock import mncc_msg, mncc_number, mncc_rtp_msg
class GsmCallFsm(pykka.ThreadingActor):
last_callref = 0
diff --git a/mncc_sock.py b/mncc_sock.py
index e99ceb2..33a2882 100644
--- a/mncc_sock.py
+++ b/mncc_sock.py
@@ -17,6 +17,18 @@ class mncc_msg(mncc.gsm_mncc):
def __unicode__(self):
return u'mncc_msg(type=0x%04x, callref=%u, fields=0x%04x)' % (self.msg_type, self.callref, self.fields)
+class mncc_rtp_msg(mncc.gsm_mncc_rtp):
+ def send(self):
+ return buffer(self)[:]
+ def receive(self, bytes):
+ fit = min(len(bytes), ctypes.sizeof(self))
+ ctypes.memmove(ctypes.addressof(self), bytes, fit)
+ def __str__(self):
+ return 'mncc_rtp_msg(type=0x%04x, callref=%u, ip=%x, port=%u)' % (self.msg_type, self.callref, self.ip, self.port)
+ def __unicode__(self):
+ return u'mncc_rtp_msg(type=0x%04x, callref=%u, ip=%x, port=%u)' % (self.msg_type, self.callref, self.ip, self.port)
+
+
def mncc_number(number, num_type = 0, num_plan = 0, num_present = 1, num_screen = 0):
return mncc.gsm_mncc_number(number = number, type = num_type,
plan = num_plan, present = num_present,
@@ -42,4 +54,7 @@ class MnccSocket(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:
+ ms = mncc_rtp_msg()
+ ms.receive(data)
return ms