library: Add template helpers for AoIP Transport Layer Address

This way one can simply pass an IP addr in string format and return the
IE no matter the IP version.

Change-Id: I743dbb7c89e504762498b7f278c12e130352e5f0
changes/79/19979/4
Pau Espin 2 years ago committed by laforge
parent 384e949cd2
commit 6a846bca2c
  1. 2
      bsc-nat/gen_links.sh
  2. 24
      library/BSSMAP_Templates.ttcn
  3. 9
      library/Misc_Helpers.ttcn
  4. 2
      selftest/gen_links.sh

@ -52,7 +52,7 @@ FILES="RTP_EncDec.cc RTP_Types.ttcn"
gen_links $DIR $FILES
DIR=../library
FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn BSSMAP_Templates.ttcn RAN_Emulation.ttcnpp MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc Osmocom_CTRL_Types.ttcn Osmocom_VTY_Functions.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn BSSAP_CodecPort.ttcn"
FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn BSSMAP_Templates.ttcn RAN_Emulation.ttcnpp MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc Osmocom_CTRL_Types.ttcn Osmocom_VTY_Functions.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn BSSAP_CodecPort.ttcn Native_Functions.ttcn Native_FunctionDefs.cc"
gen_links $DIR $FILES
ignore_pp_results

@ -14,6 +14,8 @@ module BSSMAP_Templates {
import from General_Types all;
import from Osmocom_Types all;
import from Native_Functions all;
import from Misc_Helpers all;
import from GSM_Types all;
import from BSSAP_Types all;
@ -436,6 +438,17 @@ template (value) BSSMAP_IE_AoIP_TransportLayerAddress ts_BSSMAP_IE_AoIP_TLA4(OCT
template (value) BSSMAP_IE_AoIP_TransportLayerAddress ts_BSSMAP_IE_AoIP_TLA6(OCT16 ip, uint16_t pt) :=
ts_BSSMAP_IE_AoIP_TLA({ipv6:=ip}, pt, 18);
function f_ts_BSSMAP_IE_AoIP_TLA(charstring addr, uint16_t udp_port)
return template (value) BSSMAP_IE_AoIP_TransportLayerAddress {
if (f_addr_is_ipv6(addr)) {
var OCT16 ip6 := f_inet6_addr(addr);
return ts_BSSMAP_IE_AoIP_TLA6(ip6, udp_port);
} else {
var OCT4 ip := f_inet_addr(addr);
return ts_BSSMAP_IE_AoIP_TLA4(ip, udp_port);
}
}
template BSSMAP_IE_AoIP_TransportLayerAddress tr_BSSMAP_IE_AoIP_TLA(template BSSMAP_FIELD_IPAddress addr,
template uint16_t udp_port,
template integer len := ?) := {
@ -449,6 +462,17 @@ template BSSMAP_IE_AoIP_TransportLayerAddress tr_BSSMAP_IE_AoIP_TLA4(template OC
template BSSMAP_IE_AoIP_TransportLayerAddress tr_BSSMAP_IE_AoIP_TLA6(template OCT16 ip, template uint16_t pt) :=
tr_BSSMAP_IE_AoIP_TLA({ipv6:=ip}, pt, 18);
function f_tr_BSSMAP_IE_AoIP_TLA(charstring addr, template uint16_t udp_port)
return template BSSMAP_IE_AoIP_TransportLayerAddress {
if (f_addr_is_ipv6(addr)) {
var OCT16 ip6 := f_inet6_addr(addr);
return tr_BSSMAP_IE_AoIP_TLA6(ip6, udp_port);
} else {
var OCT4 ip := f_inet_addr(addr);
return tr_BSSMAP_IE_AoIP_TLA4(ip, udp_port);
}
}
template (value) BSSMAP_IE_KC128 ts_BSSMAP_IE_Kc128(OCT16 kc128) := {
elementIdentifier := '83'O,
kC128_Value := kc128

@ -25,4 +25,13 @@ function f_shutdown(charstring file, integer line, verdicttype verdict := none,
mtc.stop
}
function f_addr_is_ipv6(charstring addr) return boolean {
for (var integer i := 0; i < lengthof(addr); i := i + 1) {
if (addr[i] == ":") {
return true;
}
}
return false;
}
}

@ -39,7 +39,7 @@ FILES="MobileL3_CC_Types.ttcn MobileL3_CommonIE_Types.ttcn MobileL3_GMM_SM_Types
gen_links $DIR $FILES
DIR=../library
FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn BSSMAP_Templates.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn GSM_RR_Types.ttcn RSL_Types.ttcn BSSAP_CodecPort.ttcn Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn GSUP_Types.ttcn"
FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn BSSMAP_Templates.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn GSM_RR_Types.ttcn RSL_Types.ttcn BSSAP_CodecPort.ttcn Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn GSUP_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc"
gen_links $DIR $FILES
ignore_pp_results

Loading…
Cancel
Save