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.orgReview at https://gerrit.osmocom.org/3585 osmo_ss7_vty: fix 'as' / 'routing-key' command The VTY definition for this command is flawed and breaks osmo-msc VTY tests. The small problem is a stray '}' in the definition, the bigger problem is that square brackets indicating optional arguments must not enclose more than one argument. Split up the command in several separate definitions with si arg, with ssn arg, with both, and with neither. If si and/or ssn are not passed, set them to zero. See https://lists.osmocom.org/pipermail/openbsc/2017-August/011026.html "optional vty items are stricter than expected" Change-Id: Idc68bfae5457960a9eae5d9648586d6ce719ad68 --- M src/osmo_ss7_vty.c 1 file changed, 58 insertions(+), 31 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/85/3585/1 diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 8d2ec96..5731326 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -778,51 +778,75 @@ { 0, NULL } }; -DEFUN(as_rout_key, as_rout_key_cmd, - "routing-key RCONTEXT DPC [si (aal2|bicc|b-isup|h248|isup|sat-isup|sccp|tup)] [ssn SSN]}", - "Define a routing key\n" - "Routing context number\n" +#define ROUTING_KEY_CMD "routing-key RCONTEXT DPC" +#define ROUTING_KEY_CMD_STRS \ + "Define a routing key\n" \ + "Routing context number\n" \ "Destination Point Code\n" - "Optional Match on Service Indicator\n" - "ATM Adaption Layer 2\n" - "Bearer Independent Call Control\n" - "Broadband ISDN User Part\n" - "H.248\n" - "ISDN User Part\n" - "Sattelite ISDN User Part\n" - "Signalling Connection Control Part\n" +#define ROUTING_KEY_SI_ARG " si (aal2|bicc|b-isup|h248|isup|sat-isup|sccp|tup)" +#define ROUTING_KEY_SI_ARG_STRS \ + "Match on Service Indicator\n" \ + "ATM Adaption Layer 2\n" \ + "Bearer Independent Call Control\n" \ + "Broadband ISDN User Part\n" \ + "H.248\n" \ + "ISDN User Part\n" \ + "Sattelite ISDN User Part\n" \ + "Signalling Connection Control Part\n" \ "Telephony User Part\n" - "Optional Match on Sub-System Number\n" - "Sub-System Number to match on\n") +#define ROUTING_KEY_SSN_ARG " ssn SSN" +#define ROUTING_KEY_SSN_ARG_STRS \ + "Match on Sub-System Number\n" \ + "Sub-System Number to match on\n" + +static int _rout_key(struct vty *vty, + const char *rcontext, const char *dpc, + const char *si, const char *ssn) { struct osmo_ss7_as *as = vty->index; struct osmo_ss7_routing_key *rkey = &as->cfg.routing_key; - int argind; int pc; - pc = osmo_ss7_pointcode_parse(as->inst, argv[1]); + pc = osmo_ss7_pointcode_parse(as->inst, dpc); if (pc < 0) { - vty_out(vty, "Invalid point code (%s)%s", argv[1], VTY_NEWLINE); + vty_out(vty, "Invalid point code (%s)%s", dpc, VTY_NEWLINE); return CMD_WARNING; } - rkey->pc = pc; - rkey->context = atoi(argv[0]); - argind = 2; - if (argind < argc && !strcmp(argv[argind], "si")) { - const char *si_str; - argind++; - si_str = argv[argind++]; - /* parse numeric SI from string */ - rkey->si = get_string_value(mtp_si_vals, si_str); - } - if (argind < argc && !strcmp(argv[argind], "ssn")) { - argind++; - rkey->ssn = atoi(argv[argind]); - } + rkey->context = atoi(rcontext); /* FIXME: input validation */ + rkey->si = si ? get_string_value(mtp_si_vals, si) : 0; /* FIXME: input validation */ + rkey->ssn = ssn ? atoi(ssn) : 0; /* FIXME: input validation */ return CMD_SUCCESS; +} + +DEFUN(as_rout_key, as_rout_key_cmd, + ROUTING_KEY_CMD, + ROUTING_KEY_CMD_STRS) +{ + return _rout_key(vty, argv[0], argv[1], NULL, NULL); +} + +DEFUN(as_rout_key_si, as_rout_key_si_cmd, + ROUTING_KEY_CMD ROUTING_KEY_SI_ARG, + ROUTING_KEY_CMD_STRS ROUTING_KEY_SI_ARG_STRS) +{ + return _rout_key(vty, argv[0], argv[1], argv[2], NULL); +} + +DEFUN(as_rout_key_ssn, as_rout_key_ssn_cmd, + ROUTING_KEY_CMD ROUTING_KEY_SSN_ARG, + ROUTING_KEY_CMD_STRS ROUTING_KEY_SSN_ARG_STRS) +{ + return _rout_key(vty, argv[0], argv[1], NULL, argv[2]); +} + +DEFUN(as_rout_key_si_ssn, as_rout_key_si_ssn_cmd, + ROUTING_KEY_CMD ROUTING_KEY_SI_ARG ROUTING_KEY_SSN_ARG, + ROUTING_KEY_CMD_STRS ROUTING_KEY_SI_ARG_STRS ROUTING_KEY_SSN_ARG_STRS) +{ + return _rout_key(vty, argv[0], argv[1], argv[2], argv[3]); } DEFUN(as_pc_override, as_pc_override_cmd, @@ -1718,6 +1742,9 @@ install_element(L_CS7_AS_NODE, &as_recov_tout_cmd); install_element(L_CS7_AS_NODE, &as_qos_class_cmd); install_element(L_CS7_AS_NODE, &as_rout_key_cmd); + install_element(L_CS7_AS_NODE, &as_rout_key_si_cmd); + install_element(L_CS7_AS_NODE, &as_rout_key_ssn_cmd); + install_element(L_CS7_AS_NODE, &as_rout_key_si_ssn_cmd); install_element(L_CS7_AS_NODE, &as_pc_override_cmd); vty_init_addr(); -- To view, visit https://gerrit.osmocom.org/3585 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idc68bfae5457960a9eae5d9648586d6ce719ad68 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>