1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // icmp6_hdr.h - ICMPv6 header structure
15 // This module defines the basic classes for accessing the header
16 // structures within ICMPv6 packets.
23 @ingroup ip_packet_formats
28 #ifndef __ICMP6_HDR_H__
29 #define __ICMP6_HDR_H__
33 #include <in_sock.h> // IPv6 enhanced in_sock.h
36 * @addtogroup ip_packet_formats
41 class TInet6HeaderICMP
43 * ICMPv6 header common part layout.
45 * The basic ICMP header format only covers the common part (4 bytes)
46 * and 4 bytes of the Message Body (can be accesses as "Parameter")
48 Extract from RFC-2462: General format of ICMP message
51 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
52 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 | Type | Code | Checksum |
54 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 inline TInt HeaderLength() const
66 * Gets the header length.
69 * This length is not the true length of the
70 * ICMP header. This only covers the fixed part.
72 * @return Header length.
75 inline static TInt MinHeaderLength()
77 * Gets the minimum header length.
79 * @return Minimum header length
82 inline static TInt MaxHeaderLength()
84 * Gets the maximum header length.
87 * This length is not the true length of the
88 * ICMP header. This only covers the fixed part.
90 * @return Maximum header length
93 inline TUint8 *EndPtr() const
95 * Gets a pointer to the byte following the header.
98 * Pointer to the byte following the minimum
101 {return (TUint8 *)i + HeaderLength();}
103 // Access, get ICMP header field values from the packet
105 inline TUint8 Type() const
107 * Gets the ICMPv6 type from the header.
108 * @return ICMPv6 type [0..255]
113 inline TUint8 Code() const
115 * Gets the ICMPv6 code from the header.
116 * @return ICMPv6 code [0..255]
121 inline TInt Checksum() const
123 * Gets the Checksum from the header.
124 * @return Header Checksum (TUint16 in NETWORK byte order)
127 // Checksum is used in network byte order
128 return *((TUint16 *)&i[2]);
130 inline TUint32 Parameter() const
132 * Gets the ICMPv6 Parameter.
134 * Accesses the first 4 bytes of ICMP message body, and assumes
135 * they form a 32 bit integer in network byte order. Returns
136 * this integer in host order.
138 * @return ICMPv6 Parameter (as an integer)
141 return (i[4] << 24) | (i[5] << 16) | (i[6] << 8) | i[7];
144 // Build, set IP header field values into the packet
146 inline void SetType(TUint8 aType)
148 * Sets the ICMPv6 type.
149 * @param aType ICMPv6 type [0..255]
154 inline void SetCode(TUint8 aCode)
156 * Sets the ICMPv6 code.
157 * @param aCode ICMPv6 code [0..255]
162 inline void SetChecksum(TInt aSum)
167 * The Checksum [0..65535] (16 least significant bits
168 * stored as is (assumed to be in NETWORK byte order).
171 *((TUint16 *)&i[2]) = (TUint16)aSum;
173 inline void SetParameter(TUint32 aValue)
175 * Sets the ICMPv6 Parameter.
177 * The value is converted into network byte order and
178 * stored as the first 4 bytes of the ICMP message body.
184 i[7] = (TUint8)aValue;
185 i[6] = (TUint8)(aValue >> 8);
186 i[5] = (TUint8)(aValue >> 16);
187 i[4] = (TUint8)(aValue >> 24);
194 TUint32 iAlign; // A dummy member to force the 4 byte alignment
200 // TInet6HeaderICMP_Echo
202 class TInet6HeaderICMP_Echo : public TInet6HeaderICMP
204 * ICMPv6 Echo Request and Echo Reply layout.
206 * Describes the ICMP Echo Request and Replay layout. The space for
207 * Identifier and Sequence is already covered by the base class.
213 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215 | Type | Code | Checksum |
216 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
217 | Identifier | Sequence Number |
218 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
230 inline TInt HeaderLength() const
232 * Gets the header length.
236 inline static TInt MinHeaderLength()
238 * Gets the minimum header length.
242 inline static TInt MaxHeaderLength()
244 * Gets the maximum header length.
250 // Access, get ICMP header field values from the packet
252 inline TInt Identifier() const
254 * Gets the Idenfifier
255 * @return The Identifier
258 return (i[4] << 8) + i[5];
260 inline TInt Sequence() const
262 * Gets the Sequence Number
266 return (i[6] << 8) + i[7];
269 // Build, set IP header field values into the packet
271 inline void SetIdentifier(TUint16 aIdentifier)
273 * Sets the Idenfifier
274 * @param aIdentifier The Identifier
277 i[4] = (TUint8)(aIdentifier >> 8);
278 i[5] = (TUint8)aIdentifier;
280 inline void SetSequence(TUint16 aSequence)
282 * Sets the Sequence Number
283 * @param aSequence The number
286 i[6] = (TUint8)(aSequence >> 8);
287 i[7] = (TUint8)aSequence;
293 class TInet6HeaderICMP_RouterSol: public TInet6HeaderICMP
295 * ICMPv6 Router Solicitation layout.
298 Router Solicitation Message Format (from RFC-2461)
301 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
302 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
303 | Type | Code | Checksum |
304 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
306 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
308 +-+-+-+-+-+-+-+-+-+-+-+-
310 * Aside from the fields provided by the base class, there is nothing
315 * - #KInet6OptionICMP_SourceLink
322 inline static TInt MinHeaderLength() {return 8; }
323 inline static TInt MaxHeaderLength() {return 8; }
324 inline TInt HeaderLength() const {return 8;}
327 // Router Advertisement Message Format from RFC-2461
328 class TInet6HeaderICMP_RouterAdv : public TInet6HeaderICMP
330 * ICMPv6 Router Advertisement layout.
332 * (Neighbour Discovery for IP version 6)
333 * (+ Home Agent flag from draft-ietf-mobileip-ipv6-08)
338 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
339 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
340 | Type | Code | Checksum |
341 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
342 | Cur Hop Limit |M|O|H|Prf|Rsrvd| Router Lifetime |
343 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
345 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
347 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
349 +-+-+-+-+-+-+-+-+-+-+-+-
353 * Above is longer thant what is declared in the base class
354 * i-member. The user must verify the sufficient length of
355 * the packet, when using this.
359 * - #KInet6OptionICMP_SourceLink
360 * - #KInet6OptionICMP_Mtu
361 * - #KInet6OptionICMP_Prefix
362 * - #KInet6OptionICMP_RouteInformation (draft)
372 inline static TInt MinHeaderLength() {return 16; }
373 inline static TInt MaxHeaderLength() {return 16; }
374 inline TInt HeaderLength() const {return 16;}
376 // Access, get ICMP header field values from the packet
378 inline TInt CurHopLimit() const
380 * Gets Cur Hop Limit.
386 inline TInt Flags() const
389 * @return Flags (M, O, H, Prf and Rsrvd)
392 return i[5]; // M + O + Reserved as one unit
394 inline TInt M() const
395 /** Gets Managed Address Configuration (M) flag */
399 inline TInt O() const
400 /** Gets Other Address Configuartion (O) flag */
404 inline TInt H() const
405 /** Gets Home Agent Configuration (H) flag */
410 inline TInt Prf() const
412 * Gets default route preference.
414 * Experimental: draft-draves-ipngwg-router-selection-01.txt
415 * Default Router Preferences and More-Specific Routes
418 return (i[5] >> 3) & 0x3; // should be treated as 2bit signed int
421 inline TInt RouterLifetime() const
423 * Gets the lifetime of the defaul route.
425 * If non-zero, specifies how long (in seconds) this
426 * router is willing to act as a default router.
428 * @return The life time of the default route.
431 * This is badly named. The parameter controls
432 * only the default route processing. The value
433 * ZERO does not mean that the sender is not a
437 return (i[6] << 8) + i[7];
439 inline TUint32 ReachableTime() const
441 * Gets the value of reachable timer.
444 return (i[8] << 24) | (i[9] << 16) | (i[10] << 8) | i[11];
446 inline TUint32 RetransTimer() const
448 * Gets the value of retransmit timer.
451 return (i[12] << 24) | (i[13] << 16) | (i[14] << 8) | i[15];
454 // Build, set IP header field values into the packet
456 inline void SetCurHopLimit(TInt aLimit)
458 * Sets the Cur Hoplimit.
459 * @param aLimit The Hoplimit [0..255]
462 i[4] = (TUint8)aLimit;
464 inline void SetFlags(TInt aFlags)
467 * @param aFlags The flags bits [0..255].
470 i[5] = (TUint8)aFlags;
472 inline void SetRouterLifetime(TInt aTime)
474 * Sets the lifetime of the default route.
475 * @param aTime The lifetime.
478 i[7] = (TUint8)aTime;
479 i[6] = (TUint8)(aTime >> 8);
481 inline void SetReachableTime(TUint32 aTime)
483 * Sets the value of reachable timer
484 * @param aTime The timer value
487 i[11] = (TUint8)aTime;
488 i[10] = (TUint8)(aTime >> 8);
489 i[9] = (TUint8)(aTime >> 16);
490 i[8] = (TUint8)(aTime >> 24);
492 inline void SetRetransTimer(TUint32 aTimer)
494 * Sets the value of the retransmit timer
495 * @param aTimer The timer value
498 i[15] = (TUint8)aTimer;
499 i[14] = (TUint8)(aTimer >> 8);
500 i[13] = (TUint8)(aTimer >> 16);
501 i[12] = (TUint8)(aTimer >> 24);
507 class TInet6HeaderICMP_NeighborSol : public TInet6HeaderICMP
509 * ICMPv6 Neighbour Solicitation layout.
511 Neigbour Solicitation Message Format from RFC-2461
514 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
515 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
516 | Type | Code | Checksum |
517 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
519 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
527 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
529 +-+-+-+-+-+-+-+-+-+-+-+-
533 * Above is longer thant what is declared in the base class
534 * i-member. The user must verify the sufficient length of
535 * the packet, when using this.
539 * - #KInet6OptionICMP_SourceLink
549 inline static TInt MinHeaderLength() {return 24; }
550 inline static TInt MaxHeaderLength() {return 24; }
551 inline TInt HeaderLength() const {return 24;}
552 inline TIp6Addr &Target() const
554 * Gets the Target Address.
556 * @return The target address (reference).
559 return (TIp6Addr &)i[8];
565 class TInet6HeaderICMP_NeighborAdv : public TInet6HeaderICMP
567 * ICMPv6 Neighbour Advertisement layout.
569 Neighbor Advertisement Message Format (from RFC-2461)
572 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
573 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
574 | Type | Code | Checksum |
575 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
577 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
585 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
587 +-+-+-+-+-+-+-+-+-+-+-+-
590 * Above is longer thant what is declared in the base class
591 * i-member. The user must verify the sufficient length of
592 * the packet, when using this.
596 * - #KInet6OptionICMP_TargetLink
606 inline static TInt MinHeaderLength() {return 24; }
607 inline static TInt MaxHeaderLength() {return 24; }
608 inline TInt HeaderLength() const {return 24;}
611 // Set and Access the Target Address
613 inline TIp6Addr &Target() const
615 * Gets the Target Address.
617 * @return The target address (reference).
620 return (TIp6Addr &)i[8];
635 inline void SetR(TInt aValue)
637 if (aValue) i[4] |= 0x80; else i[4] &= ~0x80;
639 inline void SetS(TInt aValue)
641 if (aValue) i[4] |= 0x40; else i[4] &= ~0x40;
643 inline void SetO(TInt aValue)
645 if (aValue) i[4] |= 0x20; else i[4] &= ~0x20;
651 class TInet6HeaderICMP_Redirect : public TInet6HeaderICMP
653 * ICMPv6 Redirect layout.
655 Redirect Message Format (RFC-2461)
658 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
659 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
660 | Type | Code | Checksum |
661 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
663 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
671 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
675 + Destination Address +
679 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
681 +-+-+-+-+-+-+-+-+-+-+-+-
685 * Above is longer thant what is declared in the base class
686 * i-member. The user must verify the sufficient length of
687 * the packet, when using this.
691 * - #KInet6OptionICMP_TargetLink
692 * - #KInet6OptionICMP_Redirect
702 inline static TInt MinHeaderLength() {return 40; }
703 inline static TInt MaxHeaderLength() {return 40; }
704 inline TInt HeaderLength() const {return 40;}
706 inline TIp6Addr &Target() const
708 * Gets the Target Address.
710 * @return The target address (reference).
713 return (TIp6Addr &)i[8];
715 inline TIp6Addr &Destination() const
717 * Gets the Destination Address.
719 * @return The destination address (reference).
722 return (TIp6Addr &)i[24];
727 class TInet6OptionICMP_LinkLayer
729 * ICMPv6 Link-layer Address layout.
731 Source/Target Link-layer Address Option (RFC-2461)
734 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
735 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
736 | Type | Length | Link-Layer Address ...
737 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
744 inline static TInt MinHeaderLength() {return 8; }
745 inline static TInt MaxHeaderLength() {return 8; } // Not very useful
746 inline TInt HeaderLength() const {return Length() * 8; }
750 inline TInt Type() const
754 inline TInt Length() const
761 inline TPtr8 Address() const
763 return TPtr8((TUint8 *)&i[2], i[1] * 8 - 2, i[1] * 8 - 2);
768 inline void SetType(TInt aType)
770 i[0] = (TUint8)aType;
772 inline void SetLength(TInt aLength)
774 i[1] = (TUint8)aLength;
780 TUint32 iAlign; // A dummy member to force the 4 byte alignment
785 class TInet6OptionICMP_Prefix
787 * ICMPv6 Prefix Infotmation Option.
789 Prefix Information Option (RFC-2461)
790 (+ Router Address flag from draft-ietf-mobileip-ipv6-08)
792 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
793 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
794 | Type | Length | Prefix Length |L|A|R| Rsrvd1 |
795 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
797 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
798 | Preferred Lifetime |
799 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
801 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
809 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 inline static TInt MinHeaderLength() {return 4*8; }
818 inline static TInt MaxHeaderLength() {return 4*8; } // Not very useful
819 inline TInt HeaderLength() const {return 4*8; }
821 inline TInt Type() const
825 inline TInt Length() const
829 inline TInt PrefixLength() const
831 return i[2]; // 0..128
833 inline TInt LFlag() const
837 inline TInt AFlag() const
841 inline TInt RFlag() const
845 inline TUint32 ValidLifetime() const
847 return (i[4] << 24) | (i[5] << 16) | (i[6] << 8) | i[7];
849 inline TUint32 PreferredLifetime() const
851 return (i[8] << 24) | (i[9] << 16) | (i[10] << 8) | i[11];
855 inline TIp6Addr &Prefix() const
857 return (TIp6Addr &)i[16];
862 inline void SetType(TInt aType)
864 i[0] = (TUint8)aType;
866 inline void SetLength(TInt aLength)
868 i[1] = (TUint8)aLength;
870 inline void SetPrefixLength(TInt aLength)
872 i[2] = (TUint8)aLength;
874 inline void SetFlags(TInt aFlags)
876 i[3] = (TUint8)aFlags;
878 inline void SetValidLifetime(TUint32 aTime)
880 i[7] = (TUint8)aTime;
881 i[6] = (TUint8)(aTime >> 8);
882 i[5] = (TUint8)(aTime >> 16);
883 i[4] = (TUint8)(aTime >> 24);
885 inline void SetPreferredLifetime(TUint32 aTime)
887 i[11] = (TUint8)aTime;
888 i[10] = (TUint8)(aTime >> 8);
889 i[9] = (TUint8)(aTime >> 16);
890 i[8] = (TUint8)(aTime >> 24);
892 inline void SetReserved2(TUint32 aFiller)
894 i[15] = (TUint8)aFiller;
895 i[14] = (TUint8)(aFiller >> 8);
896 i[13] = (TUint8)(aFiller >> 16);
897 i[12] = (TUint8)(aFiller >> 24);
905 TUint32 iAlign; // A dummy member to force the 4 byte alignment
910 class TInet6OptionICMP_Mtu
914 MTU Option (RFC-2461)
917 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
918 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
919 | Type | Length | Reserved |
920 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
922 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
929 inline static TInt MinHeaderLength() {return 8; }
930 inline static TInt MaxHeaderLength() {return 8; } // Not very useful
931 inline TInt HeaderLength() const {return 8; }
933 inline TInt Type() const
937 inline TInt Length() const
941 inline TInt Mtu() const
943 return (i[4] << 24) | (i[5] << 16) | (i[6] << 8) | i[7];
948 inline void SetType(TInt aType)
950 i[0] = (TUint8)aType;
952 inline void SetLength(TInt aLength)
954 i[1] = (TUint8)aLength;
955 // Silently ZERO the reserved bits... not too nice --- msa
959 inline void SetMtu(TUint32 aMtu)
962 i[6] = (TUint8)(aMtu >> 8);
963 i[5] = (TUint8)(aMtu >> 16);
964 i[4] = (TUint8)(aMtu >> 24);
972 class TInet6OptionICMP_RouteInformation
973 // Route Information Option
974 // Experimental: draft-draves-ipngwg-router-selection-01.txt
976 * ICMPv6 Route Information Option.
978 Default Router Preferences and More-Specific Routes
981 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
982 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
983 | Type | Length | Prefix Length |Resvd|Prf|Resvd|
984 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
986 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
994 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1001 inline static TInt MinHeaderLength() {return 8; }
1002 inline static TInt MaxHeaderLength() {return 3*8; }
1003 inline TInt HeaderLength() const {return Length()*8; }
1005 inline TInt Type() const
1009 inline TInt Length() const
1013 inline TInt PrefixLength() const
1015 return i[2]; // 0..128
1017 inline TInt Prf() const
1019 return (i[3] >> 3) & 0x3; // should be treated as 2bit signed int
1021 inline TUint32 RouteLifetime() const
1023 return (i[4] << 24) | (i[5] << 16) | (i[6] << 8) | i[7];
1026 // *WARNING* The "Prefix" returns a raw reference to the beginning
1027 // of the prefix field in the option structure. HOWEVER, the option
1028 // field can be shorter than 128 bits! If used to allocate space,
1029 // the maximum is allocated and the method is safe, but that is not
1030 // true if header is mapped directly to the received packet! -- msa
1031 inline TIp6Addr &Prefix() const
1033 return (TIp6Addr &)i[8];
1036 // Construct methods
1038 inline void SetType(TInt aType)
1040 i[0] = (TUint8)aType;
1042 inline void SetLength(TInt aLength)
1044 i[1] = (TUint8)aLength;
1046 inline void SetPrefixLength(TInt aLength)
1048 i[2] = (TUint8)aLength;
1050 inline void SetPrefixLifetime(TUint32 aTime)
1052 i[7] = (TUint8)aTime;
1053 i[6] = (TUint8)(aTime >> 8);
1054 i[5] = (TUint8)(aTime >> 16);
1055 i[4] = (TUint8)(aTime >> 24);
1061 TUint8 i[3*8]; // The space allocated for MAX LENGTH
1062 TUint32 iAlign; // A dummy member to force the 4 byte alignment
1066 class TInet6OptionICMP_DnsInformation
1068 * ICMPv6 Recursive DNS Server Option.
1069 * IPv6 DNS Configuration based on Router Advertisement
1071 * Experimental: draft-jeong-dnsop-ipv6-discovery-03.txt
1073 Recursive DNS Server Option
1076 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1077 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1078 | Type | Length | Pref | Reserved |
1079 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1081 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1083 : IPv6 Address of RDNSS :
1085 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1093 inline static TInt MinHeaderLength() {return 24; }
1094 inline static TInt MaxHeaderLength() {return 24; }
1095 inline TInt HeaderLength() const {return Length()*8; }
1097 inline TInt Type() const
1101 inline TInt Length() const
1105 inline TInt Pref() const
1107 return (i[3] >> 4) & 0xF;
1109 inline TUint32 Lifetime() const
1111 return (i[4] << 24) | (i[5] << 16) | (i[6] << 8) | i[7];
1113 inline TIp6Addr &Address() const
1115 return (TIp6Addr &)i[8];
1118 // Construct methods
1120 inline void SetType(TInt aType)
1122 i[0] = (TUint8)aType;
1124 inline void SetLength(TInt aLength)
1126 i[1] = (TUint8)aLength;
1128 inline void SetPref(TInt aPref)
1130 i[2] = (TUint8)(((aPref << 4) & 0xF0) | (i[2] & 0xF));
1132 inline void SetLifetime(TUint32 aTime)
1134 i[7] = (TUint8)aTime;
1135 i[6] = (TUint8)(aTime >> 8);
1136 i[5] = (TUint8)(aTime >> 16);
1137 i[4] = (TUint8)(aTime >> 24);
1143 TUint8 i[24]; // The space allocated for MAX LENGTH
1144 TUint32 iAlign; // A dummy member to force the 4 byte alignment
1151 * @name ICMPv6 Error Message Types (0-127)
1154 const TUint8 KInet6ICMP_Unreachable = 1;
1155 const TUint8 KInet6ICMP_PacketTooBig = 2;
1156 const TUint8 KInet6ICMP_TimeExceeded = 3;
1157 const TUint8 KInet6ICMP_ParameterProblem= 4;
1160 * @name ICMPv6 Informational Message Types (128-255)
1163 /** Echo Request. See TInet6HeaderICMP_Echo. */
1164 const TUint8 KInet6ICMP_EchoRequest = 128;
1165 /** Echo Reply. See TInet6HeaderICMP_Echo. */
1166 const TUint8 KInet6ICMP_EchoReply = 129;
1167 /** Not implemented. */
1168 const TUint8 KInet6ICMP_GroupQuery = 130;
1169 /** Not implemented. */
1170 const TUint8 KInet6ICMP_GroupReport = 131;
1171 /** Not implemented. */
1172 const TUint8 KInet6ICMP_GroupDone = 132;
1173 /** Router Solicitation. See TInet6HeaderICMP_RouterSol. */
1174 const TUint8 KInet6ICMP_RouterSol = 133;
1175 /** Router Advertisement. See TInet6HeaderICMP_RouterAdv. */
1176 const TUint8 KInet6ICMP_RouterAdv = 134;
1177 /** Neighbor Solicitation. See TInet6HeaderICMP_NeighborSol. */
1178 const TUint8 KInet6ICMP_NeighborSol = 135;
1179 /** Neighbor Advertisement. See TInet6HeaderICMP_NeighborAdv. */
1180 const TUint8 KInet6ICMP_NeighborAdv = 136;
1181 /** Redirect. See TInet6HeaderICMP_Redirect. */
1182 const TUint8 KInet6ICMP_Redirect = 137;
1186 * @name ICMPv6 Option types.
1187 * The default derivation of the symbol
1188 * is from the name of the header class by replacing 'T' with 'K' (or
1193 /** Source Link-Layer Address. See TInet6OptionICMP_LinkLayer. */
1194 const TInt KInet6OptionICMP_SourceLink = 1;
1195 /** Target Link-Layer Address. See TInet6OptionICMP_LinkLayer. */
1196 const TInt KInet6OptionICMP_TargetLink = 2;
1197 /** Prefix Information. See TInet6OptionICMP_Prefix. */
1198 const TInt KInet6OptionICMP_Prefix = 3;
1199 /** Redirect Header. (not implemented). */
1200 const TInt KInet6OptionICMP_Redirect = 4;
1201 /** MTU. See TInet6OptionICMP_Mtu. */
1202 const TInt KInet6OptionICMP_Mtu = 5;
1205 // Experimental: draft-draves-ipngwg-router-selection-01.txt
1206 // Default Router Preferences and More-Specific Routes
1207 // *UNOFFICIAL NUMBER ASSIGNMENT (SAME AS MSR STACK)--REAL VALUE TBD*
1208 /** Route Information. See TInet6OptionICMP_RouteInformation. */
1209 const TInt KInet6OptionICMP_RouteInformation = 9;