aboutsummaryrefslogtreecommitdiffstats
path: root/src/sccp_user.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-10-05 16:24:26 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2021-10-07 13:38:32 +0200
commitf594b7dfd209555bfd732d6d1254e768a9ec4fe5 (patch)
tree9b4c45f0715562e7317f83790d34e15cf022234b /src/sccp_user.c
parentc83f3a870ddbac17e708a0677a00141ec9332ab4 (diff)
osmo_sccp_simple_client_on_ss7_id(): Allow set internally proper IPv4/v6 default hosts
Allow user apps to relay the decision of proper default local/remote hosts values to the library. Proper configuration of these addresses can be quite cumbersome to get correctly, or confusing at least. That's due to the multi-homing feature of SCTP where both IPv4 and IPv6 are involved. We were already doing this kind of automatic setup in osmo_ss7_vty_go_parent(), where we do validations and assign addresses based on IPv6 availability. On the other hand, apps using osmo_sccp_simple_client_on_ss7_id() API usually pass "localhost" as default address. In Linux, when IPv6 is enabled localhost is resolved as "::1", and "127.0.0.1" when IPv6 is disabled. Let's instead allow apps to relay the setup to the lib, so same addresses can be applied both during VTY command as well as if there was no VTY setup at all. Related: OS#5186 Change-Id: I82e203612571b7651d758d8148661f706a1642ba
Diffstat (limited to 'src/sccp_user.c')
-rw-r--r--src/sccp_user.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sccp_user.c b/src/sccp_user.c
index a654cc6..ade9487 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -38,6 +38,7 @@
#include "sccp_internal.h"
#include "xua_internal.h"
+#include "ss7_internal.h"
/*! \brief Find a SCCP User registered for given PC+SSN or SSN only
* First search all users with a valid PC for a full PC+SSN match.
@@ -476,9 +477,9 @@ const char *osmo_sccp_user_name(struct osmo_sccp_user *scu)
* \param[in] default_pc pointcode to be used on missing VTY setting
* \param[in] prot protocol to be used (e.g OSMO_SS7_ASP_PROT_M3UA)
* \param[in] default_local_port local port to be used on missing VTY setting
- * \param[in] default_local_ip local IP-address to be used on missing VTY setting
+ * \param[in] default_local_ip local IP-address to be used on missing VTY setting (NULL: use library own defaults)
* \param[in] default_remote_port remote port to be used on missing VTY setting
- * \param[in] default_remote_ip remote IP-address to be used on missing VTY setting
+ * \param[in] default_remote_ip remote IP-address to be used on missing VTY setting (NULL: use library own defaults)
* \returns callee-allocated SCCP instance on success; NULL on error */
struct osmo_sccp_instance *
@@ -618,8 +619,12 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
if (!asp)
goto out_rt;
asp_created = true;
- osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp, &default_local_ip, 1);
- osmo_ss7_asp_peer_set_hosts(&asp->cfg.remote, asp, &default_remote_ip, 1);
+ if (default_local_ip)
+ osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp, &default_local_ip, 1);
+ if (default_remote_ip)
+ osmo_ss7_asp_peer_set_hosts(&asp->cfg.remote, asp, &default_remote_ip, 1);
+ /* Make sure proper defaults are applied if app didn't provide specific default values */
+ osmo_ss7_asp_set_default_peer_hosts(asp);
asp->simple_client_allocated = true;
}