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/.
lynxis lazus gerrit-no-reply at lists.osmocom.orglynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/20234 ) Change subject: oml: encode IPv6 NSVC using the new OML attribute NM_ATT_OSMO_NS_LINK_CFG ...................................................................... oml: encode IPv6 NSVC using the new OML attribute NM_ATT_OSMO_NS_LINK_CFG The old IE NM_ATT_IPACC_NS_LINK_CFG didn't support IPv6 NSVC. TODO: add ipv6 test to nanobts_omlattr_test.c Depends: Ic261bc43a07fa741b97a9c6ec5a9ed6f5ecae588 (libosmocore) Change-Id: I6529876a3c1116a79dd624312243d8ae48a41fe2 --- M include/osmocom/bsc/gsm_data.h M src/osmo-bsc/bsc_vty.c M src/osmo-bsc/bts_ipaccess_nanobts.c M src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c M src/osmo-bsc/bts_sysmobts.c M src/osmo-bsc/pcu_sock.c M tests/nanobts_omlattr/nanobts_omlattr_test.c 7 files changed, 72 insertions(+), 23 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/34/20234/1 diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 90ab8ea..ed1101a 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -8,6 +8,8 @@ #include <osmocom/core/timer.h> #include <osmocom/core/rate_ctr.h> #include <osmocom/core/select.h> +#include <osmocom/core/socket.h> +#include <osmocom/core/sockaddr_str.h> #include <osmocom/core/stats.h> #include <osmocom/core/stat_item.h> #include <osmocom/gsm/bts_features.h> @@ -745,9 +747,7 @@ int id; uint16_t nsvci; uint16_t local_port; /* on the BTS */ - uint16_t remote_port; /* on the SGSN */ - uint32_t remote_ip; /* on the SGSN */ - + struct osmo_sockaddr remote; struct gsm_abis_mo mo; }; diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index 003939b..bb72179 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -36,6 +36,7 @@ #include <osmocom/gsm/gsm48.h> #include <osmocom/gsm/gsm0808.h> #include <osmocom/gsm/gsm23236.h> +#include <osmocom/core/sockaddr_str.h> #include <arpa/inet.h> @@ -762,17 +763,17 @@ for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) { struct gsm_bts_gprs_nsvc *nsvc = &bts->gprs.nsvc[i]; - struct in_addr ia; + struct osmo_sockaddr_str remote; + osmo_sockaddr_str_to_sockaddr(&remote, &nsvc->remote.u.sas); - ia.s_addr = htonl(nsvc->remote_ip); vty_out(vty, " gprs nsvc %u nsvci %u%s", i, nsvc->nsvci, VTY_NEWLINE); vty_out(vty, " gprs nsvc %u local udp port %u%s", i, nsvc->local_port, VTY_NEWLINE); vty_out(vty, " gprs nsvc %u remote udp port %u%s", i, - nsvc->remote_port, VTY_NEWLINE); + remote.port, VTY_NEWLINE); vty_out(vty, " gprs nsvc %u remote ip %s%s", i, - inet_ntoa(ia), VTY_NEWLINE); + remote.ip, VTY_NEWLINE); } /* EGPRS specific parameters */ @@ -3010,26 +3011,39 @@ GPRS_CHECK_ENABLED(bts); - bts->gprs.nsvc[idx].remote_port = atoi(argv[1]); + /* sockaddr_in and sockaddr_in6 have the port at the same position */ + bts->gprs.nsvc[idx].remote.u.sin.sin_port = htons(atoi(argv[1])); return CMD_SUCCESS; } DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd, - "gprs nsvc <0-1> remote ip A.B.C.D", + "gprs nsvc <0-1> remote ip " VTY_IPV46_CMD, GPRS_TEXT NSVC_TEXT "GPRS NS Remote IP Address\n" "GPRS NS Remote IP Address\n" "GPRS NS Remote IP Address\n") { struct gsm_bts *bts = vty->index; + struct osmo_sockaddr_str remote; int idx = atoi(argv[0]); - struct in_addr ia; + int ret; GPRS_CHECK_ENABLED(bts); - inet_aton(argv[1], &ia); - bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr); + ret = osmo_sockaddr_str_from_str2(&remote, argv[1]); + if (ret) { + vty_out(vty, "%% Invalid IP address %s%s", argv[1], VTY_NEWLINE); + return CMD_WARNING; + } + + bts->gprs.nsvc[idx].remote.u.sas.ss_family = remote.af; + switch (remote.af) { + case AF_INET: + osmo_sockaddr_str_to_in_addr(&remote, &bts->gprs.nsvc[idx].remote.u.sin.sin_addr); + case AF_INET6: + osmo_sockaddr_str_to_in6_addr(&remote, &bts->gprs.nsvc[idx].remote.u.sin6.sin6_addr); + } return CMD_SUCCESS; } diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c b/src/osmo-bsc/bts_ipaccess_nanobts.c index 796d208..eb2d3c8 100644 --- a/src/osmo-bsc/bts_ipaccess_nanobts.c +++ b/src/osmo-bsc/bts_ipaccess_nanobts.c @@ -227,6 +227,12 @@ /* We skip NSVC1 since we only use NSVC0 */ if (nsvc->id == 1) break; + if (osmo_bts_has_feature(&bts->features, BTS_FEAT_IPV6_NSVC) && + nsvc->remote.u.sa.sa_family == AF_INET6) { + LOGP(DLINP, LOGL_ERROR, "BTS %d does not support IPv6 but require it!\n", bts->nr); + break; + } + if ((new_state->availability == NM_AVSTATE_OFF_LINE) || (new_state->availability == NM_AVSTATE_DEPENDENCY)) { msgb = nanobts_attr_nscv_get(bts); diff --git a/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c b/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c index b979cc7..75d0306 100644 --- a/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c +++ b/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c @@ -24,6 +24,7 @@ #include <osmocom/bsc/gsm_data.h> #include <osmocom/bsc/abis_nm.h> #include <osmocom/bsc/bts.h> +#include <osmocom/gsm/bts_features.h> struct msgb *nanobts_attr_bts_get(struct gsm_bts *bts) { @@ -202,13 +203,25 @@ buf[1] = bts->gprs.nsvc[0].nsvci & 0xff; msgb_tl16v_put(msgb, NM_ATT_IPACC_NSVCI, 2, buf); - /* remote udp port */ - osmo_store16be(bts->gprs.nsvc[0].remote_port, &buf[0]); - /* remote ip address */ - osmo_store32be(bts->gprs.nsvc[0].remote_ip, &buf[2]); - /* local udp port */ - osmo_store16be(bts->gprs.nsvc[0].local_port, &buf[6]); - msgb_tl16v_put(msgb, NM_ATT_IPACC_NS_LINK_CFG, 8, buf); + if (bts->gprs.nsvc->remote.u.sa.sa_family == AF_INET6) { + /* protocol family */ + osmo_store16be(IPPROTO_IPV6, &buf[0]); + /* local udp port */ + osmo_store16be(bts->gprs.nsvc[0].local_port, &buf[2]); + /* remote udp port */ + memcpy(&buf[4], &bts->gprs.nsvc[0].remote.u.sin6.sin6_port, sizeof(uint16_t)); + /* remote ip address */ + memcpy(&buf[6], &bts->gprs.nsvc[0].remote.u.sin6.sin6_addr, sizeof(struct in6_addr)); + msgb_tl16v_put(msgb, NM_ATT_OSMO_NS_LINK_CFG, 6 + sizeof(struct in6_addr), buf); + } else { + /* remote udp port */ + memcpy(&buf[0], &bts->gprs.nsvc[0].remote.u.sin.sin_port, sizeof(uint16_t)); + /* remote ip address */ + memcpy(&buf[2], &bts->gprs.nsvc[0].remote.u.sin.sin_addr, sizeof(struct in_addr)); + /* local udp port */ + osmo_store16be(bts->gprs.nsvc[0].local_port, &buf[6]); + msgb_tl16v_put(msgb, NM_ATT_IPACC_NS_LINK_CFG, 8, buf); + } return msgb; } diff --git a/src/osmo-bsc/bts_sysmobts.c b/src/osmo-bsc/bts_sysmobts.c index df43d76..d7d15eb 100644 --- a/src/osmo-bsc/bts_sysmobts.c +++ b/src/osmo-bsc/bts_sysmobts.c @@ -61,5 +61,7 @@ osmo_bts_set_feature(&model_sysmobts.features, BTS_FEAT_EGPRS); osmo_bts_set_feature(&model_sysmobts.features, BTS_FEAT_PAGING_COORDINATION); + model_sysmobts.nm_att_tlvdef.def[NM_ATT_OSMO_NS_LINK_CFG].type = TLV_TYPE_TL16V; + return gsm_bts_model_register(&model_sysmobts); } diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c index ae4ac8a..30a73cc 100644 --- a/src/osmo-bsc/pcu_sock.c +++ b/src/osmo-bsc/pcu_sock.c @@ -30,6 +30,7 @@ #include <sys/socket.h> #include <sys/un.h> +#include <osmocom/core/byteswap.h> #include <osmocom/core/talloc.h> #include <osmocom/core/select.h> #include <osmocom/core/socket.h> @@ -190,10 +191,21 @@ /* NSVC */ for (i = 0; i < ARRAY_SIZE(info_ind->nsvci); i++) { nsvc = &bts->gprs.nsvc[i]; + + switch (nsvc->remote.u.sa.sa_family) { + case AF_UNSPEC: + continue; + case AF_INET6: + LOGP(DPCU, LOGL_ERROR, "Can not encode IPv6 NSVC!"); + continue; + case AF_INET: + break; + } + info_ind->nsvci[i] = nsvc->nsvci; info_ind->local_port[i] = nsvc->local_port; - info_ind->remote_port[i] = nsvc->remote_port; - info_ind->remote_ip[i] = nsvc->remote_ip; + info_ind->remote_port[i] = osmo_ntohs(nsvc->remote.u.sin.sin_port); + info_ind->remote_ip[i] = osmo_ntohl(nsvc->remote.u.sin.sin_addr.s_addr); } for (i = 0; i < ARRAY_SIZE(info_ind->trx); i++) { diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.c b/tests/nanobts_omlattr/nanobts_omlattr_test.c index ea98409..6c2d582 100644 --- a/tests/nanobts_omlattr/nanobts_omlattr_test.c +++ b/tests/nanobts_omlattr/nanobts_omlattr_test.c @@ -263,9 +263,11 @@ }; /* Parameters needed to test nanobts_attr_nscv_get() */ + /* FIXME: add ipv6 test */ + struct osmo_sockaddr_str addr; + osmo_sockaddr_str_from_str(&addr, "10.9.1.101", 23000); + osmo_sockaddr_str_to_sockaddr(&addr, &bts->gprs.nsvc[0].remote.u.sas); bts->gprs.nsvc[0].nsvci = 0x65; - bts->gprs.nsvc[0].remote_port = 0x59d8; - bts->gprs.nsvc[0].remote_ip = 0x0a090165; bts->gprs.nsvc[0].local_port = 0x5a3c; uint8_t attr_nscv_expected[] = { 0x9f, 0x00, 0x02, 0x00, 0x65, 0xa2, 0x00, 0x08, 0x59, 0xd8, 0x0a, -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/20234 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I6529876a3c1116a79dd624312243d8ae48a41fe2 Gerrit-Change-Number: 20234 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lynxis at fe80.eu> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200921/94566dce/attachment.htm>