osmo_ss7_vty: add osmo_sccp_addr_by_name_local

Add a new function similar to osmo_sccp_addr_by_name, but search in a
specific ss7 instance's addressbook instead of searching in the global
address book. This is needed for osmo-bsc-nat, which uses two separate
instances at the same time.

Related: SYS#5560
Change-Id: I0f38b0d038b0dd8cd355e7284e5b56d438811bd9
This commit is contained in:
Oliver Smith 2022-01-31 17:10:49 +01:00 committed by osmith
parent e3e79e2806
commit ebccb824a0
2 changed files with 24 additions and 0 deletions

View File

@ -301,6 +301,8 @@ int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr *op
int osmo_sccp_user_sap_down_nofree(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
struct osmo_ss7_instance *osmo_sccp_addr_by_name(struct osmo_sccp_addr *dest_addr, const char *name);
int osmo_sccp_addr_by_name_local(struct osmo_sccp_addr *dest_addr, const char *name,
const struct osmo_ss7_instance *inst);
const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr);

View File

@ -1350,6 +1350,28 @@ osmo_sccp_addr_by_name(struct osmo_sccp_addr *dest_addr,
return entry->inst;
}
/*! \brief Lookup an SCCP address from the addressbook of a specific instance
* by its name.
* \param[out] dest_addr pointer to output the resulting sccp-address;
* (set to NULL if not interested)
* \param[in] name of the address to lookup
* \param[in] inst ss7 instance of which the address book will be searched
* \returns 0 on success; <0 on error */
int osmo_sccp_addr_by_name_local(struct osmo_sccp_addr *dest_addr, const char *name,
const struct osmo_ss7_instance *inst)
{
struct osmo_sccp_addr_entry *entry;
entry = addr_entry_by_name_local(name, inst);
if (!entry)
return -ENOENT;
if (dest_addr)
*dest_addr = entry->addr;
return 0;
}
/*! \brief Reverse lookup the lookup-name of a specified SCCP address.
* \param[in] name of the address to lookup
* \returns char pointer to the lookup-name; NULL on error */