Commit 86b9c0cc authored by berge's avatar berge
Browse files

Removed branches/seb/NewTypeStructure

parent 4e3a6af5
/*
* @author STF 276
* @version $Id$
* @desc This module specifies functions definitions
* that can be used by any RCF function.
*
*/
module LibIpv6_CommonRfcs_Functions {
//LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
import from LibCommon_VerdictControl { type FncRetCode };
//LibIpv6
import from LibIpv6_Interface_TypesAndValues all ;
import from LibIpv6_ExternalFunctions all;
import from LibIpv6_ModuleParameters all ;
import from LibIpv6_CommonRfcs_TypesAndValues all;
import from LibIpv6_CommonRfcs_Templates all;
group calcPrefixFns {
/* function createIpAddresses(Prefix p_prefix, Oct6to15 p_macAddr)
runs on LibIpv6Node
return FncRetCode {
const UInt8 c_uniIdLen := 64;
var Oct8 v_prefixReady := int2oct(0,8);
var Oct8 v_interfaceIdReady := int2oct(0,8);
var Oct3 v_leftPartMac := int2oct(0,3);
var Oct3 v_rightPartMac := int2oct(0,3);
var Bit24 v_leftPartBits := int2bit(0,24);
var Bit24 v_leftPartBitMask := int2bit(131072,24);
var Ipv6Address v_gla := int2oct(0,16);
if (lengthof(p_prefix) > 8) {
log("Error");
}
else {
//Fill v_prefixReady with existing Prefix
for (i:=0; i<lengthof(p_prefix); i:=i+1) {
v_prefixReady[i] := p_prefix[i];
}
//Complete v_prefixReady with Zero Bytes
for (i:=lengthof(p_prefix); i<8; i:=i+1) {
v_prefixReady[i] := '00'O;
}
}
//get leftPart
for (i:=0; i<lengthof(p_macAddr)-3; i:=i+1) {
v_leftPartMac[i] := p_macAddr[i];
}
//get leftPart
for (i:=3; i<lengthof(p_macAddr); i:=i+1) {
v_rightPartMac[i-3] := p_macAddr[i];
}
//flipBit universalBit of leftPart
v_leftPartBits := oct2int(v_leftPartMac);
v_leftPartBits := v_leftPartBits xor4b v_leftPartBitMask;
v_leftPartMac := bit2oct(v_leftPartBits);
//build InterfaceId
v_interfaceIdReady := v_leftPartMac & 'FFFE'O & v_rightPartMac;
//MAC_MCA
//GLA
v_gla := v_prefixReady & v_interfaceIdReady;
//LLA
//SOL_NODE_MCA
}
*/
/*
* @desc Creates a prefix using p_address and p_prefixLength. The p_prefixLength
* MSB bits remain unchanged, the others are set to zero.
* @param p_address Address used for prefix creation
* @param p_prefixLength Length of the prefix
*/
function f_createPrefix ( template Ipv6Address p_address, template UInt8 p_prefixLength )
runs on LibIpv6Node
return Ipv6Address {
var Bit128 v_prefix;
var integer v_pos;
v_prefix := oct2bit ( valueof ( p_address ) );
for ( v_pos := 128 - valueof ( p_prefixLength ); v_pos < 128; v_pos := v_pos + 1 ) {
v_prefix[v_pos] := '0'B;
}
return bit2oct ( v_prefix );
} // end f_createPrefix
/*
* @desc Creates a prefix using p_address. The length of the prefix is fixed
* in 64. The first 64 bits remain unchanged, the others are set to zero.
* @param p_address Address used for prefix creation
*/
function f_createPrefix64 ( template Ipv6Address p_address )
runs on LibIpv6Node
return Ipv6Address {
var Bit128 v_prefix;
var integer v_pos;
v_prefix := oct2bit ( valueof ( p_address ) );
for ( v_pos := 64; v_pos < 128; v_pos := v_pos + 1 ) {
v_prefix[v_pos] := '0'B;
}
return bit2oct ( v_prefix );
} // end f_createPrefix64
}//end group calcPrefixFns
/*
* @desc This goes through the ExtensionHeaderList and
* checks if a HomeAddressOption is present.
* @param p_extHdrList ExtensionHeaderList to be treated
* @param p_homeAddr Home address
* @return execution status
*/
function f_isPresentHomeAddressOption( in ExtensionHeaderList p_extHdrList,
inout Ipv6Address p_homeAddr)
runs on LibIpv6Node
return FncRetCode {
var FncRetCode v_ret := e_error;
var UInt8 i,j;
//select ext hdrs that need special calculation
for (i:=0; i<sizeof(p_extHdrList) and (v_ret != e_success); i:=i+1) {
if (ischosen(p_extHdrList[i].destinationOptionHeader)) {
for (j:=0; j<sizeof(p_extHdrList[i].destinationOptionHeader.destOptionList);j:=j+1) {
if (ischosen(p_extHdrList[i].destinationOptionHeader.destOptionList[j].homeAddressOption)) {
p_homeAddr := p_extHdrList[i].destinationOptionHeader.destOptionList[j].homeAddressOption.homeAddress;
v_ret := e_success;
}
}
}
}
return v_ret;
}//end function f_isPresentHomeAddressOption
/*
* @desc This goes through the ExtensionHeaderList and
* checks if a Routing Header type 2 is present.
* @param p_extHdrList ExtensionHeaderList to be treated
* @return execution status
*/
function f_isPresentRoutingHeaderType2( in ExtensionHeaderList p_extHdrList,
inout Ipv6Address p_homeAddr)
runs on LibIpv6Node
return FncRetCode {
var FncRetCode v_ret := e_error;
var UInt8 i,j;
//select ext hdrs that need special calculation
for (i:=0; i<sizeof(p_extHdrList) and (v_ret != e_success); i:=i+1) {
if (ischosen(p_extHdrList[i].routingHeader) and (p_extHdrList[i].routingHeader.routingType == c_routeHdrType2)) {
if (ischosen(p_extHdrList[i].routingHeader.routingHeaderData.rtHdrDataHomeAddress)) {
p_homeAddr := p_extHdrList[i].routingHeader.routingHeaderData.rtHdrDataHomeAddress;
v_ret := e_success;
}
}
}
return v_ret;
}//end function f_isPresentRoutingHeaderType2
/*
* @desc This goes through the ExtensionHeaderList and
* checks if a Binding Authority Data option is present.
* @param p_extHdrList ExtensionHeaderList to be treated
* @return execution status
*/
function f_isPresentBindingAuthorityDataOption ( in ExtensionHeaderList p_extHdrList )
runs on LibIpv6Node
return FncRetCode {
var FncRetCode v_ret := e_error;
var UInt8 i,j;
//select ext hdrs that need special calculation
for ( i := 0; i < sizeof ( p_extHdrList ) and ( v_ret != e_success ); i := i + 1 ) {
if ( ischosen ( p_extHdrList[i].mipHeader ) ) {
if ( ischosen ( p_extHdrList[i].mipHeader.mipMessage.bindingAck ) ) {
for ( j := 0; j < sizeof ( p_extHdrList[i].mipHeader.mipMessage.bindingAck.mipOptions ); j := j + 1 ) {
if ( ischosen ( p_extHdrList[i].mipHeader.mipMessage.bindingAck.mipOptions[j].mipBindingAuthorizationData ) == true ) {
v_ret := e_success;
}
}
}
}
}
if ( v_ret == e_error ) {
log ( "**** f_isPresentBindingAuthorityDataOption: ERROR: Binding Authentication Data option is not present in Binding Ack **** " );
}
return v_ret;
}//end function f_isPresentBindingAuthorityDataOption
/*
* @desc This goes through the ExtensionHeaderList and
* checks if a Binding Refresh Advice option is present.
* @param p_extHdrList ExtensionHeaderList to be treated
* @return execution status
*/
function f_isPresentBindingRefreshAdviceOption ( in ExtensionHeaderList p_extHdrList )
runs on LibIpv6Node
return FncRetCode {
var FncRetCode v_ret := e_error;
var UInt8 i,j;
//select ext hdrs that need special calculation
for ( i := 0; i < sizeof ( p_extHdrList ) and ( v_ret != e_success ); i := i + 1 ) {
if ( ischosen ( p_extHdrList[i].mipHeader ) ) {
if ( ischosen ( p_extHdrList[i].mipHeader.mipMessage.bindingAck ) ) {
for ( j := 0; j < sizeof ( p_extHdrList[i].mipHeader.mipMessage.bindingAck.mipOptions ); j := j + 1 ) {
if ( ischosen ( p_extHdrList[i].mipHeader.mipMessage.bindingAck.mipOptions[j].mipOptBindingRefreshAdvice ) == true ) {
v_ret := e_success;
}
}
}
}
}
if ( v_ret == e_error ) {
log ( "**** f_isPresentBindingRefreshAdviceOption: ERROR: Binding Authentication Data option is not present in Binding Ack **** " );
}
return v_ret;
}//end function f_isPresentBindingRefreshAdviceOption
} // end module LibIpv6_CommonRfcs_Functions
/*
* @author STF 276
* @version $Id$
* @desc This module specifies common template definitions
* for common IPv6 information element types, e.g.,
* IPv6 header, or extension headers
*
*/
module LibIpv6_CommonRfcs_Templates {
//LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
//LibIpv6
import from LibIpv6_CommonRfcs_TypesAndValues all;
import from LibIpv6_ModuleParameters all;
group link_Layer_Address {
/*
* @param p_addr Source MAC link layer address value
* @remark The option length is defined by module parameter PX_MAC_OPTION_LEN
*/
template SrcLinkLayerAddress m_macSlla (template Oct6to15 p_addr):={
icmpType:= c_srcLinkLayerAddress,
optionLength:= PX_MAC_OPTION_LEN,
linkLayerAddr:= p_addr
}
/*
* @param p_addr Target MAC link layer address value
* @remark The option length is defined by module parameter PX_MAC_OPTION_LEN
*/
template TgtLinkLayerAddress m_macTlla (template Oct6to15 p_addr):={
icmpType:= c_tgtLinkLayerAddress,
optionLength:= PX_MAC_OPTION_LEN,
linkLayerAddr:= p_addr
}
} // end group link_Layer_Address
group paddingTemplates {
template OptPadN m_optPad2 := {
optType := 1,
optLen := 0,
padding := omit
}
template OptPadN m_optPad4 := {
optType := 1,
optLen := 2,
padding := c_2ZeroBytes
}
}//end group paddingTemplates
group destination_Options {
/*
* @param p_dstOpt First element in the Destination option list
*/
template DestOptionList m_dstOptList_1Elem ( template DestOption p_dstOpt ) := {
p_dstOpt
}
/*
* @param p_dstOpt First 2 elements in the Destination option list
*/
template DestOptionList m_dstOptList_2Elem ( template DestOption p_dstOpt1,
template DestOption p_dstOpt2) := {
p_dstOpt1,
p_dstOpt2
}
/*
* @param p_option Destination option(s) encoded in octetstring
*/
template DestOption m_dstOpt_generalOption ( template octetstring p_option ) := {
generalOptionString := p_option
}
/*
* @param p_homeAddress Home Address
*/
template DestOption m_dstOpt_homeAddr(template Oct16 p_homeAddress) := {
homeAddressOption := {
ipv6OptType := c_optHomeAddress,
ipv6OptLen := c_optLen16,
homeAddress := p_homeAddress
}
}
/*
* @param p_homeAddress Home Address
*/
template DestOption mw_dstOpt_homeAddr := {
homeAddressOption := {
ipv6OptType := c_optHomeAddress,
ipv6OptLen := c_optLen16,
homeAddress := ?
}
}
/*
* @param p_homeAddress Home Address
*/
template DestOption m_dstOpt_padN(template OptPadN p_optPadN) := {
padN := p_optPadN
}
} // end group destination_Options
group nbrDiscOptions {
template AdvertisementInterval m_advInterval(UInt32 p_advInterval) := {
icmpType := c_advertisementInterval,
optionLength := 1,
reserved := c_uInt16Zero,
advInterval := p_advInterval
}
template HomeAgentInfo m_homeAgentInfo( UInt16 p_homeAgentPreference,
UInt16 p_homeAgentLifetime) := {
icmpType := c_homeAgentInfo,
optionLength := 1,
reserved := c_uInt16Zero,
homeAgentPreference := p_homeAgentPreference,
homeAgentLifetime := p_homeAgentLifetime
}
}//end group nbrDiscOptions
} // end module LibIpv6_CommonRfcs_Templates
/*
* @author STF 276
* @version $Id$
* @desc This module defines types and constants for
* information elements that are shared by more
* than one RFC TTCN-3 module including IPv6 options,
* addresses, and extension headers.
* Types have been derived from various RFCs.
*/
module LibIpv6_CommonRfcs_TypesAndValues {
//LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
import from LibCommon_TextStrings all;
import from LibCommon_Time all ;
group DefaultConstants {
const UInt16 c_defId := 10; // for ICMP echo proc
const UInt16 c_defSeqNo := 20; // for ICMP echo proc
}
group rfc4291AddressingArchitecture {
type Oct16 Ipv6Address;
type UInt8 PrefixLength ;//indicates nr of bits to be used as Prefix
//Unspecified address
const Ipv6Address c_unspecifiedAdd := c_16ZeroBytes;
const UInt8 c_maxNrIpv6Address := 10;
type record length(1 .. c_maxNrIpv6Address) of Ipv6Address Ipv6AddressList
with {
encode "present=isEOF()== false ;elements=valueOf(getTag('hdrExtLen'));"
}
}//end group rfc4291AddressingArchitecture
group ipv6Options {
const UInt8 c_optLen0 := 0;
const UInt8 c_optLen1 := 1;
const UInt8 c_optLen2 := 2;
const UInt8 c_optLen3 := 3;
const UInt8 c_optLen4 := 4;
const UInt8 c_optLen6 := 6;
const UInt8 c_optLen16 := 16;
group rfc2460Options {
group paddingOptions {
const UInt8 c_optPad1 := 0;
const UInt8 c_optPadN := 1;
const UInt8 c_optPadNLen0 := 0 ;
const UInt8 c_optPadNLen2 := 2;
const UInt8 c_optPadNLen4 := 4 ;
type record OptPad1 {
UInt8 optType(c_optPad1)
}
with {
encode "present=bytes(0,1,0);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-1";
}
type record OptPadN {
UInt8 optType(c_optPadN),
UInt8 optLen,
octetstring padding optional
}
with {
encode "present=bytes(0,1,1);";
encode (optLen) "tag='optLen';intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-value-2";
encode (padding) "length=valueOf(getTag('optLen'));fieldPresent=(valueOf(getTag('optLen'))>0)";
}
}//end group paddingOptions
group DestOptions { //2460 + MIPv6
const UInt8 c_maxNrDestOption := 10;
/* @remark In a DestOptionList value either the pad1 or padN
* option can appear only once!
*/
type set length (1..c_maxNrDestOption) of DestOption DestOptionList
with {
encode "elements=valueOf(getTag('hdrExtLen'));"
}
type union DestOption {
OptPad1 pad1 ,
OptPadN padN ,
OptTunnelEncapLimit tunnelEncapLimit ,
OptHomeAddress homeAddressOption,
octetstring generalOptionString
}
with {
encode (generalOptionString) "length=valueOf(getTag('hdrExtLen'))-2;";
}
}//end group DestOptions
}//end group rfc2460Options
group rfc2461Options {
group slla {
const UInt8 c_srcLinkLayerAddress := 1;
/*
* @desc Derived from RFC2461 clause4.6.1 + MIPv6
* @url http://www.ietf.org/rfc/rfc2461.txt
*/
type record SrcLinkLayerAddress {
UInt8 icmpType(c_srcLinkLayerAddress),
UInt8 optionLength,
Oct6to15 linkLayerAddr
}
with {
encode "present=bytes(0,1,1);";
encode (optionLength) "tag='SLA_optionLength';";
encode (linkLayerAddr) "length=valueOf(getTag('SLA_optionLength'))*8-2;";
}
}//end group slla
group tlla {
const UInt8 c_tgtLinkLayerAddress := 2;
/*
* @desc Derived from RFC 2461 clause 4.6.1 + MIPv6
* @url http://www.ietf.org/rfc/rfc2461.txt
*/
type record TgtLinkLayerAddress {
UInt8 icmpType(c_tgtLinkLayerAddress),
UInt8 optionLength,
Oct6to15 linkLayerAddr
}
with {
encode "present=bytes(0,1,2);";
encode (optionLength) "tag='TLA_optionLength';";
encode (linkLayerAddr) "length=valueOf(getTag('TLA_optionLength'))*8-2;";
}
}//end group tlla
group mtu {
const UInt8 c_mtuOption := 5;
/*
* @desc Derived from RFC 2461 clause 4.6.4 + MIPv6
* @url http://www.ietf.org/rfc/rfc2461.txt
*/
type record MtuOption {
UInt8 icmpType(c_mtuOption),
UInt8 optionLength,
UInt16 reserved,
UInt32 mtu
}
with {
encode "present=bytes(0,1,5);"
}
}//end group mtu
}//end group rfc2461Options
group rfc2473Options {
const UInt8 c_optTunnelEncapLimit := 4;
/*
* @desc Derived from RFC 2473 Section 4.1.1
* @url http://www.ietf.org/rfc/rfc2473.txt
*/
type record OptTunnelEncapLimit {
UInt8 optType(c_optTunnelEncapLimit),
UInt8 optLen (1),