reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Headers.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
5#include "rutil/Data.hxx"
9
10// GPERF generated external routines
12
13#include <iostream>
14
15using namespace std;
16using namespace resip;
17
18Data Headers::HeaderNames[MAX_HEADERS+1];
19bool Headers::CommaTokenizing[] = {false};
20bool Headers::CommaEncoding[] = {false};
21bool Headers::Multi[]={false};
23
24bool
26{
27 return CommaTokenizing[type+1];
28}
29
30bool
32{
33 return CommaEncoding[type+1];
34}
35
36const Data&
38{
39 if(type < MAX_HEADERS)
40 {
41 return HeaderNames[type+1];
42 }
43 else
44 {
45 return Data::Empty;
46 }
47}
48
49bool
51{
52 return Multi[type+1];
53}
54
55#define defineHeader(_enum, _name, _type, _reference) \
56Headers::Type \
57H_##_enum::getTypeNum() const {return Headers::_enum;} \
58 \
59void H_##_enum::merge(SipMessage& target, const SipMessage& embedded) \
60{ \
61 if (embedded.exists(*this)) \
62 { \
63 target.header(*this) = embedded.header(*this); \
64 } \
65} \
66 \
67H_##_enum::H_##_enum() \
68{ \
69 Headers::CommaTokenizing[Headers::_enum+1] = bool(Type::commaHandling & ParserCategory::CommasAllowedOutputMulti); \
70 Headers::CommaEncoding[Headers::_enum+1] = bool(Type::commaHandling & 2); \
71 Headers::HeaderNames[Headers::_enum+1] = _name; \
72 Headers::Multi[Headers::_enum+1] = false; \
73 HeaderBase::theHeaderInstances[Headers::_enum+1] = this; \
74} \
75 \
76_type& \
77H_##_enum::knownReturn(ParserContainerBase* container) \
78{ \
79 return dynamic_cast<ParserContainer<_type>*>(container)->front(); \
80} \
81 \
82ParserContainerBase* \
83H_##_enum::makeContainer(HeaderFieldValueList* hfvs) const \
84{ \
85 return new ParserContainer<_type>(hfvs,Headers::_enum); \
86} \
87 \
88H_##_enum resip::h_##_enum
89
90#define defineMultiHeader(_enum, _name, _type, _reference) \
91 Headers::Type \
92H_##_enum##s::getTypeNum() const {return Headers::_enum;} \
93 \
94void H_##_enum##s::merge(SipMessage& target, const SipMessage& embedded) \
95{ \
96 if (embedded.exists(*this)) \
97 { \
98 target.header(*this).append(embedded.header(*this)); \
99 } \
100} \
101 \
102H_##_enum##s::H_##_enum##s() \
103{ \
104 Headers::CommaTokenizing[Headers::_enum+1] = bool(Type::value_type::commaHandling & ParserCategory::CommasAllowedOutputMulti); \
105 Headers::CommaEncoding[Headers::_enum+1] = bool(Type::value_type::commaHandling & 2); \
106 Headers::HeaderNames[Headers::_enum+1] = _name; \
107 Headers::Multi[Headers::_enum+1] = true; \
108 HeaderBase::theHeaderInstances[Headers::_enum+1] = this; \
109} \
110 \
111ParserContainer<_type>& \
112H_##_enum##s::knownReturn(ParserContainerBase* container) \
113{ \
114 return *dynamic_cast<ParserContainer<_type>*>(container); \
115} \
116 \
117ParserContainerBase* \
118H_##_enum##s::makeContainer(HeaderFieldValueList* hfvs) const \
119{ \
120 return new ParserContainer<_type>(hfvs,Headers::_enum); \
121} \
122 \
123H_##_enum##s resip::h_##_enum##s
124
125//====================
126// Token
127//====================
128
129defineHeader(ContentDisposition, "Content-Disposition", Token, "RFC 3261");
130defineHeader(ContentEncoding, "Content-Encoding", Token, "RFC 3261");
131defineHeader(ContentTransferEncoding, "Content-Transfer-Encoding", StringCategory, "RFC ?"); // !dlb! defineMultiHeader
132defineHeader(MIMEVersion, "MIME-Version", Token, "RFC 3261");
133defineHeader(Priority, "Priority", Token, "RFC 3261");
134defineHeader(Event, "Event", Token, "RFC 3265");
135defineHeader(SubscriptionState, "Subscription-State", Token, "RFC 3265");
136
137defineHeader(SIPETag, "SIP-ETag", Token, "RFC 3903");
138defineHeader(SIPIfMatch, "SIP-If-Match", Token, "RFC 3903");
139defineHeader(ContentId, "Content-ID", Token, "RFC 2045");
140
141defineMultiHeader(AllowEvents, "Allow-Events", Token, "RFC 3265");
142// explicitly declare to avoid h_AllowEventss, ugh
143H_AllowEventss resip::h_AllowEvents;
144
145defineMultiHeader(AcceptEncoding, "Accept-Encoding", Token, "RFC 3261");
146defineMultiHeader(AcceptLanguage, "Accept-Language", Token, "RFC 3261");
147defineMultiHeader(Allow, "Allow", Token, "RFC 3261");
148defineMultiHeader(ContentLanguage, "Content-Language", Token, "RFC 3261");
149defineMultiHeader(ProxyRequire, "Proxy-Require", Token, "RFC 3261");
150defineMultiHeader(Require, "Require", Token, "RFC 3261");
151defineMultiHeader(Supported, "Supported", Token, "RFC 3261");
152defineMultiHeader(Unsupported, "Unsupported", Token, "RFC 3261");
153defineMultiHeader(SecurityClient, "Security-Client", Token, "RFC 3329");
154defineMultiHeader(SecurityServer, "Security-Server", Token, "RFC 3329");
155defineMultiHeader(SecurityVerify, "Security-Verify", Token, "RFC 3329");
156// explicitly declare to avoid h_SecurityVerifys, ugh
158
159defineMultiHeader(RequestDisposition, "Request-Disposition", Token, "RFC 3841");
160defineMultiHeader(Reason, "Reason", Token, "RFC 3326");
161defineMultiHeader(Privacy, "Privacy", PrivacyCategory, "RFC 3323");
162// explicitly declare to avoid h_Privacys
164
165defineMultiHeader(PMediaAuthorization, "P-Media-Authorization", Token, "RFC 3313");
166defineHeader(ReferSub, "Refer-Sub", Token, "RFC 4488");
167defineHeader(AnswerMode, "Answer-Mode", Token, "draft-ietf-answermode-01");
168defineHeader(PrivAnswerMode, "Priv-Answer-Mode", Token, "draft-ietf-answermode-01");
169
170defineMultiHeader(PAccessNetworkInfo, "P-Access-Network-Info", Token, "RFC 7315"); // section 5.4.
171defineHeader(PChargingVector, "P-Charging-Vector", Token, "RFC 3455");
172defineHeader(PChargingFunctionAddresses, "P-Charging-Function-Addresses", Token, "RFC 3455");
173
174//====================
175// Mime
176//====================
178
179defineMultiHeader(Accept, "Accept", Mime, "RFC 3261");
180defineHeader(ContentType, "Content-Type", Mime, "RFC 3261");
181
182//====================
183// GenericUris:
184//====================
185defineHeader(IdentityInfo, "Identity-Info", GenericUri, "RFC 4474"); // deprecated by RFC8224
186
188defineMultiHeader(CallInfo, "Call-Info", GenericUri, "RFC 3261");
189defineMultiHeader(AlertInfo, "Alert-Info", GenericUri, "RFC 3261");
190defineMultiHeader(ErrorInfo, "Error-Info", GenericUri, "RFC 3261");
191
192//====================
193// NameAddr:
194//====================
196
197defineMultiHeader(RecordRoute, "Record-Route", NameAddr, "RFC 3261");
198defineMultiHeader(Route, "Route", NameAddr, "RFC 3261");
199defineMultiHeader(Contact, "Contact", NameAddr, "RFC 3261");
200defineHeader(From, "From", NameAddr, "RFC 3261");
201defineHeader(To, "To", NameAddr, "RFC 3261");
202defineHeader(ReplyTo, "Reply-To", NameAddr, "RFC 3261");
203defineHeader(ReferTo, "Refer-To", NameAddr, "RFC 3515");
204defineHeader(ReferredBy, "Referred-By", NameAddr, "RFC 3892");
205
206defineMultiHeader(Path, "Path", NameAddr, "RFC 3327");
207defineMultiHeader(AcceptContact, "Accept-Contact", NameAddr, "RFC 3841");
208defineMultiHeader(RejectContact, "Reject-Contact", NameAddr, "RFC 3841");
209defineMultiHeader(PPreferredIdentity, "P-Preferred-Identity", NameAddr, "RFC 3325");
210// explicitly declare to avoid h_PPrefferedIdentitys
211H_PPreferredIdentitys resip::h_PPreferredIdentities;
212
213defineMultiHeader(PAssertedIdentity, "P-Asserted-Identity", NameAddr, "RFC 3325");
214// explicitly declare to avoid h_PAssertedIdentitys
215H_PAssertedIdentitys resip::h_PAssertedIdentities;
216
217
218defineHeader(PCalledPartyId, "P-Called-Party-ID", NameAddr, "RFC 3455");
219defineMultiHeader(PAssociatedUri, "P-Associated-URI", NameAddr, "RFC 3455");
220defineMultiHeader(ServiceRoute, "Service-Route", NameAddr, "RFC 3608");
221defineMultiHeader(RemotePartyId, "Remote-Party-ID", NameAddr, "draft-ietf-sip-privacy-04"); // ?bwc? Not in 3323, should we keep?
222defineMultiHeader(HistoryInfo, "History-Info", NameAddr, "RFC 4244");
223defineMultiHeader(Diversion, "Diversion", NameAddr, "RFC 5806");
224
225//====================
226// String:
227//====================
229
230defineHeader(Organization, "Organization", StringCategory, "RFC 3261");
231defineHeader(SecWebSocketKey, "Sec-WebSocket-Key", StringCategory, "RFC 6455");
232defineHeader(SecWebSocketKey1, "Sec-WebSocket-Key1", StringCategory, "draft-hixie- thewebsocketprotocol-76");
233defineHeader(SecWebSocketKey2, "Sec-WebSocket-Key2", StringCategory, "draft-hixie- thewebsocketprotocol-76");
234defineHeader(Origin, "Origin", StringCategory, "draft-hixie- thewebsocketprotocol-76");
235defineHeader(Host, "Host", StringCategory, "draft-hixie- thewebsocketprotocol-76");
236defineHeader(SecWebSocketAccept, "Sec-WebSocket-Accept", StringCategory, "RFC 6455");
238defineHeader(Server, "Server", StringCategory, "RFC 3261");
239defineHeader(Subject, "Subject", StringCategory, "RFC 3261");
240defineHeader(UserAgent, "User-Agent", StringCategory, "RFC 3261");
241defineHeader(Timestamp, "Timestamp", StringCategory, "RFC 3261");
242
243//====================
244// Integer:
245//====================
246
247// !dlb! not clear this needs to be exposed
248defineHeader(ContentLength, "Content-Length", UInt32Category, "RFC 3261");
249defineHeader(MaxForwards, "Max-Forwards", UInt32Category, "RFC 3261");
250defineHeader(MinExpires, "Min-Expires", UInt32Category, "RFC 3261");
251defineHeader(RSeq, "RSeq", UInt32Category, "RFC 3262");
252
253// !dlb! this one is not quite right -- can have (comment) after field value
254// !rwm! WHO CARES!!!! Comments are evil
255defineHeader(RetryAfter, "Retry-After", UInt32Category, "RFC 3261");
256defineHeader(FlowTimer, "Flow-Timer", UInt32Category, "RFC 5626");
257
258defineHeader(Expires, "Expires", ExpiresCategory, "RFC 3261");
259defineHeader(SessionExpires, "Session-Expires", ExpiresCategory, "RFC 4028");
260defineHeader(MinSE, "Min-SE", ExpiresCategory, "RFC 4028");
261
262//====================
263// CallId:
264//====================
265defineHeader(CallID, "Call-ID", CallId, "RFC 3261");
266H_CallId resip::h_CallId; // code convention compatible
267defineHeader(Replaces, "Replaces", CallId, "RFC 3891");
268defineHeader(InReplyTo, "In-Reply-To", CallId, "RFC 3261");
269defineHeader(Join, "Join", CallId, "RFC 3911");
270defineHeader(TargetDialog, "Target-Dialog", CallId, "RFC 4538");
271
272
273//====================
274// Auth:
275//====================
276defineHeader(AuthenticationInfo, "Authentication-Info", Auth, "RFC 3261");
277defineMultiHeader(Authorization, "Authorization", Auth, "RFC 3261");
278defineMultiHeader(ProxyAuthenticate, "Proxy-Authenticate", Auth, "RFC 3261");
279defineMultiHeader(ProxyAuthorization, "Proxy-Authorization", Auth, "RFC 3261");
280defineMultiHeader(WWWAuthenticate, "WWW-Authenticate", Auth, "RFC 3261");
281
282//====================
283// CSeqCategory:
284//====================
285defineHeader(CSeq, "CSeq", CSeqCategory, "RFC 3261");
286
287//====================
288// DateCategory:
289//====================
290defineHeader(Date, "Date", DateCategory, "RFC 3261");
291
292//====================
293// WarningCategory:
294//====================
295defineMultiHeader(Warning, "Warning", WarningCategory, "RFC 3261");
296
297//====================
298// RAckCategory
299//====================
300defineHeader(RAck, "RAck", RAckCategory, "RFC 3262");
301
302defineMultiHeader(Via, "Via", Via, "RFC 3261");
303
304//============================
305// TokenOrQuotedStringCategory
306//============================
307defineMultiHeader(PVisitedNetworkID, "P-Visited-Network-ID", TokenOrQuotedStringCategory, "RFC 3455");
308defineMultiHeader(UserToUser, "User-to-User", TokenOrQuotedStringCategory, "draft-ietf-cuss-sip-uui-17");
309
310//============================
311// IdentityCategory
312//============================
313defineMultiHeader(Identity, "Identity", IdentityCategory, "RFC 8224"); // Originally defined in RFC 4474 as a single header, but later modified by RFC8224 to be a multiheader
314// explicitly declare to avoid h_Identitys
316
317
318//Enforces string encoding of extension headers
320H_RESIP_DO_NOT_USEs::getTypeNum() const {return Headers::RESIP_DO_NOT_USE;}
321
322H_RESIP_DO_NOT_USEs::H_RESIP_DO_NOT_USEs()
323{
324 Headers::CommaTokenizing[Headers::RESIP_DO_NOT_USE+1] = bool(Type::value_type::commaHandling & ParserCategory::CommasAllowedOutputMulti);
325 Headers::CommaEncoding[Headers::RESIP_DO_NOT_USE+1] = bool(Type::value_type::commaHandling & 2);
326 Headers::HeaderNames[Headers::RESIP_DO_NOT_USE+1] = "RESIP_DO_NOT_USE";
327}
328
330H_RESIP_DO_NOT_USEs::knownReturn(ParserContainerBase* container)
331{
332 return *dynamic_cast<ParserContainer<StringCategory>*>(container);
333}
334
335H_RESIP_DO_NOT_USEs resip::h_RESIP_DO_NOT_USEs;
336
337void H_RESIP_DO_NOT_USEs::merge(SipMessage& target, const SipMessage& embedded)
338{
339}
340
342H_RESIP_DO_NOT_USEs::makeContainer(HeaderFieldValueList* hfvs) const
343{
344 return new ParserContainer<StringCategory>(hfvs,Headers::RESIP_DO_NOT_USE);
345}
346
349
351Headers::getType(const char* name, size_t len)
352{
353 const struct headers* p;
354 p = HeaderHash::in_word_set(name, len);
355 return p ? Headers::Type(p->type) : Headers::UNKNOWN;
356}
357
358/* ====================================================================
359 * The Vovida Software License, Version 1.0
360 *
361 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
362 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
363 *
364 * Redistribution and use in source and binary forms, with or without
365 * modification, are permitted provided that the following conditions
366 * are met:
367 *
368 * 1. Redistributions of source code must retain the above copyright
369 * notice, this list of conditions and the following disclaimer.
370 *
371 * 2. Redistributions in binary form must reproduce the above copyright
372 * notice, this list of conditions and the following disclaimer in
373 * the documentation and/or other materials provided with the
374 * distribution.
375 *
376 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
377 * and "Vovida Open Communication Application Library (VOCAL)" must
378 * not be used to endorse or promote products derived from this
379 * software without prior written permission. For written
380 * permission, please contact vocal@vovida.org.
381 *
382 * 4. Products derived from this software may not be called "VOCAL", nor
383 * may "VOCAL" appear in their name, without prior written
384 * permission of Vovida Networks, Inc.
385 *
386 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
387 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
388 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
389 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
390 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
391 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
392 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
393 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
394 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
395 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
396 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
397 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
398 * DAMAGE.
399 *
400 * ====================================================================
401 *
402 * This software consists of voluntary contributions made by Vovida
403 * Networks, Inc. and many individuals on behalf of Vovida Networks,
404 * Inc. For more information on Vovida Networks, Inc., please see
405 * <http://www.vovida.org/>.
406 *
407 */
#define defineHeader(_enum, _name, _type, _reference)
Definition Headers.cxx:55
#define defineMultiHeader(_enum, _name, _type, _reference)
Definition Headers.cxx:90
Represents the "credentials" and "challenge" elements in the SIP grammar.
Definition Auth.hxx:18
Represents a CSeq header field value (this doesn't have an official name in the RFC 3261 grammar).
Represents the "callid" element in the SIP grammar.
Definition CallId.hxx:18
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
Represents the "SIP-date" element in the RFC 3261 grammar.
Represents the header field value for an Expires-type header.
Represents the "absoluteURI" element in the RFC 3261 grammar.
static HeaderBase * theHeaderInstances[Headers::MAX_HEADERS+1]
Definition Headers.hxx:75
static const struct headers * in_word_set(const char *str, size_t len)
static Type getType(const char *name, size_t len)
Definition Headers.cxx:351
static bool Multi[MAX_HEADERS+1]
static const Data & getHeaderName(int)
Definition Headers.cxx:37
static bool isCommaTokenizing(Type type)
Definition Headers.cxx:25
static bool isMulti(Type type)
Definition Headers.cxx:50
static bool CommaEncoding[MAX_HEADERS+1]
static bool isCommaEncoding(Type type)
Definition Headers.cxx:31
static bool CommaTokenizing[MAX_HEADERS+1]
static Data HeaderNames[MAX_HEADERS+1]
Represents an Identity header from RFC8824.
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
Abstract Base class implemented in derived class ParserContainer.
Container class for ParserCategory, used by SipMessage to represent multi-valued headers (Contact,...
Represents the "token" element in the RFC 3261 grammar.
Represents the RAck header field value defined in the RFC 3262 grammar.
Represents a SIP message.
Represents the "header-value" element in the RFC 3261 grammar (ie, an unknown header field value).
Generically represents a token whose value can be wrapped and encoded using double quotes.
Represents the "token" element in the RFC 3261 grammar.
Definition Token.hxx:18
Represents a numeric-with-comment header field value.
Represents the "via-parm" element in the RFC 3261 grammar.
Definition Via.hxx:18
Represents the "warning-value" element in the RFC 3261 grammar.
dcm! – add UnusedChecking(_enum) below;
StatusLineType h_StatusLine
Definition Headers.cxx:348
ParserContainer< Mime > Mimes
Definition Headers.hxx:164
ParserContainer< GenericUri > GenericUris
H_Privacys h_Privacies
Definition Headers.cxx:163
H_PPreferredIdentitys h_PPreferredIdentities
Definition Headers.cxx:211
H_SecurityVerifys h_SecurityVerifies
Definition Headers.cxx:157
H_CallID H_CallId
Definition Headers.hxx:258
H_PAssertedIdentitys h_PAssertedIdentities
Definition Headers.cxx:215
ParserContainer< NameAddr > NameAddrs
Definition Headers.hxx:181
H_Identitys h_Identities
Definition Headers.cxx:315
RequestLineType h_RequestLine
Definition Headers.cxx:347
ParserContainer< StringCategory > StringCategories
Definition Headers.hxx:213
H_AllowEventss h_AllowEvents
Definition Headers.cxx:143
H_CallId h_CallId
Definition Headers.cxx:266
Headers::Type type