diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2018-09-29 20:33:00 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2018-10-03 18:44:10 +0700 |
commit | b3c78fa1f732f8158aa384b08138a35e3937d0dd (patch) | |
tree | 56bc63adea2df67eee551d08b272b36ea7ce51a2 /src/host/layer23/src/mobile | |
parent | 94cb0b3bf7ae2b2228c1037f9dfd2c4352f00651 (diff) |
mobile/mncc_sock.c: ensure MNCC_SOCKET_HELLO message is sent
This message is used to negotiate MNCC protocol version, and also
in order to make sure that the sutructure alignment is equivalent
for both sides.
Change-Id: I7c5d8aa17540dd61bbe003a6468d97ecea415636
Diffstat (limited to 'src/host/layer23/src/mobile')
-rw-r--r-- | src/host/layer23/src/mobile/mncc_sock.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/mncc_sock.c b/src/host/layer23/src/mobile/mncc_sock.c index d7d56cc0..5d8d2dd1 100644 --- a/src/host/layer23/src/mobile/mncc_sock.c +++ b/src/host/layer23/src/mobile/mncc_sock.c @@ -206,6 +206,38 @@ static int mncc_sock_cb(struct osmo_fd *bfd, unsigned int flags) return rc; } +/* Send a version indication to the remote */ +static void mncc_sock_queue_hello(struct mncc_sock_state *state) +{ + struct gsm_mncc_hello *hello; + struct msgb *msg; + + msg = msgb_alloc(sizeof(*hello), "MNCC_SOCKET_HELLO"); + if (!msg) { + LOGP(DMNCC, LOGL_ERROR, "Failed to allocate MNCC_SOCKET_HELLO\n"); + mncc_sock_close(state); + return; + } + + /* Put header */ + hello = (struct gsm_mncc_hello *) msgb_put(msg, sizeof(*hello)); + hello->msg_type = MNCC_SOCKET_HELLO; + hello->version = MNCC_SOCK_VERSION; + + /* The sizes of some structures */ + hello->mncc_size = sizeof(struct gsm_mncc); + hello->data_frame_size = sizeof(struct gsm_data_frame); + + /* Some offsets */ + hello->called_offset = offsetof(struct gsm_mncc, called); + hello->signal_offset = offsetof(struct gsm_mncc, signal); + hello->emergency_offset = offsetof(struct gsm_mncc, emergency); + hello->lchan_type_offset = offsetof(struct gsm_mncc, lchan_type); + + msgb_enqueue(&state->upqueue, msg); + state->conn_bfd.when |= BSC_FD_WRITE; +} + /* accept a new connection */ static int mncc_sock_accept(struct osmo_fd *bfd, unsigned int flags) { @@ -246,6 +278,9 @@ static int mncc_sock_accept(struct osmo_fd *bfd, unsigned int flags) LOGP(DMNCC, LOGL_NOTICE, "MNCC Socket has connection with external " "call control application\n"); + /* Send HELLO */ + mncc_sock_queue_hello(state); + return 0; } |