From e484d42bf2bdbc4e4add056a6564faa7c856e46b Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Tue, 9 Oct 2018 14:09:04 +0200 Subject: add support for ipaccess messages on the ctrl interface In ctrl_handle_msg(), check for IPACCESS protocol messages and respond to such messages in the same way as ipa_ccm_rcvmsg_base() does. This will allow the TTCN3 IPA "chopped ping" test to pass on control interfaces. Change-Id: I9d7137c830981ccad03806b30b776e2b1f1b4699 Related: OS#2010 --- src/ctrl/control_if.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index 5962f7eb..ed18a2fc 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -389,20 +389,44 @@ int ctrl_handle_msg(struct ctrl_handle *ctrl, struct ctrl_connection *ccon, stru struct ipaccess_head_ext *iph_ext; int result; - if (msg->len < sizeof(*iph) + sizeof(*iph_ext)) { + if (msg->len < sizeof(*iph)) { LOGP(DLCTRL, LOGL_ERROR, "The message is too short.\n"); return -EINVAL; } - iph = (struct ipaccess_head *) msg->data; + if (iph->proto == IPAC_PROTO_IPACCESS) { + uint8_t msg_type = *(msg->l2h); + switch (msg_type) { + case IPAC_MSGT_PING: + if (ipa_ccm_send_pong(ccon->write_queue.bfd.fd) < 0) + LOGP(DLINP, LOGL_ERROR, "Cannot send PONG message. Reason: %s\n", strerror(errno)); + break; + case IPAC_MSGT_PONG: + break; + case IPAC_MSGT_ID_ACK: + if (ipa_ccm_send_id_ack(ccon->write_queue.bfd.fd) < 0) + LOGP(DLINP, LOGL_ERROR, "Cannot send ID_ACK message. Reason: %s\n", strerror(errno)); + break; + default: + LOGP(DLCTRL, LOGL_DEBUG, "Received unhandled IPACCESS protocol message of type 0x%x: %s\n", + msg_type, msgb_hexdump(msg)); + break; + } + return 0; + } if (iph->proto != IPAC_PROTO_OSMO) { - LOGP(DLCTRL, LOGL_ERROR, "Protocol mismatch. We got 0x%x\n", iph->proto); + LOGP(DLCTRL, LOGL_ERROR, "Protocol mismatch. Received protocol 0x%x message: %s\n", + iph->proto, msgb_hexdump(msg)); + return -EINVAL; + } + if (msg->len < sizeof(*iph) + sizeof(*iph_ext)) { + LOGP(DLCTRL, LOGL_ERROR, "The message is too short.\n"); return -EINVAL; } - iph_ext = (struct ipaccess_head_ext *) iph->data; if (iph_ext->proto != IPAC_PROTO_EXT_CTRL) { - LOGP(DLCTRL, LOGL_ERROR, "Extended protocol mismatch. We got 0x%x\n", iph_ext->proto); + LOGP(DLCTRL, LOGL_ERROR, "Extended protocol mismatch. Received protocol 0x%x message: %s\n", + iph_ext->proto, msgb_hexdump(msg)); return -EINVAL; } -- cgit v1.2.3