This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/10619 ) Change subject: X-Osmo-IGN: rather parse items by token, not char ...................................................................... X-Osmo-IGN: rather parse items by token, not char Adjust the X-Osmo-IGN parsing to use string tokens instead of parsing single characters. Reconsidering the first implementation as a poor choice, rather specify the format of X-Osmo-IGN as any-length string tokens separated by spaces, which is more flexible and more future proof. See also osmo-gsm-manuals If15a88c3b5b40fd1d24ad0f94f3231f678669ab1 which defines the X-Osmo-IGN format as string tokens, matching this patch. In mgcp_test, add an unknown X-Osmo-IGN item. Though the output is not checked by the testsuite.at, running manually shows the error log about the unkown X-Osmo-IGN item. Change-Id: Ia6fe5ead4b601931c1bf41b29fc1b237aac37d2c --- M src/libosmo-mgcp/mgcp_protocol.c M tests/mgcp/mgcp_test.c M tests/mgcp/mgcp_test.ok 3 files changed, 28 insertions(+), 17 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index cb2c965..7f4a7b8 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -674,6 +674,30 @@ return 534; } +static bool parse_x_osmo_ign(struct mgcp_endpoint *endp, char *line) +{ + char *saveptr = NULL; + + if (strncmp(line, MGCP_X_OSMO_IGN_HEADER, strlen(MGCP_X_OSMO_IGN_HEADER))) + return false; + line += strlen(MGCP_X_OSMO_IGN_HEADER); + + while (1) { + char *token = strtok_r(line, " ", &saveptr); + line = NULL; + if (!token) + break; + + if (!strcmp(token, "C")) + endp->x_osmo_ign |= MGCP_X_OSMO_IGN_CALLID; + else + LOGP(DLMGCP, LOGL_ERROR, "endpoint %x: received unknown X-Osmo-IGN item '%s'\n", + ENDPOINT_NUMBER(endp), token); + } + + return true; +} + /* CRCX command handler, processes the received command */ static struct msgb *handle_create_con(struct mgcp_parse_data *p) { @@ -723,22 +747,9 @@ break; } - /* Parse X-Osmo-IGN header */ - if (!strncmp(line, MGCP_X_OSMO_IGN_HEADER, - strlen(MGCP_X_OSMO_IGN_HEADER))) { - int i; - int line_len = strlen(line); - for (i = strlen(MGCP_X_OSMO_IGN_HEADER); i < line_len; i++) { - switch (line[i]) { - case 'C': - endp->x_osmo_ign |= MGCP_X_OSMO_IGN_CALLID; - break; - default: - break; - } - } + if (parse_x_osmo_ign(endp, line)) break; - } + /* Ignore unknown X-headers */ break; case '\0': diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c index 2d1e28a..f8f701e 100644 --- a/tests/mgcp/mgcp_test.c +++ b/tests/mgcp/mgcp_test.c @@ -314,7 +314,7 @@ "M: recvonly\r\n" \ "C: 2\r\n" \ "L: p:20\r\n" \ - "X-Osmo-IGN: C\r\n" \ + "X-Osmo-IGN: C foo\r\n" \ "\r\n" \ "v=0\r\n" \ "c=IN IP4 123.12.12.123\r\n" \ diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok index bdaf5d7..fcad85a 100644 --- a/tests/mgcp/mgcp_test.ok +++ b/tests/mgcp/mgcp_test.ok @@ -427,7 +427,7 @@ M: recvonly C: 2 L: p:20 -X-Osmo-IGN: C +X-Osmo-IGN: C foo v=0 c=IN IP4 123.12.12.123 -- To view, visit https://gerrit.osmocom.org/10619 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Ia6fe5ead4b601931c1bf41b29fc1b237aac37d2c Gerrit-Change-Number: 10619 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180828/d1c2b6d9/attachment.htm>