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/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/16795 ) Change subject: ss7: Introduce APIs to manage asp_peer hosts ...................................................................... ss7: Introduce APIs to manage asp_peer hosts The coe managing addresses is decoupled from xua_server since they will also be used to manage addresses for ASPs. Change-Id: I4af2a6915ac57c7baa67343bd9414c65154d67f7 --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c 2 files changed, 51 insertions(+), 35 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/95/16795/1 diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index de9494b..1e5ca2c 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -429,6 +429,8 @@ }; int osmo_ss7_asp_peer_snprintf(char* buf, size_t buf_len, struct osmo_ss7_asp_peer *peer); +int osmo_ss7_asp_peer_set_hosts(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char* const* local_hosts, size_t local_host_cnt); +int osmo_ss7_asp_peer_add_host(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *local_host); struct osmo_ss7_asp * osmo_ss7_asp_find_by_name(struct osmo_ss7_instance *inst, const char *name); diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index ee762c4..b8396b8 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -1113,6 +1113,49 @@ return len; } +int osmo_ss7_asp_peer_set_hosts(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char* const* hosts, size_t host_cnt) +{ + int i = 0; + + if (host_cnt > ARRAY_SIZE(peer->host)) + return -EINVAL; + + for (; i < host_cnt; i++) + osmo_talloc_replace_string(talloc_ctx, &peer->host[i], hosts[i]); + for (; i < peer->host_cnt; i++) { + talloc_free(peer->host[i]); + peer->host[i] = NULL; + } + + peer->host_cnt = host_cnt; + return 0; +} + +int osmo_ss7_asp_peer_add_host(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *host) + +{ + int i; + bool new_is_any = !host || !strcmp(host, "0.0.0.0"); + bool iter_is_any; + + /* Makes no sense to have INET_ANY and specific addresses in the set */ + for (i = 0; i < peer->host_cnt; i++) { + iter_is_any = !peer->host[i] || + !strcmp(peer->host[i], "0.0.0.0"); + if (new_is_any && iter_is_any) + return -EINVAL; + if (!new_is_any && iter_is_any) + return -EINVAL; + } + /* Makes no sense to have INET_ANY many times */ + if (new_is_any && peer->host_cnt) + return -EINVAL; + + osmo_talloc_replace_string(talloc_ctx, &peer->host[peer->host_cnt], host); + peer->host_cnt++; + return 0; +} + struct osmo_ss7_asp * osmo_ss7_asp_find_by_name(struct osmo_ss7_instance *inst, const char *name) { @@ -1985,51 +2028,22 @@ int osmo_ss7_xua_server_set_local_hosts(struct osmo_xua_server *xs, const char **local_hosts, size_t local_host_cnt) { - int i = 0; + int rc; OSMO_ASSERT(ss7_initialized); - if (local_host_cnt > ARRAY_SIZE(xs->cfg.local.host)) - return -EINVAL; - - for (; i < local_host_cnt; i++) - osmo_talloc_replace_string(xs, &xs->cfg.local.host[i], local_hosts[i]); - for (; i < xs->cfg.local.host_cnt; i++) { - talloc_free(xs->cfg.local.host[i]); - xs->cfg.local.host[i] = NULL; - } - - xs->cfg.local.host_cnt = local_host_cnt; - + rc = osmo_ss7_asp_peer_set_hosts(&xs->cfg.local, xs, local_hosts, local_host_cnt); osmo_stream_srv_link_set_addrs(xs->server, (const char **)xs->cfg.local.host, xs->cfg.local.host_cnt); - - return 0; + return rc; } int osmo_ss7_xua_server_add_local_host(struct osmo_xua_server *xs, const char *local_host) { - int i; - bool new_is_any = !local_host || !strcmp(local_host, "0.0.0.0"); - bool iter_is_any; + int rc; - /* Makes no sense to have INET_ANY and specific addresses in the set */ - for (i = 0; i < xs->cfg.local.host_cnt; i++) { - iter_is_any = !xs->cfg.local.host[i] || - !strcmp(xs->cfg.local.host[i], "0.0.0.0"); - if (new_is_any && iter_is_any) - return -EINVAL; - if (!new_is_any && iter_is_any) - return -EINVAL; - } - /* Makes no sense to have INET_ANY many times */ - if (new_is_any && xs->cfg.local.host_cnt) - return -EINVAL; - - osmo_talloc_replace_string(xs, &xs->cfg.local.host[xs->cfg.local.host_cnt], local_host); - xs->cfg.local.host_cnt++; - + rc = osmo_ss7_asp_peer_add_host(&xs->cfg.local, xs, local_host); osmo_stream_srv_link_set_addrs(xs->server, (const char **)xs->cfg.local.host, xs->cfg.local.host_cnt); - return 0; + return rc; } void osmo_ss7_xua_server_destroy(struct osmo_xua_server *xs) -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/16795 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Change-Id: I4af2a6915ac57c7baa67343bd9414c65154d67f7 Gerrit-Change-Number: 16795 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200110/7ee210f4/attachment.htm>