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
This commit is contained in:
Alexander Couzens 2020-06-13 21:36:56 +02:00 committed by laforge
parent 90e0c205b5
commit 650a0c31a7
3 changed files with 65 additions and 10 deletions

View File

@ -2,6 +2,7 @@
#define _BTS_H
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/socket.h>
#include <osmo-bts/gsm_data.h>
#include <osmo-bts/bts_trx.h>
@ -69,9 +70,8 @@ struct gsm_bts_gprs_nsvc {
* via OML from BSC */
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 local; /* on the BTS */
struct osmo_sockaddr remote; /* on the SGSN */
struct gsm_abis_mo mo;
};

View File

@ -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;
}

View File

@ -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) {