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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // arp_hdr.h - ARP header structure
15 // ARP header structure.
22 @ingroup ip_packet_formats
33 * @addtogroup ip_packet_formats
38 * "Fake" protocol number for ARP.
40 * This protocol value is only used to recognize the ARP packets
41 * coming from the interface. There is no "real" ARP.PRT.
43 const TUint KProtocolArp = 0xFAD; // (get some better value)
45 const TUint16 KArpProtocolType_IP = 0x0800; // Protocol Type value for IPv4
47 // Hardware types listed only as example, it is assumed that the
48 // driver knows its own type...
50 const TUint16 KArpHarwareType_ETHERNET = 1;
51 const TUint16 KArpHarwareType_IEEE_802 = 6;
57 enum TArpOperation // from RFC-1700
59 EArpOperation_REQUEST = 1, // RFC-826
60 EArpOperation_REPLY = 2, // RFC-826
61 EArpOperation_REQUEST_REVERSE = 3, // RFC-903
62 EArpOperation_REPLY_REVERSE = 4, // RFC-903
63 EArpOperation_DRARP_REQUEST = 5, //
64 EArpOperation_DRARP_REPLY = 6,
65 EArpOperation_DRARP_ERROR = 7,
66 EArpOperation_INARP_REQUEST = 8, // RFC-1293
67 EArpOperation_INARP_REPLY = 9, // RFC-1293
68 EArpOperation_ARP_NAK = 10
77 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 | Hardware Type | Protocol Type |
79 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 | HwAddrLen | PrAddrLen | ARP Operation |
81 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82 | Sender's physical hardware address |
83 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
84 | Sender's protocol address |
85 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
86 | Target's physical hardware address |
87 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
88 | Target's protocol address |
89 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 * This definition covers only the fixed portion of the
93 * message. DO NOT DECLARE A VARIABLE WITH THIS CLASS!
99 inline static TInt MinHeaderLength() {return 8; }
100 inline static TInt MaxHeaderLength() {return 128; }
102 inline TUint8* EndPtr() { return i + HeaderLength(); }
103 inline TInt HeaderLength() const { return 8 + 2 * HwAddrLen() + 2 * PrAddrLen(); } // Return true byte length
107 inline TInt HardwareType() const // Return hardware type value in host order
109 return i[0] << 8 | i[1];
112 inline TInt ProtocolType() const // Return protocol type value in host order
114 return i[2] << 8 | i[3];
117 inline TInt HwAddrLen() const // Return hardware address length (in bytes)
122 inline TInt PrAddrLen() const // Return protocol address length (in bytes)
127 inline TInt Operation() const
129 return i[6] << 8 | i[7];
134 inline TPtr8 SenderHwAddr()
136 return TPtr8(&i[8], HwAddrLen(), HwAddrLen());
138 inline TPtr8 SenderPrAddr()
140 return TPtr8(&i[8] + HwAddrLen(), PrAddrLen(), PrAddrLen());
142 inline TPtr8 TargetHwAddr()
144 return TPtr8(&i[8] + HwAddrLen() + PrAddrLen(), HwAddrLen(), HwAddrLen());
146 inline TPtr8 TargetPrAddr()
148 return TPtr8(&i[8] + 2*HwAddrLen() + PrAddrLen(), PrAddrLen(), PrAddrLen());
153 inline void SetHardwareType(TInt aType) // Set hardware type value
155 i[1] = (TUint8)aType;
156 i[0] = (TUint8)(aType >> 8);
159 inline void SetProtocolType(TInt aType) // Set protocol type value
161 i[3] = (TUint8)aType;
162 i[2] = (TUint8)(aType >> 8);
165 inline void SetHwAddrLen(TInt aLength) // Set hardware address length (in bytes)
167 i[4] = (TUint8)aLength;
170 inline void SetPrAddrLen(TInt aLength) // Set protocol address length (in bytes)
172 i[5] = (TUint8)aLength;
175 inline void SetOperation(TInt aOperation)
177 i[7] = (TUint8)aOperation;
178 i[6] = (TUint8)(aOperation >> 8);
185 TUint32 iAlign; // A dummy member to force the 4 byte alignment