aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2021-06-03 20:35:47 +0200
committerlaforge <laforge@osmocom.org>2021-06-05 15:46:13 +0000
commitd7948067195799c49ae1c1895b97f211eddd22ef (patch)
tree9480d9fc1c67f6346da03c22ecc02dfc69d9209b
parent7d68959b0c8a3bf06c1bc57505690b03b9c06abc (diff)
gprs_ns2: rework id strings of nsvcsfor-1.6
Ensure all nsvcs ids are unique as UDP ids might not be unique when multiple NSVCs connect to the same remote endpoint (multiple binds). Change the format of all ids to look similiar. FR: NSE11-NSVC23-FR-fr0-DLCI13. UDP: NSE11-NSVC-UDP-10.0.0.1:23000-192.168.1.1:24000 UDP: NSE11-NSVC23-UDP-10.0.0.1:23000-192.168.1.1:24000 UDP: NSE11-NSVC66-UDP-[fd01::1]:23000-[fd03::2]:24000 Change-Id: I618e263e73fcc64d4e46b57aa3a2cb2783837907
-rw-r--r--src/gb/gprs_ns2.c11
-rw-r--r--src/gb/gprs_ns2_fr.c5
-rw-r--r--src/gb/gprs_ns2_udp.c14
3 files changed, 19 insertions, 11 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index d72f34e4..975909ba 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -980,7 +980,8 @@ enum ns2_cs ns2_create_vc(struct gprs_ns2_vc_bind *bind,
enum gprs_ns2_vc_mode vc_mode;
uint16_t nsvci;
uint16_t nsei;
- char idbuf[32];
+ const struct osmo_sockaddr *local;
+ char idbuf[256], tmp[INET6_ADDRSTRLEN + 8];
int rc, tlv;
@@ -1113,8 +1114,12 @@ enum ns2_cs ns2_create_vc(struct gprs_ns2_vc_bind *bind,
nsvci = tlvp_val16be(&tp, NS_IE_VCI);
vc_mode = ns2_dialect_to_vc_mode(dialect);
- snprintf(idbuf, sizeof(idbuf), "%s-NSE%05u-NSVC%05u", gprs_ns2_lltype_str(nse->ll),
- nse->nsei, nsvci);
+
+ local = gprs_ns2_ip_bind_sockaddr(bind);
+ osmo_sockaddr_to_str_buf(tmp, sizeof(tmp), local);
+ snprintf(idbuf, sizeof(idbuf), "%s-NSE%05u-NSVC%05u-%s-%s", gprs_ns2_lltype_str(nse->ll),
+ nse->nsei, nsvci, tmp, osmo_sockaddr_to_str(remote));
+ osmo_identifier_sanitize_buf(idbuf, NULL, '_');
nsvc = ns2_vc_alloc(bind, nse, false, vc_mode, idbuf);
if (!nsvc)
return NS2_CS_SKIPPED;
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 7791094a..3113b002 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -976,8 +976,9 @@ struct gprs_ns2_vc *gprs_ns2_fr_connect(struct gprs_ns2_vc_bind *bind,
goto err;
}
- snprintf(idbuf, sizeof(idbuf), "%s-%s-DLCI%u-NSE%05u-NSVC%05u", gprs_ns2_lltype_str(nse->ll),
- bpriv->netif, dlci, nse->nsei, nsvci);
+ snprintf(idbuf, sizeof(idbuf), "NSE%05u-NSVC%05u-%s-%s-DLCI%u", nse->nsei, nsvci,
+ gprs_ns2_lltype_str(nse->ll), bpriv->netif, dlci);
+ osmo_identifier_sanitize_buf(idbuf, NULL, '_');
nsvc = ns2_vc_alloc(bind, nse, true, GPRS_NS2_VC_MODE_BLOCKRESET, idbuf);
if (!nsvc)
goto err;
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 7980df59..428fd4a8 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -384,10 +384,10 @@ struct gprs_ns2_vc *ns2_ip_bind_connect(struct gprs_ns2_vc_bind *bind,
const struct osmo_sockaddr *remote)
{
struct gprs_ns2_vc *nsvc;
+ const struct osmo_sockaddr *local;
struct priv_vc *priv;
enum gprs_ns2_vc_mode vc_mode;
- char *sockaddr_str;
- char idbuf[64];
+ char idbuf[256], tmp[INET6_ADDRSTRLEN + 8];
OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
@@ -402,10 +402,12 @@ struct gprs_ns2_vc *ns2_ip_bind_connect(struct gprs_ns2_vc_bind *bind,
if (gprs_ns2_nsvc_by_sockaddr_bind(bind, remote))
return NULL;
- sockaddr_str = (char *)osmo_sockaddr_to_str(remote);
- osmo_identifier_sanitize_buf(sockaddr_str, NULL, '_');
- snprintf(idbuf, sizeof(idbuf), "%s-NSE%05u-remote-%s", gprs_ns2_lltype_str(nse->ll),
- nse->nsei, sockaddr_str);
+ local = gprs_ns2_ip_bind_sockaddr(bind);
+ osmo_sockaddr_to_str_buf(tmp, sizeof(tmp), local);
+ snprintf(idbuf, sizeof(idbuf), "NSE%05u-NSVC-%s-%s-%s", nse->nsei, gprs_ns2_lltype_str(nse->ll),
+ tmp, osmo_sockaddr_to_str(remote));
+ osmo_identifier_sanitize_buf(idbuf, NULL, '_');
+
nsvc = ns2_vc_alloc(bind, nse, true, vc_mode, idbuf);
if (!nsvc)
return NULL;