[PATCH] libosmo-sccp[master]: sccp: improve sccp-addressbook API

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
Wed Jul 19 11:55:36 UTC 2017


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

sccp: improve sccp-addressbook API

When searching the addressbook, return the SS7 instance
and write sccp-address to given destination pointer.
(name -> addr+ss7inst)

Remove the no longer needed ss7 instance pointer when
using the backward search. (addr -> name)

Change-Id: I68209dd1b2c0aa94b1894637a22b5cc3a3ff1250
---
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7_vty.c
2 files changed, 20 insertions(+), 27 deletions(-)


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

diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h
index 2258b0d..c00320c 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -248,8 +248,7 @@
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
 
-struct osmo_sccp_addr *
-osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
+struct osmo_ss7_instance *
+osmo_sccp_addr_by_name(struct osmo_sccp_addr *addr, const char *name);
 
-char * osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
-			      const struct osmo_ss7_instance *ss7);
+const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr);
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 76882eb..e3f7f46 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -979,41 +979,35 @@
 }
 
 /*! \brief Lookup an SCCP address from the addressbook by its name.
- *  \param[in] lookup-name of the address to lookup
- *  \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
-					      *ss7)
+ *  \param[in] addr pointer to output the resulting sccp-address;
+ *  (set to NULL if not interested)
+ *  \param[in] name of the address to lookup
+ *  \returns SS7 instance; NULL on error */
+struct osmo_ss7_instance *osmo_sccp_addr_by_name(struct osmo_sccp_addr *addr,
+						 const char *name)
 {
 	struct osmo_sccp_addr_entry *entry;
 
-	entry = addr_entry_by_name(name, ss7);
-	if (entry)
-		return &entry->addr;
+	entry = addr_entry_by_name(name, NULL);
+	if (!entry)
+		return NULL;
 
-	return NULL;
+	if (addr)
+		memcpy(addr, &entry->addr, sizeof(*addr));
+
+	return entry->inst;
 }
 
 /*! \brief Reverse lookup the lookup-name of a specified SCCP address.
  *  \param[in] name of the address to lookup
- *  \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)
+const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr)
 {
 	struct osmo_sccp_addr_entry *entry;
 
-	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;
-		}
+	llist_for_each_entry(entry, &sccp_address_book_global, list_global) {
+		if (memcmp(&entry->addr, addr, sizeof(*addr)) == 0)
+			return entry->name;
 	}
 
 	return NULL;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68209dd1b2c0aa94b1894637a22b5cc3a3ff1250
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