HACK: Bump MNCC_SOCK_VERSION to 6

Update mncc.h, but to not have to figure out ctypes generation and still be
MNCC v6 compatible, simply add a single SDP byte of '\0' to sent buffers, so
that an MNCC v6 MSC doesn't complain about a too short MNCC message.

Sending no SDP is compliant, and sending a single '\0' is the specified proper
way to do so, but we're achieving it in a hacky way.

To accept incoming MNCC v6: allow trailing data

Related: osmo-sip-connector I522ce7f206932a816a64f03d916799c3215bb8c7
This commit is contained in:
Oliver Smith 2020-03-04 17:08:50 +01:00 committed by Neels Hofmeyr
parent b93472b534
commit a000551a40
3 changed files with 8 additions and 4 deletions

6
mncc.h
View File

@ -265,6 +265,9 @@ struct gsm_mncc {
unsigned char lchan_type;
unsigned char lchan_mode;
/* A buffer to contain SDP ('\0' terminated) */
char sdp[1024];
};
struct gsm_data_frame {
@ -273,7 +276,7 @@ struct gsm_data_frame {
unsigned char data[0];
};
#define MNCC_SOCK_VERSION 5
#define MNCC_SOCK_VERSION 6
struct gsm_mncc_hello {
uint32_t msg_type;
uint32_t version;
@ -296,6 +299,7 @@ struct gsm_mncc_rtp {
uint16_t port;
uint32_t payload_type;
uint32_t payload_msg_type;
char sdp[1024];
};
struct gsm_mncc_bridge {

View File

@ -244,7 +244,7 @@ __USE_ATFILE = 1 # Variable c_int '1'
MNCC_START_DTMF_REJ = 279 # Variable c_int '279'
INT_LEAST16_MAX = 32767 # Variable c_int '32767'
MNCC_SETUP_COMPL_IND = 262 # Variable c_int '262'
MNCC_SOCK_VERSION = 5 # Variable c_int '5'
MNCC_SOCK_VERSION = 6 # Variable c_int '6'
INTMAX_MIN = -9223372036854775808 # Variable c_long '-0x08000000000000000l'
INT32_MAX = 2147483647 # Variable c_int '2147483647'
INTMAX_MAX = 9223372036854775807 # Variable c_long '9223372036854775807l'

View File

@ -17,7 +17,7 @@ import ctypes
class mncc_msg_common:
def send(self):
return buffer(self)[:]
return buffer(self)[:] + bytes('\0')
def receive(self, bytes):
fit = min(len(bytes), ctypes.sizeof(self))
ctypes.memmove(ctypes.addressof(self), bytes, fit)
@ -142,7 +142,7 @@ class MnccSocket(MnccSocketBase):
'(0x%04x vs 0x%04x)\n' % (msg.version, mncc.MNCC_SOCK_VERSION))
# Match expected message sizes / offsets
if (msg.mncc_size != ctypes.sizeof(mncc.gsm_mncc) or
if (msg.mncc_size < ctypes.sizeof(mncc.gsm_mncc) or
msg.data_frame_size != ctypes.sizeof(mncc.gsm_data_frame) or
msg.called_offset != mncc.gsm_mncc.called.offset or
msg.signal_offset != mncc.gsm_mncc.signal.offset or