Change in mncc-python[master]: mncc_sock.py: share common send() / receive() calls

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Sep 30 12:30:38 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/11154 )

Change subject: mncc_sock.py: share common send() / receive() calls
......................................................................

mncc_sock.py: share common send() / receive() calls

Change-Id: I871c72c8e3392a1be76e0126a24b3bc9a787113d
---
M mncc_sock.py
1 file changed, 6 insertions(+), 19 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved; Verified



diff --git a/mncc_sock.py b/mncc_sock.py
index 34ab361..9887471 100644
--- a/mncc_sock.py
+++ b/mncc_sock.py
@@ -15,45 +15,32 @@
 import mncc
 import ctypes
 
-class mncc_msg(mncc.gsm_mncc):
+class mncc_msg_common:
     def send(self):
         return buffer(self)[:]
     def receive(self, bytes):
         fit = min(len(bytes), ctypes.sizeof(self))
         ctypes.memmove(ctypes.addressof(self), bytes, fit)
+
+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)
     def __unicode__(self):
         return u'mncc_msg(type=0x%04x, callref=%u, fields=0x%04x)' % (self.msg_type, self.callref, self.fields)
 
-class mncc_hello_msg(mncc.gsm_mncc_hello):
-    def send(self):
-        return buffer(self)[:]
-    def receive(self, bytes):
-        fit = min(len(bytes), ctypes.sizeof(self))
-        ctypes.memmove(ctypes.addressof(self), bytes, fit)
+class mncc_hello_msg(mncc.gsm_mncc_hello, mncc_msg_common):
     def __str__(self):
         return 'mncc_hello_msg(version=0x%04x)' % (self.version)
     def __unicode__(self):
         return u'mncc_hello_msg(version=0x%04x)' % (self.version)
 
-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)
+class mncc_rtp_msg(mncc.gsm_mncc_rtp, mncc_msg_common):
     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)
 
-class mncc_bridge_msg(mncc.gsm_mncc_bridge):
-    def send(self):
-        return buffer(self)[:]
-    def receive(self, bytes):
-        fit = min(len(bytes), ctypes.sizeof(self))
-        ctypes.memmove(ctypes.addressof(self), bytes, fit)
+class mncc_bridge_msg(mncc.gsm_mncc_bridge, mncc_msg_common):
     def __str__(self):
         return 'mncc_bridge_msg(%u, %u)' % (self.callref[0], self.callref[1])
     def __unicode__(self):

-- 
To view, visit https://gerrit.osmocom.org/11154
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: mncc-python
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I871c72c8e3392a1be76e0126a24b3bc9a787113d
Gerrit-Change-Number: 11154
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180930/63b15d2f/attachment.htm>


More information about the gerrit-log mailing list