diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2020-06-13 21:36:56 +0200 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2020-10-06 11:36:45 +0000 |
commit | 650a0c31a78856566c897e187492b693a1b259f6 (patch) | |
tree | 39bcfe43dbb1b10122f99496444bcdb997ca9727 /src/common | |
parent | 90e0c205b5ff4e94c7705cc8f81ccb510c0eb6df (diff) |
Introduce the new OML NM_ATT_OSMO_NS_LINK_CFG to configure IPv6 NSVC for PCU
With PCU interface version 10 it supports IPv6 NSVC. The new OML IE
NM_ATT_OSMO_NS_LINK_CFG allows to configure IPv6 NSVC.
Change-Id: I310699fabbfec4255f0474f31717f215c1201eca
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/oml.c | 50 | ||||
-rw-r--r-- | src/common/pcu_sock.c | 19 |
2 files changed, 62 insertions, 7 deletions
diff --git a/src/common/oml.c b/src/common/oml.c index 9fca0085..1f74cac8 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -1259,16 +1259,59 @@ static int oml_ipa_mo_set_attr_nsvc(struct gsm_bts_gprs_nsvc *nsvc, uint16_t _cur_s; uint32_t _cur_l; + memset(&nsvc->local, 0, sizeof(nsvc->local)); + memset(&nsvc->remote, 0, sizeof(nsvc->remote)); + + nsvc->local.u.sin.sin_family = AF_INET; + nsvc->remote.u.sin.sin_family = AF_INET; + memcpy(&_cur_s, cur, 2); - nsvc->remote_port = ntohs(_cur_s); + nsvc->remote.u.sin.sin_port = _cur_s; cur += 2; memcpy(&_cur_l, cur, 4); - nsvc->remote_ip = ntohl(_cur_l); + nsvc->remote.u.sin.sin_addr.s_addr = _cur_l; cur += 4; memcpy(&_cur_s, cur, 2); - nsvc->local_port = ntohs(_cur_s); + nsvc->local.u.sin.sin_port = ntohs(_cur_s); + } + + if (TLVP_PRES_LEN(tp, NM_ATT_OSMO_NS_LINK_CFG, 10)) { + const uint8_t *cur = TLVP_VAL(tp, NM_ATT_OSMO_NS_LINK_CFG); + uint16_t address_family; + + memset(&nsvc->local, 0, sizeof(nsvc->local)); + memset(&nsvc->remote, 0, sizeof(nsvc->remote)); + + address_family = osmo_load16be(cur); + cur += 2; + + memcpy(&nsvc->local.u.sin.sin_port, cur, 2); + cur += 2; + + memcpy(&nsvc->remote.u.sin.sin_port, cur, 2); + cur += 2; + + switch (address_family) { + case OSMO_NSVC_ADDR_IPV4: + /* we already checked for 10 bytes */ + nsvc->remote.u.sas.ss_family = AF_INET; + nsvc->local.u.sas.ss_family = AF_INET; + memcpy(&nsvc->remote.u.sin.sin_addr.s_addr, cur, sizeof(in_addr_t)); + break; + case OSMO_NSVC_ADDR_IPV6: + if (TLVP_LEN(tp, NM_ATT_OSMO_NS_LINK_CFG) < 22) { + return -1; + } + nsvc->remote.u.sas.ss_family = AF_INET6; + nsvc->local.u.sas.ss_family = AF_INET6; + memcpy(&nsvc->remote.u.sin6.sin6_addr, cur, sizeof(struct in6_addr)); + break; + default: + return -1; + } } + osmo_signal_dispatch(SS_GLOBAL, S_NEW_NSVC_ATTR, nsvc); return 0; @@ -1505,6 +1548,7 @@ int oml_init(struct gsm_abis_mo *mo) DEBUGP(DOML, "Initializing OML attribute definitions\n"); tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef_ipa); tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_osmo_att_tlvdef); return 0; } diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c index c922584c..68cd0398 100644 --- a/src/common/pcu_sock.c +++ b/src/common/pcu_sock.c @@ -330,10 +330,21 @@ int pcu_tx_info_ind(void) for (i = 0; i < 2; i++) { nsvc = &bts->gprs.nsvc[i]; 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].v4.s_addr = htonl(nsvc->remote_ip); - info_ind->address_type[i] = PCU_IF_ADDR_TYPE_IPV4; + info_ind->local_port[i] = nsvc->local.u.sin.sin_port; + info_ind->remote_port[i] = nsvc->remote.u.sin.sin_port; + switch (nsvc->remote.u.sas.ss_family) { + case AF_INET: + info_ind->address_type[i] = PCU_IF_ADDR_TYPE_IPV4; + info_ind->remote_ip[i].v4 = nsvc->remote.u.sin.sin_addr; + break; + case AF_INET6: + info_ind->address_type[i] = PCU_IF_ADDR_TYPE_IPV6; + info_ind->remote_ip[i].v6 = nsvc->remote.u.sin6.sin6_addr; + break; + default: + info_ind->address_type[i] = PCU_IF_ADDR_TYPE_UNSPEC; + break; + } } llist_for_each_entry(trx, &bts->trx_list, list) { |