Initial port from python2 to python3

This is a very crude port, including manual edits to the ctypeslib-generated
mncc.py file.  There's no real clean way to do this, as ctypeslib is
ancient, abandoned and unmaintained.

Change-Id: Ie6ecd37353b35a6ac13c6578585c714c9ab46e06
This commit is contained in:
Harald Welte 2024-03-16 19:40:57 +01:00
parent ec0c3ce444
commit e3d93518bd
5 changed files with 49 additions and 47 deletions

60
mncc.py
View File

@ -383,7 +383,7 @@ SOL_ALG = 279 # Variable c_int '279'
PF_X25 = 9 # Variable c_int '9'
IP_UNICAST_IF = 50 # Variable c_int '50'
IP_RECVERR = 11 # Variable c_int '11'
IN_CLASSA_HOST = 16777215L # Variable c_uint '16777215u'
IN_CLASSA_HOST = 16777215 # Variable c_uint '16777215u'
__time_t_defined = 1 # Variable c_int '1'
INT_LEAST16_MAX = 32767 # Variable c_int '32767'
__NFDBITS = 64 # Variable c_int '64'
@ -428,12 +428,12 @@ SO_INCOMING_NAPI_ID = 56 # Variable c_int '56'
__GLIBC_USE_LIB_EXT2 = 1 # Variable c_int '1'
INET_ADDRSTRLEN = 16 # Variable c_int '16'
SO_DETACH_REUSEPORT_BPF = 68 # Variable c_int '68'
INADDR_BROADCAST = 4294967295L # Variable c_uint '4294967295u'
INADDR_BROADCAST = 4294967295 # Variable c_uint '4294967295u'
WCHAR_WIDTH = 32 # Variable c_int '32'
INTPTR_MIN = -9223372036854775808 # Variable c_long '-0x08000000000000000l'
PF_MPLS = 28 # Variable c_int '28'
_ENDIAN_H = 1 # Variable c_int '1'
INADDR_ALLSNOOPERS_GROUP = 3758096490L # Variable c_uint '3758096490u'
INADDR_ALLSNOOPERS_GROUP = 3758096490 # Variable c_uint '3758096490u'
FIOGETOWN = 35075 # Variable c_int '35075'
MCAST_JOIN_GROUP = 42 # Variable c_int '42'
__USE_FORTIFY_LEVEL = 0 # Variable c_int '0'
@ -450,14 +450,14 @@ SO_DONTROUTE = 5 # Variable c_int '5'
PF_IUCV = 32 # Variable c_int '32'
MNCC_REJ_IND = 296 # Variable c_int '296'
PF_APPLETALK = 5 # Variable c_int '5'
UINTMAX_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
UINTMAX_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
IPV6_PMTUDISC_PROBE = 3 # Variable c_int '3'
PF_VSOCK = 40 # Variable c_int '40'
MNCC_SETUP_COMPL_REQ = 261 # Variable c_int '261'
IPV6_DONTFRAG = 62 # Variable c_int '62'
SOL_PACKET = 263 # Variable c_int '263'
MNCC_START_DTMF_IND = 277 # Variable c_int '277'
UINT_FAST16_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
UINT_FAST16_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
__WORDSIZE = 64 # Variable c_int '64'
UINT_FAST64_WIDTH = 64 # Variable c_int '64'
MNCC_FRAME_DROP = 514 # Variable c_int '514'
@ -465,7 +465,7 @@ SOL_RXRPC = 272 # Variable c_int '272'
INT_FAST8_MIN = -128 # Variable c_int '-0x00000000000000080'
_XOPEN_SOURCE = 700 # Variable c_int '700'
SO_KEEPALIVE = 9 # Variable c_int '9'
WINT_MIN = 0L # Variable c_uint '0u'
WINT_MIN = 0 # Variable c_uint '0u'
__USE_ISOC95 = 1 # Variable c_int '1'
IN_CLASSA_MAX = 128 # Variable c_int '128'
MNCC_ALERT_IND = 267 # Variable c_int '267'
@ -486,7 +486,7 @@ INT_LEAST8_MAX = 127 # Variable c_int '127'
UINT8_MAX = 255 # Variable c_int '255'
SOL_NETBEUI = 267 # Variable c_int '267'
SO_BUSY_POLL = 46 # Variable c_int '46'
IN_CLASSB_HOST = 65535L # Variable c_uint '65535u'
IN_CLASSB_HOST = 65535 # Variable c_uint '65535u'
__USE_XOPEN = 1 # Variable c_int '1'
PF_ROSE = 11 # Variable c_int '11'
IPV6_ADDRFORM = 1 # Variable c_int '1'
@ -506,7 +506,7 @@ IP_PMTUDISC = 10 # Variable c_int '10'
IPV6_2292PKTINFO = 2 # Variable c_int '2'
SO_TIMESTAMPNS_NEW = 64 # Variable c_int '64'
SO_PRIORITY = 12 # Variable c_int '12'
UINT64_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
UINT64_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
SO_INCOMING_CPU = 49 # Variable c_int '49'
IN_CLASSB_MAX = 65536 # Variable c_int '65536'
SO_LINGER = 13 # Variable c_int '13'
@ -537,7 +537,7 @@ __GLIBC_MINOR__ = 32 # Variable c_int '32'
INT64_MIN = -9223372036854775808 # Variable c_long '-0x08000000000000000l'
IPV6_IPSEC_POLICY = 34 # Variable c_int '34'
SO_ZEROCOPY = 60 # Variable c_int '60'
__SOCKADDR_COMMON_SIZE = 2L # Variable c_ulong '2ul'
__SOCKADDR_COMMON_SIZE = 2 # Variable c_ulong '2ul'
__clockid_t_defined = 1 # Variable c_int '1'
SO_ACCEPTCONN = 30 # Variable c_int '30'
IP_MULTICAST_LOOP = 34 # Variable c_int '34'
@ -578,9 +578,9 @@ _DEFAULT_SOURCE = 1 # Variable c_int '1'
_BITS_ENDIAN_H = 1 # Variable c_int '1'
SO_CNX_ADVICE = 53 # Variable c_int '53'
INT8_MIN = -128 # Variable c_int '-0x00000000000000080'
UINT_LEAST64_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
UINT_LEAST64_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
IP_BLOCK_SOURCE = 38 # Variable c_int '38'
UINT_FAST64_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
UINT_FAST64_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
SOL_ATM = 264 # Variable c_int '264'
__SIZEOF_PTHREAD_RWLOCK_T = 56 # Variable c_int '56'
_THREAD_SHARED_TYPES_H = 1 # Variable c_int '1'
@ -615,7 +615,7 @@ SIOCGSTAMPNS_OLD = 35079 # Variable c_int '35079'
PF_LOCAL = 1 # Variable c_int '1'
MNCC_RETRIEVE_CNF = 291 # Variable c_int '291'
MNCC_F_EMERGENCY = 256 # Variable c_int '256'
INADDR_ALLHOSTS_GROUP = 3758096385L # Variable c_uint '3758096385u'
INADDR_ALLHOSTS_GROUP = 3758096385 # Variable c_uint '3758096385u'
MNCC_REJ_REQ = 295 # Variable c_int '295'
IPV6_TCLASS = 67 # Variable c_int '67'
INT_FAST8_MAX = 127 # Variable c_int '127'
@ -629,7 +629,7 @@ MNCC_F_CALLING = 4 # Variable c_int '4'
PF_IB = 27 # Variable c_int '27'
IP_MULTICAST_TTL = 33 # Variable c_int '33'
MNCC_CALL_PROC_REQ = 264 # Variable c_int '264'
WINT_MAX = 4294967295L # Variable c_uint '4294967295u'
WINT_MAX = 4294967295 # Variable c_uint '4294967295u'
SIOCGPGRP = 35076 # Variable c_int '35076'
_BITS_STDINT_UINTN_H = 1 # Variable c_int '1'
IP_ADD_MEMBERSHIP = 35 # Variable c_int '35'
@ -650,7 +650,7 @@ IP_ORIGDSTADDR = 20 # Variable c_int '20'
PF_NFC = 39 # Variable c_int '39'
IPV6_LEAVE_ANYCAST = 28 # Variable c_int '28'
GSM_TCHF_FRAME_EFR = 769 # Variable c_int '769'
IN_CLASSA_NET = 4278190080L # Variable c_uint '4278190080u'
IN_CLASSA_NET = 4278190080 # Variable c_uint '4278190080u'
SOL_TIPC = 271 # Variable c_int '271'
IPV6_MULTICAST_IF = 17 # Variable c_int '17'
MNCC_NOTIFY_IND = 269 # Variable c_int '269'
@ -669,15 +669,15 @@ PF_PPPOX = 24 # Variable c_int '24'
SO_BSDCOMPAT = 14 # Variable c_int '14'
__RLIM_T_MATCHES_RLIM64_T = 1 # Variable c_int '1'
MNCC_DISC_REQ = 270 # Variable c_int '270'
IN_CLASSC_HOST = 255L # Variable c_uint '255u'
IN_CLASSC_HOST = 255 # Variable c_uint '255u'
PF_RXRPC = 33 # Variable c_int '33'
__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = 0 # Variable c_int '0'
UINT_LEAST32_MAX = 4294967295L # Variable c_uint '4294967295u'
UINT_LEAST32_MAX = 4294967295 # Variable c_uint '4294967295u'
__GLIBC_USE_IEC_60559_TYPES_EXT = 1 # Variable c_int '1'
SO_SNDBUF = 7 # Variable c_int '7'
SO_PEEK_OFF = 42 # Variable c_int '42'
WINT_WIDTH = 32 # Variable c_int '32'
UINT32_MAX = 4294967295L # Variable c_uint '4294967295u'
UINT32_MAX = 4294967295 # Variable c_uint '4294967295u'
MNCC_F_PROGRESS = 128 # Variable c_int '128'
MNCC_HOLD_REJ = 289 # Variable c_int '289'
IPV6_UNICAST_HOPS = 16 # Variable c_int '16'
@ -690,7 +690,7 @@ IPV6_RTHDRDSTOPTS = 55 # Variable c_int '55'
IP_FREEBIND = 15 # Variable c_int '15'
__USE_XOPEN2K = 1 # Variable c_int '1'
__FD_SETSIZE = 1024 # Variable c_int '1024'
INADDR_ALLRTRS_GROUP = 3758096386L # Variable c_uint '3758096386u'
INADDR_ALLRTRS_GROUP = 3758096386 # Variable c_uint '3758096386u'
SIOCATMARK = 35077 # Variable c_int '35077'
IPV6_PKTINFO = 50 # Variable c_int '50'
UINTMAX_WIDTH = 64 # Variable c_int '64'
@ -701,14 +701,14 @@ SOL_DCCP = 269 # Variable c_int '269'
SO_NO_CHECK = 11 # Variable c_int '11'
__GLIBC_USE_ISOC2X = 1 # Variable c_int '1'
SOL_ICMPV6 = 58 # Variable c_int '58'
UINTPTR_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
UINTPTR_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
IPV6_ROUTER_ALERT = 22 # Variable c_int '22'
__SIZEOF_PTHREAD_BARRIERATTR_T = 4 # Variable c_int '4'
INT16_MIN = -32768 # Variable c_int '-0x00000000000008000'
MNCC_RETRIEVE_REJ = 292 # Variable c_int '292'
SO_TXTIME = 61 # Variable c_int '61'
UINT8_WIDTH = 8 # Variable c_int '8'
IN_CLASSC_NET = 4294967040L # Variable c_uint '4294967040u'
IN_CLASSC_NET = 4294967040 # Variable c_uint '4294967040u'
INT_LEAST64_MAX = 9223372036854775807 # Variable c_long '9223372036854775807l'
PF_INET = 2 # Variable c_int '2'
IPV6_MULTICAST_HOPS = 18 # Variable c_int '18'
@ -719,7 +719,7 @@ MNCC_RETRIEVE_IND = 290 # Variable c_int '290'
SOL_DECNET = 261 # Variable c_int '261'
PF_KCM = 41 # Variable c_int '41'
MNCC_F_CONNECTED = 16 # Variable c_int '16'
IN_CLASSB_NET = 4294901760L # Variable c_uint '4294901760u'
IN_CLASSB_NET = 4294901760 # Variable c_uint '4294901760u'
_STDINT_H = 1 # Variable c_int '1'
__PTHREAD_MUTEX_HAVE_PREV = 1 # Variable c_int '1'
PF_KEY = 15 # Variable c_int '15'
@ -735,7 +735,7 @@ PF_IEEE802154 = 36 # Variable c_int '36'
SO_TIMESTAMPING_OLD = 37 # Variable c_int '37'
IPV6_CHECKSUM = 7 # Variable c_int '7'
MNCC_USERINFO_IND = 294 # Variable c_int '294'
UINT_FAST32_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
UINT_FAST32_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
SO_SNDTIMEO_NEW = 67 # Variable c_int '67'
IPV6_PMTUDISC_OMIT = 5 # Variable c_int '5'
SIG_ATOMIC_MIN = -2147483648 # Variable c_int '-0x00000000080000000'
@ -762,7 +762,7 @@ _SYS_CDEFS_H = 1 # Variable c_int '1'
MNCC_MODIFY_RSP = 284 # Variable c_int '284'
MNCC_SETUP_RSP = 259 # Variable c_int '259'
SO_PROTOCOL = 38 # Variable c_int '38'
SIZE_MAX = 18446744073709551615L # Variable c_ulong '-1ul'
SIZE_MAX = 18446744073709551615 # Variable c_ulong '-1ul'
UINT_LEAST16_MAX = 65535 # Variable c_int '65535'
SOL_KCM = 281 # Variable c_int '281'
SO_TIMESTAMP_OLD = 29 # Variable c_int '29'
@ -791,7 +791,7 @@ GSM_TCH_FRAME_AMR = 771 # Variable c_int '771'
IP_PMTUDISC_PROBE = 3 # Variable c_int '3'
SO_MAX_PACING_RATE = 47 # Variable c_int '47'
_BITS_UINTN_IDENTITY_H = 1 # Variable c_int '1'
_SS_PADSIZE = 118L # Variable c_ulong '118ul'
_SS_PADSIZE = 118 # Variable c_ulong '118ul'
IP_IPSEC_POLICY = 16 # Variable c_int '16'
MNCC_SOCK_VERSION = 7 # Variable c_int '7'
SCM_TIMESTAMPING_OPT_STATS = 54 # Variable c_int '54'
@ -805,7 +805,7 @@ _ISOC95_SOURCE = 1 # Variable c_int '1'
SO_SNDBUFFORCE = 32 # Variable c_int '32'
_ISOC99_SOURCE = 1 # Variable c_int '1'
MCAST_INCLUDE = 1 # Variable c_int '1'
INADDR_LOOPBACK = 2130706433L # Variable c_uint '2130706433u'
INADDR_LOOPBACK = 2130706433 # Variable c_uint '2130706433u'
PF_PACKET = 17 # Variable c_int '17'
PF_ATMPVC = 8 # Variable c_int '8'
__clock_t_defined = 1 # Variable c_int '1'
@ -823,7 +823,7 @@ MCAST_MSFILTER = 48 # Variable c_int '48'
__BIT_TYPES_DEFINED__ = 1 # Variable c_int '1'
SO_BPF_EXTENSIONS = 48 # Variable c_int '48'
IP_DEFAULT_MULTICAST_TTL = 1 # Variable c_int '1'
INADDR_NONE = 4294967295L # Variable c_uint '4294967295u'
INADDR_NONE = 4294967295 # Variable c_uint '4294967295u'
IPV6_V6ONLY = 26 # Variable c_int '26'
SOMAXCONN = 4096 # Variable c_int '4096'
SO_RXQ_OVFL = 40 # Variable c_int '40'
@ -836,7 +836,7 @@ _SS_SIZE = 128 # Variable c_int '128'
_BITS_SOCKADDR_H = 1 # Variable c_int '1'
MNCC_FRAME_RECV = 513 # Variable c_int '513'
IPV6_ROUTER_ALERT_ISOLATE = 30 # Variable c_int '30'
INADDR_UNSPEC_GROUP = 3758096384L # Variable c_uint '3758096384u'
INADDR_UNSPEC_GROUP = 3758096384 # Variable c_uint '3758096384u'
SOL_RAW = 255 # Variable c_int '255'
_ISOC11_SOURCE = 1 # Variable c_int '1'
IPV6_TRANSPARENT = 75 # Variable c_int '75'
@ -848,7 +848,7 @@ PF_ASH = 18 # Variable c_int '18'
IPV6_2292HOPLIMIT = 8 # Variable c_int '8'
IN_LOOPBACKNET = 127 # Variable c_int '127'
UINT_FAST8_WIDTH = 8 # Variable c_int '8'
INADDR_MAX_LOCAL_GROUP = 3758096639L # Variable c_uint '3758096639u'
INADDR_MAX_LOCAL_GROUP = 3758096639 # Variable c_uint '3758096639u'
SOL_IP = 0 # Variable c_int '0'
IP_XFRM_POLICY = 17 # Variable c_int '17'
SO_PEERGROUPS = 59 # Variable c_int '59'
@ -856,7 +856,7 @@ IN_CLASSA_NSHIFT = 24 # Variable c_int '24'
PF_BRIDGE = 7 # Variable c_int '7'
PF_XDP = 44 # Variable c_int '44'
INT_LEAST32_MIN = -2147483648 # Variable c_int '-0x00000000080000000'
INADDR_ANY = 0L # Variable c_uint '0u'
INADDR_ANY = 0 # Variable c_uint '0u'
_THREAD_MUTEX_INTERNAL_H = 1 # Variable c_int '1'
UINT_LEAST8_MAX = 255 # Variable c_int '255'
MNCC_HOLD_IND = 287 # Variable c_int '287'
@ -891,7 +891,7 @@ IP_TRANSPARENT = 19 # Variable c_int '19'
_LARGEFILE64_SOURCE = 1 # Variable c_int '1'
__OFF_T_MATCHES_OFF64_T = 1 # Variable c_int '1'
IPV6_XFRM_POLICY = 35 # Variable c_int '35'
_SIGSET_NWORDS = 16L # Variable c_ulong '16ul'
_SIGSET_NWORDS = 16 # Variable c_ulong '16ul'
PF_WANPIPE = 25 # Variable c_int '25'
IPV6_RECVTCLASS = 66 # Variable c_int '66'
SO_DOMAIN = 39 # Variable c_int '39'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Python testing tool for establishing mobile-terminated calls using
# the OsmoMSC MNCC interface. It wants to communicate via CTRL with a
@ -16,8 +16,8 @@ RTPSOURCE_CTRL_PORT = 11111
from gsm_call_fsm import GsmCallFsm, GSM48
from mncc_sock import MnccSocket
from thread import start_new_thread
from ctrl import OsmoCtrlSimple
import threading
import pykka
import logging as log
import signal, sys, time
@ -166,7 +166,8 @@ signal.signal(signal.SIGINT, sigint_handler)
# start the MnccSocket and associated pykka actor + rx thread
mncc_sock = MnccSocket()
mncc_act = MnccActor.start(mncc_sock)
start_new_thread(mncc_rx_thread, (mncc_sock,))
rx_t = threading.Thread(target=mncc_rx_thread, args=(mncc_sock,))
rx_t.start()
# connect via CTRL to rtpsource
rtpctrl_act = RtpSourceCtrlActor.start(RTPSOURCE_CTRL_IP, RTPSOURCE_CTRL_PORT)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Python interface to OsmoNITB MNCC (Mobile Network Call Control)
# interface

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Python testing tool for establishing calls via the OsmoNITB MNCC
# interface.
@ -11,7 +11,7 @@
from gsm_call_fsm import GsmCallFsm, GsmCallConnector, GSM48
from mncc_sock import MnccSocket
from thread import start_new_thread
import threading
import pykka
import logging as log
import signal, sys, time
@ -57,7 +57,8 @@ signal.signal(signal.SIGINT, sigint_handler)
# start the MnccSocket and associated pykka actor + rx thread
mncc_sock = MnccSocket()
mncc_act = MnccActor.start(mncc_sock)
start_new_thread(mncc_rx_thread, (mncc_sock,))
rx_t = threading.Thread(target=mncc_rx_thread, args=(mncc_sock,))
rx_t.start()
# convenience wrapper
def connect_call(msisdn_a, msisdn_b, rtp_bridge = True, codecs = GSM48.AllCodecs):
@ -68,16 +69,16 @@ def connect_call(msisdn_a, msisdn_b, rtp_bridge = True, codecs = GSM48.AllCodecs
def calls(nr, ramp=1.0):
if (nr & 1):
print('Only even numbers allowed, because each invocation has two call legs')
return
nr /= 2
return
nr //= 2
for i in range(nr):
a = 90001 + 2*i
b = a + 1
a = str(a)
b = str(b)
print('%d: connect_call(%r, %r)' % (i, a, b))
connect_call(a, b)
time.sleep(ramp)
a = 90001 + 2*i
b = a + 1
a = str(a)
b = str(b)
print('%d: connect_call(%r, %r)' % (i, a, b))
connect_call(a, b)
time.sleep(ramp)
# start a first bogus call

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import logging
import sys