/[resiprocate]/branches/b-identity-0505/Headers.cxx
ViewVC logotype

Contents of /branches/b-identity-0505/Headers.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4598 - (show annotations) (download)
Wed May 11 22:53:07 2005 UTC (14 years, 6 months ago) by derek
File size: 16847 byte(s)
set svn:eol-style to LF
1 #if defined(HAVE_CONFIG_H)
2 #include "resiprocate/config.hxx"
3 #endif
4
5 #include "resiprocate/os/Data.hxx"
6 #include "resiprocate/Headers.hxx"
7 #include "resiprocate/Symbols.hxx"
8 #include "resiprocate/SipMessage.hxx"
9
10 // GPERF generated external routines
11 #include "resiprocate/HeaderHash.hxx"
12
13 #include <iostream>
14 using namespace std;
15
16 //int strcasecmp(const char*, const char*);
17 //int strncasecmp(const char*, const char*, int len);
18
19 using namespace resip;
20
21 Data Headers::HeaderNames[MAX_HEADERS+1];
22 bool Headers::CommaTokenizing[] = {false};
23 bool Headers::CommaEncoding[] = {false};
24
25 bool
26 Headers::isCommaTokenizing(Type type)
27 {
28 return CommaTokenizing[type+1];
29 }
30
31 bool
32 Headers::isCommaEncoding(Type type)
33 {
34 return CommaEncoding[type+1];
35 }
36
37 const Data&
38 Headers::getHeaderName(int type)
39 {
40 return HeaderNames[type+1];
41 }
42
43 #define defineHeader(_enum, _name, _type, _reference) \
44 Headers::Type \
45 H_##_enum::getTypeNum() const {return Headers::_enum;} \
46 \
47 void H_##_enum::merge(SipMessage& target, const SipMessage& embedded) \
48 { \
49 if (embedded.exists(*this)) \
50 { \
51 target.header(*this) = embedded.header(*this); \
52 } \
53 } \
54 \
55 H_##_enum::H_##_enum() \
56 { \
57 Headers::CommaTokenizing[Headers::_enum+1] = bool(Type::commaHandling & ParserCategory::CommasAllowedOutputMulti); \
58 Headers::CommaEncoding[Headers::_enum+1] = bool(Type::commaHandling & 2); \
59 Headers::HeaderNames[Headers::_enum+1] = _name; \
60 } \
61 \
62 _type& \
63 H_##_enum::knownReturn(ParserContainerBase* container) \
64 { \
65 return dynamic_cast<ParserContainer<_type>*>(container)->front(); \
66 } \
67 \
68 H_##_enum resip::h_##_enum
69
70 #define defineMultiHeader(_enum, _name, _type, _reference) \
71 Headers::Type \
72 H_##_enum##s::getTypeNum() const {return Headers::_enum;} \
73 \
74 void H_##_enum##s::merge(SipMessage& target, const SipMessage& embedded) \
75 { \
76 if (embedded.exists(*this)) \
77 { \
78 target.header(*this).append(embedded.header(*this)); \
79 } \
80 } \
81 \
82 H_##_enum##s::H_##_enum##s() \
83 { \
84 Headers::CommaTokenizing[Headers::_enum+1] = bool(Type::value_type::commaHandling & ParserCategory::CommasAllowedOutputMulti); \
85 Headers::CommaEncoding[Headers::_enum+1] = bool(Type::value_type::commaHandling & 2); \
86 Headers::HeaderNames[Headers::_enum+1] = _name; \
87 } \
88 \
89 ParserContainer<_type>& \
90 H_##_enum##s::knownReturn(ParserContainerBase* container) \
91 { \
92 return *dynamic_cast<ParserContainer<_type>*>(container); \
93 } \
94 \
95 H_##_enum##s resip::h_##_enum##s
96
97 //====================
98 // Token
99 //====================
100
101 defineHeader(ContentDisposition, "Content-Disposition", Token, "RFC 3261");
102 defineHeader(ContentEncoding, "Content-Encoding", Token, "RFC 3261");
103 defineHeader(ContentTransferEncoding, "Content-Transfer-Encoding", StringCategory, "RFC ?"); // !dlb! defineMultiHeader
104 defineHeader(MIMEVersion, "MIME-Version", Token, "RFC 3261");
105 defineHeader(Priority, "Priority", Token, "RFC 3261");
106 defineHeader(Event, "Event", Token, "RFC 3265");
107 defineHeader(SubscriptionState, "Subscription-State", Token, "RFC 3265");
108
109 defineHeader(SIPETag, "SIP-ETag", Token, "RFC 3903");
110 defineHeader(SIPIfMatch, "SIP-If-Match", Token, "RFC 3903");
111 defineHeader(ContentId, "Content-ID", Token, "RFC 2045");
112
113 defineHeader(Identity, "Identity", StringCategory, "draft-sip-identity-03");
114
115 defineMultiHeader(AllowEvents, "Allow-Events", Token, "RFC 3265");
116 // explicitly declare to avoid h_AllowEventss, ugh
117 H_AllowEventss resip::h_AllowEvents;
118
119 defineMultiHeader(AcceptEncoding, "Accept-Encoding", Token, "RFC 3261");
120 defineMultiHeader(AcceptLanguage, "Accept-Language", Token, "RFC 3261");
121 defineMultiHeader(Allow, "Allow", Token, "RFC 3261");
122 defineMultiHeader(ContentLanguage, "Content-Language", Token, "RFC 3261");
123 defineMultiHeader(ProxyRequire, "Proxy-Require", Token, "RFC 3261");
124 defineMultiHeader(Require, "Require", Token, "RFC 3261");
125 defineMultiHeader(Supported, "Supported", Token, "RFC 3261");
126 defineMultiHeader(Unsupported, "Unsupported", Token, "RFC 3261");
127 defineMultiHeader(SecurityClient, "Security-Client", Token, "RFC 3329");
128 defineMultiHeader(SecurityServer, "Security-Server", Token, "RFC 3329");
129 defineMultiHeader(SecurityVerify, "Security-Verify", Token, "RFC 3329");
130 // explicitly declare to avoid h_SecurityVerifys, ugh
131 H_SecurityVerifys resip::h_SecurityVerifies;
132
133 defineMultiHeader(RequestDisposition, "Request-Disposition", Token, "RFC 3841");
134 defineMultiHeader(Reason, "Reason", Token, "RFC 3326");
135 defineMultiHeader(Privacy, "Privacy", Token, "RFC 3323");
136 // explicitly declare to avoid h_Privacys
137 H_Privacys resip::h_Privacies;
138
139 defineMultiHeader(PMediaAuthorization, "P-Media-Authorization", Token, "RFC 3313");
140
141 //====================
142 // Mime
143 //====================
144 typedef ParserContainer<Mime> Mimes;
145
146 defineMultiHeader(Accept, "Accept", Mime, "RFC 3261");
147 defineHeader(ContentType, "Content-Type", Mime, "RFC 3261");
148
149 //====================
150 // GenericUris:
151 //====================
152 defineHeader(IdentityInfo, "Identity-Info", GenericUri, "draft-sip-identity-03");
153
154 typedef ParserContainer<GenericUri> GenericUris;
155 defineMultiHeader(CallInfo, "Call-Info", GenericUri, "RFC 3261");
156 defineMultiHeader(AlertInfo, "Alert-Info", GenericUri, "RFC 3261");
157 defineMultiHeader(ErrorInfo, "Error-Info", GenericUri, "RFC 3261");
158
159 //====================
160 // NameAddr:
161 //====================
162 typedef ParserContainer<NameAddr> NameAddrs;
163
164 defineMultiHeader(RecordRoute, "Record-Route", NameAddr, "RFC 3261");
165 defineMultiHeader(Route, "Route", NameAddr, "RFC 3261");
166 defineMultiHeader(Contact, "Contact", NameAddr, "RFC 3261");
167 defineHeader(From, "From", NameAddr, "RFC 3261");
168 defineHeader(To, "To", NameAddr, "RFC 3261");
169 defineHeader(ReplyTo, "Reply-To", NameAddr, "RFC 3261");
170 defineHeader(ReferTo, "Refer-To", NameAddr, "RFC 3515");
171 defineHeader(ReferredBy, "Referred-By", NameAddr, "RFC 3892");
172
173 defineMultiHeader(Path, "Path", NameAddr, "RFC 3327");
174 defineMultiHeader(AcceptContact, "Accept-Contact", NameAddr, "RFC 3841");
175 defineMultiHeader(RejectContact, "Reject-Contact", NameAddr, "RFC 3841");
176 defineMultiHeader(PPreferredIdentity, "P-Preferred-Identity", NameAddr, "RFC 3325");
177 // explicitly declare to avoid h_PAssertedIdentitys
178 H_PPreferredIdentitys resip::h_PPreferredIdentities;
179
180 defineMultiHeader(PAssertedIdentity, "P-Asserted-Identity", NameAddr, "RFC 3325");
181 // explicitly declare to avoid h_PAssertedIdentitys
182 H_PAssertedIdentitys resip::h_PAssertedIdentities;
183
184
185 defineHeader(PCalledPartyId, "P-Called-Party-ID", NameAddr, "RFC 3455");
186 defineMultiHeader(PAssociatedUri, "P-Associated-URI", NameAddr, "RFC 3455");
187 defineMultiHeader(ServiceRoute, "Service-Route", NameAddr, "RFC 3608");
188
189 //====================
190 // String:
191 //====================
192 typedef ParserContainer<StringCategory> StringCategories;
193
194 defineHeader(Organization, "Organization", StringCategory, "RFC 3261");
195 defineHeader(Server, "Server", StringCategory, "RFC 3261");
196 defineHeader(Subject, "Subject", StringCategory, "RFC 3261");
197 defineHeader(UserAgent, "User-Agent", StringCategory, "RFC 3261");
198 defineHeader(Timestamp, "Timestamp", StringCategory, "RFC 3261");
199
200 //====================
201 // Integer:
202 //====================
203 typedef ParserContainer<IntegerCategory> IntegerCategories;
204
205 // !dlb! not clear this needs to be exposed
206 defineHeader(ContentLength, "Content-Length", IntegerCategory, "RFC 3261");
207 defineHeader(MaxForwards, "Max-Forwards", IntegerCategory, "RFC 3261");
208 defineHeader(MinExpires, "Min-Expires", IntegerCategory, "RFC 3261");
209 defineHeader(RSeq, "RSeq", IntegerCategory, "RFC 3262");
210
211 // !dlb! this one is not quite right -- can have (comment) after field value
212 // !rwm! WHO CARES!!!! Comments are evil
213 defineHeader(RetryAfter, "Retry-After", IntegerCategory, "RFC 3261");
214 defineHeader(Expires, "Expires", ExpiresCategory, "RFC 3261");
215 defineHeader(SessionExpires, "Session-Expires", ExpiresCategory, "Session Timer draft");
216 defineHeader(MinSE, "Min-SE", ExpiresCategory, "Session Timer draft");
217
218 //====================
219 // CallId:
220 //====================
221 defineHeader(CallID, "Call-ID", CallId, "RFC 3261");
222 H_CallId resip::h_CallId; // code convention compatible
223 defineHeader(Replaces, "Replaces", CallId, "RFC 3261");
224 defineHeader(InReplyTo, "In-Reply-To", CallId, "RFC 3261");
225 defineHeader(Join, "Join", CallId, "RFC 3911");
226 defineHeader(TargetDialog, "Target-Dialog", CallId, "Target Dialog draft");
227
228
229 //====================
230 // Auth:
231 //====================
232 defineHeader(AuthenticationInfo, "Authentication-Info", Auth, "RFC 3261");
233 defineMultiHeader(Authorization, "Authorization", Auth, "RFC 3261");
234 defineMultiHeader(ProxyAuthenticate, "Proxy-Authenticate", Auth, "RFC 3261");
235 defineMultiHeader(ProxyAuthorization, "Proxy-Authorization", Auth, "RFC 3261");
236 defineMultiHeader(WWWAuthenticate, "WWW-Authenticate", Auth, "RFC 3261");
237
238 //====================
239 // CSeqCategory:
240 //====================
241 defineHeader(CSeq, "CSeq", CSeqCategory, "RFC 3261");
242
243 //====================
244 // DateCategory:
245 //====================
246 defineHeader(Date, "Date", DateCategory, "RFC 3261");
247
248 //====================
249 // WarningCategory:
250 //====================
251 defineMultiHeader(Warning, "Warning", WarningCategory, "RFC 3261");
252
253 //====================
254 // RAckCategory
255 //====================
256 defineHeader(RAck, "RAck", RAckCategory, "RFC 3262");
257
258 defineMultiHeader(Via, "Via", Via, "RFC 3261");
259
260 RequestLineType resip::h_RequestLine;
261 StatusLineType resip::h_StatusLine;
262
263 Headers::Type
264 Headers::getType(const char* name, int len)
265 {
266 struct headers* p;
267 p = HeaderHash::in_word_set(name, len);
268 return p ? Headers::Type(p->type) : Headers::UNKNOWN;
269 }
270
271 /* ====================================================================
272 * The Vovida Software License, Version 1.0
273 *
274 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
275 *
276 * Redistribution and use in source and binary forms, with or without
277 * modification, are permitted provided that the following conditions
278 * are met:
279 *
280 * 1. Redistributions of source code must retain the above copyright
281 * notice, this list of conditions and the following disclaimer.
282 *
283 * 2. Redistributions in binary form must reproduce the above copyright
284 * notice, this list of conditions and the following disclaimer in
285 * the documentation and/or other materials provided with the
286 * distribution.
287 *
288 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
289 * and "Vovida Open Communication Application Library (VOCAL)" must
290 * not be used to endorse or promote products derived from this
291 * software without prior written permission. For written
292 * permission, please contact vocal@vovida.org.
293 *
294 * 4. Products derived from this software may not be called "VOCAL", nor
295 * may "VOCAL" appear in their name, without prior written
296 * permission of Vovida Networks, Inc.
297 *
298 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
299 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
300 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
301 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
302 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
303 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
304 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
305 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
306 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
307 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
308 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
309 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
310 * DAMAGE.
311 *
312 * ====================================================================
313 *
314 * This software consists of voluntary contributions made by Vovida
315 * Networks, Inc. and many individuals on behalf of Vovida Networks,
316 * Inc. For more information on Vovida Networks, Inc., please see
317 * <http://www.vovida.org/>.
318 *
319 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27