diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2020-12-03 06:02:03 +0100 |
---|---|---|
committer | Alexander Couzens <lynxis@fe80.eu> | 2020-12-10 01:25:00 +0100 |
commit | 2dee00b10dc8f9fbe60282cef9469d602d854ce1 (patch) | |
tree | 66d1aa736f61f93c0012099c30e47840bfe98f89 /src/gb/gprs_ns2_udp.c | |
parent | 8218f457119852de35257c8702194ff507c0ec0a (diff) |
gprs_ns2: add member name to bind
Every bind will have a unique name. Add a name argument
to all bind creating functions and require them to be unique.
This is an API break but there wasn't yet a release with NS2.
Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Diffstat (limited to 'src/gb/gprs_ns2_udp.c')
-rw-r--r-- | src/gb/gprs_ns2_udp.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c index c078badf..c0ab5f5e 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -298,6 +298,7 @@ struct gprs_ns2_vc_bind *gprs_ns2_ip_bind_by_sockaddr(struct gprs_ns2_inst *nsi, * \param[out] result if set, returns the bind object * \return 0 on success; negative in case of error */ int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi, + const char *name, const struct osmo_sockaddr *local, int dscp, struct gprs_ns2_vc_bind **result) @@ -306,6 +307,12 @@ int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi, struct priv_bind *priv; int rc; + if (!name) + return -EINVAL; + + if (gprs_ns2_bind_by_name(nsi, name)) + return -EALREADY; + bind = gprs_ns2_ip_bind_by_sockaddr(nsi, local); if (bind) { *result = bind; @@ -316,6 +323,12 @@ int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi, if (!bind) return -ENOSPC; + bind->name = talloc_strdup(bind, name); + if (!bind->name) { + talloc_free(bind); + return -ENOSPC; + } + if (local->u.sa.sa_family != AF_INET && local->u.sa.sa_family != AF_INET6) { talloc_free(bind); return -EINVAL; |