|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __TDNSHEADER_INL__ |
|
20 #define __TDNSHEADER_INL__ |
|
21 |
|
22 |
|
23 TDnsHeader::TDnsHeader() |
|
24 { |
|
25 iQCount = 0; |
|
26 iACount = 0; |
|
27 iNSCount = 0; |
|
28 iARCount = 0; |
|
29 iID = 0; |
|
30 iFlags = 0; |
|
31 } |
|
32 |
|
33 |
|
34 TDnsHeader::TDnsHeader(const TDnsHeader& aHeader) |
|
35 { |
|
36 iQCount = aHeader.QueryCount(); |
|
37 iACount = aHeader.AnswerCount(); |
|
38 iNSCount = aHeader.AuthorityNSCount(); |
|
39 iARCount = aHeader.AdditionalRCount(); |
|
40 iID = aHeader.Id(); |
|
41 iFlags = aHeader.Flags(); |
|
42 } |
|
43 |
|
44 |
|
45 |
|
46 TUint16 TDnsHeader::Id()const |
|
47 { |
|
48 return iID; |
|
49 } |
|
50 |
|
51 TUint16 TDnsHeader::IsQuery()const |
|
52 { |
|
53 return !(iFlags & EFlagQuery); |
|
54 } |
|
55 |
|
56 TUint16 TDnsHeader::Opcode()const |
|
57 { |
|
58 return (iFlags >> 3) & EFlagOpcode; |
|
59 } |
|
60 |
|
61 TUint16 TDnsHeader::IsAuthoritative()const |
|
62 { |
|
63 return iFlags & EFlagAuthoritative; |
|
64 } |
|
65 |
|
66 TUint16 TDnsHeader::IsTruncated()const |
|
67 { |
|
68 return iFlags & EFlagTruncated; |
|
69 } |
|
70 |
|
71 TUint16 TDnsHeader::RecursionDesired()const |
|
72 { |
|
73 return iFlags & EFlagRecurse; |
|
74 } |
|
75 |
|
76 TUint16 TDnsHeader::RecursionAvailable()const |
|
77 { |
|
78 return iFlags & EFlagRecursionAvailable; |
|
79 } |
|
80 |
|
81 TUint16 TDnsHeader::Reserved()const |
|
82 { |
|
83 return iFlags & EFlagReserved; |
|
84 } |
|
85 |
|
86 TUint16 TDnsHeader::ResponseCode()const |
|
87 { |
|
88 return iFlags & EFlagResponseCode; |
|
89 } |
|
90 |
|
91 TUint16 TDnsHeader::Flags()const |
|
92 { |
|
93 return iFlags; |
|
94 } |
|
95 |
|
96 TUint16 TDnsHeader::QueryCount()const |
|
97 { |
|
98 return iQCount; |
|
99 } |
|
100 |
|
101 TUint16 TDnsHeader::AnswerCount()const |
|
102 { |
|
103 return iACount; |
|
104 } |
|
105 |
|
106 TUint16 TDnsHeader::AuthorityNSCount()const |
|
107 { |
|
108 return iNSCount; |
|
109 } |
|
110 |
|
111 TUint16 TDnsHeader::AdditionalRCount()const |
|
112 { |
|
113 return iARCount; |
|
114 } |
|
115 |
|
116 void TDnsHeader::SetId(TUint16 aId) |
|
117 { |
|
118 iID = aId; |
|
119 } |
|
120 |
|
121 void TDnsHeader::SetQuery(TBool aQuery) |
|
122 { |
|
123 if (!aQuery) |
|
124 iFlags |= EFlagQuery; |
|
125 else |
|
126 iFlags &= ~EFlagQuery; |
|
127 } |
|
128 |
|
129 |
|
130 void TDnsHeader::SetOpcode(TUint16 aOpcode) |
|
131 { |
|
132 aOpcode << 11; |
|
133 iFlags |= aOpcode ; |
|
134 } |
|
135 |
|
136 void TDnsHeader::SetAuthoritative(TBool aAuthBit) |
|
137 { |
|
138 if(aAuthBit) |
|
139 iFlags |= EFlagAuthoritative; |
|
140 else |
|
141 iFlags &= ~EFlagAuthoritative; |
|
142 } |
|
143 |
|
144 |
|
145 void TDnsHeader::SetTruncated(TBool aTruncBit) |
|
146 { |
|
147 if(aTruncBit) |
|
148 iFlags |= EFlagTruncated; |
|
149 else |
|
150 iFlags &= ~EFlagTruncated; |
|
151 } |
|
152 |
|
153 void TDnsHeader::SetRecursionDesired(TBool aRecDesired) |
|
154 { |
|
155 if (aRecDesired) |
|
156 iFlags |= EFlagRecurse; |
|
157 else |
|
158 iFlags &= ~EFlagRecurse; |
|
159 } |
|
160 |
|
161 void TDnsHeader::SetRecursionAvailable(TBool aRecAvailable) |
|
162 { |
|
163 if (aRecAvailable) |
|
164 iFlags |= EFlagRecursionAvailable; |
|
165 else |
|
166 iFlags &= ~EFlagRecursionAvailable; |
|
167 } |
|
168 |
|
169 void TDnsHeader::SetReserved(TUint16 aResv) |
|
170 { |
|
171 aResv << 4; |
|
172 iFlags |= aResv; |
|
173 } |
|
174 |
|
175 void TDnsHeader::SetResponseCode(TUint16 aRespCode) |
|
176 { |
|
177 iFlags |= aRespCode; |
|
178 } |
|
179 |
|
180 void TDnsHeader::SetFlags(TUint16 aFlags) |
|
181 { |
|
182 iFlags = aFlags; |
|
183 } |
|
184 |
|
185 void TDnsHeader::SetQueryCount(TUint16 aCount) |
|
186 { |
|
187 iQCount = aCount; |
|
188 } |
|
189 |
|
190 void TDnsHeader::SetAnswerCount(TUint16 aCount) |
|
191 { |
|
192 iACount = aCount; |
|
193 } |
|
194 |
|
195 void TDnsHeader::SetAuthorityNSCount(TUint16 aCount) |
|
196 { |
|
197 iNSCount = aCount; |
|
198 } |
|
199 |
|
200 void TDnsHeader::SetAdditionalRCount(TUint16 aCount) |
|
201 { |
|
202 iARCount = aCount; |
|
203 } |
|
204 |
|
205 #endif //__TDNSHEADER_INL__ |
|
206 |