Newer
Older
/*
* @author STF 276
* @version $Id$
* @desc This module specifies functions definitions
* that can be used by any RCF function.
module LibIpv6_CommonRfcs_Functions {
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;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* 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
}
*/
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* @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
* @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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* @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 **** " );
}//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 **** " );
}
}//end function f_isPresentBindingRefreshAdviceOption
} // end module LibIpv6_CommonRfcs_Functions