[PATCH] libosmo-sccp[master]: sccp: enable global addressbook search

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Jul 17 09:36:00 UTC 2017


Review at  https://gerrit.osmocom.org/3265

sccp: enable global addressbook search

The sccp-addressbook only allows defining addresses for a specific
ss7 instance. It is not possible to use an sscp-address, that is
defined in the one ss7 instance in another ss7 instance.

Add a second global list where all sscp-addresses are added,
regardless on which instance they are defined.

Fixup the search functions so that they search the global list
when the ss7 instance pointer is set to NULL

Change-Id: I5acc1e5abc3b3081149a9f476038e4e53d23b763
---
M src/osmo_ss7_vty.c
1 file changed, 35 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/65/3265/1

diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 685df29..17e0644 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -934,6 +934,7 @@
 /* SCCP addressbook */
 struct osmo_sccp_addr_entry {
 	struct llist_head list;
+	struct llist_head list_global;
 	struct osmo_ss7_instance *inst;
 	char name[512];
 	struct osmo_sccp_addr addr;
@@ -951,22 +952,35 @@
 	1,
 };
 
+/* A global list that holds all addressbook entries at once
+ * (see also .cfg in struct osmo_ss7_instance) */
+LLIST_HEAD(sccp_address_book_global);
+
 /* Pick an SCCP address entry from the addressbook by its name */
-struct osmo_sccp_addr_entry *addr_entry_by_name(const char *name,
-						const struct osmo_ss7_instance
-						*inst)
+static struct osmo_sccp_addr_entry
+*addr_entry_by_name(const char *name, const struct osmo_ss7_instance *inst)
 {
 	struct osmo_sccp_addr_entry *entry;
-	llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
-		if (strcmp(entry->name, name) == 0)
-			return entry;
+
+	if (inst == NULL) {
+		llist_for_each_entry(entry, &sccp_address_book_global,
+				     list_global) {
+			if (strcmp(entry->name, name) == 0)
+				return entry;
+		}
+	} else {
+		llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+			if (strcmp(entry->name, name) == 0)
+				return entry;
+		}
 	}
+
 	return NULL;
 }
 
 /*! \brief Lookup an SCCP address from the addressbook by its name.
  *  \param[in] lookup-name of the address to lookup
- *  \param[in] ss7 instance
+ *  \param[in] ss7 instance (NULL to search global)
  *  \returns SCCP address; NULL on error */
 struct osmo_sccp_addr *osmo_sccp_addr_by_name(const char *name,
 					      const struct osmo_ss7_instance
@@ -983,15 +997,23 @@
 
 /*! \brief Reverse lookup the lookup-name of a specified SCCP address.
  *  \param[in] name of the address to lookup
- *  \param[in] ss7 instance
+ *  \param[in] ss7 instance (NULL to search global)
  *  \returns char pointer to the lookup-name; NULL on error */
 char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
 			     const struct osmo_ss7_instance *ss7)
 {
 	struct osmo_sccp_addr_entry *entry;
-	llist_for_each_entry(entry, &ss7->cfg.sccp_address_book, list) {
-		if (memcmp(&entry->addr, addr, sizeof(*addr)) == 0)
-			return entry->name;
+
+	if (ss7 == NULL) {
+		llist_for_each_entry(entry, &sccp_address_book_global, list_global) {
+			if (memcmp(&entry->addr, addr, sizeof(*addr)) == 0)
+				return entry->name;
+		}
+	} else {
+		llist_for_each_entry(entry, &ss7->cfg.sccp_address_book, list) {
+			if (memcmp(&entry->addr, addr, sizeof(*addr)) == 0)
+				return entry->name;
+		}
 	}
 
 	return NULL;
@@ -1185,6 +1207,7 @@
 		entry = talloc_zero(inst, struct osmo_sccp_addr_entry);
 		osmo_strlcpy(entry->name, name, sizeof(entry->name));
 		llist_add_tail(&entry->list, &inst->cfg.sccp_address_book);
+		llist_add_tail(&entry->list_global, &sccp_address_book_global);
 		entry->addr.ri = OSMO_SCCP_RI_SSN_PC;
 	}
 
@@ -1207,6 +1230,7 @@
 	entry = addr_entry_by_name(name, inst);
 	if (entry) {
 		llist_del(&entry->list);
+		llist_del(&entry->list_global);
 		talloc_free(entry);
 	} else {
 		vty_out(vty, "Addressbook entry not found!%s", VTY_NEWLINE);

-- 
To view, visit https://gerrit.osmocom.org/3265
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5acc1e5abc3b3081149a9f476038e4e53d23b763
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list