summaryrefslogtreecommitdiffstats
path: root/src/ctrl
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-10-09 14:09:04 +0200
committerStefan Sperling <ssperling@sysmocom.de>2018-10-15 11:53:20 +0000
commite484d42bf2bdbc4e4add056a6564faa7c856e46b (patch)
tree3b6c930fab57870d79b26abeaca85bb980ad01e0 /src/ctrl
parent4290803d89d129c1eb8b762b9b547e5df6204401 (diff)
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
Diffstat (limited to 'src/ctrl')
-rw-r--r--src/ctrl/control_if.c34
1 files 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;
}