sip 1.12.11devel
Loading...
Searching...
No Matches
sip_header.h
Go to the documentation of this file.
1/*
2 * This file is part of the Sofia-SIP package
3 *
4 * Copyright (C) 2005 Nokia Corporation.
5 *
6 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef SIP_HEADER_H
27#define SIP_HEADER_H
28
38#ifndef SU_ALLOC_H
39#include <sofia-sip/su_alloc.h>
40#endif
41
42#ifndef SU_TAG_H
43#include <sofia-sip/su_tag.h>
44#endif
45
46#ifndef SIP_H
47#include <sofia-sip/sip.h>
48#endif
49
50#ifndef MSG_HEADER_H
52#endif
53
54#ifndef _STRING_H
55#include <string.h>
56#endif
57
58SOFIA_BEGIN_DECLS
59
62
65
67#define sip_is_sip(sip) ((sip) && (sip)->sip_ident == SIP_PROTOCOL_TAG)
68
70#define SIP_HDR_INIT(name) {{{ 0, 0, sip_##name##_class }}}
71
73#define SIP_HEADER_INIT(h, sip_class, size) \
74 ((void)memset((h), 0, (size)), \
75 (void)(((sip_common_t *)(h))->h_class = (sip_class)), \
76 (h))
77
80
82SOFIAPUBFUN issize_t sip_e(sip_t const *sip, int flags, char b[], isize_t size);
83
86
89 sip_header_t const *h);
90
93
96 msg_hclass_t *hc, sip_header_t const *o);
97
100 void const *extra, va_list headers);
101
103SOFIAPUBFUN int sip_add_tl(msg_t *msg, sip_t *sip,
104 tag_type_t tag, tag_value_t value, ...);
105
107SOFIAPUBFUN int sip_add_tagis(msg_t *, sip_t *, tagi_t const **inout_list);
108
110SOFIAPUBFUN int sip_add_make(msg_t *, sip_t *, msg_hclass_t *hc, char const *s);
111
114 tag_type_t tag, tag_value_t value,
115 ...);
116
119 char const *query,
120 msg_mclass_t const *parser);
121
124
126#define sip_fragment_clear(a) ((a)->h_data = NULL, (a)->h_len = 0)
127
128/* Use __attribute__ to allow argument checking for sip_header_format() */
129#if !defined(__GNUC__) && !defined(__attribute__)
130#define __attribute__(x)
131#endif
132
135 msg_hclass_t *hc,
136 char const *fmt,
137 ...)
138 __attribute__((__format__ (printf, 3, 4)));
139
141SOFIAPUBFUN sip_time_t sip_now(void);
142
143SOFIAPUBVAR char const sip_method_name_ack[];
144SOFIAPUBVAR char const sip_method_name_bye[];
145SOFIAPUBVAR char const sip_method_name_cancel[];
146SOFIAPUBVAR char const sip_method_name_invite[];
147SOFIAPUBVAR char const sip_method_name_options[];
148SOFIAPUBVAR char const sip_method_name_register[];
149SOFIAPUBVAR char const sip_method_name_info[];
150SOFIAPUBVAR char const sip_method_name_prack[];
151SOFIAPUBVAR char const sip_method_name_comet[];
152SOFIAPUBVAR char const sip_method_name_message[];
153SOFIAPUBVAR char const sip_method_name_subscribe[];
154SOFIAPUBVAR char const sip_method_name_notify[];
155SOFIAPUBVAR char const sip_method_name_refer[];
156
158SOFIAPUBVAR char const sip_transport_udp[];
160SOFIAPUBVAR char const sip_transport_tcp[];
162SOFIAPUBVAR char const sip_transport_sctp[];
164SOFIAPUBVAR char const sip_transport_tls[];
166SOFIAPUBVAR char const sip_version_2_0[];
167
168#define SIP_VERSION_CURRENT sip_version_2_0
169
172
174#define SIP_PORT(s) ((s) ? (s) : "5060")
175
177#define SIPS_PORT(s) ((s) ? (s) : "5061")
178
180SOFIAPUBFUN char const *sip_method_name(sip_method_t method, char const *name);
181
184
185SOFIAPUBVAR char const * const sip_method_names[];
186
187#define SIP_METHOD_NAME(method, name) \
188 ((method) == sip_method_unknown ? (name) : sip_method_name(method, name))
189
190#define sip_header_make(h, c, s) \
191 ((sip_header_t *)msg_header_make((h), (c), (s)))
192#define sip_header_vformat(h, c, f, a) \
193 ((sip_header_t *)msg_header_vformat((h), (c), (f), (a)))
194
195SOFIA_END_DECLS
196#ifndef SIP_PROTOS_H
197#include <sofia-sip/sip_protos.h>
198#endif
199SOFIA_BEGIN_DECLS
200
204 sip_method_t method, const char *name,
205 url_string_t const *url,
206 char const *version);
207
211 unsigned status,
212 char const *phrase,
213 char const *version);
214
217 char const *domain);
218
221 unsigned method, char const *name);
222
225 url_string_t const *url,
226 char const *param,
227 /* char const *params, */
228 ...);
229
232 sip_expires_t const *ex,
233 sip_date_t const *date,
234 sip_time_t def,
235 sip_time_t now);
236
240
243
246
249 url_t const *maddr);
250
253 url_t const *rq_url,
254 url_t const *m_url);
255
258
259SOFIAPUBFUN int sip_from_tag(su_home_t *, sip_from_t *from, char const *tag);
260
263
264SOFIAPUBFUN int sip_to_tag(su_home_t *, sip_to_t *to, char const *tag);
265
268 char const *host,
269 char const *port,
270 char const *transport,
271 /* char const *params */
272 ...);
273
275#if SU_HAVE_INLINE
277{
278 char const *tp = v->v_protocol;
279 if (tp) {
280 tp = strchr(tp, '/');
281 if (tp) {
282 tp = strchr(tp + 1, '/');
283 if (tp)
284 return tp + 1;
285 }
286 }
287 return NULL;
288}
289#else
290char const *sip_via_transport(sip_via_t const *v);
291#endif
292
293SOFIAPUBFUN char const *sip_via_port(sip_via_t const *v, int *using_rport);
294
296sip_payload_t *sip_payload_create(su_home_t *, void const *data, isize_t len);
297
315#define SIP_PAYLOAD_INIT2(data, length) \
316 {{{ 0, 0, sip_payload_class, data, length }, NULL, data, length }}
317
319SOFIAPUBFUN sip_separator_t *sip_separator_create(su_home_t *home);
320
324 sip_supported_t const *support,
325 sip_require_t const *require);
326
329 sip_supported_t const *support,
330 sip_require_t const *by_require,
331 sip_require_t const *require);
332
336 sip_supported_t const *support,
337 sip_require_t const *by_require,
338 sip_proxy_require_t const *by_proxy_require,
339 sip_require_t const *require,
340 sip_require_t const *require2,
341 sip_require_t const *require3);
342
345int sip_has_supported(sip_supported_t const *support, char const *feature);
346
349int sip_has_feature(msg_list_t const *supported, char const *feature);
350
352SOFIAPUBFUN int sip_is_allowed(sip_allow_t const *allow,
353 sip_method_t method, char const *name);
354
356#define SIP_IS_ALLOWED(allow, method) \
357 (sip_method_unknown < (method) && (method) < 32 && \
358 (allow) && ((allow)->k_bitmap & (1 << (method))) != 0)
359
381
388
394 sip_mask_ua = (1 << 2),
395
401 sip_mask_proxy = (1 << 3),
402
410
417 sip_mask_100rel = (1 << 5),
418
425 sip_mask_events = (1 << 6),
426
433 sip_mask_timer = (1 << 7),
434
442
449 sip_mask_pref = (1 << 9),
450
457 sip_mask_publish = (1 << 10)
458
459 /* NOTE:
460 * When adding bits, please update nta_agent_create() and
461 * NTATAG_BAD_RESP_MASK()/NTATAG_BAD_REQ_MASK() documentation.
462 */
464
465/* ------------------------------------------------------------------------- */
466
467/* Here are @deprecated functions and names for compatibility */
468
470SOFIAPUBFUN issize_t sip_header_e(char[], isize_t, sip_header_t const *, int);
471
474sip_header_t *sip_header_d(su_home_t *, msg_t const *, char const *);
475
477SOFIAPUBFUN issize_t sip_header_field_e(char[], isize_t, sip_header_t const *, int);
478
480SOFIAPUBFUN issize_t sip_header_field_d(su_home_t *, sip_header_t *, char *, isize_t);
481
484
487
490
494 char const *e);
495
498 char const *param);
499
500SOFIAPUBFUN int sip_to_add_param(su_home_t *, sip_to_t *, char const *);
501
502SOFIAPUBFUN int sip_from_add_param(su_home_t *, sip_from_t *, char const *);
503
505SOFIAPUBFUN int sip_via_add_param(su_home_t *, sip_via_t *, char const *);
506
507#define sip_from_make_url sip_from_create
508#define sip_to_make_url sip_to_create
509#define sip_params_find msg_params_find
510
511SOFIA_END_DECLS
512
513#endif
sip_call_id_t * sip_call_id_create(su_home_t *home, char const *domain)
Create a Call-ID header object.
Definition sip_basic.c:1124
int sip_contact_add_param(su_home_t *, sip_contact_t *, char const *param)
Add a parameter to a Contact header object.
Definition sip_basic.c:1488
sip_contact_t * sip_contact_create(su_home_t *, url_string_t const *url, char const *param,...)
Create a Contact header object.
Definition sip_util.c:96
sip_content_length_t * sip_content_length_create(su_home_t *, uint32_t n)
Create a Content-Length header object.
Definition sip_basic.c:1565
sip_cseq_t * sip_cseq_create(su_home_t *, uint32_t seq, unsigned method, char const *name)
Create a CSeq header object.
Definition sip_basic.c:1281
sip_date_t * sip_date_create(su_home_t *, sip_time_t t)
Create an Date header object.
Definition sip_basic.c:1651
sip_expires_t * sip_expires_create(su_home_t *, sip_time_t delta)
Create an Expires header object.
Definition sip_basic.c:1735
sip_time_t sip_contact_expires(sip_contact_t const *m, sip_expires_t const *ex, sip_date_t const *date, sip_time_t def, sip_time_t now)
Calculate expiration time of a Contact header.
Definition sip_time.c:72
int sip_from_tag(su_home_t *, sip_from_t *from, char const *tag)
Add a tag to a From header.
Definition sip_basic.c:1855
sip_from_t * sip_from_create(su_home_t *, url_string_t const *url)
Create a From header object.
Definition sip_basic.c:1814
int sip_from_add_param(su_home_t *, sip_from_t *, char const *)
Add a parameter to an sip_from_t object.
Definition sip_basic.c:1832
sip_payload_t * sip_payload_create(su_home_t *, void const *data, isize_t len)
Create a SIP payload structure.
Definition sip_basic.c:452
sip_record_route_t * sip_record_route_create(su_home_t *, url_t const *rq_url, url_t const *m_url)
Create a Record-Route header object.
Definition sip_basic.c:2357
sip_request_t * sip_request_create(su_home_t *home, sip_method_t method, const char *name, url_string_t const *url, char const *version)
Create a request line object.
Definition sip_basic.c:208
sip_route_t * sip_route_create(su_home_t *home, url_t const *url, url_t const *maddr)
Create a Route header object.
Definition sip_basic.c:2282
sip_separator_t * sip_separator_create(su_home_t *home)
Create a SIP separator line structure.
Definition sip_basic.c:514
sip_status_t * sip_status_create(su_home_t *home, unsigned status, char const *phrase, char const *version)
Create a status line object.
Definition sip_basic.c:377
int sip_to_add_param(su_home_t *, sip_to_t *, char const *)
Add a parameter to a sip_to_t object.
Definition sip_basic.c:2447
sip_to_t * sip_to_create(su_home_t *, url_string_t const *url)
Create a To header object.
Definition sip_basic.c:2427
char const * sip_via_port(sip_via_t const *v, int *using_rport)
Get port number corresponding to a Via line.
Definition sip_basic.c:2754
int sip_via_add_param(su_home_t *, sip_via_t *, char const *)
Add a parameter to a Via header object.
Definition sip_basic.c:2679
sip_via_t * sip_via_create(su_home_t *h, char const *host, char const *port, char const *transport,...)
Create a Via object.
Definition sip_basic.c:2705
struct msg_hclass_s const msg_hclass_t
SIP objects.
msg_time_t sip_time_t
Time in seconds since Jan 01 1900.
Definition sip.h:105
union sip_header_u sip_header_t
Any SIP header - union of all possible SIP headers.
Definition sip.h:114
sip_method_t
IDs for well-known SIP methods.
Definition sip.h:48
issize_t sip_header_field_e(char[], isize_t, sip_header_t const *, int)
Encode contents of a SIP header field.
char const * sip_via_transport(sip_via_t const *v)
Get transport protocol name.
Definition sip_header.h:276
sip_unsupported_t * sip_has_unsupported_any(su_home_t *, sip_supported_t const *support, sip_require_t const *by_require, sip_proxy_require_t const *by_proxy_require, sip_require_t const *require, sip_require_t const *require2, sip_require_t const *require3)
Check if required features are not supported.
Definition sip_feature.c:396
char const sip_version_2_0[]
SIP version 2.0.
Definition sip_parser.c:61
sip_header_t * sip_header_format(su_home_t *home, msg_hclass_t *hc, char const *fmt,...)))
Make a SIP header with formatting provided.
Definition sip_header.c:97
int sip_is_header(sip_header_t const *header)
Test if header is a pointer to a SIP header object.
char * sip_headers_as_url_query(su_home_t *home, tag_type_t tag, tag_value_t value,...)
Convert headers from taglist as URL query.
Definition sip_tag_class.c:302
sip_unsupported_t * sip_has_unsupported2(su_home_t *, sip_supported_t const *support, sip_require_t const *by_require, sip_require_t const *require)
Check if required feature is not supported.
Definition sip_feature.c:362
int sip_has_feature(msg_list_t const *supported, char const *feature)
Check that a feature is in the list.
Definition sip_feature.c:471
sip_time_t sip_now(void)
Return current time.
Definition sip_time.c:49
int sip_has_supported(sip_supported_t const *support, char const *feature)
Check that a feature is supported.
Definition sip_feature.c:488
sip_header_t * sip_header_d(su_home_t *, msg_t const *, char const *)
Decode a SIP header string (name: contents CRLF?).
Definition sip_header.c:83
sip_method_t sip_method_code(char const *name)
Return code corresponding to the method code.
Definition sip_parser.c:449
isize_t sip_header_size(sip_header_t const *h)
Calculate the size of a SIP header and associated memory areas.
Definition sip_util.c:428
char * sip_header_as_string(su_home_t *home, sip_header_t const *h)
Convert the header h to a string allocated from home.
Definition sip_util.c:394
int sip_add_make(msg_t *, sip_t *, msg_hclass_t *hc, char const *s)
Parse a string as a header and add it to the SIP message.
Definition sip_header.c:130
issize_t sip_header_e(char[], isize_t, sip_header_t const *, int)
Encode a SIP header field (name: contents CRLF).
Definition sip_header.c:92
sip_unsupported_t * sip_has_unsupported(su_home_t *, sip_supported_t const *support, sip_require_t const *require)
Check that a required feature is supported.
Definition sip_feature.c:346
int sip_allow_events_add(su_home_t *, sip_allow_events_t *ae, char const *e)
Add an event to Allow-Events header.
Definition sip_event.c:229
int sip_complete_message(msg_t *msg)
Complete SIP message.
Definition sip_parser.c:600
int sip_add_tl(msg_t *msg, sip_t *sip, tag_type_t tag, tag_value_t value,...)
Add duplicates of headers from taglist to the SIP message.
Definition sip_tag_class.c:191
issize_t sip_e(sip_t const *sip, int flags, char b[], isize_t size)
Encode a SIP message.
int sip_is_allowed(sip_allow_t const *allow, sip_method_t method, char const *name)
Return true if the method is listed in Allow header.
Definition sip_feature.c:129
sip_bad_mask
Bitmasks for header classifications.
Definition sip_header.h:374
@ sip_mask_request
Bit marking essential headers in a request message.
Definition sip_header.h:380
@ sip_mask_privacy
Bit marking essential headers for privacy extension.
Definition sip_header.h:441
@ sip_mask_events
Bit marking essential headers for SIP events.
Definition sip_header.h:425
@ sip_mask_proxy
Bit marking essential headers for proxy server.
Definition sip_header.h:401
@ sip_mask_timer
Bit marking essential headers for session timer extension.
Definition sip_header.h:433
@ sip_mask_pref
Bit marking essential headers for caller preference extension.
Definition sip_header.h:449
@ sip_mask_registrar
Bit marking essential headers for registrar server.
Definition sip_header.h:409
@ sip_mask_publish
Bit marking essential headers for PUBLISH servers and clients.
Definition sip_header.h:457
@ sip_mask_100rel
Bit marking essential headers for 100rel extension.
Definition sip_header.h:417
@ sip_mask_ua
Bit marking essential headers for User-Agent.
Definition sip_header.h:394
@ sip_mask_response
Bit marking essential headers in a response message.
Definition sip_header.h:387
sip_header_t * sip_header_dup(su_home_t *, sip_header_t const *)
Duplicate (deep copy) a SIP header or whole list.
Definition sip_header.c:71
sip_header_t * sip_header_copy(su_home_t *, sip_header_t const *o)
Copy a SIP header or whole list.
Definition sip_header.c:60
int sip_add_tagis(msg_t *, sip_t *, tagi_t const **inout_list)
Add duplicates of headers from taglist to the SIP message.
Definition sip_tag_class.c:209
int sip_serialize(msg_t *msg, sip_t *sip)
Serialize headers into the fragment chain.
tagi_t * sip_url_query_as_taglist(su_home_t *home, char const *query, msg_mclass_t const *parser)
Convert URL query to a tag list.
Definition sip_tag_class.c:418
msg_mclass_t * sip_extend_mclass(msg_mclass_t *input)
Extend SIP parser class with extension headers.
Definition sip_parser.c:127
char const sip_parser_version[]
SIP parser version.
Definition sip_parser.c:58
int sip_add_headers(msg_t *msg, sip_t *sip, void const *extra, va_list headers)
Add duplicates of headers to the SIP message.
int sip_add_dup(msg_t *, sip_t *, sip_header_t const *)
Add a duplicate of header object to a SIP message.
Definition sip_header.c:115
char const * sip_method_name(sip_method_t method, char const *name)
Return string corresponding to the method.
Definition sip_parser.c:337
issize_t sip_header_field_d(su_home_t *, sip_header_t *, char *, isize_t)
Decode the string containing header field.
Definition sip_util.c:365
char const *const sip_method_names[]
Well-known SIP method names.
Definition sip_parser.c:316
msg_mclass_t const * sip_default_mclass(void)
Return a built-in SIP parser object.
Definition sip_parser.c:69
int sip_add_dup_as(msg_t *msg, sip_t *sip, msg_hclass_t *hc, sip_header_t const *o)
Add a duplicate of header object to the SIP message.
Definition sip_header.c:122
int sip_update_default_mclass(msg_mclass_t const *mclass)
Update the default SIP parser.
Definition sip_parser.c:98
SIP prototypes and macros for each header.
Structure for From and To headers.
Definition sip.h:382
Structure for Allow header field.
Definition sip.h:415
Structure for Call-ID (and In-Reply-To) header fields.
Definition sip.h:438
Structure for Contact header field.
Definition sip.h:473
Structure for Content-Length header.
Definition sip.h:489
Structure for CSeq header.
Definition sip.h:461
Structure for Date header.
Definition sip.h:514
Structure for Expires header.
Definition sip.h:547
Structure for SIP request line.
Definition sip.h:357
Structure for Route and Record-Route header fields.
Definition sip.h:681
SIP message object.
Definition sip.h:230
Structure for SIP status line.
Definition sip.h:370
Structure for Via header field.
Definition sip.h:753
char const * v_protocol
Application and transport protocol.
Definition sip.h:756
SU_HOME_T su_home_t
#define SOFIAPUBFUN
#define SOFIAPUBVAR
#define su_inline
intptr_t tag_value_t
struct tag_type_s const * tag_type_t
SU_U32_T uint32_t

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.