Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/**
* @author ETSI / STF405
* @version $URL: svn+ssh://vcs.etsi.org/TTCN3/LIB/LibIts/trunk/ttcn/GeoNetworking/LibItsGeoNetworking_Functions.ttcn $
* $Id: LibItsGeoNetworking_Functions.ttcn 168 2010-09-22 15:18:22Z berge $
* @desc Module containing functions for Ipv6OverGeoNetworking
*
*/
module LibItsIpv6OverGeoNetworking_Functions {
// Libcommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
import from LibCommon_VerdictControl all;
// LibIts
import from LibIts_TestSystem all;
import from LibIts_Interface all;
import from LibItsGeoNetworking_TypesAndValues all;
import from LibItsGeoNetworking_Functions all;
import from LibItsGeoNetworking_Templates all;
import from LibItsIpv6OverGeoNetworking_TypesAndValues all;
group ipv6OverGeoConfigurationFunctions {
/**
* @desc This configuration features:
* - one ITS node (IUT)
* - two ITS nodes (nodeA, nodeB)
* - Area1 which only includes NodeB and IUT
* - Area2 which only includes NodeB
* NodeB being close to the area center
*/
function f_ipv6_cf01Up() runs on ItsNt {
// Variables
// Map
map(self:ipv6OverGeoNetworkingPort, system:ipv6OverGeoNetworkingPort);
f_cf01Up();
} // end f_cf01Up
/**
* @desc Deletes configuration cf01
*/
function f_ipv6_cf01Down() runs on ItsNt {
// Map
unmap(self:ipv6OverGeoNetworkingPort, system:ipv6OverGeoNetworkingPort);
f_cf01Down();
} // end f_cf01Down
} // emd ipv6OverGeoConfigurationFunctions
group testAdapter {
function f_taGetInterfaces() {
//TODO
}
} // end testAdapter
group miscellaneous {
/**
* @desc Gets the Geographical Virtual link entry associated to an area
* @param p_areaIndex The index of the area
*/
function f_getGVL(in integer p_areaIndex) runs on ItsNt return GvlTableEntry {
return vc_gvlTable[p_areaIndex];
} //end f_getGVL
/**
* @desc Retrieves the MAC address from the GN address.
* @param p_gnAddr The GN address
* @return The MAC address
*/
function f_gnAddr2MacAddr(in GN_Address p_gnAddr) return MacAddress {
return p_gnAddr.mid;
}
/**
* @desc Retrieves the GN address from the MAC address.
* @param p_macAddr The MAC address
* @return The GN address
*/
function f_macAddr2GnAddr(in MacAddress p_macAddr) return GN_Address {
var GN_Address v_gnAddr := valueof(m_dummyGnAddr);
v_gnAddr.mid := p_macAddr;
return v_gnAddr;
}
/**
* @desc Compute an Unique Interface ID based on a MAC Address
* @param p_macAddr MAC Address
* @return Unique interface ID
*/
function f_createUniqueInterfaceId (
in Oct6 p_macAddr
)
return Oct8 {
var UInt8 i;
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 := oct2bit('020000'O);
//get leftPart
for (i:=0; i<lengthof(p_macAddr)-3; i:=i+1) {
v_leftPartMac[i] := p_macAddr[i];
}
//get rightPart
for (i:=3; i<lengthof(p_macAddr); i:=i+1) {
v_rightPartMac[i-3] := p_macAddr[i];
}
//flipBit universalBit of leftPart
v_leftPartBits := oct2bit(v_leftPartMac);
v_leftPartBits := v_leftPartBits xor4b v_leftPartBitMask;
v_leftPartMac := bit2oct(v_leftPartBits);
//build InterfaceId
return v_leftPartMac & 'FFFE'O & v_rightPartMac;
}
/**
* @desc Compute link-local, global, solicited-node multicast IPv6 addresses<br>
* and MAC-Solicited-node Address, based on prefix and MAC address
* @param p_macAddr MAC Address
* @param p_prefix Prefix
* @param p_prefixLen Prefix Length
* @param p_lla Computed link-local address
* @param p_gla Computed global address
* @param p_solNodeMca Computed solicited-node multicast address
* @param p_macSolNodeMca Computed MAC solicited-node multicast address
* @return Execution status
*/
function f_createIpAddresses(
in MacAddress p_macAddr,
in Oct16 p_prefix,
in UInt8 p_prefixLen,
out Ipv6Address p_lla,
out Ipv6Address p_gla,
out Ipv6Address p_solNodeMca,
out MacAddress p_macSolNodeMca
)
return FncRetCode {
var UInt8 i;
const UInt8 c_uniIdLen := 64;
var Bit128 v_prefixBits := oct2bit(p_prefix);
var Bit64 v_prefixReadyBits := int2bit(0, 64);
var Oct8 v_prefixReady := int2oct(0,8);
var Oct8 v_interfaceIdReady := int2oct(0,8);
var Oct3 v_rightPartMac := int2oct(0,3);
if (p_prefixLen > 64) {
log("**** f_createIpAddresses: Wrong prefixLen ****");
return e_error;
}
else {
//Fill v_prefixReady with existing Prefix
for (i:=0; i<p_prefixLen; i:=i+1) {
v_prefixReadyBits[i] := v_prefixBits[i];
}
//Complete v_prefixReady with Zero Bytes
for (i:=p_prefixLen; i<64; i:=i+1) {
v_prefixReadyBits[i] := int2bit(0,1);
}
v_prefixReady := bit2oct(v_prefixReadyBits);
}
// compute interface ID
v_interfaceIdReady := f_createUniqueInterfaceId (p_macAddr);
//LLA
p_lla := 'FE80000000000000'O & v_interfaceIdReady;
//GLA
p_gla := v_prefixReady & v_interfaceIdReady;
//get rightPart
for (i:=3; i<lengthof(p_macAddr); i:=i+1) {
v_rightPartMac[i-3] := p_macAddr[i];
}
//SOL_NODE_MCA
p_solNodeMca := 'FF0200000000000000000001FF'O & v_rightPartMac;
//MAC_MCA
p_macSolNodeMca := '3333FF'O & v_rightPartMac;
return e_success;
}//end function f_createIpAddresses
/**
* @desc Derives the traffic class from the IPv6 TrafficClass field
* @param p_trafficClass The traffic class value in the IPv6 packet
* @return The traffic class based on the definition in ETSI TS 102 636-6-1 Table 1
*/
function f_getTrafficClassFromIpv6Packet(in UInt8 p_trafficClass) return TrafficClass {
var TrafficClass v_trafficClass;
v_trafficClass.reserved := 0;
v_trafficClass.relevance := 0;
if (p_trafficClass<64) {
v_trafficClass.reliability := e_low;
v_trafficClass.latency := e_high
}
else if (p_trafficClass>63 and p_trafficClass<128) {
v_trafficClass.reliability := e_low;
v_trafficClass.latency := e_medium
}
else if (p_trafficClass>127 and p_trafficClass<193) {
v_trafficClass.reliability := e_low;
v_trafficClass.latency := e_low
}
else {
v_trafficClass.reliability := e_low;
v_trafficClass.latency := e_veryLow
}
return v_trafficClass;
} // end f_getTrafficClassFromPriority
} // end miscellaneous
} // end LibItsIpv6OverGeoNetworking_Functions