aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-01-10 14:39:42 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2020-01-13 12:43:59 +0100
commit191a305cb58087844103dd961756666e911218b4 (patch)
tree70dd50f17f61d97175f5a18fa1258c4abdac8718
parent7b56b75f36a603e878a0a762818253926b3271e5 (diff)
ss7: Set ASP addresses using asp_peer APIs
-rw-r--r--src/osmo_ss7.c12
-rw-r--r--src/osmo_ss7_vty.c18
-rw-r--r--src/sccp_user.c15
3 files changed, 14 insertions, 31 deletions
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 7eb94b2..70ec847 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1800,7 +1800,6 @@ static int xua_accept_cb(struct osmo_stream_srv_link *link, int fd)
struct osmo_xua_server *oxs = osmo_stream_srv_link_get_data(link);
struct osmo_stream_srv *srv;
struct osmo_ss7_asp *asp;
- int i;
char *sock_name = osmo_sock_get_name(link, fd);
const char *proto_name = get_value_string(osmo_ss7_asp_protocol_vals, oxs->cfg.proto);
@@ -1840,6 +1839,7 @@ static int xua_accept_cb(struct osmo_stream_srv_link *link, int fd)
oxs->cfg.proto);
if (asp) {
char hostbuf[INET6_ADDRSTRLEN];
+ const char *hostbuf_ptr = &hostbuf[0];
char portbuf[16];
osmo_sock_get_ip_and_port(fd, hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf), false);
@@ -1848,14 +1848,14 @@ static int xua_accept_cb(struct osmo_stream_srv_link *link, int fd)
asp->cfg.is_server = true;
asp->cfg.role = OSMO_SS7_ASP_ROLE_SG;
asp->cfg.local.port = oxs->cfg.local.port;
- for (i = 0; i < oxs->cfg.local.host_cnt; i++)
- asp->cfg.local.host[i] = talloc_strdup(asp, oxs->cfg.local.host[i]);
- asp->cfg.local.host_cnt = oxs->cfg.local.host_cnt;
asp->cfg.remote.port = atoi(portbuf);
- asp->cfg.remote.host[0] = talloc_strdup(asp, hostbuf);
- asp->cfg.remote.host_cnt = 1;
asp->dyn_allocated = true;
asp->server = srv;
+ osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp,
+ (const char* const*)oxs->cfg.local.host,
+ oxs->cfg.local.host_cnt);
+ osmo_ss7_asp_peer_set_hosts(&asp->cfg.remote, asp,
+ &hostbuf_ptr, 1);
osmo_ss7_asp_restart(asp);
}
}
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 591254e..2931fb9 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -615,8 +615,7 @@ DEFUN(asp_local_ip, asp_local_ip_cmd,
"Local IP Address from which to contact of ASP\n")
{
struct osmo_ss7_asp *asp = vty->index;
- osmo_talloc_replace_string(asp, &asp->cfg.local.host[asp->cfg.local.host_cnt], argv[0]);
- asp->cfg.local.host_cnt++;
+ osmo_ss7_asp_peer_add_host(&asp->cfg.local, asp, argv[0]);
return CMD_SUCCESS;
}
@@ -626,8 +625,7 @@ DEFUN(asp_remote_ip, asp_remote_ip_cmd,
"Remote IP Address of ASP\n")
{
struct osmo_ss7_asp *asp = vty->index;
- osmo_talloc_replace_string(asp, &asp->cfg.remote.host[asp->cfg.remote.host_cnt], argv[0]);
- asp->cfg.remote.host_cnt++;
+ osmo_ss7_asp_peer_add_host(&asp->cfg.remote, asp, argv[0]);
return CMD_SUCCESS;
}
@@ -1780,15 +1778,11 @@ int osmo_ss7_vty_go_parent(struct vty *vty)
case L_CS7_ASP_NODE:
asp = vty->index;
/* If no local addr was set */
- if (!asp->cfg.local.host_cnt) {
- asp->cfg.local.host[0] = NULL;
- asp->cfg.local.host_cnt = 1;
- }
+ if (!asp->cfg.local.host_cnt)
+ osmo_ss7_asp_peer_add_host(&asp->cfg.local, asp, NULL);
/* If no remote addr was set */
- if (!asp->cfg.remote.host_cnt) {
- asp->cfg.remote.host[0] = "127.0.0.1";
- asp->cfg.remote.host_cnt = 1;
- }
+ if (!asp->cfg.remote.host_cnt)
+ osmo_ss7_asp_peer_add_host(&asp->cfg.remote, asp, "127.0.0.1");
osmo_ss7_asp_restart(asp);
vty->node = L_CS7_NODE;
vty->index = asp->inst;
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 49cc212..39ebc71 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -566,19 +566,8 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
if (!asp)
goto out_rt;
asp_created = true;
-
- asp->cfg.local.host[0] = NULL;
- asp->cfg.remote.host[0] = NULL;
- if (default_local_ip) {
- asp->cfg.local.host[0] =
- talloc_strdup(asp, default_local_ip);
- }
- if (default_remote_ip) {
- asp->cfg.remote.host[0] =
- talloc_strdup(asp, default_remote_ip);
- }
- asp->cfg.local.host_cnt = 1;
- asp->cfg.remote.host_cnt = 1;
+ 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);
asp->simple_client_allocated = true;
} else
talloc_free(asp_name);