|
1 // Copyright (c) 1997-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Obsolete TCP/IP header file |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file in_ip.inl |
|
20 @internalTechnology |
|
21 @deprecated This file originates from an obsolete implementation of the TCP/IP stack |
|
22 */ |
|
23 |
|
24 #ifndef __IN_IP_INL__ |
|
25 #define __IN_IP_INL__ |
|
26 |
|
27 inline ThdrIP* ThdrIP::Ptr(RMBufPacketBase& aPacket) |
|
28 { return (ThdrIP*)aPacket.First()->Ptr(); } |
|
29 |
|
30 inline ThdrIP* ThdrIP::Ptr(ThdrICMP* aHdr) |
|
31 { return (ThdrIP*)aHdr->IpPtr(); } |
|
32 |
|
33 inline TUint8* ThdrIP::EndPtr() |
|
34 { return ((TUint8*)this)+GetHdrLen(); } |
|
35 |
|
36 inline TUint8* ThdrIP::NetEndPtr() |
|
37 { return ((TUint8*)this)+NetGetHdrLen(); } |
|
38 |
|
39 inline TUint8* ThdrIP::OptPtr() |
|
40 { return ((TUint8*)this)+KIPMinHeaderSize; } |
|
41 |
|
42 inline TBool ThdrIP::IsOptCopied(TUint8* aBuf) |
|
43 { return aBuf[KIPOptionValByte] & KIPOptionIsCopiedFlag; } |
|
44 |
|
45 inline TUint ThdrIP::GetVersion() |
|
46 { return u.iData8[3]>>4; } |
|
47 inline void ThdrIP::SetVersion(TUint aVal) |
|
48 { u.iData8[3] = (TUint8)((u.iData8[3] & 0x0f) | (aVal<<4)); } |
|
49 inline TUint ThdrIP::NetGetVersion() |
|
50 { return u.iData8[0]>>4; } |
|
51 |
|
52 inline TUint ThdrIP::GetHdrLen() |
|
53 { return (u.iData8[3] & 0x0f)<<2; } |
|
54 inline void ThdrIP::SetHdrLen(TUint aVal) |
|
55 { u.iData8[3] = (TUint8)((u.iData8[3] & 0xf0) | (aVal>>2)); } |
|
56 inline TUint ThdrIP::NetGetHdrLen() |
|
57 { return (u.iData8[0] & 0x0f)<<2; } |
|
58 |
|
59 inline TUint ThdrIP::GetTOS() |
|
60 { return u.iData8[2]; } |
|
61 inline void ThdrIP::SetTOS(TUint aVal) |
|
62 { u.iData8[2] = (TUint8)aVal; } |
|
63 |
|
64 inline TUint ThdrIP::GetLength() |
|
65 { return u.iData16[0]; } |
|
66 inline void ThdrIP::SetLength(TUint aVal) |
|
67 { u.iData16[0] = (TUint16)aVal; } |
|
68 |
|
69 |
|
70 inline TUint ThdrIP::GetId() |
|
71 { return u.iData16[3]; } |
|
72 inline void ThdrIP::SetId(TUint aVal) |
|
73 { u.iData16[3] = (TUint16)aVal; } |
|
74 |
|
75 //#ifdef VJCOMP |
|
76 /* |
|
77 * Little Endian not swapped |
|
78 */ |
|
79 inline TUint ThdrIP::NetGetId() |
|
80 { return BigEndian::Get16((const TUint8 *)&u.iData16[2]);} |
|
81 inline void ThdrIP::NetSetId(TUint aVal) |
|
82 { BigEndian::Put16((TUint8 *)&u.iData16[2],(TUint16)aVal); } |
|
83 |
|
84 inline TUint16 ThdrIP::NetGetLength() |
|
85 { return BigEndian::Get16((const TUint8*)&u.iData16[1]); } |
|
86 inline void ThdrIP::NetSetLength(TUint16 aVal) |
|
87 { BigEndian::Put16((TUint8*)&u.iData16[1],aVal); } |
|
88 |
|
89 inline void ThdrIP::NetSetProtocol(TUint aVal) |
|
90 { u.iData8[9] = (TUint8)aVal; } |
|
91 inline void ThdrIP::VJSetChecksum(TUint16 aVal) |
|
92 { BigEndian::Put16((TUint8 *)&u.iData16[5], aVal);} |
|
93 inline TUint ThdrIP::NetGetFragment() |
|
94 /** @return just offset and MF flag */ |
|
95 { return BigEndian::Get16((const TUint8*)&u.iData16[3]) & 0x3fff; } |
|
96 |
|
97 inline TUint16 ThdrIP::Word0() |
|
98 { return u.iData16[0];} |
|
99 inline TUint16 ThdrIP::Word3() |
|
100 { return u.iData16[3];} |
|
101 inline TUint16 ThdrIP::Word4() |
|
102 { return u.iData16[4];} |
|
103 inline TUint8* ThdrIP::GetOptions() |
|
104 { return (&u.iData8[0])+KIPMinHeaderSize; } |
|
105 //#endif |
|
106 |
|
107 |
|
108 inline TUint ThdrIP::GetMF() |
|
109 { return (u.iData8[5] & 0x20) >> 5; } |
|
110 inline void ThdrIP::SetMF(TUint aVal) |
|
111 { u.iData8[5] = (TUint8) ((u.iData8[5] & ~0x20) | (aVal<<5)) ; } |
|
112 |
|
113 inline TUint ThdrIP::GetDF() |
|
114 { return (u.iData8[5] & 0x40) >> 6; } |
|
115 inline void ThdrIP::SetDF(TUint aVal) |
|
116 { u.iData8[5] = (TUint8) ((u.iData8[5] & ~0x40) | (aVal<<6)) ; } |
|
117 |
|
118 inline TUint ThdrIP::GetOffset() |
|
119 { return (u.iData16[2] & 0x1fff) << 3; } |
|
120 inline void ThdrIP::SetOffset(TUint aVal) |
|
121 { u.iData16[2] = (TUint16)((u.iData16[2] & 0x1fff) | (aVal>>3)); } |
|
122 |
|
123 inline TUint ThdrIP::GetFragment() |
|
124 { return u.iData16[2] & 0x3fff; } // just offset and MF flag |
|
125 inline void ThdrIP::SetFragment(TUint aVal) |
|
126 { u.iData16[2] = (TUint16)aVal; } |
|
127 inline void ThdrIP::SetFragment(TUint aOffset, TUint aMF) |
|
128 { u.iData16[2] = (TUint16)(aOffset>>3 | aMF << 13); } |
|
129 |
|
130 inline TUint ThdrIP::GetTTL() |
|
131 { return u.iData8[11]; } |
|
132 inline void ThdrIP::SetTtl(TUint aVal) |
|
133 { u.iData8[11] = (TUint8)aVal; } |
|
134 |
|
135 inline TUint ThdrIP::GetProtocol() |
|
136 { return u.iData8[10]; } |
|
137 inline TUint ThdrIP::NetGetProtocol() |
|
138 { return u.iData8[9]; } |
|
139 inline void ThdrIP::SetProtocol(TUint aVal) |
|
140 { u.iData8[10] = (TUint8)aVal; } |
|
141 |
|
142 inline TUint ThdrIP::GetChecksum() |
|
143 { return u.iData16[4]; } |
|
144 inline void ThdrIP::SetChecksum(TUint aVal) |
|
145 { u.iData16[4] = (TUint16)aVal; } |
|
146 |
|
147 inline TUint ThdrIP::NetGetChecksum() |
|
148 { return u.iData16[5]; } |
|
149 inline void ThdrIP::NetSetChecksum(TUint aVal) |
|
150 { u.iData16[5] = (TUint16)aVal; } |
|
151 |
|
152 inline TUint32 ThdrIP::GetSrcAddr() |
|
153 { return iSrcAddr; } |
|
154 inline TUint32 ThdrIP::NetGetSrcAddr() |
|
155 { return ByteOrder::Swap32(iSrcAddr); } |
|
156 inline void ThdrIP::SetSrcAddr(TUint32 aAddr) |
|
157 { iSrcAddr = aAddr; } |
|
158 |
|
159 inline TUint32 ThdrIP::GetDstAddr() |
|
160 { return iDstAddr; } |
|
161 inline TUint32 ThdrIP::NetGetDstAddr() |
|
162 { return ByteOrder::Swap32(iDstAddr); } |
|
163 inline void ThdrIP::SetDstAddr(TUint32 aAddr) |
|
164 { iDstAddr = aAddr; } |
|
165 |
|
166 inline void ThdrIP::SetWord0(TUint aHdrLen, TUint aTOS, TUint aLen) |
|
167 { u.iData32[0] = 0x40000000 | (aHdrLen<<22) | (aTOS<<16) | aLen; } |
|
168 inline void ThdrIP::SetWord1(TUint aId) |
|
169 { u.iData32[1] = aId<<16; } |
|
170 inline void ThdrIP::SetWord1(TUint aId, TUint aDF) |
|
171 { u.iData32[1] = (aId<<16) | (aDF<<14); } |
|
172 inline void ThdrIP::SetWord1(TUint aId, TUint aMF, TUint aOffset) |
|
173 { u.iData32[1] = (aId<<16) | (aMF<<13) | (aOffset>>3); } |
|
174 inline void ThdrIP::SetWord2(TUint aTTL, TUint aProtocol) // Checksum invariably set afterwards |
|
175 { u.iData32[2] = (aTTL<<24) | (aProtocol<<16); } |
|
176 |
|
177 inline ThdrICMP* ThdrICMP::Ptr(RMBufPacketBase& aPacket) |
|
178 { return (ThdrICMP*)aPacket.First()->Ptr(); } |
|
179 |
|
180 inline ThdrICMP* ThdrICMP::Ptr(ThdrIP* aHdr) |
|
181 { return (ThdrICMP*)aHdr->EndPtr(); } |
|
182 |
|
183 inline ThdrICMP* ThdrICMP::NetPtr(ThdrIP* aHdr) |
|
184 { return (ThdrICMP*)aHdr->NetEndPtr(); } |
|
185 |
|
186 inline ThdrIP* ThdrICMP::IpPtr() |
|
187 { return (ThdrIP*)(((TUint8*)this)+8); } |
|
188 |
|
189 inline TUint ThdrICMP::NetGetType() |
|
190 { return u.iData8[0]; } |
|
191 inline void ThdrICMP::NetSetType(TInt aVal) |
|
192 { u.iData8[0] = (TUint8)aVal; } |
|
193 inline TUint ThdrICMP::NetGetCode() |
|
194 { return u.iData8[1]; } |
|
195 inline void ThdrICMP::NetSetCode(TInt aVal) |
|
196 { u.iData8[1] = (TUint8)aVal; } |
|
197 inline void ThdrICMP::NetSet(TUint aType, TUint aCode) |
|
198 { u.iData8[0] = (TUint8)aType; u.iData8[1] = (TUint8)aCode; } |
|
199 inline TInt ThdrICMP::NetGetChecksum() |
|
200 { return u.iData16[1]; } |
|
201 inline void ThdrICMP::NetSetChecksum(TInt aSum) |
|
202 { u.iData16[1] = (TUint16)aSum; } |
|
203 |
|
204 #endif |