diff options
Diffstat (limited to 'src/gsup_router.c')
-rw-r--r-- | src/gsup_router.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/gsup_router.c b/src/gsup_router.c index adf3af7..ba71fe4 100644 --- a/src/gsup_router.c +++ b/src/gsup_router.c @@ -47,6 +47,11 @@ struct osmo_gsup_conn *gsup_route_find(struct osmo_gsup_server *gs, return NULL; } +struct osmo_gsup_conn *gsup_route_find_by_ipa_name(struct osmo_gsup_server *gs, const struct osmo_ipa_name *ipa_name) +{ + return gsup_route_find(gs, ipa_name->val, ipa_name->len); +} + /*! Find a GSUP connection's route (to read the IPA address from the route). * \param[in] conn GSUP connection * \return GSUP route @@ -67,10 +72,15 @@ struct gsup_route *gsup_route_find_by_conn(const struct osmo_gsup_conn *conn) int gsup_route_add(struct osmo_gsup_conn *conn, const uint8_t *addr, size_t addrlen) { struct gsup_route *gr; + struct osmo_gsup_conn *exists_on_conn; /* Check if we already have a route for this address */ - if (gsup_route_find(conn->server, addr, addrlen)) - return -EEXIST; + exists_on_conn = gsup_route_find(conn->server, addr, addrlen); + if (exists_on_conn) { + if (exists_on_conn != conn) + return -EEXIST; + return 0; + } /* allocate new route and populate it */ gr = talloc_zero(conn->server, struct gsup_route); @@ -86,6 +96,11 @@ int gsup_route_add(struct osmo_gsup_conn *conn, const uint8_t *addr, size_t addr return 0; } +int gsup_route_add_ipa_name(struct osmo_gsup_conn *conn, const struct osmo_ipa_name *ipa_name) +{ + return gsup_route_add(conn, ipa_name->val, ipa_name->len); +} + /* delete all routes for the given connection */ int gsup_route_del_conn(struct osmo_gsup_conn *conn) { @@ -95,7 +110,7 @@ int gsup_route_del_conn(struct osmo_gsup_conn *conn) llist_for_each_entry_safe(gr, gr2, &conn->server->routes, list) { if (gr->conn == conn) { LOGP(DMAIN, LOGL_INFO, "Removing GSUP route for %s (GSUP disconnect)\n", - gr->addr); + osmo_quote_str_c(OTC_SELECT, (char*)gr->addr, talloc_total_size(gr->addr))); llist_del(&gr->list); talloc_free(gr); num_deleted++; |