LibIpv6_CommonRfcs_TypesAndValues.ttcn 10.5 KB
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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
/*
 *	@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_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),
				UInt8			optTunnelEncapLimitValue
			}
			with {
				encode "present=bytes(0,1,4);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-3";
			}
	
		}//end group rfc2473Options

		group rfc2675Options {

			const UInt8 c_optJumboPayload := 194;
			const UInt32 c_jumboLen8 := 8;
			const UInt32 c_jumboLen128K := 131072;

			/*
			 * @desc Derived from RFC 2675 Section 2
			 * @url http://www.ietf.org/rfc/rfc2675.txt
			*/
			type record OptJumboPayload {
				UInt8			optType(c_optJumboPayload),
				UInt8			optLen(4),
				UInt32			optJumboPayloadLength
			}
			with {
				encode "present=bytes(0,1,194);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-6";
			}

		}//end group rfc2675Options

		group rfc2711Options {
	
			const UInt8		c_optRouterAlert := 5; 	

			/*
			 * @desc Derived from RFC 2711 Section 2.1
			 * @url http://www.ietf.org/rfc/rfc2711.txt
			*/
			type record OptRouterAlert {
				UInt8			optType(c_optRouterAlert),
				UInt8			optLen(2),
				UInt16			optValue
			}
			with {
				encode "present=bytes(0,1,5);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-4";
			}

		}//end group rfc2711Options
	
		group rfc3775Options {

			/*
			 * @desc  Extra ICMP option introduced by RFC3775, clause 7.3
			*/
			type record AdvertisementInterval { //ND + MIPv6
				UInt8 		icmpType (c_advertisementInterval),
				UInt8 		optionLength (1),
				UInt16		reserved,
				UInt32		advInterval
			}
			with {
				encode "present=bytes(1, 0x07)"
			}
		
			/*
			 * @desc Extra ICMP option introduced by RFC3775, clause 7.4
			*/
			type record HomeAgentInfo { //ND + MIPv6
				UInt8 		icmpType (c_homeAgentInfo),
				UInt8 		optionLength (1),
				UInt16		reserved,
				UInt16		homeAgentPreference,
				UInt16		homeAgentLifetime
			}
			with {
				encode "present=bytes(1, 0x08)"
			}

			/* @desc Derived from RFCxxxx MIpv6, clause 6.2 
			 * @remark This extension shall be inserted:  
			 *       1) After the routing header, if that header is present, 
			 *		 2) Before the Fragment Header, if that header is present
			 *		 3) Before the AH Header or ESP Header, if either one of those headers is present 
			*/
			type record OptHomeAddress { // as destination option
				UInt8	ipv6OptType(c_optHomeAddress),
				UInt8	ipv6OptLen(0..16),
				Oct16	homeAddress
			}
			with {
				encode "present=bytes(0,1,201);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-18";
			}

			group mipOptionValues {
				const UInt8	c_bindingRefreshAdvice := 2;
				const UInt8	c_alternateCareofAddress := 3;
				const UInt8	c_nonceIndices := 4;
				const UInt8	c_authorizationData := 5;
				const UInt8 c_advertisementInterval := 7;
				const UInt8 c_homeAgentInfo := 8;
			
			}//end group mipOptionValues

			const UInt8	c_optHomeAddress := 201; 
			
		}//end group rfc3775Options

	} // end ipv6Options


	group security {

		//Use c_cryptoDummyByte when no message needs to be specified in fx_cryptoFunction
		const Oct1 c_cryptoDummyByte := int2oct(0,1);

		type enumerated EncryptionAlgo {
			e_null(0),
			e_tripleDes_cbc(1),
			e_aes_cbc(2),
			e_aes_ctr(3),
			e_des_cbc(4)
		}
		with {
			//encode "use=com.testingtech.ttcn.tci.*;";
			encode "TODO";
		}

		type enumerated IntegrityAlgo {
			e_null(0),
			e_hmac_sha1_96(1),
			e_aes_xcbc_mac_96(2),
			e_hmac_md5_96(3),
			e_hmac_sha1_64(4),
			e_sha1_96(1)
		}
		with {
			//encode "use=com.testingtech.ttcn.tci.*;";
			encode "TODO";
		}

		type enumerated CombinedModeAlgo {
			e_null(0)
		}
		with {
			//encode "use=com.testingtech.ttcn.tci.*;";
			encode "TODO";
		}

		type enumerated IpSecProtocolMode {
			e_transportMode (0),
			e_tunnelMode (1)
		}
		with {
			//encode "use=com.testingtech.ttcn.tci.*;";
			encode "TODO";
		}

		type enumerated IpSecProtocol{
			e_esp (0),
			e_ah (1)
		}

		type record MipSec {
			MnSimuParams mnSimuParams,
			HaSimuParams haSimuParams,
			CnSimuParams cnSimuParams
		}

		type CnSimuParams HaSimuParams;

		type record CnSimuParams {
			//Keygen Token
			UInt16 homeNonceIndex,
			octetstring homeNonce,
			Oct20 kcn,
			Bit64 homeKeygenToken,
			Bit64 careOfKeygenToken,
			Bit64 receivedHomeInitCookie,
			Oct20 kbm
		}

		type record MnSimuParams {
			//Keygen Token
			UInt16 receivedHomeNonceIndex,
			//octetstring homeNonce,
			//Oct20 kcn,
			Bit64 receivedHomeKeygenToken,
			Bit64 receivedCareOfKeygenToken,
			Bit64 homeInitCookie,
			Oct20 kbm
		}

		const UInt8 c_maxNrDa := 8;

		//Security Association
		type record Sa {
			UInt32 securityParametersIndex,
			UInt32 sequenceNumber,
			IntegrityAlgo ahIntegrityAlgo,
			octetstring	ahIntegrityKey,
			EncryptionAlgo espEncryptionAlgo,
			octetstring	espEncryptionKey,
			IntegrityAlgo espIntegrityAlgo,
			octetstring	espIntegrityKey,
			CombinedModeAlgo espCombinedModeAlgo,
			octetstring	espCombinedModeKey,
			IpSecProtocolMode ipSecProtocolMode		
		}
		with {
			//encode "use=com.testingtech.ttcn.tci.*;";
			encode "TODO";
		}

		//Security Association Database
		type record length (1 .. c_maxNrDa) of Sa Sad;

		type record EncryptResult {
			octetstring		iv optional,	
seb's avatar
seb committed
			octetstring 	encryptedData optional,
			octetstring 	tfcPadding optional
seb's avatar
seb committed
		type record IntegrityExtHdr {
			octetstring icv optional	
		}

		/*
		 * @desc PDU type to be used when building ESP payload for encryption
		*/
		//TODO as well possibe to delete this type and make Ipv6Packet.ipv6Hdr optional
		type record ModularIpv6Packet {
			Ipv6Header			ipv6Hdr optional,
			ExtensionHeaderList extHdrList optional,
			Ipv6Payload			ipv6Payload optional
	    }
		with {
			encode "TODO";
		}

		} // end security


} // end LibIpv6_CommonRfcs_TypesAndValues