lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

  • 1 participants
  • 97208 discussions
Change in libosmo-sccp[master]: xua_asp_fsm: Fix gcc false positive warning
by pespin 01 Feb '22

01 Feb '22
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/27041 ) Change subject: xua_asp_fsm: Fix gcc false positive warning ...................................................................... xua_asp_fsm: Fix gcc false positive warning As of GCC 11.1.0, it starts printing a warning about uninitialized variable. It is a false positive since tmode is really only used in the case where traffic_mode is not zero, in which case tmode is set. Let's restrict the scope of tmode to fix the issue and also make it clearer where the variable is used. """ In file included from /git/libosmo-sccp/src/xua_asp_fsm.c:25: /git/libosmo-sccp/src/xua_asp_fsm.c: In function ‘xua_asp_fsm_inactive’: /git/libosmo-sccp/include/osmocom/sigtran/osmo_ss7.h:274:16: error: ‘tmode’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 274 | return get_value_string(osmo_ss7_as_traffic_mode_vals, mode); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /git/libosmo-sccp/src/xua_asp_fsm.c:476:39: note: ‘tmode’ was declared here 476 | enum osmo_ss7_as_traffic_mode tmode; | """ Change-Id: I4fc38724aba3a3f178ba0b45444e1394db44d039 --- M src/xua_asp_fsm.c 1 file changed, 1 insertion(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/41/27041/1 diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c index 5fe1d80..a93dbd2 100644 --- a/src/xua_asp_fsm.c +++ b/src/xua_asp_fsm.c @@ -473,7 +473,6 @@ struct osmo_ss7_as *as; struct xua_msg *xua_in; uint32_t traf_mode = 0; - enum osmo_ss7_as_traffic_mode tmode; struct xua_msg_part *part; int i; @@ -515,7 +514,6 @@ peer_send_error(fi, M3UA_ERR_UNSUPP_TRAF_MOD_TYP); return; } - tmode = osmo_ss7_tmode_from_xua(traf_mode); } if ((part = xua_msg_find_tag(xua_in, M3UA_IEI_ROUTE_CTX))) { for (i = 0; i < part->len / sizeof(uint32_t); i++) { @@ -529,6 +527,7 @@ } if (traf_mode) { /* if the peer has specified a traffic mode at all */ + enum osmo_ss7_as_traffic_mode tmode = osmo_ss7_tmode_from_xua(traf_mode); llist_for_each_entry(as, &asp->inst->as_list, list) { if (!osmo_ss7_as_has_asp(as, asp)) continue; -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/27041 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Change-Id: I4fc38724aba3a3f178ba0b45444e1394db44d039 Gerrit-Change-Number: 27041 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-bsc-nat[master]: bsc_nat_fsm: initial msc <> bsc msg forwarding
by osmith 01 Feb '22

01 Feb '22
Attention is currently required from: pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27030 ) Change subject: bsc_nat_fsm: initial msc <> bsc msg forwarding ...................................................................... Patch Set 5: (1 comment) File src/osmo-bsc-nat/bsc_nat_fsm.c: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27030/comment/645d50ef_cf58b721 PS5, Line 142: oph->msg = NULL; > Why are you doing this? So I can properly msgb_free(oph->msg) before return of this function, if it is not NULL. > Is msgb_free() called somewhere inside osmo_sccp_tx_unitdata_msg ? Yes: https://git.osmocom.org/libosmo-sccp/tree/src/sccp_helpers.c?id=5cac653a986… > Did you check if oph pointer is actually allocated INSIDE the msg data? because then you are writing to already-freed memory. If that's the case, you should not use oph nor oph->msg anymore. Thanks for pointing this out, indeed the callers of sccp_user_prim_up in libosmo-sccp allocate oph inside msg and as I understand, I should set oph = NULL to check later if msgb_free is needed. I'm not so familiar with internals of msgb, but now I understood that I don't even need to set l3h to l2h, I can just use msgb_pull_to_l2. Patch updated. -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27030 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: I4af398bb433341a98f818822e6c3af28b6d9dacd Gerrit-Change-Number: 27030 Gerrit-PatchSet: 5 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 01 Feb 2022 10:58:32 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
Change in osmo-bsc-nat[master]: bsc_nat_fsm: initial msc <> bsc msg forwarding
by osmith 01 Feb '22

01 Feb '22
Attention is currently required from: osmith. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27030 to look at the new patch set (#6). Change subject: bsc_nat_fsm: initial msc <> bsc msg forwarding ...................................................................... bsc_nat_fsm: initial msc <> bsc msg forwarding Add an initial implementation of sccp_sap_up, that assumes one BSC and one MSC, and successfully forwards RESET and RESET ACK between both. Related: SYS#5560 Depends: libosmo-sccp I0f38b0d038b0dd8cd355e7284e5b56d438811bd9 Change-Id: I4af398bb433341a98f818822e6c3af28b6d9dacd --- M doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg M src/osmo-bsc-nat/bsc_nat_fsm.c 2 files changed, 113 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc-nat refs/changes/30/27030/6 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27030 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: I4af398bb433341a98f818822e6c3af28b6d9dacd Gerrit-Change-Number: 27030 Gerrit-PatchSet: 6 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-bsc-nat[master]: bsc_nat_fsm: fix SSN of OsmoBSCNAT-RAN
by osmith 01 Feb '22

01 Feb '22
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27029 ) Change subject: bsc_nat_fsm: fix SSN of OsmoBSCNAT-RAN ...................................................................... bsc_nat_fsm: fix SSN of OsmoBSCNAT-RAN Related: SYS#5560 Change-Id: I0491ba90d28eea6f10d8d6f98a00d3dd6c698476 --- M src/osmo-bsc-nat/bsc_nat_fsm.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c index 7706276..62059a3 100644 --- a/src/osmo-bsc-nat/bsc_nat_fsm.c +++ b/src/osmo-bsc-nat/bsc_nat_fsm.c @@ -105,7 +105,7 @@ return; } - if (ss7_inst_init(bsc_nat->ran, "OsmoBSCNAT-RAN", DEFAULT_PC_RAN, OSMO_SCCP_SSN_MSC) < 0) { + if (ss7_inst_init(bsc_nat->ran, "OsmoBSCNAT-RAN", DEFAULT_PC_RAN, OSMO_SCCP_SSN_BSSAP) < 0) { osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STOPPED, 0, 0); return; } -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27029 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: I0491ba90d28eea6f10d8d6f98a00d3dd6c698476 Gerrit-Change-Number: 27029 Gerrit-PatchSet: 4 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-bsc-nat[master]: Add bsc_nat fsm
by osmith 01 Feb '22

01 Feb '22
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/26662 ) Change subject: Add bsc_nat fsm ...................................................................... Add bsc_nat fsm Create the initial FSM that starts and stops two SS7 instances (one for CN, one for RAN), and binds an sccp user to each. Related: SYS#5560 Depends: libosmocore I81c64a7ae440304522c2179c212023a566ddced8 Change-Id: I7d52fa649c397582b18a1a7dcc40bb407f3b2c97 --- M doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg M include/osmocom/bsc_nat/Makefile.am M include/osmocom/bsc_nat/bsc_nat.h A include/osmocom/bsc_nat/bsc_nat_fsm.h M src/osmo-bsc-nat/Makefile.am M src/osmo-bsc-nat/bsc_nat.c A src/osmo-bsc-nat/bsc_nat_fsm.c M src/osmo-bsc-nat/main.c M src/osmo-bsc-nat/vty.c 9 files changed, 325 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg b/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg index e69de29..c3c5825 100644 --- a/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg +++ b/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg @@ -0,0 +1,15 @@ +cs7 instance 0 + point-code 0.23.3 + asp asp-clnt-OsmoBSCNAT-CN 2905 0 m3ua + remote-ip 127.0.0.1 + local-ip 127.0.0.3 + +cs7 instance 1 + point-code 0.23.1 + asp asp-clnt-OsmoBSCNAT-RAN 2905 0 m3ua + remote-ip 127.0.0.2 + local-ip 127.0.0.4 + +bsc-nat + cs7-instance-cn 0 + cs7-instance-ran 1 diff --git a/include/osmocom/bsc_nat/Makefile.am b/include/osmocom/bsc_nat/Makefile.am index f573dd9..90f44a7 100644 --- a/include/osmocom/bsc_nat/Makefile.am +++ b/include/osmocom/bsc_nat/Makefile.am @@ -1,5 +1,6 @@ noinst_HEADERS = \ bsc_nat.h \ + bsc_nat_fsm.h \ logging.h \ vty.h \ $(NULL) diff --git a/include/osmocom/bsc_nat/bsc_nat.h b/include/osmocom/bsc_nat/bsc_nat.h index 511d5a4..2031527 100644 --- a/include/osmocom/bsc_nat/bsc_nat.h +++ b/include/osmocom/bsc_nat/bsc_nat.h @@ -18,7 +18,21 @@ */ #pragma once +#include <osmocom/core/fsm.h> +#include <osmocom/sigtran/sccp_sap.h> + + +struct bsc_nat_ss7_inst { + uint32_t ss7_id; + struct osmo_sccp_addr local_sccp_addr; + struct osmo_sccp_user *scu; +}; + struct bsc_nat { + struct osmo_fsm_inst *fi; + + struct bsc_nat_ss7_inst *cn; + struct bsc_nat_ss7_inst *ran; }; struct bsc_nat *bsc_nat_alloc(void *tall_ctx); diff --git a/include/osmocom/bsc_nat/bsc_nat_fsm.h b/include/osmocom/bsc_nat/bsc_nat_fsm.h new file mode 100644 index 0000000..944de71 --- /dev/null +++ b/include/osmocom/bsc_nat/bsc_nat_fsm.h @@ -0,0 +1,23 @@ +/* (C) 2021 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Oliver Smith <osmith(a)sysmocom.de> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/lienses/>. + * + */ +#pragma once + +void bsc_nat_fsm_alloc(struct bsc_nat *bsc_nat); +void bsc_nat_fsm_start(struct bsc_nat *bsc_nat); +void bsc_nat_fsm_stop(struct bsc_nat *bsc_nat); diff --git a/src/osmo-bsc-nat/Makefile.am b/src/osmo-bsc-nat/Makefile.am index 9aa9524..6a759cb 100644 --- a/src/osmo-bsc-nat/Makefile.am +++ b/src/osmo-bsc-nat/Makefile.am @@ -26,6 +26,7 @@ osmo_bsc_nat_SOURCES = \ bsc_nat.c \ + bsc_nat_fsm.c \ logging.c \ main.c \ vty.c \ diff --git a/src/osmo-bsc-nat/bsc_nat.c b/src/osmo-bsc-nat/bsc_nat.c index f3a6748..adb32c4 100644 --- a/src/osmo-bsc-nat/bsc_nat.c +++ b/src/osmo-bsc-nat/bsc_nat.c @@ -22,6 +22,7 @@ #include <osmocom/core/talloc.h> #include <osmocom/core/utils.h> #include <osmocom/bsc_nat/bsc_nat.h> +#include <osmocom/bsc_nat/bsc_nat_fsm.h> struct bsc_nat *bsc_nat_alloc(void *tall_ctx) { @@ -30,10 +31,25 @@ bsc_nat = talloc_zero(tall_ctx, struct bsc_nat); OSMO_ASSERT(bsc_nat); + bsc_nat->cn = talloc_zero(bsc_nat, struct bsc_nat_ss7_inst); + OSMO_ASSERT(bsc_nat->cn); + talloc_set_name_const(bsc_nat->cn, "struct bsc_nat_ss7_inst (CN)"); + + bsc_nat->ran = talloc_zero(bsc_nat, struct bsc_nat_ss7_inst); + OSMO_ASSERT(bsc_nat->ran); + talloc_set_name_const(bsc_nat->ran, "struct bsc_nat_ss7_inst (RAN)"); + + bsc_nat_fsm_alloc(bsc_nat); + return bsc_nat; } void bsc_nat_free(struct bsc_nat *bsc_nat) { + if (bsc_nat->fi) { + osmo_fsm_inst_free(bsc_nat->fi); + bsc_nat->fi = NULL; + } + talloc_free(bsc_nat); } diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c new file mode 100644 index 0000000..7706276 --- /dev/null +++ b/src/osmo-bsc-nat/bsc_nat_fsm.c @@ -0,0 +1,214 @@ +/* (C) 2021 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Oliver Smith <osmith(a)sysmocom.de> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/lienses/>. + * + */ + +#include "config.h" + +#include <errno.h> +#include <stdint.h> + +#include <osmocom/core/fsm.h> +#include <osmocom/core/select.h> + +#include <osmocom/sigtran/osmo_ss7.h> + +#include <osmocom/bsc_nat/bsc_nat.h> +#include <osmocom/bsc_nat/bsc_nat_fsm.h> +#include <osmocom/bsc_nat/logging.h> + +#define DEFAULT_PC_RAN "0.23.1" /* same as default for OsmoMSC */ +#define DEFAULT_PC_CN "0.23.3" /* same as default for OsmoBSC */ + +#define X(s) (1 << (s)) + +enum bsc_nat_fsm_states { + BSC_NAT_FSM_ST_STOPPED, + BSC_NAT_FSM_ST_STARTING, + BSC_NAT_FSM_ST_STARTED, +}; + +enum bsc_nat_fsm_events { + BSC_NAT_FSM_EV_START, + BSC_NAT_FSM_EV_STOP, +}; + +static int sccp_sap_up(struct osmo_prim_hdr *oph, void *priv) +{ + LOGP(DMAIN, LOGL_NOTICE, "STUB: sccp_sap_up() called\n"); + + return 0; +} + +static int ss7_inst_init(struct bsc_nat_ss7_inst *inst, const char *name, const char *default_pc_str, + enum osmo_sccp_ssn ssn) +{ + int default_pc; + struct osmo_sccp_instance *sccp; + + default_pc = osmo_ss7_pointcode_parse(NULL, default_pc_str); + OSMO_ASSERT(default_pc >= 0); + + sccp = osmo_sccp_simple_client_on_ss7_id(inst, inst->ss7_id, name, default_pc, OSMO_SS7_ASP_PROT_M3UA, 0, NULL, + 0, NULL); + if (!sccp) { + LOGP(DMAIN, LOGL_ERROR, "%s: failed to request sccp client instance for sccp user\n", name); + return -1; + } + + osmo_sccp_local_addr_by_instance(&inst->local_sccp_addr, sccp, ssn); + + inst->scu = osmo_sccp_user_bind(sccp, name, sccp_sap_up, ssn); + if (!inst->scu) { + LOGP(DMAIN, LOGL_ERROR, "%s: failed to bind sccp user\n", name); + return -2; + } + + osmo_sccp_user_set_priv(inst->scu, inst); + return 0; +} + +static void ss7_inst_free(struct bsc_nat_ss7_inst *inst) +{ + if (inst->scu) { + osmo_sccp_user_unbind(inst->scu); + inst->scu = NULL; + } + + struct osmo_ss7_instance *ss7 = osmo_ss7_instance_find(inst->ss7_id); + if (ss7) + osmo_ss7_instance_destroy(ss7); + + talloc_free(inst); +} + +static void st_starting_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct bsc_nat *bsc_nat = (struct bsc_nat *)fi->priv; + + if (ss7_inst_init(bsc_nat->cn, "OsmoBSCNAT-CN", DEFAULT_PC_CN, OSMO_SCCP_SSN_RANAP) < 0) { + osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STOPPED, 0, 0); + return; + } + + if (ss7_inst_init(bsc_nat->ran, "OsmoBSCNAT-RAN", DEFAULT_PC_RAN, OSMO_SCCP_SSN_MSC) < 0) { + osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STOPPED, 0, 0); + return; + } + + osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STARTED, 0, 0); +} + +static void st_started(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case BSC_NAT_FSM_EV_STOP: + osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STOPPED, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +static void st_stopped_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct bsc_nat *bsc_nat = (struct bsc_nat *)fi->priv; + + ss7_inst_free(bsc_nat->cn); + bsc_nat->cn = NULL; + + ss7_inst_free(bsc_nat->ran); + bsc_nat->ran = NULL; +} + +static void st_stopped(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case BSC_NAT_FSM_EV_START: + osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STARTING, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +static struct osmo_fsm_state bsc_nat_fsm_states[] = { + [BSC_NAT_FSM_ST_STOPPED] = { + .name = "STOPPED", + .in_event_mask = 0 + | X(BSC_NAT_FSM_EV_START) + , + .out_state_mask = 0 + | X(BSC_NAT_FSM_ST_STARTING) + , + .action = st_stopped, + .onenter = st_stopped_on_enter, + }, + [BSC_NAT_FSM_ST_STARTING] = { + .name = "STARTING", + .out_state_mask = 0 + | X(BSC_NAT_FSM_ST_STARTED) + | X(BSC_NAT_FSM_ST_STOPPED) + , + .onenter = st_starting_on_enter, + }, + [BSC_NAT_FSM_ST_STARTED] = { + .name = "STARTED", + .in_event_mask = 0 + | X(BSC_NAT_FSM_EV_STOP) + , + .out_state_mask = 0 + | X(BSC_NAT_FSM_ST_STOPPED) + , + .action = st_started, + }, +}; + +const struct value_string bsc_nat_fsm_event_names[] = { + OSMO_VALUE_STRING(BSC_NAT_FSM_EV_START), + OSMO_VALUE_STRING(BSC_NAT_FSM_EV_STOP), + { 0, NULL } +}; + +struct osmo_fsm bsc_nat_fsm = { + .name = "BSC_NAT", + .states = bsc_nat_fsm_states, + .num_states = ARRAY_SIZE(bsc_nat_fsm_states), + .log_subsys = DMAIN, + .event_names = bsc_nat_fsm_event_names, +}; + +static __attribute__((constructor)) void bsc_nat_fsm_init(void) +{ + OSMO_ASSERT(osmo_fsm_register(&bsc_nat_fsm) == 0); +} + +void bsc_nat_fsm_alloc(struct bsc_nat *bsc_nat) +{ + bsc_nat->fi = osmo_fsm_inst_alloc(&bsc_nat_fsm, bsc_nat, bsc_nat, LOGL_INFO, NULL); + OSMO_ASSERT(bsc_nat->fi); +} + +void bsc_nat_fsm_start(struct bsc_nat *bsc_nat) +{ + osmo_fsm_inst_dispatch(bsc_nat->fi, BSC_NAT_FSM_EV_START, NULL); +} + +void bsc_nat_fsm_stop(struct bsc_nat *bsc_nat) +{ + osmo_fsm_inst_dispatch(bsc_nat->fi, BSC_NAT_FSM_EV_STOP, NULL); +} diff --git a/src/osmo-bsc-nat/main.c b/src/osmo-bsc-nat/main.c index a37d3cb..715ade0 100644 --- a/src/osmo-bsc-nat/main.c +++ b/src/osmo-bsc-nat/main.c @@ -22,6 +22,8 @@ #include <getopt.h> #include <osmocom/core/application.h> +#include <osmocom/sigtran/osmo_ss7.h> +#include <osmocom/sigtran/sccp_sap.h> #include <osmocom/vty/cpu_sched_vty.h> #include <osmocom/vty/logging.h> #include <osmocom/vty/misc.h> @@ -29,6 +31,7 @@ #include <osmocom/vty/telnet_interface.h> #include <osmocom/bsc_nat/bsc_nat.h> +#include <osmocom/bsc_nat/bsc_nat_fsm.h> #include <osmocom/bsc_nat/logging.h> #include <osmocom/bsc_nat/vty.h> @@ -113,7 +116,10 @@ logging_vty_add_cmds(); osmo_talloc_vty_add_cmds(); + osmo_fsm_vty_add_cmds(); osmo_cpu_sched_vty_init(tall_bsc_nat_ctx); + osmo_ss7_vty_init_asp(NULL); + osmo_sccp_vty_init(); handle_options(argc, argv); @@ -185,14 +191,25 @@ if (rc < 0) exit(1); + rc = osmo_ss7_init(); + if (rc < 0) + exit(1); + g_bsc_nat = bsc_nat_alloc(tall_bsc_nat_ctx); main_vty_init(argc, argv); signal_handler_init(); + bsc_nat_fsm_start(g_bsc_nat); + while (!osmo_select_shutdown_done()) osmo_select_main_ctx(0); + bsc_nat_fsm_stop(g_bsc_nat); + + talloc_report_full(g_bsc_nat, stderr); + bsc_nat_free(g_bsc_nat); + log_fini(); talloc_report_full(tall_bsc_nat_ctx, stderr); talloc_free(tall_bsc_nat_ctx); talloc_free(tall_vty_ctx); diff --git a/src/osmo-bsc-nat/vty.c b/src/osmo-bsc-nat/vty.c index 089d27b..128940e 100644 --- a/src/osmo-bsc-nat/vty.c +++ b/src/osmo-bsc-nat/vty.c @@ -68,12 +68,36 @@ static int config_write_bsc_nat(struct vty *vty) { vty_out(vty, "bsc-nat%s", VTY_NEWLINE); + vty_out(vty, " cs7-instance-cn %u%s", g_bsc_nat->cn->ss7_id, VTY_NEWLINE); + vty_out(vty, " cs7-instance-ran %u%s", g_bsc_nat->ran->ss7_id, VTY_NEWLINE); + return CMD_SUCCESS; } +#define SS7_REF_STR "SS7 instance reference number\n" + +DEFUN(cfg_cs7_instance_cn, + cfg_cs7_instance_cn_cmd, + "cs7-instance-cn <0-15>", + "Set SS7 to be used to connect to CN-side\n" SS7_REF_STR) +{ + g_bsc_nat->cn->ss7_id = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_cs7_instance_ran, + cfg_cs7_instance_ran_cmd, + "cs7-instance-ran <0-15>", + "Set SS7 to be used to connect to RAN-side\n" SS7_REF_STR) +{ + g_bsc_nat->ran->ss7_id = atoi(argv[0]); + return CMD_SUCCESS; +} void bsc_nat_vty_init(void) { install_element(CONFIG_NODE, &cfg_bsc_nat_cmd); install_node(&bsc_nat_node, config_write_bsc_nat); + install_element(BSC_NAT_NODE, &cfg_cs7_instance_cn_cmd); + install_element(BSC_NAT_NODE, &cfg_cs7_instance_ran_cmd); } -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/26662 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: I7d52fa649c397582b18a1a7dcc40bb407f3b2c97 Gerrit-Change-Number: 26662 Gerrit-PatchSet: 11 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-bsc-nat[master]: vty: use osmo_ss7_vty_go_parent
by osmith 01 Feb '22

01 Feb '22
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27028 ) Change subject: vty: use osmo_ss7_vty_go_parent ...................................................................... vty: use osmo_ss7_vty_go_parent Remove unnecessary bsc_nat_vty_go_parent function, and use osmo_ss7_vty_go_parent instead. Without the latter, it segfaults while attempting to parse a config segment like this: cs7 instance 0 point-code 0.23.3 asp asp-clnt-OsmoBSCNAT-CN 2905 0 m3ua remote-ip 127.0.0.1 local-ip 127.0.0.3 sccp-address msc # segfault here, vty->index == NULL routing-indicator PC point-code 0.23.1 Related: SYS#5560 Related: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/26659/comment/c99b8cca_865449aa/ Change-Id: Iee6ece062f11694acb771463be7effb7342e92f2 --- M include/osmocom/bsc_nat/vty.h M src/osmo-bsc-nat/main.c M src/osmo-bsc-nat/vty.c 3 files changed, 1 insertion(+), 22 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved laforge: Looks good to me, approved pespin: Looks good to me, but someone else must approve diff --git a/include/osmocom/bsc_nat/vty.h b/include/osmocom/bsc_nat/vty.h index f882c23..9a842b5 100644 --- a/include/osmocom/bsc_nat/vty.h +++ b/include/osmocom/bsc_nat/vty.h @@ -28,4 +28,3 @@ }; void bsc_nat_vty_init(void); -int bsc_nat_vty_go_parent(struct vty *vty); diff --git a/src/osmo-bsc-nat/main.c b/src/osmo-bsc-nat/main.c index 715ade0..7e9696e 100644 --- a/src/osmo-bsc-nat/main.c +++ b/src/osmo-bsc-nat/main.c @@ -49,7 +49,7 @@ static struct vty_app_info vty_info = { .name = "OsmoBSCNAT", .version = PACKAGE_VERSION, - .go_parent_cb = bsc_nat_vty_go_parent, + .go_parent_cb = osmo_ss7_vty_go_parent, }; static struct { diff --git a/src/osmo-bsc-nat/vty.c b/src/osmo-bsc-nat/vty.c index 128940e..41681d4 100644 --- a/src/osmo-bsc-nat/vty.c +++ b/src/osmo-bsc-nat/vty.c @@ -28,26 +28,6 @@ #include <osmocom/bsc_nat/bsc_nat.h> #include <osmocom/bsc_nat/vty.h> -int bsc_nat_vty_go_parent(struct vty *vty) -{ - switch (vty->node) { - case BSC_NAT_NODE: - vty->node = CONFIG_NODE; - vty->index = g_bsc_nat; - break; - case CONFIG_NODE: - vty->node = ENABLE_NODE; - vty->index = NULL; - break; - default: - vty->node = CONFIG_NODE; - vty->index = NULL; - break; - } - - return vty->node; -} - static struct cmd_node bsc_nat_node = { BSC_NAT_NODE, "%s(config-bsc-nat)# ", -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27028 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: Iee6ece062f11694acb771463be7effb7342e92f2 Gerrit-Change-Number: 27028 Gerrit-PatchSet: 4 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-e1d[master]: Allow configuration of interfaces/lines via VTY
by pespin 31 Jan '22

31 Jan '22
Attention is currently required from: laforge. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27016 ) Change subject: Allow configuration of interfaces/lines via VTY ...................................................................... Patch Set 6: Code-Review+1 (1 comment) File src/usb.c: https://gerrit.osmocom.org/c/osmo-e1d/+/27016/comment/112a59ae_5803b92c PS6, Line 565: /* try to find the matching interface config create by the vty */ created by -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27016 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77 Gerrit-Change-Number: 27016 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: tnt <tnt(a)246tNt.com> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Mon, 31 Jan 2022 19:13:14 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in osmo-e1d[master]: Proper libusb error reporting in all error paths
by pespin 31 Jan '22

31 Jan '22
Attention is currently required from: laforge. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27040 ) Change subject: Proper libusb error reporting in all error paths ...................................................................... Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27040 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: Id205f1cf1bbccd83b789f8ab31fe1d5d4e1fb8a9 Gerrit-Change-Number: 27040 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Mon, 31 Jan 2022 19:10:55 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in osmo-e1d[master]: Allow configuration of interfaces/lines via VTY
by laforge 31 Jan '22

31 Jan '22
Attention is currently required from: pespin. Hello Jenkins Builder, tnt, pespin, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-e1d/+/27016 to look at the new patch set (#6). Change subject: Allow configuration of interfaces/lines via VTY ...................................................................... Allow configuration of interfaces/lines via VTY So far, osmo-e1d automatically opened all compatible icE1usb devices and all E1 lines on those interfaces. Let's allow for 'interface' and 'line' configuration in the VTY. USB devices can be identified by their serial number string. If a given device (== E1 interface) has a VTY configuration, then only those E1 lines with VTY configuration opened. For each Line (icE1usb or vpair), the mode (channelized/superchannel) can also be set via VTY. Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77 Closes: OS#5400 --- M src/e1d.h M src/intf_line.c M src/usb.c M src/vty.c 4 files changed, 261 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/16/27016/6 -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27016 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77 Gerrit-Change-Number: 27016 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: tnt <tnt(a)246tNt.com> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-e1d[master]: e1_{intf,line}_new: Allow caller to specify the numeric identifier
by laforge 31 Jan '22

31 Jan '22
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27015 ) Change subject: e1_{intf,line}_new: Allow caller to specify the numeric identifier ...................................................................... e1_{intf,line}_new: Allow caller to specify the numeric identifier This will be used by the upcoming VTY interface changes. Change-Id: I9ff80831a3e3e3cb6dae178f8b438a9f3f4747df --- M src/e1d.h M src/intf_line.c M src/usb.c M src/vpair.c 4 files changed, 43 insertions(+), 16 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/e1d.h b/src/e1d.h index a0c8ceb..b76df7a 100644 --- a/src/e1d.h +++ b/src/e1d.h @@ -166,7 +166,7 @@ e1_intf_find_line(struct e1_intf *intf, uint8_t id); struct e1_intf * -e1_intf_new(struct e1_daemon *e1d, void *drv_data); +e1_intf_new(struct e1_daemon *e1d, int intf_id, void *drv_data); struct e1_intf * e1d_find_intf(struct e1_daemon *e1d, uint8_t id); @@ -179,7 +179,7 @@ e1_intf_find_line(struct e1_intf *intf, uint8_t id); struct e1_line * -e1_line_new(struct e1_intf *intf, void *drv_data); +e1_line_new(struct e1_intf *intf, int line_id, void *drv_data); void e1_line_destroy(struct e1_line *line); diff --git a/src/intf_line.c b/src/intf_line.c index 1f833fb..cb3f277 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -107,11 +107,21 @@ return NULL; } +/* intf_id can be specified as '-1' to mean "auto-allocate intf->id" */ struct e1_intf * -e1_intf_new(struct e1_daemon *e1d, void *drv_data) +e1_intf_new(struct e1_daemon *e1d, int intf_id, void *drv_data) { struct e1_intf *intf; + if (intf_id != -1) { + /* ensure non-duplicate interface number */ + intf = e1d_find_intf(e1d, intf_id); + if (intf) { + LOGPIF(intf, DE1D, LOGL_ERROR, "Cannot create duplicate interface %d\n", intf_id); + return NULL; + } + } + intf = talloc_zero(e1d->ctx, struct e1_intf); OSMO_ASSERT(intf); @@ -121,10 +131,14 @@ INIT_LLIST_HEAD(&intf->list); INIT_LLIST_HEAD(&intf->lines); - if (!llist_empty(&e1d->interfaces)) { - struct e1_intf *f = llist_last_entry(&e1d->interfaces, struct e1_intf, list); - intf->id = f->id + 1; - } + if (intf_id == -1) { + if (!llist_empty(&e1d->interfaces)) { + struct e1_intf *f = llist_last_entry(&e1d->interfaces, struct e1_intf, list); + intf->id = f->id + 1; + } else + intf->id = 0; + } else + intf->id = intf_id; llist_add_tail(&intf->list, &e1d->interfaces); @@ -180,11 +194,20 @@ ts->fd = -1; } +/* line_id can be specified as '-1' to mean "auto-allocate intf->id" */ struct e1_line * -e1_line_new(struct e1_intf *intf, void *drv_data) +e1_line_new(struct e1_intf *intf, int line_id, void *drv_data) { struct e1_line *line; + if (line_id != -1) { + line = e1_intf_find_line(intf, line_id); + if (line) { + LOGPLI(line, DE1D, LOGL_ERROR, "Cannot create duplicate line %d\n", line_id); + return NULL; + } + } + line = talloc_zero(intf->e1d->ctx, struct e1_line); OSMO_ASSERT(line); @@ -198,10 +221,14 @@ INIT_LLIST_HEAD(&line->list); - if (!llist_empty(&intf->lines)) { - struct e1_line *l = llist_last_entry(&intf->lines, struct e1_line, list); - line->id = l->id + 1; - } + if (line_id == -1) { + if (!llist_empty(&intf->lines)) { + struct e1_line *l = llist_last_entry(&intf->lines, struct e1_line, list); + line->id = l->id + 1; + } else + line->id = 0; + } else + line->id = line_id; line->ctrs = rate_ctr_group_alloc(line, &line_ctrg_desc, line->id); OSMO_ASSERT(line->ctrs); diff --git a/src/usb.c b/src/usb.c index 0c0afe4..0100c31 100644 --- a/src/usb.c +++ b/src/usb.c @@ -543,7 +543,7 @@ intf_data = talloc_zero(e1d->ctx, struct e1_usb_intf_data); intf_data->devh = devh; - intf = e1_intf_new(e1d, intf_data); + intf = e1_intf_new(e1d, -1, intf_data); intf->drv = E1_DRIVER_USB; ret = libusb_get_active_config_descriptor(dev, &cd); @@ -608,7 +608,7 @@ return -EINVAL; } - line = e1_line_new(intf, line_data); + line = e1_line_new(intf, -1, line_data); line_data->flow_in = e1uf_create(line, e1_usb_xfer_in, line_data->ep_in, 4, line_data->pkt_size, 4); line_data->flow_out = e1uf_create(line, e1_usb_xfer_out, line_data->ep_out, 4, line_data->pkt_size, 4); diff --git a/src/vpair.c b/src/vpair.c index 8484be0..524f998 100644 --- a/src/vpair.c +++ b/src/vpair.c @@ -67,14 +67,14 @@ intf_data = talloc_zero(e1d->ctx, struct ve1_intf_data); - intf = e1_intf_new(e1d, intf_data); + intf = e1_intf_new(e1d, -1, intf_data); intf->drv = E1_DRIVER_VPAIR; for (i = 0; i < num_lines; i++) { struct ve1_line_data *line_data; line_data = talloc_zero(e1d->ctx, struct ve1_line_data); - e1_line_new(intf, line_data); + e1_line_new(intf, -1, line_data); } return intf; -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27015 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I9ff80831a3e3e3cb6dae178f8b438a9f3f4747df Gerrit-Change-Number: 27015 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 9641
  • 9642
  • 9643
  • 9644
  • 9645
  • 9646
  • 9647
  • ...
  • 9721
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.