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 -----
  • 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

November 2024

  • 1 participants
  • 2209 discussions
[L] Change in libosmo-sigtran[master]: sigtran: Make osmo_ss7_route struct and several APIs private
by pespin 05 Nov '24

05 Nov '24
Attention is currently required from: fixeria, laforge, osmith, pespin. Hello Jenkins Builder, fixeria, laforge, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/38636?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review+1 by osmith, Verified+1 by Jenkins Builder Change subject: sigtran: Make osmo_ss7_route struct and several APIs private ...................................................................... sigtran: Make osmo_ss7_route struct and several APIs private The struct is in general managed internally by the library, only a few APIs which are in use by some external users (osmo-hnbgw and osmo-bsc vty) are left public. Change-Id: I8a86966cb6a5361687987a2e9acd79c4ab3d97c4 --- M TODO-RELEASE M include/osmocom/sigtran/osmo_ss7.h M src/Makefile.am M src/osmo_ss7.c M src/osmo_ss7_as.c M src/osmo_ss7_hmrt.c A src/osmo_ss7_route.c M src/osmo_ss7_route_table.c M src/osmo_ss7_vty.c M src/sccp_scrc.c M src/sccp_user.c A src/ss7_route.h M src/xua_as_fsm.c M src/xua_rkm.c M tests/ss7/ss7_test.c 15 files changed, 401 insertions(+), 335 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/36/38636/2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/38636?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I8a86966cb6a5361687987a2e9acd79c4ab3d97c4 Gerrit-Change-Number: 38636 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(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-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[L] Change in libosmo-sigtran[master]: sigtran: Make osmo_ss7_linkset APIs private
by pespin 05 Nov '24

05 Nov '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/38638?usp=email ) Change subject: sigtran: Make osmo_ss7_linkset APIs private ...................................................................... sigtran: Make osmo_ss7_linkset APIs private linkset objects are managed so far exclusively through libosmo-sigtran VTY interface, hence make the struct as well as all its APIs private. Change-Id: I3b16f858d890b0a31780a2b85a609eae6374665a --- M include/osmocom/sigtran/osmo_ss7.h M src/Makefile.am M src/osmo_ss7.c M src/osmo_ss7_hmrt.c A src/osmo_ss7_linkset.c M src/osmo_ss7_route.c M src/sccp_scrc.c A src/ss7_linkset.h M tests/ss7/ss7_test.c 9 files changed, 159 insertions(+), 109 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/38/38638/1 diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 002117a..e91d354 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -155,27 +155,7 @@ * SS7 Linksets ***********************************************************************/ -struct osmo_ss7_linkset { - struct llist_head list; - /*! \ref osmo_ss7_instance to which we belong */ - struct osmo_ss7_instance *inst; - /*! array of \ref osmo_ss7_link */ - struct osmo_ss7_link *links[16]; - - struct { - char *name; - char *description; - uint32_t adjacent_pc; - uint32_t local_pc; - } cfg; -}; - -void osmo_ss7_linkset_destroy(struct osmo_ss7_linkset *lset); -struct osmo_ss7_linkset * -osmo_ss7_linkset_find_by_name(struct osmo_ss7_instance *inst, const char *name); -struct osmo_ss7_linkset * -osmo_ss7_linkset_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint32_t pc); - +struct osmo_ss7_linkset; /*********************************************************************** * SS7 Routes diff --git a/src/Makefile.am b/src/Makefile.am index af6bae8..f92f353 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ noinst_HEADERS = \ sccp_internal.h \ ss7_internal.h \ + ss7_linkset.h \ ss7_route.h \ ss7_route_table.h \ xua_asp_fsm.h \ @@ -37,6 +38,7 @@ osmo_ss7_asp.c \ osmo_ss7_asp_peer.c \ osmo_ss7_hmrt.c \ + osmo_ss7_linkset.c \ osmo_ss7_vty.c \ osmo_ss7_xua_srv.c \ osmo_ss7_route.c \ diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 37b50da..b8d8141 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -51,6 +51,7 @@ #include "sccp_internal.h" #include "xua_internal.h" #include "ss7_internal.h" +#include "ss7_linkset.h" #include "ss7_route.h" #include "ss7_route_table.h" #include "xua_asp_fsm.h" @@ -377,7 +378,7 @@ osmo_ss7_as_destroy(as); llist_for_each_entry_safe(lset, lset2, &inst->linksets, list) - osmo_ss7_linkset_destroy(lset); + ss7_linkset_destroy(lset); llist_del(&inst->list); talloc_free(inst); @@ -492,80 +493,6 @@ } /*********************************************************************** - * SS7 Linkset - ***********************************************************************/ - -/*! \brief Destroy a SS7 Linkset - * \param[in] lset Linkset to be destroyed */ -void osmo_ss7_linkset_destroy(struct osmo_ss7_linkset *lset) -{ - struct osmo_ss7_route *rt, *rt2; - unsigned int i; - - OSMO_ASSERT(ss7_initialized); - LOGSS7(lset->inst, LOGL_INFO, "Destroying Linkset %s\n", - lset->cfg.name); - - /* find any routes pointing to this AS and remove them */ - llist_for_each_entry_safe(rt, rt2, &lset->inst->rtable_system->routes, list) { - if (rt->dest.linkset == lset) - ss7_route_destroy(rt); - } - - for (i = 0; i < ARRAY_SIZE(lset->links); i++) { - struct osmo_ss7_link *link = lset->links[i]; - if (!link) - continue; - osmo_ss7_link_destroy(link); - } - llist_del(&lset->list); - talloc_free(lset); -} - -/*! \brief Find SS7 Linkset by given name - * \param[in] inst SS7 Instance in which to look - * \param[in] name Name of SS7 Linkset - * \returns pointer to linkset on success; NULL on error */ -struct osmo_ss7_linkset * -osmo_ss7_linkset_find_by_name(struct osmo_ss7_instance *inst, const char *name) -{ - struct osmo_ss7_linkset *lset; - OSMO_ASSERT(ss7_initialized); - llist_for_each_entry(lset, &inst->linksets, list) { - if (!strcmp(name, lset->cfg.name)) - return lset; - } - return NULL; -} - -/*! \brief Find or allocate SS7 Linkset - * \param[in] inst SS7 Instance in which we operate - * \param[in] name Name of SS7 Linkset - * \param[in] pc Adjacent Pointcode - * \returns pointer to Linkset on success; NULL on error */ -struct osmo_ss7_linkset * -osmo_ss7_linkset_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint32_t pc) -{ - struct osmo_ss7_linkset *lset; - - OSMO_ASSERT(ss7_initialized); - lset = osmo_ss7_linkset_find_by_name(inst, name); - if (lset && lset->cfg.adjacent_pc != pc) - return NULL; - - if (!lset) { - LOGSS7(inst, LOGL_INFO, "Creating Linkset %s\n", name); - lset = talloc_zero(inst, struct osmo_ss7_linkset); - lset->inst = inst; - lset->cfg.adjacent_pc = pc; - lset->cfg.name = talloc_strdup(lset, name); - llist_add_tail(&lset->list, &inst->linksets); - } - - return lset; -} - -/*********************************************************************** * SS7 Link ***********************************************************************/ diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c index 55e5776..b0208b0 100644 --- a/src/osmo_ss7_hmrt.c +++ b/src/osmo_ss7_hmrt.c @@ -35,6 +35,7 @@ #include <osmocom/sigtran/protocol/m3ua.h> #include "xua_internal.h" +#include "ss7_linkset.h" #include "ss7_route.h" #include "ss7_route_table.h" #include "ss7_internal.h" diff --git a/src/osmo_ss7_linkset.c b/src/osmo_ss7_linkset.c new file mode 100644 index 0000000..18af7b6 --- /dev/null +++ b/src/osmo_ss7_linkset.c @@ -0,0 +1,105 @@ +/* (C) 2015-2017 by Harald Welte <laforge(a)gnumonks.org> + * (C) 2023-2024 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <errno.h> + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/logging.h> +#include <osmocom/sigtran/osmo_ss7.h> + +#include "ss7_linkset.h" +#include "ss7_route.h" +#include "ss7_route_table.h" +#include "ss7_internal.h" + +/*********************************************************************** + * SS7 Linkset + ***********************************************************************/ + +/*! \brief Destroy a SS7 Linkset + * \param[in] lset Linkset to be destroyed */ +void ss7_linkset_destroy(struct osmo_ss7_linkset *lset) +{ + struct osmo_ss7_route *rt, *rt2; + unsigned int i; + + OSMO_ASSERT(ss7_initialized); + LOGSS7(lset->inst, LOGL_INFO, "Destroying Linkset %s\n", + lset->cfg.name); + + /* find any routes pointing to this AS and remove them */ + llist_for_each_entry_safe(rt, rt2, &lset->inst->rtable_system->routes, list) { + if (rt->dest.linkset == lset) + ss7_route_destroy(rt); + } + + for (i = 0; i < ARRAY_SIZE(lset->links); i++) { + struct osmo_ss7_link *link = lset->links[i]; + if (!link) + continue; + osmo_ss7_link_destroy(link); + } + llist_del(&lset->list); + talloc_free(lset); +} + +/*! \brief Find SS7 Linkset by given name + * \param[in] inst SS7 Instance in which to look + * \param[in] name Name of SS7 Linkset + * \returns pointer to linkset on success; NULL on error */ +struct osmo_ss7_linkset * +ss7_linkset_find_by_name(struct osmo_ss7_instance *inst, const char *name) +{ + struct osmo_ss7_linkset *lset; + OSMO_ASSERT(ss7_initialized); + llist_for_each_entry(lset, &inst->linksets, list) { + if (!strcmp(name, lset->cfg.name)) + return lset; + } + return NULL; +} + +/*! \brief Find or allocate SS7 Linkset + * \param[in] inst SS7 Instance in which we operate + * \param[in] name Name of SS7 Linkset + * \param[in] pc Adjacent Pointcode + * \returns pointer to Linkset on success; NULL on error */ +struct osmo_ss7_linkset * +ss7_linkset_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint32_t pc) +{ + struct osmo_ss7_linkset *lset; + + OSMO_ASSERT(ss7_initialized); + lset = ss7_linkset_find_by_name(inst, name); + if (lset && lset->cfg.adjacent_pc != pc) + return NULL; + + if (!lset) { + LOGSS7(inst, LOGL_INFO, "Creating Linkset %s\n", name); + lset = talloc_zero(inst, struct osmo_ss7_linkset); + lset->inst = inst; + lset->cfg.adjacent_pc = pc; + lset->cfg.name = talloc_strdup(lset, name); + llist_add_tail(&lset->list, &inst->linksets); + } + + return lset; +} diff --git a/src/osmo_ss7_route.c b/src/osmo_ss7_route.c index b5b2d93..32e3eb7 100644 --- a/src/osmo_ss7_route.c +++ b/src/osmo_ss7_route.c @@ -26,6 +26,7 @@ #include <osmocom/sigtran/mtp_sap.h> #include <osmocom/sigtran/osmo_ss7.h> +#include "ss7_linkset.h" #include "ss7_route.h" #include "ss7_route_table.h" #include "ss7_internal.h" @@ -107,7 +108,7 @@ return -EALREADY; } - lset = osmo_ss7_linkset_find_by_name(rtbl->inst, linkset_name); + lset = ss7_linkset_find_by_name(rtbl->inst, linkset_name); if (!lset) { as = osmo_ss7_as_find_by_name(rtbl->inst, linkset_name); if (!as) diff --git a/src/sccp_scrc.c b/src/sccp_scrc.c index 5b541d3..d9eb6df 100644 --- a/src/sccp_scrc.c +++ b/src/sccp_scrc.c @@ -33,6 +33,7 @@ #include <osmocom/sigtran/protocol/mtp.h> #include "sccp_internal.h" +#include "ss7_linkset.h" #include "ss7_route.h" #include "xua_internal.h" diff --git a/src/ss7_linkset.h b/src/ss7_linkset.h new file mode 100644 index 0000000..daa442f --- /dev/null +++ b/src/ss7_linkset.h @@ -0,0 +1,32 @@ +#pragma once + +#include <stdint.h> +#include <osmocom/core/linuxlist.h> + +/*********************************************************************** + * SS7 Linksets + ***********************************************************************/ + +struct osmo_ss7_instance; +struct osmo_ss7_link; + +struct osmo_ss7_linkset { + struct llist_head list; + /*! \ref osmo_ss7_instance to which we belong */ + struct osmo_ss7_instance *inst; + /*! array of \ref osmo_ss7_link */ + struct osmo_ss7_link *links[16]; + + struct { + char *name; + char *description; + uint32_t adjacent_pc; + uint32_t local_pc; + } cfg; +}; + +void ss7_linkset_destroy(struct osmo_ss7_linkset *lset); +struct osmo_ss7_linkset * +ss7_linkset_find_by_name(struct osmo_ss7_instance *inst, const char *name); +struct osmo_ss7_linkset * +ss7_linkset_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint32_t pc); diff --git a/tests/ss7/ss7_test.c b/tests/ss7/ss7_test.c index 79f6912..3b6a4b3 100644 --- a/tests/ss7/ss7_test.c +++ b/tests/ss7/ss7_test.c @@ -1,3 +1,4 @@ +#include "../src/ss7_linkset.h" #include "../src/ss7_route.h" #include "../src/ss7_route_table.h" #include "../src/xua_internal.h" @@ -156,9 +157,9 @@ rtbl = ss7_route_table_find(s7i, "system"); OSMO_ASSERT(rtbl && rtbl == s7i->rtable_system); - lset_a = osmo_ss7_linkset_find_or_create(s7i, "a", 100); + lset_a = ss7_linkset_find_or_create(s7i, "a", 100); OSMO_ASSERT(lset_a); - lset_b = osmo_ss7_linkset_find_or_create(s7i, "b", 200); + lset_b = ss7_linkset_find_or_create(s7i, "b", 200); OSMO_ASSERT(lset_b); /* route with full mask */ @@ -197,8 +198,8 @@ printf("route with non-consecutive mask: %s\n", osmo_ss7_route_print(rt)); ss7_route_destroy(rt); - osmo_ss7_linkset_destroy(lset_a); - osmo_ss7_linkset_destroy(lset_b); + ss7_linkset_destroy(lset_a); + ss7_linkset_destroy(lset_b); } static void test_linkset(void) @@ -208,16 +209,16 @@ printf("Testing SS7 linkset/link\n"); - OSMO_ASSERT(osmo_ss7_linkset_find_by_name(s7i, "a") == NULL); - OSMO_ASSERT(osmo_ss7_linkset_find_by_name(s7i, "b") == NULL); + OSMO_ASSERT(ss7_linkset_find_by_name(s7i, "a") == NULL); + OSMO_ASSERT(ss7_linkset_find_by_name(s7i, "b") == NULL); - lset_a = osmo_ss7_linkset_find_or_create(s7i, "a", 100); + lset_a = ss7_linkset_find_or_create(s7i, "a", 100); OSMO_ASSERT(lset_a); - OSMO_ASSERT(osmo_ss7_linkset_find_by_name(s7i, "a") == lset_a); + OSMO_ASSERT(ss7_linkset_find_by_name(s7i, "a") == lset_a); - lset_b = osmo_ss7_linkset_find_or_create(s7i, "b", 200); + lset_b = ss7_linkset_find_or_create(s7i, "b", 200); OSMO_ASSERT(lset_b); - OSMO_ASSERT(osmo_ss7_linkset_find_by_name(s7i, "b") == lset_b); + OSMO_ASSERT(ss7_linkset_find_by_name(s7i, "b") == lset_b); l_a1 = osmo_ss7_link_find_or_create(lset_a, 1); OSMO_ASSERT(l_a1); @@ -232,8 +233,8 @@ osmo_ss7_link_destroy(l_a1); osmo_ss7_link_destroy(l_a2); - osmo_ss7_linkset_destroy(lset_a); - osmo_ss7_linkset_destroy(lset_b); + ss7_linkset_destroy(lset_a); + ss7_linkset_destroy(lset_b); } static void test_as(void) -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/38638?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I3b16f858d890b0a31780a2b85a609eae6374665a Gerrit-Change-Number: 38638 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in libosmo-sigtran[master]: sigtran: Make osmo_ss7_link APIs private
by pespin 05 Nov '24

05 Nov '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/38639?usp=email ) Change subject: sigtran: Make osmo_ss7_link APIs private ...................................................................... sigtran: Make osmo_ss7_link APIs private link objects are managed so far exclusively through libosmo-sigtran VTY interface, hence make the struct as well as all its APIs private. Change-Id: Ia6fa48bdc23adb15579852cff4873f654b3bf029 --- M include/osmocom/sigtran/osmo_ss7.h M src/Makefile.am M src/osmo_ss7.c A src/osmo_ss7_link.c M src/osmo_ss7_linkset.c A src/ss7_link.h M tests/ss7/ss7_test.c 7 files changed, 121 insertions(+), 78 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/39/38639/1 diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index e91d354..9a754cd 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -125,32 +125,8 @@ * SS7 Links ***********************************************************************/ -enum osmo_ss7_link_adm_state { - OSMO_SS7_LS_SHUTDOWN, - OSMO_SS7_LS_INHIBITED, - OSMO_SS7_LS_ENABLED, - _NUM_OSMO_SS7_LS -}; - -struct osmo_ss7_linkset; struct osmo_ss7_link; -struct osmo_ss7_link { - /*! \ref osmo_ss7_linkset to which we belong */ - struct osmo_ss7_linkset *linkset; - struct { - char *name; - char *description; - uint32_t id; - - enum osmo_ss7_link_adm_state adm_state; - } cfg; -}; - -void osmo_ss7_link_destroy(struct osmo_ss7_link *link); -struct osmo_ss7_link * -osmo_ss7_link_find_or_create(struct osmo_ss7_linkset *lset, uint32_t id); - /*********************************************************************** * SS7 Linksets ***********************************************************************/ diff --git a/src/Makefile.am b/src/Makefile.am index f92f353..6dd338e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ noinst_HEADERS = \ sccp_internal.h \ ss7_internal.h \ + ss7_link.h \ ss7_linkset.h \ ss7_route.h \ ss7_route_table.h \ @@ -38,6 +39,7 @@ osmo_ss7_asp.c \ osmo_ss7_asp_peer.c \ osmo_ss7_hmrt.c \ + osmo_ss7_link.c \ osmo_ss7_linkset.c \ osmo_ss7_vty.c \ osmo_ss7_xua_srv.c \ diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index b8d8141..8f6d417 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -493,53 +493,6 @@ } /*********************************************************************** - * SS7 Link - ***********************************************************************/ - -/*! \brief Destroy SS7 Link - * \param[in] link SS7 Link to be destroyed */ -void osmo_ss7_link_destroy(struct osmo_ss7_link *link) -{ - struct osmo_ss7_linkset *lset = link->linkset; - - OSMO_ASSERT(ss7_initialized); - LOGSS7(lset->inst, LOGL_INFO, "Destroying Link %s:%u\n", - lset->cfg.name, link->cfg.id); - /* FIXME: do cleanup */ - lset->links[link->cfg.id] = NULL; - talloc_free(link); -} - -/*! \brief Find or create SS7 Link with given ID in given Linkset - * \param[in] lset SS7 Linkset on which we operate - * \param[in] id Link number within Linkset - * \returns pointer to SS7 Link on success; NULL on error */ -struct osmo_ss7_link * -osmo_ss7_link_find_or_create(struct osmo_ss7_linkset *lset, uint32_t id) -{ - struct osmo_ss7_link *link; - - OSMO_ASSERT(ss7_initialized); - if (id >= ARRAY_SIZE(lset->links)) - return NULL; - - if (lset->links[id]) { - link = lset->links[id]; - } else { - LOGSS7(lset->inst, LOGL_INFO, "Creating Link %s:%u\n", - lset->cfg.name, id); - link = talloc_zero(lset, struct osmo_ss7_link); - if (!link) - return NULL; - link->linkset = lset; - lset->links[id] = link; - link->cfg.id = id; - } - - return link; -} - -/*********************************************************************** * SS7 Application Server ***********************************************************************/ diff --git a/src/osmo_ss7_link.c b/src/osmo_ss7_link.c new file mode 100644 index 0000000..321d72e --- /dev/null +++ b/src/osmo_ss7_link.c @@ -0,0 +1,77 @@ +/* (C) 2015-2017 by Harald Welte <laforge(a)gnumonks.org> + * (C) 2023-2024 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <errno.h> + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/logging.h> +#include <osmocom/sigtran/osmo_ss7.h> + +#include "ss7_link.h" +#include "ss7_linkset.h" +#include "ss7_internal.h" + +/*********************************************************************** + * SS7 Link + ***********************************************************************/ + +/*! \brief Destroy SS7 Link + * \param[in] link SS7 Link to be destroyed */ +void ss7_link_destroy(struct osmo_ss7_link *link) +{ + struct osmo_ss7_linkset *lset = link->linkset; + + OSMO_ASSERT(ss7_initialized); + LOGSS7(lset->inst, LOGL_INFO, "Destroying Link %s:%u\n", + lset->cfg.name, link->cfg.id); + /* FIXME: do cleanup */ + lset->links[link->cfg.id] = NULL; + talloc_free(link); +} + +/*! \brief Find or create SS7 Link with given ID in given Linkset + * \param[in] lset SS7 Linkset on which we operate + * \param[in] id Link number within Linkset + * \returns pointer to SS7 Link on success; NULL on error */ +struct osmo_ss7_link * +ss7_link_find_or_create(struct osmo_ss7_linkset *lset, uint32_t id) +{ + struct osmo_ss7_link *link; + + OSMO_ASSERT(ss7_initialized); + if (id >= ARRAY_SIZE(lset->links)) + return NULL; + + if (lset->links[id]) { + link = lset->links[id]; + } else { + LOGSS7(lset->inst, LOGL_INFO, "Creating Link %s:%u\n", + lset->cfg.name, id); + link = talloc_zero(lset, struct osmo_ss7_link); + if (!link) + return NULL; + link->linkset = lset; + lset->links[id] = link; + link->cfg.id = id; + } + + return link; +} diff --git a/src/osmo_ss7_linkset.c b/src/osmo_ss7_linkset.c index 18af7b6..9e0b17b 100644 --- a/src/osmo_ss7_linkset.c +++ b/src/osmo_ss7_linkset.c @@ -25,6 +25,7 @@ #include <osmocom/core/logging.h> #include <osmocom/sigtran/osmo_ss7.h> +#include "ss7_link.h" #include "ss7_linkset.h" #include "ss7_route.h" #include "ss7_route_table.h" @@ -55,7 +56,7 @@ struct osmo_ss7_link *link = lset->links[i]; if (!link) continue; - osmo_ss7_link_destroy(link); + ss7_link_destroy(link); } llist_del(&lset->list); talloc_free(lset); diff --git a/src/ss7_link.h b/src/ss7_link.h new file mode 100644 index 0000000..5ea6556 --- /dev/null +++ b/src/ss7_link.h @@ -0,0 +1,33 @@ +#pragma once + +#include <stdint.h> +#include <osmocom/core/linuxlist.h> + +/*********************************************************************** + * SS7 Linksets + ***********************************************************************/ + +struct osmo_ss7_linkset; + +enum osmo_ss7_link_adm_state { + OSMO_SS7_LS_SHUTDOWN, + OSMO_SS7_LS_INHIBITED, + OSMO_SS7_LS_ENABLED, + _NUM_OSMO_SS7_LS +}; + +struct osmo_ss7_link { + /*! \ref osmo_ss7_linkset to which we belong */ + struct osmo_ss7_linkset *linkset; + struct { + char *name; + char *description; + uint32_t id; + + enum osmo_ss7_link_adm_state adm_state; + } cfg; +}; + +void ss7_link_destroy(struct osmo_ss7_link *link); +struct osmo_ss7_link * +ss7_link_find_or_create(struct osmo_ss7_linkset *lset, uint32_t id); diff --git a/tests/ss7/ss7_test.c b/tests/ss7/ss7_test.c index 3b6a4b3..7d4ec5f 100644 --- a/tests/ss7/ss7_test.c +++ b/tests/ss7/ss7_test.c @@ -1,3 +1,4 @@ +#include "../src/ss7_link.h" #include "../src/ss7_linkset.h" #include "../src/ss7_route.h" #include "../src/ss7_route_table.h" @@ -220,18 +221,18 @@ OSMO_ASSERT(lset_b); OSMO_ASSERT(ss7_linkset_find_by_name(s7i, "b") == lset_b); - l_a1 = osmo_ss7_link_find_or_create(lset_a, 1); + l_a1 = ss7_link_find_or_create(lset_a, 1); OSMO_ASSERT(l_a1); - l_a2 = osmo_ss7_link_find_or_create(lset_a, 2); + l_a2 = ss7_link_find_or_create(lset_a, 2); OSMO_ASSERT(l_a2); /* ID too high */ - OSMO_ASSERT(osmo_ss7_link_find_or_create(lset_a, 1000) == NULL); + OSMO_ASSERT(ss7_link_find_or_create(lset_a, 1000) == NULL); /* already exists */ - OSMO_ASSERT(osmo_ss7_link_find_or_create(lset_a, 1) == l_a1); + OSMO_ASSERT(ss7_link_find_or_create(lset_a, 1) == l_a1); - osmo_ss7_link_destroy(l_a1); - osmo_ss7_link_destroy(l_a2); + ss7_link_destroy(l_a1); + ss7_link_destroy(l_a2); ss7_linkset_destroy(lset_a); ss7_linkset_destroy(lset_b); -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/38639?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: Ia6fa48bdc23adb15579852cff4873f654b3bf029 Gerrit-Change-Number: 38639 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in ...osmo-python-tests[master]: Update osmopy module version to match released tag
by pespin 05 Nov '24

05 Nov '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/38637?usp=email ) Change subject: Update osmopy module version to match released tag ...................................................................... Update osmopy module version to match released tag Change-Id: Idca3f28dad015e626d604e545a0f9b9c9e7bf979 --- M osmopy/__init__.py 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/37/38637/1 diff --git a/osmopy/__init__.py b/osmopy/__init__.py index 05f3335..4ae51c8 100644 --- a/osmopy/__init__.py +++ b/osmopy/__init__.py @@ -1,4 +1,4 @@ #!/usr/bin/env python3 -__version__ = '0.2.1' +__version__ = '0.3.0' __all__ = ['obscvty', 'osmoutil', 'osmo_ipa', 'osmo_interact', 'trap_helper', 'twisted_ipa'] -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/38637?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Idca3f28dad015e626d604e545a0f9b9c9e7bf979 Gerrit-Change-Number: 38637 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in libosmo-sigtran[master]: sigtran: Make osmo_ss7_route struct and several APIs private
by osmith 05 Nov '24

05 Nov '24
Attention is currently required from: fixeria, laforge, pespin. osmith has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/38636?usp=email ) Change subject: sigtran: Make osmo_ss7_route struct and several APIs private ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/38636?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I8a86966cb6a5361687987a2e9acd79c4ab3d97c4 Gerrit-Change-Number: 38636 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(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-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Tue, 05 Nov 2024 11:44:54 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in osmo-bsc[master]: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as()
by pespin 05 Nov '24

05 Nov '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email ) Change subject: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as() ...................................................................... bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as() Use this new API instead of accessing the route struct directly. Depends: libosmo-sigtran.git Change-Id Ife63bd384d247a761e0b89505ea71c41a4a16d9b Change-Id: I198351fba4cfeba310b397c964e5306cd73189ba --- M TODO-RELEASE M src/osmo-bsc/bsc_ctrl.c 2 files changed, 6 insertions(+), 1 deletion(-) Approvals: osmith: Looks good to me, approved laforge: Looks good to me, but someone else must approve pespin: Verified diff --git a/TODO-RELEASE b/TODO-RELEASE index 0ed7189..c073b60 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,4 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line +libosmo-sigtran >2.0.1 Use API osmo_ss7_route_get_dest_as() \ No newline at end of file diff --git a/src/osmo-bsc/bsc_ctrl.c b/src/osmo-bsc/bsc_ctrl.c index aff1d83..5cc8d90 100644 --- a/src/osmo-bsc/bsc_ctrl.c +++ b/src/osmo-bsc/bsc_ctrl.c @@ -632,11 +632,15 @@ static struct osmo_ss7_as *msc_get_ss7_as(struct bsc_msc_data *msc) { struct osmo_ss7_route *rt; + struct osmo_ss7_as *as; struct osmo_ss7_instance *ss7 = osmo_sccp_get_ss7(msc->a.sccp); rt = osmo_ss7_route_lookup(ss7, msc->a.msc_addr.pc); if (!rt) return NULL; - return rt->dest.as; + as = osmo_ss7_route_get_dest_as(rt); + if (!as) + return NULL; + return as; } static int _ss7_as_send(struct osmo_ss7_as *as, struct msgb *msg) -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I198351fba4cfeba310b397c964e5306cd73189ba Gerrit-Change-Number: 38628 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-bsc[master]: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as()
by pespin 05 Nov '24

05 Nov '24
pespin has removed a vote from this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email ) Change subject: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as() ...................................................................... Removed Verified-1 by Jenkins Builder (1000002) -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: deleteVote Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I198351fba4cfeba310b397c964e5306cd73189ba Gerrit-Change-Number: 38628 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-bsc[master]: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as()
by pespin 05 Nov '24

05 Nov '24
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email ) Change subject: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as() ...................................................................... Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I198351fba4cfeba310b397c964e5306cd73189ba Gerrit-Change-Number: 38628 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 05 Nov 2024 11:37:54 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[L] Change in libosmo-sigtran[master]: sigtran: Make osmo_ss7_route struct and several APIs private
by pespin 05 Nov '24

05 Nov '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/38636?usp=email ) Change subject: sigtran: Make osmo_ss7_route struct and several APIs private ...................................................................... sigtran: Make osmo_ss7_route struct and several APIs private The struct is in general managed internally by the library, only a few APIs which are in use by some external users (osmo-hnbgw and osmo-bsc vty) are left public. Change-Id: I8a86966cb6a5361687987a2e9acd79c4ab3d97c4 --- M TODO-RELEASE M include/osmocom/sigtran/osmo_ss7.h M src/Makefile.am M src/osmo_ss7.c M src/osmo_ss7_as.c M src/osmo_ss7_hmrt.c A src/osmo_ss7_route.c M src/osmo_ss7_route_table.c M src/osmo_ss7_vty.c M src/sccp_scrc.c M src/sccp_user.c A src/ss7_route.h M src/xua_as_fsm.c M src/xua_rkm.c M tests/ss7/ss7_test.c 15 files changed, 383 insertions(+), 317 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/36/38636/1 diff --git a/TODO-RELEASE b/TODO-RELEASE index 06d4f53..06ae923 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -9,4 +9,5 @@ #library what description / commit summary line libosmo-sigtran API change struct osmo_ss7_instance has new member 'secondary_pc' libosmo-sigtran add API osmo_sccp_{release,return,reset,error,refusal}_cause_name(s), osmo_sua_sccp_cause_name -libosmo-sigtran add API osmo_ss7_route_get_dest_as() \ No newline at end of file +libosmo-sigtran add API osmo_ss7_route_get_dest_as() +libosmo-sigtran Make private osmo_ss7_route diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 3b5aa4f..002117a 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -181,37 +181,10 @@ * SS7 Routes ***********************************************************************/ -struct osmo_ss7_route { - /*! member in \ref osmo_ss7_route_table.routes */ - struct llist_head list; - /*! \ref osmo_ss7_route_table to which we belong */ - struct osmo_ss7_route_table *rtable; - - struct { - /*! pointer to linkset (destination) of route */ - struct osmo_ss7_linkset *linkset; - /*! pointer to Application Server */ - struct osmo_ss7_as *as; - } dest; - - struct { - /* FIXME: presence? */ - uint32_t pc; - uint32_t mask; - /*! human-specified linkset name */ - char *linkset_name; - /*! lower priority is higher */ - uint32_t priority; - uint8_t qos_class; - } cfg; -}; +struct osmo_ss7_route; struct osmo_ss7_route * osmo_ss7_route_lookup(struct osmo_ss7_instance *inst, uint32_t dpc); -struct osmo_ss7_route * -osmo_ss7_route_create(struct osmo_ss7_route_table *rtbl, uint32_t dpc, - uint32_t mask, const char *linkset_name); -void osmo_ss7_route_destroy(struct osmo_ss7_route *rt); const char *osmo_ss7_route_print(const struct osmo_ss7_route *rt); const char *osmo_ss7_route_name(struct osmo_ss7_route *rt, bool list_asps); struct osmo_ss7_as * diff --git a/src/Makefile.am b/src/Makefile.am index 5dddb05..af6bae8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ noinst_HEADERS = \ sccp_internal.h \ ss7_internal.h \ + ss7_route.h \ ss7_route_table.h \ xua_asp_fsm.h \ xua_as_fsm.h \ @@ -38,6 +39,7 @@ osmo_ss7_hmrt.c \ osmo_ss7_vty.c \ osmo_ss7_xua_srv.c \ + osmo_ss7_route.c \ osmo_ss7_route_table.c \ sccp2sua.c \ sccp_helpers.c \ diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 95e58a7..9ce333d 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -51,6 +51,7 @@ #include "sccp_internal.h" #include "xua_internal.h" #include "ss7_internal.h" +#include "ss7_route.h" #include "ss7_route_table.h" #include "xua_asp_fsm.h" #include "xua_as_fsm.h" @@ -508,7 +509,7 @@ /* find any routes pointing to this AS and remove them */ llist_for_each_entry_safe(rt, rt2, &lset->inst->rtable_system->routes, list) { if (rt->dest.linkset == lset) - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); } for (i = 0; i < ARRAY_SIZE(lset->links); i++) { @@ -611,105 +612,6 @@ return link; } -/*********************************************************************** - * SS7 Routes - ***********************************************************************/ - -/*! \brief Allocate a route entry - * \param[in] rtbl Routing Table where the route belongs - * \param[in] pc Point Code of the destination of the route - * \param[in] mask Mask of the destination Point Code \ref pc - * \returns Allocated route (not yet inserted into its rtbl), NULL on error - * - * The returned route has no linkset associated yet, user *must* associate it - * using API ss7_route_set_linkset() before inserting the route into its - * routing table. - * - * Fields priority and qos_class may be set *before* inserting the route into - * its routing table: - * - A default priority of 0 is configured on the route. - * - A default qos-class of 0 is configured on the route. - * - * Use API ss7_route_insert() to insert the route into its routing table. - * - * The route entry allocated with this API can be destroyed/freed at any point using API - * osmo_ss7_route_destroy(), regardless of it being already inserted or not in - * its routing table. - */ -struct osmo_ss7_route * -ss7_route_alloc(struct osmo_ss7_route_table *rtbl, uint32_t pc, uint32_t mask) -{ - struct osmo_ss7_route *rt; - - OSMO_ASSERT(ss7_initialized); - - rt = talloc_zero(rtbl, struct osmo_ss7_route); - if (!rt) - return NULL; - - /* Mark it as not being inserted yet in rtbl */ - INIT_LLIST_HEAD(&rt->list); - rt->rtable = rtbl; - /* truncate mask to maximum. Let's avoid callers specifying arbitrary large - * masks to ensure we don't fail duplicate detection with longer mask lengths */ - rt->cfg.mask = osmo_ss7_pc_normalize(&rtbl->inst->cfg.pc_fmt, mask); - rt->cfg.pc = osmo_ss7_pc_normalize(&rtbl->inst->cfg.pc_fmt, pc); - rt->cfg.priority = OSMO_SS7_ROUTE_PRIO_DEFAULT; - return rt; -} - -/*! \brief Check whether route has already been inserted into its routing table. - * \returns true if already inserted, false if not. - */ -static bool ss7_route_inserted(const struct osmo_ss7_route *rt) -{ - return !llist_empty(&rt->list); -} - -/*! \brief Set linkset on route entry - * \param[in] rt Route to be configured - * \param[in] linkset_name string name of the linkset to be used - * \returns 0 on success, negative on error. - */ -int -ss7_route_set_linkset(struct osmo_ss7_route *rt, const char *linkset_name) -{ - struct osmo_ss7_linkset *lset; - struct osmo_ss7_as *as = NULL; - struct osmo_ss7_route_table *rtbl = rt->rtable; - - if (rt->cfg.linkset_name) { - LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt setting linkset on route already configured!\n"); - return -EBUSY; - } - - if (ss7_route_inserted(rt)) { - LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt setting linkset on route already in the routing table!\n"); - return -EALREADY; - } - - lset = osmo_ss7_linkset_find_by_name(rtbl->inst, linkset_name); - if (!lset) { - as = osmo_ss7_as_find_by_name(rtbl->inst, linkset_name); - if (!as) - return -ENODEV; - } - - rt->cfg.linkset_name = talloc_strdup(rt, linkset_name); - if (lset) { - rt->dest.linkset = lset; - LOGSS7(rtbl->inst, LOGL_INFO, "Creating route: pc=%u=%s mask=0x%x via linkset '%s'\n", - rt->cfg.pc, osmo_ss7_pointcode_print(rtbl->inst, rt->cfg.pc), - rt->cfg.mask, lset->cfg.name); - } else { - rt->dest.as = as; - LOGSS7(rtbl->inst, LOGL_INFO, "Creating route: pc=%u=%s mask=0x%x via AS '%s'\n", - rt->cfg.pc, osmo_ss7_pointcode_print(rtbl->inst, rt->cfg.pc), - rt->cfg.mask, as->cfg.name); - } - return 0; -} - /*! \brief Find a SS7 route for given destination point code in given SS7 */ struct osmo_ss7_route * osmo_ss7_route_lookup(struct osmo_ss7_instance *inst, uint32_t dpc) @@ -718,170 +620,6 @@ return ss7_route_table_find_route_by_dpc(inst->rtable_system, dpc); } -/* insert the route in the ordered list of routes. The list is sorted by - * mask length, so that the more specific (longer mask) routes are - * first, while the less specific routes with shorter masks are last. - * Within the same mask length, the routes are ordered by priority. - * Hence, the first matching route in a linear iteration is the most - * specific match. */ -static void route_insert_sorted(struct osmo_ss7_route_table *rtbl, - struct osmo_ss7_route *cmp) -{ - struct osmo_ss7_route *rt; - - llist_for_each_entry(rt, &rtbl->routes, list) { - if (rt->cfg.mask == cmp->cfg.mask && - rt->cfg.priority > cmp->cfg.priority) { - /* insert before the current entry */ - llist_add(&cmp->list, rt->list.prev); - return; - } - if (rt->cfg.mask < cmp->cfg.mask) { - /* insert before the current entry */ - llist_add(&cmp->list, rt->list.prev); - return; - } - } - /* not added, i.e. no smaller mask length and priority found: we are the - * smallest mask and priority and thus should go last */ - llist_add_tail(&cmp->list, &rtbl->routes); -} - -/*! \brief Insert route into its routing table - * \param[in] rt Route to be inserted into its routing table - * \returns 0 on success, negative on error - * - * A route is only really used once it has been inserted into its routing table. - */ -int -ss7_route_insert(struct osmo_ss7_route *rt) -{ - struct osmo_ss7_route *prev_rt; - struct osmo_ss7_route_table *rtbl = rt->rtable; - - if (ss7_route_inserted(rt)) { - LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt insert of route already in the routing table!\n"); - return -EALREADY; - } - - if (!rt->cfg.linkset_name) { - LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt insert of route with unset linkset!\n"); - return -EINVAL; - } - - /* check for duplicates */ - prev_rt = ss7_route_table_find_route_by_dpc_mask(rtbl, rt->cfg.pc, rt->cfg.mask); - if (prev_rt && !strcmp(prev_rt->cfg.linkset_name, rt->cfg.linkset_name)) { - LOGSS7(rtbl->inst, LOGL_ERROR, - "Refusing to create route with existing linkset name: pc=%u=%s mask=0x%x via linkset/AS '%s'\n", - rt->cfg.pc, osmo_ss7_pointcode_print(rtbl->inst, rt->cfg.pc), - rt->cfg.mask, rt->cfg.linkset_name); - return -EADDRINUSE; - } - - route_insert_sorted(rtbl, rt); - return 0; -} - -/*! \brief Create a new route in the given routing table - * \param[in] rtbl Routing Table in which the route is to be created - * \param[in] pc Point Code of the destination of the route - * \param[in] mask Mask of the destination Point Code \ref pc - * \param[in] linkset_name string name of the linkset to be used - * \returns callee-allocated + initialized route, NULL on error - * - * The route allocated and returned by this API is already inserted into the - * routing table, with priority and qos-class set to 0. - * If you plan to use different values for priority and qos-class, avoid using - * this API and use ss7_route_alloc() + ss7_route_set_linkset() + - * ss7_route_insert() instead. - */ -struct osmo_ss7_route * -osmo_ss7_route_create(struct osmo_ss7_route_table *rtbl, uint32_t pc, - uint32_t mask, const char *linkset_name) -{ - struct osmo_ss7_route *rt; - int rc; - - rt = ss7_route_alloc(rtbl, pc, mask); - if (!rt) - return NULL; - - if (ss7_route_set_linkset(rt, linkset_name) < 0) { - talloc_free(rt); - return NULL; - } - - rc = ss7_route_insert(rt); - /* Keep old behavior, return already existing route: */ - if (rc == -EADDRINUSE) { - talloc_free(rt); - return ss7_route_table_find_route_by_dpc_mask(rtbl, rt->cfg.pc, rt->cfg.mask); - } - - return rt; -} - -/*! \brief Destroy a given SS7 route */ -void osmo_ss7_route_destroy(struct osmo_ss7_route *rt) -{ - OSMO_ASSERT(ss7_initialized); - - if (!rt) - return; - - if (ss7_route_inserted(rt)) { - struct osmo_ss7_instance *inst = rt->rtable->inst; - LOGSS7(inst, LOGL_INFO, - "Destroying route: pc=%u=%s mask=0x%x via linkset/ASP '%s'\n", - rt->cfg.pc, osmo_ss7_pointcode_print(inst, rt->cfg.pc), - rt->cfg.mask, rt->cfg.linkset_name); - llist_del(&rt->list); - } - talloc_free(rt); -} - -/* count number of consecutive leading (MSB) bits that are '1' */ -static unsigned int count_leading_one_bits(uint32_t inp, unsigned int nbits) -{ - unsigned int i; - - for (i = 0; i < nbits; i++) { - if (!(inp & (1 << (nbits-1-i)))) - return i; - } - return i; -} - -/* determine the mask length in number of bits; negative if non-consecutive mask */ -static int u32_masklen(uint32_t mask, unsigned int nbits) -{ - unsigned int i; - unsigned int leading_one_bits = count_leading_one_bits(mask, nbits); - - /* are there any bits set after the initial bits? */ - for (i = leading_one_bits; i < nbits; i++) { - if (mask & (1 << (nbits-1-i))) - return -1; /* not a simple prefix mask */ - } - return leading_one_bits; -} - -const char *osmo_ss7_route_print(const struct osmo_ss7_route *rt) -{ - const struct osmo_ss7_instance *inst = rt->rtable->inst; - unsigned int pc_width = osmo_ss7_pc_width(&inst->cfg.pc_fmt); - static char buf[64]; - int rc = u32_masklen(rt->cfg.mask, pc_width); - - if (rc < 0) - snprintf(buf, sizeof(buf), "%s/%s", osmo_ss7_pointcode_print(inst, rt->cfg.pc), - osmo_ss7_pointcode_print2(inst, rt->cfg.mask)); - else - snprintf(buf, sizeof(buf), "%s/%u", osmo_ss7_pointcode_print(inst, rt->cfg.pc), rc); - return buf; -} - /*! \brief Get destination AS of route * \param[in] rt Route entry holding the AS destination * \returns pointer to Application Server on success; NULL if rt doesn't route diff --git a/src/osmo_ss7_as.c b/src/osmo_ss7_as.c index 87e7e04..cc61b12 100644 --- a/src/osmo_ss7_as.c +++ b/src/osmo_ss7_as.c @@ -33,6 +33,7 @@ #include <osmocom/core/talloc.h> #include <osmocom/core/logging.h> +#include "ss7_route.h" #include "ss7_route_table.h" #include "ss7_internal.h" #include "xua_as_fsm.h" @@ -166,7 +167,7 @@ /* find any routes pointing to this AS and remove them */ llist_for_each_entry_safe(rt, rt2, &as->inst->rtable_system->routes, list) { if (rt->dest.as == as) - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); } as->inst = NULL; diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c index 57d7388..55e5776 100644 --- a/src/osmo_ss7_hmrt.c +++ b/src/osmo_ss7_hmrt.c @@ -35,6 +35,7 @@ #include <osmocom/sigtran/protocol/m3ua.h> #include "xua_internal.h" +#include "ss7_route.h" #include "ss7_route_table.h" #include "ss7_internal.h" diff --git a/src/osmo_ss7_route.c b/src/osmo_ss7_route.c new file mode 100644 index 0000000..daef749 --- /dev/null +++ b/src/osmo_ss7_route.c @@ -0,0 +1,294 @@ +/* (C) 2015-2017 by Harald Welte <laforge(a)gnumonks.org> + * (C) 2023-2024 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <errno.h> + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/logging.h> +#include <osmocom/sigtran/mtp_sap.h> +#include <osmocom/sigtran/osmo_ss7.h> + +#include "ss7_route.h" +#include "ss7_route_table.h" +#include "ss7_internal.h" + +/*********************************************************************** + * SS7 Routes + ***********************************************************************/ + +/*! \brief Allocate a route entry + * \param[in] rtbl Routing Table where the route belongs + * \param[in] pc Point Code of the destination of the route + * \param[in] mask Mask of the destination Point Code \ref pc + * \returns Allocated route (not yet inserted into its rtbl), NULL on error + * + * The returned route has no linkset associated yet, user *must* associate it + * using API ss7_route_set_linkset() before inserting the route into its + * routing table. + * + * Fields priority and qos_class may be set *before* inserting the route into + * its routing table: + * - A default priority of 0 is configured on the route. + * - A default qos-class of 0 is configured on the route. + * + * Use API ss7_route_insert() to insert the route into its routing table. + * + * The route entry allocated with this API can be destroyed/freed at any point using API + * ss7_route_destroy(), regardless of it being already inserted or not in + * its routing table. + */ +struct osmo_ss7_route * +ss7_route_alloc(struct osmo_ss7_route_table *rtbl, uint32_t pc, uint32_t mask) +{ + struct osmo_ss7_route *rt; + + OSMO_ASSERT(ss7_initialized); + + rt = talloc_zero(rtbl, struct osmo_ss7_route); + if (!rt) + return NULL; + + /* Mark it as not being inserted yet in rtbl */ + INIT_LLIST_HEAD(&rt->list); + rt->rtable = rtbl; + /* truncate mask to maximum. Let's avoid callers specifying arbitrary large + * masks to ensure we don't fail duplicate detection with longer mask lengths */ + rt->cfg.mask = osmo_ss7_pc_normalize(&rtbl->inst->cfg.pc_fmt, mask); + rt->cfg.pc = osmo_ss7_pc_normalize(&rtbl->inst->cfg.pc_fmt, pc); + rt->cfg.priority = OSMO_SS7_ROUTE_PRIO_DEFAULT; + return rt; +} + +/*! \brief Check whether route has already been inserted into its routing table. + * \returns true if already inserted, false if not. + */ +static bool ss7_route_inserted(const struct osmo_ss7_route *rt) +{ + return !llist_empty(&rt->list); +} + +/*! \brief Set linkset on route entry + * \param[in] rt Route to be configured + * \param[in] linkset_name string name of the linkset to be used + * \returns 0 on success, negative on error. + */ +int +ss7_route_set_linkset(struct osmo_ss7_route *rt, const char *linkset_name) +{ + struct osmo_ss7_linkset *lset; + struct osmo_ss7_as *as = NULL; + struct osmo_ss7_route_table *rtbl = rt->rtable; + + if (rt->cfg.linkset_name) { + LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt setting linkset on route already configured!\n"); + return -EBUSY; + } + + if (ss7_route_inserted(rt)) { + LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt setting linkset on route already in the routing table!\n"); + return -EALREADY; + } + + lset = osmo_ss7_linkset_find_by_name(rtbl->inst, linkset_name); + if (!lset) { + as = osmo_ss7_as_find_by_name(rtbl->inst, linkset_name); + if (!as) + return -ENODEV; + } + + rt->cfg.linkset_name = talloc_strdup(rt, linkset_name); + if (lset) { + rt->dest.linkset = lset; + LOGSS7(rtbl->inst, LOGL_INFO, "Creating route: pc=%u=%s mask=0x%x via linkset '%s'\n", + rt->cfg.pc, osmo_ss7_pointcode_print(rtbl->inst, rt->cfg.pc), + rt->cfg.mask, lset->cfg.name); + } else { + rt->dest.as = as; + LOGSS7(rtbl->inst, LOGL_INFO, "Creating route: pc=%u=%s mask=0x%x via AS '%s'\n", + rt->cfg.pc, osmo_ss7_pointcode_print(rtbl->inst, rt->cfg.pc), + rt->cfg.mask, as->cfg.name); + } + return 0; +} + +/* insert the route in the ordered list of routes. The list is sorted by + * mask length, so that the more specific (longer mask) routes are + * first, while the less specific routes with shorter masks are last. + * Within the same mask length, the routes are ordered by priority. + * Hence, the first matching route in a linear iteration is the most + * specific match. */ +static void route_insert_sorted(struct osmo_ss7_route_table *rtbl, + struct osmo_ss7_route *cmp) +{ + struct osmo_ss7_route *rt; + + llist_for_each_entry(rt, &rtbl->routes, list) { + if (rt->cfg.mask == cmp->cfg.mask && + rt->cfg.priority > cmp->cfg.priority) { + /* insert before the current entry */ + llist_add(&cmp->list, rt->list.prev); + return; + } + if (rt->cfg.mask < cmp->cfg.mask) { + /* insert before the current entry */ + llist_add(&cmp->list, rt->list.prev); + return; + } + } + /* not added, i.e. no smaller mask length and priority found: we are the + * smallest mask and priority and thus should go last */ + llist_add_tail(&cmp->list, &rtbl->routes); +} + +/*! \brief Insert route into its routing table + * \param[in] rt Route to be inserted into its routing table + * \returns 0 on success, negative on error + * + * A route is only really used once it has been inserted into its routing table. + */ +int +ss7_route_insert(struct osmo_ss7_route *rt) +{ + struct osmo_ss7_route *prev_rt; + struct osmo_ss7_route_table *rtbl = rt->rtable; + + if (ss7_route_inserted(rt)) { + LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt insert of route already in the routing table!\n"); + return -EALREADY; + } + + if (!rt->cfg.linkset_name) { + LOGSS7(rtbl->inst, LOGL_ERROR, "Attempt insert of route with unset linkset!\n"); + return -EINVAL; + } + + /* check for duplicates */ + prev_rt = ss7_route_table_find_route_by_dpc_mask(rtbl, rt->cfg.pc, rt->cfg.mask); + if (prev_rt && !strcmp(prev_rt->cfg.linkset_name, rt->cfg.linkset_name)) { + LOGSS7(rtbl->inst, LOGL_ERROR, + "Refusing to create route with existing linkset name: pc=%u=%s mask=0x%x via linkset/AS '%s'\n", + rt->cfg.pc, osmo_ss7_pointcode_print(rtbl->inst, rt->cfg.pc), + rt->cfg.mask, rt->cfg.linkset_name); + return -EADDRINUSE; + } + + route_insert_sorted(rtbl, rt); + return 0; +} + +/*! \brief Create a new route in the given routing table + * \param[in] rtbl Routing Table in which the route is to be created + * \param[in] pc Point Code of the destination of the route + * \param[in] mask Mask of the destination Point Code \ref pc + * \param[in] linkset_name string name of the linkset to be used + * \returns callee-allocated + initialized route, NULL on error + * + * The route allocated and returned by this API is already inserted into the + * routing table, with priority and qos-class set to 0. + * If you plan to use different values for priority and qos-class, avoid using + * this API and use ss7_route_alloc() + ss7_route_set_linkset() + + * ss7_route_insert() instead. + */ +struct osmo_ss7_route * +ss7_route_create(struct osmo_ss7_route_table *rtbl, uint32_t pc, + uint32_t mask, const char *linkset_name) +{ + struct osmo_ss7_route *rt; + int rc; + + rt = ss7_route_alloc(rtbl, pc, mask); + if (!rt) + return NULL; + + if (ss7_route_set_linkset(rt, linkset_name) < 0) { + talloc_free(rt); + return NULL; + } + + rc = ss7_route_insert(rt); + /* Keep old behavior, return already existing route: */ + if (rc == -EADDRINUSE) { + talloc_free(rt); + return ss7_route_table_find_route_by_dpc_mask(rtbl, rt->cfg.pc, rt->cfg.mask); + } + + return rt; +} + +/*! \brief Destroy a given SS7 route */ +void ss7_route_destroy(struct osmo_ss7_route *rt) +{ + OSMO_ASSERT(ss7_initialized); + + if (!rt) + return; + + if (ss7_route_inserted(rt)) { + struct osmo_ss7_instance *inst = rt->rtable->inst; + LOGSS7(inst, LOGL_INFO, + "Destroying route: pc=%u=%s mask=0x%x via linkset/ASP '%s'\n", + rt->cfg.pc, osmo_ss7_pointcode_print(inst, rt->cfg.pc), + rt->cfg.mask, rt->cfg.linkset_name); + llist_del(&rt->list); + } + talloc_free(rt); +} + +/* count number of consecutive leading (MSB) bits that are '1' */ +static unsigned int count_leading_one_bits(uint32_t inp, unsigned int nbits) +{ + unsigned int i; + + for (i = 0; i < nbits; i++) { + if (!(inp & (1 << (nbits-1-i)))) + return i; + } + return i; +} + +/* determine the mask length in number of bits; negative if non-consecutive mask */ +static int u32_masklen(uint32_t mask, unsigned int nbits) +{ + unsigned int i; + unsigned int leading_one_bits = count_leading_one_bits(mask, nbits); + + /* are there any bits set after the initial bits? */ + for (i = leading_one_bits; i < nbits; i++) { + if (mask & (1 << (nbits-1-i))) + return -1; /* not a simple prefix mask */ + } + return leading_one_bits; +} + +const char *osmo_ss7_route_print(const struct osmo_ss7_route *rt) +{ + const struct osmo_ss7_instance *inst = rt->rtable->inst; + unsigned int pc_width = osmo_ss7_pc_width(&inst->cfg.pc_fmt); + static char buf[64]; + int rc = u32_masklen(rt->cfg.mask, pc_width); + + if (rc < 0) + snprintf(buf, sizeof(buf), "%s/%s", osmo_ss7_pointcode_print(inst, rt->cfg.pc), + osmo_ss7_pointcode_print2(inst, rt->cfg.mask)); + else + snprintf(buf, sizeof(buf), "%s/%u", osmo_ss7_pointcode_print(inst, rt->cfg.pc), rc); + return buf; +} diff --git a/src/osmo_ss7_route_table.c b/src/osmo_ss7_route_table.c index 2939bf4..4ab4594 100644 --- a/src/osmo_ss7_route_table.c +++ b/src/osmo_ss7_route_table.c @@ -24,6 +24,7 @@ #include <osmocom/sigtran/mtp_sap.h> #include <osmocom/sigtran/osmo_ss7.h> +#include "ss7_route.h" #include "ss7_route_table.h" #include "ss7_internal.h" diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index aa8c9bc..6c9db5a 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -46,6 +46,7 @@ #include "xua_internal.h" #include <osmocom/sigtran/sccp_sap.h> #include "sccp_internal.h" +#include "ss7_route.h" #include "ss7_route_table.h" #include "ss7_internal.h" @@ -443,7 +444,7 @@ return CMD_SUCCESS; destroy_warning: - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); return CMD_WARNING; } @@ -477,7 +478,7 @@ return CMD_WARNING; } - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); return CMD_SUCCESS; } @@ -2025,7 +2026,7 @@ if (cs7_role == CS7_ROLE_ASP) { rt = ss7_route_table_find_route_by_dpc_mask(as->inst->rtable_system, rkey->pc, 0xffffff); if (rt) - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); } rkey->pc = pc; @@ -2036,7 +2037,7 @@ /* automatically add new route (see also comment above) */ if (cs7_role == CS7_ROLE_ASP) { - if (!osmo_ss7_route_create(as->inst->rtable_system, rkey->pc, 0xffffff, as->cfg.name)) { + if (!ss7_route_create(as->inst->rtable_system, rkey->pc, 0xffffff, as->cfg.name)) { vty_out(vty, "Cannot create route (pc=%s, linkset=%s) to AS %s", dpc, as->cfg.name, VTY_NEWLINE); return CMD_WARNING; } diff --git a/src/sccp_scrc.c b/src/sccp_scrc.c index be23c21..5b541d3 100644 --- a/src/sccp_scrc.c +++ b/src/sccp_scrc.c @@ -33,8 +33,10 @@ #include <osmocom/sigtran/protocol/mtp.h> #include "sccp_internal.h" +#include "ss7_route.h" #include "xua_internal.h" + /*********************************************************************** * Helper Functions ***********************************************************************/ diff --git a/src/sccp_user.c b/src/sccp_user.c index 277ca5f..6edbfd1 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -39,6 +39,7 @@ #include "sccp_internal.h" #include "xua_internal.h" +#include "ss7_route.h" #include "ss7_route_table.h" #include "ss7_internal.h" @@ -589,7 +590,7 @@ rt = ss7_route_table_find_route_by_dpc_mask(ss7->rtable_system, 0, 0); if (!rt) { LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating default route\n", name); - rt = osmo_ss7_route_create(ss7->rtable_system, 0, 0, + rt = ss7_route_create(ss7->rtable_system, 0, 0, as->cfg.name); if (!rt) goto out_as; @@ -711,7 +712,7 @@ osmo_ss7_asp_destroy(asp); out_rt: if (rt_created) - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); out_as: if (as_created) osmo_ss7_as_destroy(as); @@ -838,7 +839,7 @@ goto out_strings; /* route only selected PC to the client */ - rt = osmo_ss7_route_create(ss7->rtable_system, pc, 0xffff, as_name); + rt = ss7_route_create(ss7->rtable_system, pc, 0xffff, as_name); if (!rt) goto out_as; @@ -868,7 +869,7 @@ out_asp: osmo_ss7_asp_destroy(asp); out_rt: - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); out_as: osmo_ss7_as_destroy(as); out_strings: diff --git a/src/ss7_route.h b/src/ss7_route.h new file mode 100644 index 0000000..6e74ff0 --- /dev/null +++ b/src/ss7_route.h @@ -0,0 +1,48 @@ +#pragma once + +#include <stdint.h> +#include <osmocom/core/linuxlist.h> + +/*********************************************************************** + * SS7 Routes + ***********************************************************************/ + +struct osmo_ss7_instance; +struct osmo_ss7_route_table; +struct osmo_ss7_linkset; +struct osmo_ss7_as; + +struct osmo_ss7_route { + /*! member in \ref osmo_ss7_route_table.routes */ + struct llist_head list; + /*! \ref osmo_ss7_route_table to which we belong */ + struct osmo_ss7_route_table *rtable; + + struct { + /*! pointer to linkset (destination) of route */ + struct osmo_ss7_linkset *linkset; + /*! pointer to Application Server */ + struct osmo_ss7_as *as; + } dest; + + struct { + /* FIXME: presence? */ + uint32_t pc; + uint32_t mask; + /*! human-specified linkset name */ + char *linkset_name; + /*! lower priority is higher */ + uint32_t priority; + uint8_t qos_class; + } cfg; +}; + +struct osmo_ss7_route * +ss7_route_find_dpc(struct osmo_ss7_route_table *rtbl, uint32_t dpc); +struct osmo_ss7_route * +ss7_route_find_dpc_mask(struct osmo_ss7_route_table *rtbl, uint32_t dpc, + uint32_t mask); +struct osmo_ss7_route * +ss7_route_create(struct osmo_ss7_route_table *rtbl, uint32_t dpc, + uint32_t mask, const char *linkset_name); +void ss7_route_destroy(struct osmo_ss7_route *rt); diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c index 2083ca0..dff0d06 100644 --- a/src/xua_as_fsm.c +++ b/src/xua_as_fsm.c @@ -23,6 +23,7 @@ #include <osmocom/sigtran/protocol/sua.h> #include <osmocom/sigtran/protocol/m3ua.h> +#include "ss7_route.h" #include "ss7_route_table.h" #include "xua_asp_fsm.h" #include "xua_as_fsm.h" @@ -236,7 +237,7 @@ /* As opposed to M3UA, there is no RKM and we have to implicitly * automatically add a route once an IPA connection has come up */ - if (osmo_ss7_route_create(inst->rtable_system, as->cfg.routing_key.pc, 0xffffff, as->cfg.name)) + if (ss7_route_create(inst->rtable_system, as->cfg.routing_key.pc, 0xffffff, as->cfg.name)) xafp->ipa_route_created = true; } @@ -269,7 +270,7 @@ return; } - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); xafp->ipa_route_created = false; } diff --git a/src/xua_rkm.c b/src/xua_rkm.c index 774cf3a..38fb903 100644 --- a/src/xua_rkm.c +++ b/src/xua_rkm.c @@ -28,6 +28,7 @@ #include <osmocom/sigtran/osmo_ss7.h> #include <osmocom/sigtran/protocol/m3ua.h> +#include "ss7_route.h" #include "ss7_route_table.h" #include "xua_internal.h" #include "xua_as_fsm.h" @@ -260,7 +261,7 @@ as->cfg.routing_key.context = rctx; /* add route for that routing key */ - rt = osmo_ss7_route_create(as->inst->rtable_system, dpc, 0xFFFFFF, namebuf); + rt = ss7_route_create(as->inst->rtable_system, dpc, 0xFFFFFF, namebuf); if (!rt) { LOGPASP(asp, DLSS7, LOGL_ERROR, "RKM: Cannot insert route for DPC %s / as %s\n", osmo_ss7_pointcode_print(asp->inst, dpc), namebuf); @@ -271,7 +272,7 @@ /* append to list of newly assigned as */ if (*nas_idx >= max_nas_idx) { - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); osmo_ss7_as_destroy(as); LOGPASP(asp, DLSS7, LOGL_ERROR, "RKM: not enough room for newly assigned AS (max %u AS)\n", max_nas_idx+1); @@ -392,7 +393,7 @@ * route and destroy the AS */ if (as->rkm_dyn_allocated) { /* remove route + AS definition */ - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); osmo_ss7_as_destroy(as); } /* report success */ diff --git a/tests/ss7/ss7_test.c b/tests/ss7/ss7_test.c index 5f00f78..79f6912 100644 --- a/tests/ss7/ss7_test.c +++ b/tests/ss7/ss7_test.c @@ -1,3 +1,4 @@ +#include "../src/ss7_route.h" #include "../src/ss7_route_table.h" #include "../src/xua_internal.h" #include "../src/xua_asp_fsm.h" @@ -162,14 +163,14 @@ /* route with full mask */ OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 12) == NULL); - rt = osmo_ss7_route_create(rtbl, 12, 0xffff, "a"); + rt = ss7_route_create(rtbl, 12, 0xffff, "a"); printf("route with full mask: %s\n", osmo_ss7_route_print(rt)); OSMO_ASSERT(rt); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 12) == rt); - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); /* route with partial mask */ - rt = osmo_ss7_route_create(rtbl, 8, 0xfff8, "a"); + rt = ss7_route_create(rtbl, 8, 0xfff8, "a"); printf("route with partial mask: %s\n", osmo_ss7_route_print(rt)); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 8) == rt); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 9) == rt); @@ -178,23 +179,23 @@ OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 16) == NULL); /* insert more specific route for 12, must have higher priority * than existing one */ - rt12 = osmo_ss7_route_create(rtbl, 12, 0xffff, "b"); + rt12 = ss7_route_create(rtbl, 12, 0xffff, "b"); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 12) == rt12); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 15) == rt); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 16) == NULL); /* add a default route, which should have lowest precedence */ - rtdef = osmo_ss7_route_create(rtbl, 0, 0, "a"); + rtdef = ss7_route_create(rtbl, 0, 0, "a"); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 12) == rt12); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 15) == rt); OSMO_ASSERT(ss7_route_table_find_route_by_dpc(rtbl, 16) == rtdef); - osmo_ss7_route_destroy(rtdef); - osmo_ss7_route_destroy(rt12); - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rtdef); + ss7_route_destroy(rt12); + ss7_route_destroy(rt); - rt = osmo_ss7_route_create(rtbl, 8, 0xfff9, "a"); + rt = ss7_route_create(rtbl, 8, 0xfff9, "a"); printf("route with non-consecutive mask: %s\n", osmo_ss7_route_print(rt)); - osmo_ss7_route_destroy(rt); + ss7_route_destroy(rt); osmo_ss7_linkset_destroy(lset_a); osmo_ss7_linkset_destroy(lset_b); -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/38636?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I8a86966cb6a5361687987a2e9acd79c4ab3d97c4 Gerrit-Change-Number: 38636 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-bsc[master]: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as()
by osmith 05 Nov '24

05 Nov '24
Attention is currently required from: pespin. osmith has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email ) Change subject: bsc_ctrl: Use new libosmo-sigtran API osmo_ss7_route_get_dest_as() ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38628?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I198351fba4cfeba310b397c964e5306cd73189ba Gerrit-Change-Number: 38628 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 05 Nov 2024 11:11:11 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • ...
  • 221
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.