1
/* $Id: sip_msg.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJSIP_SIP_MSG_H__
21
#define __PJSIP_SIP_MSG_H__
24
* @file pjsip/sip_msg.h
25
* @brief SIP Message Structure.
28
#include <pjsip/sip_types.h>
29
#include <pjsip/sip_uri.h>
35
* @defgroup PJSIP_MSG Messaging Elements
37
* @brief Various SIP message elements such as methods, headers, URIs, etc.
41
/* **************************************************************************/
43
* @defgroup PJSIP_MSG_METHOD Methods
44
* @brief Method names and manipulation.
50
* This enumeration declares SIP methods as described by RFC3261. Additional
51
* methods do exist, and they are described by corresponding RFCs for the SIP
52
* extentensions. Since they won't alter the characteristic of the processing
53
* of the message, they don't need to be explicitly mentioned here.
55
typedef enum pjsip_method_e
57
PJSIP_INVITE_METHOD, /**< INVITE method, for establishing dialogs. */
58
PJSIP_CANCEL_METHOD, /**< CANCEL method, for cancelling request. */
59
PJSIP_ACK_METHOD, /**< ACK method. */
60
PJSIP_BYE_METHOD, /**< BYE method, for terminating dialog. */
61
PJSIP_REGISTER_METHOD, /**< REGISTER method. */
62
PJSIP_OPTIONS_METHOD, /**< OPTIONS method. */
64
PJSIP_OTHER_METHOD /**< Other method. */
71
* This structure represents a SIP method.
72
* Application must always use either #pjsip_method_init or #pjsip_method_set
73
* to make sure that method name is initialized correctly. This way, the name
74
* member will always contain a valid method string regardless whether the ID
75
* is recognized or not.
79
pjsip_method_e id; /**< Method ID, from \a pjsip_method_e. */
80
pj_str_t name; /**< Method name, which will always contain the
86
* For convenience, standard method structures are defined in the library.
88
/** INVITE method constant. @see pjsip_get_invite_method() */
89
PJ_DECL_DATA(const pjsip_method) pjsip_invite_method;
91
/** CANCEL method constant. @see pjsip_get_cancel_method() */
92
PJ_DECL_DATA(const pjsip_method) pjsip_cancel_method;
94
/** ACK method constant. @see pjsip_get_ack_method() */
95
PJ_DECL_DATA(const pjsip_method) pjsip_ack_method;
97
/** BYE method constant. @see pjsip_get_bye_method() */
98
PJ_DECL_DATA(const pjsip_method) pjsip_bye_method;
100
/** REGISTER method constant. @see pjsip_get_register_method() */
101
PJ_DECL_DATA(const pjsip_method) pjsip_register_method;
103
/** OPTIONS method constant. @see pjsip_get_options_method() */
104
PJ_DECL_DATA(const pjsip_method) pjsip_options_method;
107
* Accessor functions for standard SIP methods.
109
/** Get INVITE method constant. */
110
PJ_DECL(const pjsip_method*) pjsip_get_invite_method(void);
111
/** Get CANCEL method constant. */
112
PJ_DECL(const pjsip_method*) pjsip_get_cancel_method(void);
113
/** Get ACK method constant. */
114
PJ_DECL(const pjsip_method*) pjsip_get_ack_method(void);
115
/** Get BYE method constant. */
116
PJ_DECL(const pjsip_method*) pjsip_get_bye_method(void);
117
/** Get REGISTER method constant.*/
118
PJ_DECL(const pjsip_method*) pjsip_get_register_method(void);
119
/** Get OPTIONS method constant. */
120
PJ_DECL(const pjsip_method*) pjsip_get_options_method(void);
128
* Initialize the method structure from a string.
129
* This function will check whether the method is a known method then set
130
* both the id and name accordingly.
132
* @param m The method to initialize.
133
* @param pool Pool where memory allocation will be allocated from, if required.
134
* @param str The method string.
136
PJ_DECL(void) pjsip_method_init( pjsip_method *m,
138
const pj_str_t *str);
141
* Initialize the method structure from a string, without cloning the string.
142
* See #pjsip_method_init.
144
* @param m The method structure to be initialized.
145
* @param str The method string.
147
PJ_DECL(void) pjsip_method_init_np( pjsip_method *m,
151
* Set the method with the predefined method ID.
152
* This function will also set the name member of the structure to the correct
153
* string according to the method.
155
* @param m The method structure.
156
* @param id The method ID.
158
PJ_DECL(void) pjsip_method_set( pjsip_method *m, pjsip_method_e id );
162
* Copy one method structure to another. If the method is of the known methods,
163
* then memory allocation is not required.
165
* @param pool Pool to allocate memory from, if required.
166
* @param method The destination method to copy to.
167
* @param rhs The source method to copy from.
169
PJ_DECL(void) pjsip_method_copy( pj_pool_t *pool,
170
pjsip_method *method,
171
const pjsip_method *rhs );
174
* Compare one method with another, and conveniently determine whether the
175
* first method is equal, less than, or greater than the second method.
177
* @param m1 The first method.
178
* @param m2 The second method.
180
* @return Zero if equal, otherwise will return -1 if less or +1 if greater.
182
PJ_DECL(int) pjsip_method_cmp( const pjsip_method *m1, const pjsip_method *m2);
188
/* **************************************************************************/
190
* @defgroup PJSIP_MSG_HDR Header Fields
191
* @brief Declarations for various SIP header fields.
197
* Header types, as defined by RFC3261.
199
typedef enum pjsip_hdr_e
202
* These are the headers documented in RFC3261. Headers not documented
203
* there must have type PJSIP_H_OTHER, and the header type itself is
204
* recorded in the header name string.
206
* DO NOT CHANGE THE VALUE/ORDER OF THE HEADER IDs!!!.
209
PJSIP_H_ACCEPT_ENCODING_UNIMP, /* N/A, use pjsip_generic_string_hdr */
210
PJSIP_H_ACCEPT_LANGUAGE_UNIMP, /* N/A, use pjsip_generic_string_hdr */
211
PJSIP_H_ALERT_INFO_UNIMP, /* N/A, use pjsip_generic_string_hdr */
213
PJSIP_H_AUTHENTICATION_INFO_UNIMP, /* N/A, use pjsip_generic_string_hdr */
214
PJSIP_H_AUTHORIZATION,
216
PJSIP_H_CALL_INFO_UNIMP, /* N/A, use pjsip_generic_string_hdr */
218
PJSIP_H_CONTENT_DISPOSITION_UNIMP, /* N/A, use pjsip_generic_string_hdr */
219
PJSIP_H_CONTENT_ENCODING_UNIMP, /* N/A, use pjsip_generic_string_hdr */
220
PJSIP_H_CONTENT_LANGUAGE_UNIMP, /* N/A, use pjsip_generic_string_hdr */
221
PJSIP_H_CONTENT_LENGTH,
222
PJSIP_H_CONTENT_TYPE,
224
PJSIP_H_DATE_UNIMP, /* N/A, use pjsip_generic_string_hdr */
225
PJSIP_H_ERROR_INFO_UNIMP, /* N/A, use pjsip_generic_string_hdr */
228
PJSIP_H_IN_REPLY_TO_UNIMP, /* N/A, use pjsip_generic_string_hdr */
229
PJSIP_H_MAX_FORWARDS,
230
PJSIP_H_MIME_VERSION_UNIMP, /* N/A, use pjsip_generic_string_hdr */
232
PJSIP_H_ORGANIZATION_UNIMP, /* N/A, use pjsip_generic_string_hdr */
233
PJSIP_H_PRIORITY_UNIMP, /* N/A, use pjsip_generic_string_hdr */
234
PJSIP_H_PROXY_AUTHENTICATE,
235
PJSIP_H_PROXY_AUTHORIZATION,
236
PJSIP_H_PROXY_REQUIRE_UNIMP, /* N/A, use pjsip_generic_string_hdr */
237
PJSIP_H_RECORD_ROUTE,
238
PJSIP_H_REPLY_TO_UNIMP, /* N/A, use pjsip_generic_string_hdr */
242
PJSIP_H_SERVER_UNIMP, /* N/A, use pjsip_generic_string_hdr */
243
PJSIP_H_SUBJECT_UNIMP, /* N/A, use pjsip_generic_string_hdr */
245
PJSIP_H_TIMESTAMP_UNIMP, /* N/A, use pjsip_generic_string_hdr */
248
PJSIP_H_USER_AGENT_UNIMP, /* N/A, use pjsip_generic_string_hdr */
250
PJSIP_H_WARNING_UNIMP, /* N/A, use pjsip_generic_string_hdr */
251
PJSIP_H_WWW_AUTHENTICATE,
258
* This structure provides the pointer to basic functions that are needed
259
* for generic header operations. All header fields will have pointer to
260
* this structure, so that they can be manipulated uniformly.
262
typedef struct pjsip_hdr_vptr
265
* Function to clone the header.
267
* @param pool Memory pool to allocate the new header.
268
* @param hdr Header to clone.
270
* @return A new instance of the header.
272
void *(*clone)(pj_pool_t *pool, const void *hdr);
275
* Pointer to function to shallow clone the header.
276
* Shallow cloning will just make a memory copy of the original header,
277
* thus all pointers in original header will be kept intact. Because the
278
* function does not need to perform deep copy, the operation should be
279
* faster, but the application must make sure that the original header
280
* is still valid throughout the lifetime of new header.
282
* @param pool Memory pool to allocate the new header.
283
* @param hdr The header to clone.
285
void *(*shallow_clone)(pj_pool_t *pool, const void *hdr);
287
/** Pointer to function to print the header to the specified buffer.
288
* Returns the length of string written, or -1 if the remaining buffer
289
* is not enough to hold the header.
291
* @param hdr The header to print.
292
* @param buf The buffer.
293
* @param len The size of the buffer.
295
* @return The size copied to buffer, or -1 if there's not enough space.
297
int (*print_on)(void *hdr, char *buf, pj_size_t len);
303
* Generic fields for all SIP headers are declared using this macro, to make
304
* sure that all headers will have exactly the same layout in their start of
305
* the storage. This behaves like C++ inheritance actually.
307
#define PJSIP_DECL_HDR_MEMBER(hdr) \
308
/** List members. */ \
309
PJ_DECL_LIST_MEMBER(hdr); \
312
/** Header name. */ \
314
/** Header short name version. */ \
316
/** Virtual function table. */ \
321
* Generic SIP header structure, for generic manipulation for headers in the
322
* message. All header fields can be typecasted to this type.
326
PJSIP_DECL_HDR_MEMBER(struct pjsip_hdr);
331
* This generic function will clone any header, by calling "clone" function
332
* in header's virtual function table.
334
* @param pool The pool to allocate memory from.
335
* @param hdr The header to clone.
337
* @return A new instance copied from the original header.
339
PJ_DECL(void*) pjsip_hdr_clone( pj_pool_t *pool, const void *hdr );
343
* This generic function will clone any header, by calling "shallow_clone"
344
* function in header's virtual function table.
346
* @param pool The pool to allocate memory from.
347
* @param hdr The header to clone.
349
* @return A new instance copied from the original header.
351
PJ_DECL(void*) pjsip_hdr_shallow_clone( pj_pool_t *pool, const void *hdr );
354
* This generic function will print any header, by calling "print"
355
* function in header's virtual function table.
357
* @param hdr The header to print.
358
* @param buf The buffer.
359
* @param len The size of the buffer.
361
* @return The size copied to buffer, or -1 if there's not enough space.
363
PJ_DECL(int) pjsip_hdr_print_on( void *hdr, char *buf, pj_size_t len);
369
/* **************************************************************************/
371
* @defgroup PJSIP_MSG_LINE Request and Status Line.
372
* @brief Request and status line structures and manipulation.
378
* This structure describes SIP request line.
380
typedef struct pjsip_request_line
382
pjsip_method method; /**< Method for this request line. */
383
pjsip_uri *uri; /**< URI for this request line. */
384
} pjsip_request_line;
388
* This structure describes SIP status line.
390
typedef struct pjsip_status_line
392
int code; /**< Status code. */
393
pj_str_t reason; /**< Reason string. */
398
* This enumeration lists standard SIP status codes according to RFC 3261.
399
* In addition, it also declares new status class 7xx for errors generated
400
* by the stack. This status class however should not get transmitted on the
403
typedef enum pjsip_status_code
405
PJSIP_SC_TRYING = 100,
406
PJSIP_SC_RINGING = 180,
407
PJSIP_SC_CALL_BEING_FORWARDED = 181,
408
PJSIP_SC_QUEUED = 182,
409
PJSIP_SC_PROGRESS = 183,
412
PJSIP_SC_ACCEPTED = 202,
414
PJSIP_SC_MULTIPLE_CHOICES = 300,
415
PJSIP_SC_MOVED_PERMANENTLY = 301,
416
PJSIP_SC_MOVED_TEMPORARILY = 302,
417
PJSIP_SC_USE_PROXY = 305,
418
PJSIP_SC_ALTERNATIVE_SERVICE = 380,
420
PJSIP_SC_BAD_REQUEST = 400,
421
PJSIP_SC_UNAUTHORIZED = 401,
422
PJSIP_SC_PAYMENT_REQUIRED = 402,
423
PJSIP_SC_FORBIDDEN = 403,
424
PJSIP_SC_NOT_FOUND = 404,
425
PJSIP_SC_METHOD_NOT_ALLOWED = 405,
426
PJSIP_SC_NOT_ACCEPTABLE = 406,
427
PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED = 407,
428
PJSIP_SC_REQUEST_TIMEOUT = 408,
430
PJSIP_SC_REQUEST_ENTITY_TOO_LARGE = 413,
431
PJSIP_SC_REQUEST_URI_TOO_LONG = 414,
432
PJSIP_SC_UNSUPPORTED_MEDIA_TYPE = 415,
433
PJSIP_SC_UNSUPPORTED_URI_SCHEME = 416,
434
PJSIP_SC_BAD_EXTENSION = 420,
435
PJSIP_SC_EXTENSION_REQUIRED = 421,
436
PJSIP_SC_SESSION_TIMER_TOO_SMALL = 422,
437
PJSIP_SC_INTERVAL_TOO_BRIEF = 423,
438
PJSIP_SC_TEMPORARILY_UNAVAILABLE = 480,
439
PJSIP_SC_CALL_TSX_DOES_NOT_EXIST = 481,
440
PJSIP_SC_LOOP_DETECTED = 482,
441
PJSIP_SC_TOO_MANY_HOPS = 483,
442
PJSIP_SC_ADDRESS_INCOMPLETE = 484,
443
PJSIP_AC_AMBIGUOUS = 485,
444
PJSIP_SC_BUSY_HERE = 486,
445
PJSIP_SC_REQUEST_TERMINATED = 487,
446
PJSIP_SC_NOT_ACCEPTABLE_HERE = 488,
447
PJSIP_SC_BAD_EVENT = 489,
448
PJSIP_SC_REQUEST_UPDATED = 490,
449
PJSIP_SC_REQUEST_PENDING = 491,
450
PJSIP_SC_UNDECIPHERABLE = 493,
452
PJSIP_SC_INTERNAL_SERVER_ERROR = 500,
453
PJSIP_SC_NOT_IMPLEMENTED = 501,
454
PJSIP_SC_BAD_GATEWAY = 502,
455
PJSIP_SC_SERVICE_UNAVAILABLE = 503,
456
PJSIP_SC_SERVER_TIMEOUT = 504,
457
PJSIP_SC_VERSION_NOT_SUPPORTED = 505,
458
PJSIP_SC_MESSAGE_TOO_LARGE = 513,
459
PJSIP_SC_PRECONDITION_FAILURE = 580,
461
PJSIP_SC_BUSY_EVERYWHERE = 600,
462
PJSIP_SC_DECLINE = 603,
463
PJSIP_SC_DOES_NOT_EXIST_ANYWHERE = 604,
464
PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE = 606,
466
PJSIP_SC_TSX_TIMEOUT = PJSIP_SC_REQUEST_TIMEOUT,
467
/*PJSIP_SC_TSX_RESOLVE_ERROR = 702,*/
468
PJSIP_SC_TSX_TRANSPORT_ERROR = PJSIP_SC_SERVICE_UNAVAILABLE,
470
/* This is not an actual status code, but rather a constant
471
* to force GCC to use 32bit to represent this enum, since
472
* we have a code in PJSUA-LIB that assigns an integer
473
* to this enum (see pjsua_acc_get_info() function).
475
PJSIP_SC__force_32bit = 0x7FFFFFFF
480
* Get the default status text for the status code.
482
* @param status_code SIP Status Code
484
* @return textual message for the status code.
486
PJ_DECL(const pj_str_t*) pjsip_get_status_text(int status_code);
489
* This macro returns non-zero (TRUE) if the specified status_code is
490
* in the same class as the code_class.
492
* @param status_code The status code.
493
* @param code_class The status code in the class (for example 100, 200).
495
#define PJSIP_IS_STATUS_IN_CLASS(status_code, code_class) \
496
(status_code/100 == code_class/100)
502
/* **************************************************************************/
504
* @addtogroup PJSIP_MSG_MEDIA Media/MIME Type
505
* @brief Media/MIME type declaration and manipulations.
511
* This structure describes SIP media type, as used for example in
512
* Accept and Content-Type header..
514
typedef struct pjsip_media_type
516
pj_str_t type; /**< Media type. */
517
pj_str_t subtype; /**< Media subtype. */
518
pjsip_param param; /**< Media type parameters */
523
* Initialize the media type with the specified type and subtype string.
525
* @param mt The media type.
526
* @param type Optionally specify the media type.
527
* @param subtype Optionally specify the media subtype.
529
PJ_DECL(void) pjsip_media_type_init(pjsip_media_type *mt,
534
* Initialize the media type with the specified type and subtype string.
536
* @param mt The media type.
537
* @param type Optionally specify the media type.
538
* @param subtype Optionally specify the media subtype.
540
PJ_DECL(void) pjsip_media_type_init2(pjsip_media_type *mt,
545
* Compare two media types.
547
* @param mt1 The first media type.
548
* @param mt2 The second media type.
549
* @param cmp_param Specify how to compare the media type parameters:
550
* - 0: do not compare parameters
551
* - 1: compare parameters but ignore parameters that
552
* only appear in one of the media type.
553
* - 2: compare the parameters.
555
* @return Zero if both media types are equal, -1 if mt1 < mt2,
558
PJ_DECL(int) pjsip_media_type_cmp(const pjsip_media_type *mt1,
559
const pjsip_media_type *mt2,
563
* Copy SIP media type to another.
565
* @param pool Pool to duplicate strings.
566
* @param dst Destination structure.
567
* @param src Source structure.
569
PJ_DECL(void) pjsip_media_type_cp(pj_pool_t *pool,
570
pjsip_media_type *dst,
571
const pjsip_media_type *src);
574
* Print media type to the specified buffer.
576
* @param buf Destination buffer.
577
* @param len Length of the buffer.
578
* @param mt The media type to be printed.
580
* @return The number of characters printed to the buffer, or -1
581
* if there's not enough space in the buffer.
583
PJ_DECL(int) pjsip_media_type_print(char *buf, unsigned len,
584
const pjsip_media_type *mt);
590
/* **************************************************************************/
592
* @addtogroup PJSIP_MSG_BODY Message Body
593
* @brief SIP message body structures and manipulation.
599
* Generic abstraction to message body.
600
* When an incoming message is parsed (pjsip_parse_msg()), the parser fills in
601
* all members with the appropriate value. The 'data' and 'len' member will
602
* describe portion of incoming packet which denotes the message body.
603
* When application needs to attach message body to outgoing SIP message, it
604
* must fill in all members of this structure.
606
struct pjsip_msg_body
608
/** MIME content type.
609
* For incoming messages, the parser will fill in this member with the
610
* content type found in Content-Type header.
612
* For outgoing messages, application may fill in this member with
613
* appropriate value, because the stack will generate Content-Type header
614
* based on the value specified here.
616
* If the content_type is empty, no Content-Type AND Content-Length header
617
* will be added to the message. The stack assumes that application adds
618
* these headers themselves.
620
pjsip_media_type content_type;
622
/** Pointer to buffer which holds the message body data.
623
* For incoming messages, the parser will fill in this member with the
624
* pointer to the body string.
626
* When sending outgoing message, this member doesn't need to point to the
627
* actual message body string. It can be assigned with arbitrary pointer,
628
* because the value will only need to be understood by the print_body()
629
* function. The stack itself will not try to interpret this value, but
630
* instead will always call the print_body() whenever it needs to get the
631
* actual body string.
635
/** The length of the data.
636
* For incoming messages, the parser will fill in this member with the
637
* actual length of message body.
639
* When sending outgoing message, again just like the "data" member, the
640
* "len" member doesn't need to point to the actual length of the body
645
/** Pointer to function to print this message body.
646
* Application must set a proper function here when sending outgoing
649
* @param msg_body This structure itself.
650
* @param buf The buffer.
651
* @param size The buffer size.
653
* @return The length of the string printed, or -1 if there is
654
* not enough space in the buffer to print the whole
657
int (*print_body)(struct pjsip_msg_body *msg_body,
658
char *buf, pj_size_t size);
660
/** Clone the data part only of this message body. Note that this only
661
* duplicates the data part of the body instead of the whole message
662
* body. If application wants to duplicate the entire message body
663
* structure, it must call #pjsip_msg_body_clone().
665
* @param pool Pool used to clone the data.
666
* @param data The data inside message body, to be cloned.
667
* @param len The length of the data.
669
* @return New data duplicated from the original data.
671
void* (*clone_data)(pj_pool_t *pool, const void *data, unsigned len);
676
* General purpose function to textual data in a SIP body. Attach this function
677
* in a SIP message body only if the data in pjsip_msg_body is a textual
678
* message ready to be embedded in a SIP message. If the data in the message
679
* body is not a textual body, then application must supply a custom function
680
* to print that body.
682
* @param msg_body The message body.
683
* @param buf Buffer to copy the message body to.
684
* @param size The size of the buffer.
686
* @return The length copied to the buffer, or -1.
688
PJ_DECL(int) pjsip_print_text_body( pjsip_msg_body *msg_body,
689
char *buf, pj_size_t size);
692
* General purpose function to clone textual data in a SIP body. Attach this
693
* function as "clone_data" member of the SIP body only if the data type
694
* is a text (i.e. C string, not pj_str_t), and the length indicates the
695
* length of the text.
697
* @param pool Pool used to clone the data.
698
* @param data Textual data.
699
* @param len The length of the string.
701
* @return New text duplicated from the original text.
703
PJ_DECL(void*) pjsip_clone_text_data( pj_pool_t *pool, const void *data,
708
* Clone the message body in src_body to the dst_body. This will duplicate
709
* the contents of the message body using the \a clone_data member of the
710
* source message body.
712
* @param pool Pool to use to duplicate the message body.
713
* @param dst_body Destination message body.
714
* @param src_body Source message body to duplicate.
716
* @return PJ_SUCCESS on success.
718
PJ_DECL(pj_status_t) pjsip_msg_body_copy( pj_pool_t *pool,
719
pjsip_msg_body *dst_body,
720
const pjsip_msg_body *src_body );
724
* Create cloned message body. This will duplicate the contents of the message
725
* body using the \a clone_data member of the source message body.
727
* @param pool Pool to use to duplicate the message body.
728
* @param body Source message body to duplicate.
730
* @return The cloned message body on successfull.
732
PJ_DECL(pjsip_msg_body*) pjsip_msg_body_clone( pj_pool_t *pool,
733
const pjsip_msg_body *body );
737
* Create a text message body. Use this function to create message body when
738
* the content is a simple text. For non-text message body (e.g.
739
* pjmedia_sdp_session or pj_xml_node), application must construct the message
742
* @param pool Pool to allocate message body and its contents.
743
* @param type MIME type (e.g. "text").
744
* @param subtype MIME subtype (e.g. "plain").
745
* @param text The text content to be put in the message body.
747
* @return A new message body with the specified Content-Type and
750
PJ_DECL(pjsip_msg_body*) pjsip_msg_body_create( pj_pool_t *pool,
751
const pj_str_t *type,
752
const pj_str_t *subtype,
753
const pj_str_t *text );
759
/* **************************************************************************/
761
* @defgroup PJSIP_MSG_MSG Message Structure
762
* @brief SIP message (request and response) structure and operations.
768
* Message type (request or response).
770
typedef enum pjsip_msg_type_e
772
PJSIP_REQUEST_MSG, /**< Indicates request message. */
773
PJSIP_RESPONSE_MSG /**< Indicates response message. */
778
* This structure describes a SIP message.
782
/** Message type (ie request or response). */
783
pjsip_msg_type_e type;
785
/** The first line of the message can be either request line for request
786
* messages, or status line for response messages. It is represented here
792
struct pjsip_request_line req;
795
struct pjsip_status_line status;
798
/** List of message headers. */
801
/** Pointer to message body, or NULL if no message body is attached to
804
pjsip_msg_body *body;
809
* Create new request or response message.
811
* @param pool The pool.
812
* @param type Message type.
813
* @return New message, or THROW exception if failed.
815
PJ_DECL(pjsip_msg*) pjsip_msg_create( pj_pool_t *pool, pjsip_msg_type_e type);
819
* Perform a deep clone of a SIP message.
821
* @param pool The pool for creating the new message.
822
* @param msg The message to be duplicated.
824
* @return New message, which is duplicated from the original
827
PJ_DECL(pjsip_msg*) pjsip_msg_clone( pj_pool_t *pool, const pjsip_msg *msg);
831
* Find a header in the message by the header type.
833
* @param msg The message.
834
* @param type The header type to find.
835
* @param start The first header field where the search should begin.
836
* If NULL is specified, then the search will begin from the
837
* first header, otherwise the search will begin at the
840
* @return The header field, or NULL if no header with the specified
843
PJ_DECL(void*) pjsip_msg_find_hdr( const pjsip_msg *msg,
844
pjsip_hdr_e type, const void *start);
847
* Find a header in the message by its name.
849
* @param msg The message.
850
* @param name The header name to find.
851
* @param start The first header field where the search should begin.
852
* If NULL is specified, then the search will begin from the
853
* first header, otherwise the search will begin at the
856
* @return The header field, or NULL if no header with the specified
859
PJ_DECL(void*) pjsip_msg_find_hdr_by_name( const pjsip_msg *msg,
860
const pj_str_t *name,
864
* Find a header in the message by its name and short name version.
866
* @param msg The message.
867
* @param name The header name to find.
868
* @param sname The short name version of the header name.
869
* @param start The first header field where the search should begin.
870
* If NULL is specified, then the search will begin from the
871
* first header, otherwise the search will begin at the
874
* @return The header field, or NULL if no header with the specified
877
PJ_DECL(void*) pjsip_msg_find_hdr_by_names(const pjsip_msg *msg,
878
const pj_str_t *name,
879
const pj_str_t *sname,
883
* Find and remove a header in the message.
885
* @param msg The message.
886
* @param hdr The header type to find.
887
* @param start The first header field where the search should begin,
888
* or NULL to search from the first header in the message.
890
* @return The header field, or NULL if not found.
892
PJ_DECL(void*) pjsip_msg_find_remove_hdr( pjsip_msg *msg,
893
pjsip_hdr_e hdr, void *start);
896
* Add a header to the message, putting it last in the header list.
898
* @param msg The message.
899
* @param hdr The header to add.
901
* @bug Once the header is put in a list (or message), it can not be put in
902
* other list (or message). Otherwise Real Bad Thing will happen.
904
PJ_INLINE(void) pjsip_msg_add_hdr( pjsip_msg *msg, pjsip_hdr *hdr )
906
pj_list_insert_before(&msg->hdr, hdr);
910
* Add header field to the message, putting it in the front of the header list.
912
* @param msg The message.
913
* @param hdr The header to add.
915
* @bug Once the header is put in a list (or message), it can not be put in
916
* other list (or message). Otherwise Real Bad Thing will happen.
918
PJ_INLINE(void) pjsip_msg_insert_first_hdr( pjsip_msg *msg, pjsip_hdr *hdr )
920
pj_list_insert_after(&msg->hdr, hdr);
924
* Print the message to the specified buffer.
926
* @param msg The message to print.
927
* @param buf The buffer
928
* @param size The size of the buffer.
930
* @return The length of the printed characters (in bytes), or NEGATIVE
931
* value if the message is too large for the specified buffer.
933
PJ_DECL(pj_ssize_t) pjsip_msg_print(const pjsip_msg *msg,
934
char *buf, pj_size_t size);
938
* Some usefull macros to find common headers.
943
* Find Call-ID header.
945
* @param msg The message.
946
* @return Call-ID header instance.
948
#define PJSIP_MSG_CID_HDR(msg) \
949
((pjsip_cid_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CALL_ID, NULL))
954
* @param msg The message.
955
* @return CSeq header instance.
957
#define PJSIP_MSG_CSEQ_HDR(msg) \
958
((pjsip_cseq_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CSEQ, NULL))
963
* @param msg The message.
964
* @return From header instance.
966
#define PJSIP_MSG_FROM_HDR(msg) \
967
((pjsip_from_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_FROM, NULL))
972
* @param msg The message.
973
* @return To header instance.
975
#define PJSIP_MSG_TO_HDR(msg) \
976
((pjsip_to_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_TO, NULL))
983
/* **************************************************************************/
985
* @addtogroup PJSIP_MSG_HDR
990
* Generic SIP header, which contains hname and a string hvalue.
991
* Note that this header is not supposed to be used as 'base' class for headers.
993
typedef struct pjsip_generic_string_hdr
995
/** Standard header field. */
996
PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_string_hdr);
999
} pjsip_generic_string_hdr;
1003
* Create a new instance of generic header. A generic header can have an
1004
* arbitrary header name.
1006
* @param pool The pool.
1007
* @param hname The header name to be assigned to the header, or NULL to
1008
* assign the header name with some string.
1009
* @param hvalue Optional string to be assigned as the value.
1011
* @return The header, or THROW exception.
1013
PJ_DECL(pjsip_generic_string_hdr*)
1014
pjsip_generic_string_hdr_create( pj_pool_t *pool,
1015
const pj_str_t *hname,
1016
const pj_str_t *hvalue);
1020
* Initialize a preallocated memory with the header structure. This function
1021
* should only be called when application uses its own memory allocation to
1022
* allocate memory block for the specified header (e.g. in C++, when the
1023
* header is allocated with "new" operator).
1024
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1025
* which allocates memory and initialize it in one go.
1027
* @param pool Pool for additional memory allocation if required.
1028
* @param mem Pre-allocated memory to be initialized as the header.
1029
* @param hname The header name to be assigned to the header, or NULL to
1030
* assign the header name with some string later.
1031
* @param hvalue Optional string to be assigned as the value.
1033
* @return The header instance, which points to the same memory
1034
* location as the mem argument.
1036
PJ_DECL(pjsip_generic_string_hdr*)
1037
pjsip_generic_string_hdr_init( pj_pool_t *pool,
1039
const pj_str_t *hname,
1040
const pj_str_t *hvalue);
1044
* Construct a generic string header without allocating memory from the pool.
1045
* This function is useful to create a temporary header which life-time is
1046
* very short (for example, creating the header in the stack to be passed
1047
* as argument to a function which will copy the header).
1049
* @param h The header to be initialized.
1050
* @param hname The header name to be assigned to the header, or NULL to
1051
* assign the header name with some string.
1052
* @param hvalue Optional string to be assigned as the value.
1054
* @return The header, or THROW exception.
1056
PJ_DECL(void) pjsip_generic_string_hdr_init2(pjsip_generic_string_hdr *h,
1061
/* **************************************************************************/
1064
* Generic SIP header, which contains hname and a string hvalue.
1066
typedef struct pjsip_generic_int_hdr
1068
PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_int_hdr); /**< Standard header field. */
1069
pj_int32_t ivalue; /**< ivalue */
1070
} pjsip_generic_int_hdr;
1074
* Create a new instance of generic header. A generic header can have an
1075
* arbitrary header name.
1077
* @param pool The pool.
1078
* @param hname The header name to be assigned to the header, or NULL to
1079
* assign the header name with some string.
1080
* @param hvalue The value to be assigned to the header.
1082
* @return The header, or THROW exception.
1084
PJ_DECL(pjsip_generic_int_hdr*) pjsip_generic_int_hdr_create( pj_pool_t *pool,
1085
const pj_str_t *hname,
1090
* Initialize a preallocated memory with the header structure. This function
1091
* should only be called when application uses its own memory allocation to
1092
* allocate memory block for the specified header (e.g. in C++, when the
1093
* header is allocated with "new" operator).
1094
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1095
* which allocates memory and initialize it in one go.
1097
* @param pool Pool for additional memory allocation if required.
1098
* @param mem Pre-allocated memory to be initialized as the header.
1099
* @param hname The header name to be assigned to the header, or NULL to
1100
* assign the header name with some string later.
1101
* @param value Value to be assigned to the header.
1103
* @return The header instance, which points to the same memory
1104
* location as the mem argument.
1106
PJ_DECL(pjsip_generic_int_hdr*) pjsip_generic_int_hdr_init( pj_pool_t *pool,
1108
const pj_str_t *hname,
1111
/* **************************************************************************/
1113
/** Maximum elements in the header array. */
1114
#define PJSIP_GENERIC_ARRAY_MAX_COUNT 32
1117
* Generic array of string header.
1119
typedef struct pjsip_generic_array_hdr
1121
/** Standard header fields. */
1122
PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_array_hdr);
1124
/** Number of tags/elements. */
1127
/** Tags/elements. */
1128
pj_str_t values[PJSIP_GENERIC_ARRAY_MAX_COUNT];
1130
} pjsip_generic_array_hdr;
1133
* Create generic array header.
1135
* @param pool Pool to allocate memory from.
1136
* @param hname Header name.
1138
* @return New generic array header.
1140
PJ_DECL(pjsip_generic_array_hdr*) pjsip_generic_array_hdr_create(pj_pool_t *pool,
1141
const pj_str_t *hname);
1144
* Initialize a preallocated memory with the header structure. This function
1145
* should only be called when application uses its own memory allocation to
1146
* allocate memory block for the specified header (e.g. in C++, when the
1147
* header is allocated with "new" operator).
1148
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1149
* which allocates memory and initialize it in one go.
1151
* @param pool Pool for additional memory allocation if required.
1152
* @param mem Pre-allocated memory to be initialized as the header.
1153
* @param hname The header name to be assigned to the header, or NULL to
1154
* assign the header name with some string later.
1156
* @return The header instance, which points to the same memory
1157
* location as the mem argument.
1159
PJ_DECL(pjsip_generic_array_hdr*) pjsip_generic_array_hdr_init(pj_pool_t *pool,
1161
const pj_str_t *hname);
1164
/* **************************************************************************/
1166
/** Accept header. */
1167
typedef pjsip_generic_array_hdr pjsip_accept_hdr;
1169
/** Maximum fields in Accept header. */
1170
#define PJSIP_MAX_ACCEPT_COUNT PJSIP_GENERIC_ARRAY_MAX_COUNT
1173
* Create new Accept header instance.
1175
* @param pool The pool.
1177
* @return New Accept header instance.
1179
PJ_DECL(pjsip_accept_hdr*) pjsip_accept_hdr_create(pj_pool_t *pool);
1182
* Initialize a preallocated memory with the header structure. This function
1183
* should only be called when application uses its own memory allocation to
1184
* allocate memory block for the specified header (e.g. in C++, when the
1185
* header is allocated with "new" operator).
1186
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1187
* which allocates memory and initialize it in one go.
1189
* @param pool Pool for additional memory allocation if required.
1190
* @param mem Pre-allocated memory to be initialized as the header.
1192
* @return The header instance, which points to the same memory
1193
* location as the mem argument.
1195
PJ_DECL(pjsip_accept_hdr*) pjsip_accept_hdr_init( pj_pool_t *pool,
1199
/* **************************************************************************/
1204
typedef pjsip_generic_array_hdr pjsip_allow_hdr;
1207
* Create new Allow header instance.
1209
* @param pool The pool.
1211
* @return New Allow header instance.
1213
PJ_DECL(pjsip_allow_hdr*) pjsip_allow_hdr_create(pj_pool_t *pool);
1218
* Initialize a preallocated memory with the header structure. This function
1219
* should only be called when application uses its own memory allocation to
1220
* allocate memory block for the specified header (e.g. in C++, when the
1221
* header is allocated with "new" operator).
1222
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1223
* which allocates memory and initialize it in one go.
1225
* @param pool Pool for additional memory allocation if required.
1226
* @param mem Pre-allocated memory to be initialized as the header.
1228
* @return The header instance, which points to the same memory
1229
* location as the mem argument.
1231
PJ_DECL(pjsip_allow_hdr*) pjsip_allow_hdr_init( pj_pool_t *pool,
1234
/* **************************************************************************/
1239
typedef struct pjsip_cid_hdr
1241
PJSIP_DECL_HDR_MEMBER(struct pjsip_cid_hdr);
1242
pj_str_t id; /**< Call-ID string. */
1247
* Create new Call-ID header.
1249
* @param pool The pool.
1251
* @return new Call-ID header.
1253
PJ_DECL(pjsip_cid_hdr*) pjsip_cid_hdr_create( pj_pool_t *pool );
1257
* Initialize a preallocated memory with the header structure. This function
1258
* should only be called when application uses its own memory allocation to
1259
* allocate memory block for the specified header (e.g. in C++, when the
1260
* header is allocated with "new" operator).
1261
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1262
* which allocates memory and initialize it in one go.
1264
* @param pool Pool for additional memory allocation if required.
1265
* @param mem Pre-allocated memory to be initialized as the header.
1267
* @return The header instance, which points to the same memory
1268
* location as the mem argument.
1270
PJ_DECL(pjsip_cid_hdr*) pjsip_cid_hdr_init( pj_pool_t *pool,
1275
/* **************************************************************************/
1277
* Content-Length header.
1279
typedef struct pjsip_clen_hdr
1281
PJSIP_DECL_HDR_MEMBER(struct pjsip_clen_hdr);
1282
int len; /**< Content length. */
1286
* Create new Content-Length header.
1288
* @param pool the pool.
1289
* @return A new Content-Length header instance.
1291
PJ_DECL(pjsip_clen_hdr*) pjsip_clen_hdr_create( pj_pool_t *pool );
1294
* Initialize a preallocated memory with the header structure. This function
1295
* should only be called when application uses its own memory allocation to
1296
* allocate memory block for the specified header (e.g. in C++, when the
1297
* header is allocated with "new" operator).
1298
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1299
* which allocates memory and initialize it in one go.
1301
* @param pool Pool for additional memory allocation if required.
1302
* @param mem Pre-allocated memory to be initialized as the header.
1304
* @return The header instance, which points to the same memory
1305
* location as the mem argument.
1307
PJ_DECL(pjsip_clen_hdr*) pjsip_clen_hdr_init( pj_pool_t *pool,
1311
/* **************************************************************************/
1315
typedef struct pjsip_cseq_hdr
1317
PJSIP_DECL_HDR_MEMBER(struct pjsip_cseq_hdr);
1318
pj_int32_t cseq; /**< CSeq number. */
1319
pjsip_method method; /**< CSeq method. */
1323
/** Create new CSeq header.
1325
* @param pool The pool.
1326
* @return A new CSeq header instance.
1328
PJ_DECL(pjsip_cseq_hdr*) pjsip_cseq_hdr_create( pj_pool_t *pool );
1331
* Initialize a preallocated memory with the header structure. This function
1332
* should only be called when application uses its own memory allocation to
1333
* allocate memory block for the specified header (e.g. in C++, when the
1334
* header is allocated with "new" operator).
1335
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1336
* which allocates memory and initialize it in one go.
1338
* @param pool Pool for additional memory allocation if required.
1339
* @param mem Pre-allocated memory to be initialized as the header.
1341
* @return The header instance, which points to the same memory
1342
* location as the mem argument.
1344
PJ_DECL(pjsip_cseq_hdr*) pjsip_cseq_hdr_init( pj_pool_t *pool,
1347
/* **************************************************************************/
1350
* In this library, contact header only contains single URI. If a message has
1351
* multiple URI in the Contact header, the URI will be put in separate Contact
1354
typedef struct pjsip_contact_hdr
1356
PJSIP_DECL_HDR_MEMBER(struct pjsip_contact_hdr);
1357
int star; /**< The contact contains only a '*' character */
1358
pjsip_uri *uri; /**< URI in the contact. */
1359
int q1000; /**< The "q" value times 1000 (to avoid float) */
1360
pj_int32_t expires; /**< Expires parameter, otherwise -1 if not present. */
1361
pjsip_param other_param; /**< Other parameters, concatenated in a single string. */
1362
} pjsip_contact_hdr;
1366
* Create a new Contact header.
1368
* @param pool The pool.
1369
* @return A new instance of Contact header.
1371
PJ_DECL(pjsip_contact_hdr*) pjsip_contact_hdr_create( pj_pool_t *pool );
1374
* Initialize a preallocated memory with the header structure. This function
1375
* should only be called when application uses its own memory allocation to
1376
* allocate memory block for the specified header (e.g. in C++, when the
1377
* header is allocated with "new" operator).
1378
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1379
* which allocates memory and initialize it in one go.
1381
* @param pool Pool for additional memory allocation if required.
1382
* @param mem Pre-allocated memory to be initialized as the header.
1384
* @return The header instance, which points to the same memory
1385
* location as the mem argument.
1387
PJ_DECL(pjsip_contact_hdr*) pjsip_contact_hdr_init( pj_pool_t *pool,
1391
/* **************************************************************************/
1395
typedef struct pjsip_ctype_hdr
1397
PJSIP_DECL_HDR_MEMBER(struct pjsip_ctype_hdr);
1398
pjsip_media_type media; /**< Media type. */
1403
* Create a nwe Content Type header.
1405
* @param pool The pool.
1406
* @return A new Content-Type header.
1408
PJ_DECL(pjsip_ctype_hdr*) pjsip_ctype_hdr_create( pj_pool_t *pool );
1411
* Initialize a preallocated memory with the header structure. This function
1412
* should only be called when application uses its own memory allocation to
1413
* allocate memory block for the specified header (e.g. in C++, when the
1414
* header is allocated with "new" operator).
1415
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1416
* which allocates memory and initialize it in one go.
1418
* @param pool Pool for additional memory allocation if required.
1419
* @param mem Pre-allocated memory to be initialized as the header.
1421
* @return The header instance, which points to the same memory
1422
* location as the mem argument.
1424
PJ_DECL(pjsip_ctype_hdr*) pjsip_ctype_hdr_init( pj_pool_t *pool,
1427
/* **************************************************************************/
1428
/** Expires header. */
1429
typedef pjsip_generic_int_hdr pjsip_expires_hdr;
1432
* Create a new Expires header.
1434
* @param pool The pool.
1435
* @param value The expiration value.
1437
* @return A new Expires header.
1439
PJ_DECL(pjsip_expires_hdr*) pjsip_expires_hdr_create( pj_pool_t *pool,
1443
* Initialize a preallocated memory with the header structure. This function
1444
* should only be called when application uses its own memory allocation to
1445
* allocate memory block for the specified header (e.g. in C++, when the
1446
* header is allocated with "new" operator).
1447
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1448
* which allocates memory and initialize it in one go.
1450
* @param pool Pool for additional memory allocation if required.
1451
* @param mem Pre-allocated memory to be initialized as the header.
1452
* @param value The expiration value.
1454
* @return The header instance, which points to the same memory
1455
* location as the mem argument.
1457
PJ_DECL(pjsip_expires_hdr*) pjsip_expires_hdr_init( pj_pool_t *pool,
1463
/* **************************************************************************/
1465
* To or From header.
1467
typedef struct pjsip_fromto_hdr
1469
PJSIP_DECL_HDR_MEMBER(struct pjsip_fromto_hdr);
1470
pjsip_uri *uri; /**< URI in From/To header. */
1471
pj_str_t tag; /**< Header "tag" parameter. */
1472
pjsip_param other_param; /**< Other params, concatenated as a single string. */
1475
/** Alias for From header. */
1476
typedef pjsip_fromto_hdr pjsip_from_hdr;
1478
/** Alias for To header. */
1479
typedef pjsip_fromto_hdr pjsip_to_hdr;
1482
* Create a From header.
1484
* @param pool The pool.
1485
* @return New instance of From header.
1487
PJ_DECL(pjsip_from_hdr*) pjsip_from_hdr_create( pj_pool_t *pool );
1490
* Initialize a preallocated memory with the header structure. This function
1491
* should only be called when application uses its own memory allocation to
1492
* allocate memory block for the specified header (e.g. in C++, when the
1493
* header is allocated with "new" operator).
1494
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1495
* which allocates memory and initialize it in one go.
1497
* @param pool Pool for additional memory allocation if required.
1498
* @param mem Pre-allocated memory to be initialized as the header.
1500
* @return The header instance, which points to the same memory
1501
* location as the mem argument.
1503
PJ_DECL(pjsip_from_hdr*) pjsip_from_hdr_init( pj_pool_t *pool,
1507
* Create a To header.
1509
* @param pool The pool.
1510
* @return New instance of To header.
1512
PJ_DECL(pjsip_to_hdr*) pjsip_to_hdr_create( pj_pool_t *pool );
1515
* Initialize a preallocated memory with the header structure. This function
1516
* should only be called when application uses its own memory allocation to
1517
* allocate memory block for the specified header (e.g. in C++, when the
1518
* header is allocated with "new" operator).
1519
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1520
* which allocates memory and initialize it in one go.
1522
* @param pool Pool for additional memory allocation if required.
1523
* @param mem Pre-allocated memory to be initialized as the header.
1525
* @return The header instance, which points to the same memory
1526
* location as the mem argument.
1528
PJ_DECL(pjsip_to_hdr*) pjsip_to_hdr_init( pj_pool_t *pool,
1532
* Convert the header to a From header.
1534
* @param hdr The generic from/to header.
1535
* @return "From" header.
1537
PJ_DECL(pjsip_from_hdr*) pjsip_fromto_hdr_set_from( pjsip_fromto_hdr *hdr );
1540
* Convert the header to a To header.
1542
* @param hdr The generic from/to header.
1543
* @return "To" header.
1545
PJ_DECL(pjsip_to_hdr*) pjsip_fromto_hdr_set_to( pjsip_fromto_hdr *hdr );
1548
/* **************************************************************************/
1550
* Max-Forwards header.
1552
typedef pjsip_generic_int_hdr pjsip_max_fwd_hdr;
1555
* Create new Max-Forwards header instance.
1557
* @param pool The pool.
1558
* @param value The Max-Forwards value.
1560
* @return New Max-Forwards header instance.
1562
PJ_DECL(pjsip_max_fwd_hdr*)
1563
pjsip_max_fwd_hdr_create(pj_pool_t *pool, int value);
1567
* Initialize a preallocated memory with the header structure. This function
1568
* should only be called when application uses its own memory allocation to
1569
* allocate memory block for the specified header (e.g. in C++, when the
1570
* header is allocated with "new" operator).
1571
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1572
* which allocates memory and initialize it in one go.
1574
* @param pool Pool for additional memory allocation if required.
1575
* @param mem Pre-allocated memory to be initialized as the header.
1576
* @param value The Max-Forwards value.
1578
* @return The header instance, which points to the same memory
1579
* location as the mem argument.
1581
PJ_DECL(pjsip_max_fwd_hdr*)
1582
pjsip_max_fwd_hdr_init( pj_pool_t *pool, void *mem, int value );
1585
/* **************************************************************************/
1587
* Min-Expires header.
1589
typedef pjsip_generic_int_hdr pjsip_min_expires_hdr;
1592
* Create new Min-Expires header instance.
1594
* @param pool The pool.
1595
* @param value The Min-Expires value.
1597
* @return New Min-Expires header instance.
1599
PJ_DECL(pjsip_min_expires_hdr*) pjsip_min_expires_hdr_create(pj_pool_t *pool,
1604
* Initialize a preallocated memory with the header structure. This function
1605
* should only be called when application uses its own memory allocation to
1606
* allocate memory block for the specified header (e.g. in C++, when the
1607
* header is allocated with "new" operator).
1608
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1609
* which allocates memory and initialize it in one go.
1611
* @param pool Pool for additional memory allocation if required.
1612
* @param mem Pre-allocated memory to be initialized as the header.
1613
* @param value The Min-Expires value.
1615
* @return The header instance, which points to the same memory
1616
* location as the mem argument.
1618
PJ_DECL(pjsip_min_expires_hdr*) pjsip_min_expires_hdr_init( pj_pool_t *pool,
1623
/* **************************************************************************/
1625
* Record-Route and Route headers.
1627
typedef struct pjsip_routing_hdr
1629
PJSIP_DECL_HDR_MEMBER(struct pjsip_routing_hdr); /**< Generic header fields. */
1630
pjsip_name_addr name_addr; /**< The URL in the Route/Record-Route header. */
1631
pjsip_param other_param; /**< Other parameter. */
1632
} pjsip_routing_hdr;
1634
/** Alias for Record-Route header. */
1635
typedef pjsip_routing_hdr pjsip_rr_hdr;
1637
/** Alias for Route header. */
1638
typedef pjsip_routing_hdr pjsip_route_hdr;
1642
* Create new Record-Route header from the pool.
1644
* @param pool The pool.
1645
* @return A new instance of Record-Route header.
1647
PJ_DECL(pjsip_rr_hdr*) pjsip_rr_hdr_create( pj_pool_t *pool );
1650
* Initialize a preallocated memory with the header structure. This function
1651
* should only be called when application uses its own memory allocation to
1652
* allocate memory block for the specified header (e.g. in C++, when the
1653
* header is allocated with "new" operator).
1654
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1655
* which allocates memory and initialize it in one go.
1657
* @param pool Pool for additional memory allocation if required.
1658
* @param mem Pre-allocated memory to be initialized as the header.
1660
* @return The header instance, which points to the same memory
1661
* location as the mem argument.
1663
PJ_DECL(pjsip_rr_hdr*) pjsip_rr_hdr_init( pj_pool_t *pool,
1667
* Create new Route header from the pool.
1669
* @param pool The pool.
1670
* @return A new instance of "Route" header.
1672
PJ_DECL(pjsip_route_hdr*) pjsip_route_hdr_create( pj_pool_t *pool );
1675
* Initialize a preallocated memory with the header structure. This function
1676
* should only be called when application uses its own memory allocation to
1677
* allocate memory block for the specified header (e.g. in C++, when the
1678
* header is allocated with "new" operator).
1679
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1680
* which allocates memory and initialize it in one go.
1682
* @param pool Pool for additional memory allocation if required.
1683
* @param mem Pre-allocated memory to be initialized as the header.
1685
* @return The header instance, which points to the same memory
1686
* location as the mem argument.
1688
PJ_DECL(pjsip_route_hdr*) pjsip_route_hdr_init( pj_pool_t *pool,
1692
* Convert generic routing header to Record-Route header.
1694
* @param r The generic routing header, or a "Routing" header.
1695
* @return Record-Route header.
1697
PJ_DECL(pjsip_rr_hdr*) pjsip_routing_hdr_set_rr( pjsip_routing_hdr *r );
1700
* Convert generic routing header to "Route" header.
1702
* @param r The generic routing header, or a "Record-Route" header.
1703
* @return "Route" header.
1705
PJ_DECL(pjsip_route_hdr*) pjsip_routing_hdr_set_route( pjsip_routing_hdr *r );
1707
/* **************************************************************************/
1711
typedef pjsip_generic_array_hdr pjsip_require_hdr;
1714
* Create new Require header instance.
1716
* @param pool The pool.
1718
* @return New Require header instance.
1720
PJ_DECL(pjsip_require_hdr*) pjsip_require_hdr_create(pj_pool_t *pool);
1723
* Initialize a preallocated memory with the header structure. This function
1724
* should only be called when application uses its own memory allocation to
1725
* allocate memory block for the specified header (e.g. in C++, when the
1726
* header is allocated with "new" operator).
1727
* For normal applications, they should use pjsip_xxx_hdr_create() instead,
1728
* which allocates memory and initialize it in one go.
1730
* @param pool Pool for additional memory allocation if required.
1731
* @param mem Pre-allocated memory to be initialized as the header.
1733
* @return The header instance, which points to the same memory
1734
* location as the mem argument.
1736
PJ_DECL(pjsip_require_hdr*) pjsip_require_hdr_init( pj_pool_t *pool,
1740
/* **************************************************************************/
1742
* Retry-After header.
1744
typedef struct pjsip_retry_after_hdr
1746
/** Standard header field. */
1747
PJSIP_DECL_HDR_MEMBER(struct pjsip_retry_after_hdr);
1748
pj_int32_t ivalue; /**< Retry-After value */
1749
pjsip_param param; /**< Optional parameters */
1750
pj_str_t comment; /**< Optional comments. */
1751
} pjsip_retry_after_hdr;
1755
* Create new Retry-After header instance.
1757
* @param pool The pool.
1758
* @param value The Retry-After value.
1760
* @return New Retry-After header instance.
1762
PJ_DECL(pjsip_retry_after_hdr*) pjsip_retry_after_hdr_create(pj_pool_t *pool,
1766
* Initialize a preallocated memory with the header structure.
1768
* @param pool Pool for additional memory allocation if required.
1769
* @param mem Pre-allocated memory to be initialized as the header.
1770
* @param value The Retry-After value.
1772
* @return The header instance, which points to the same memory
1773
* location as the mem argument.
1775
PJ_DECL(pjsip_retry_after_hdr*) pjsip_retry_after_hdr_init( pj_pool_t *pool,
1780
/* **************************************************************************/
1784
typedef pjsip_generic_array_hdr pjsip_supported_hdr;
1787
* Create new Supported header instance.
1789
* @param pool The pool.
1791
* @return New Supported header instance.
1793
PJ_DECL(pjsip_supported_hdr*) pjsip_supported_hdr_create(pj_pool_t *pool);
1796
* Initialize a preallocated memory with the header structure.
1798
* @param pool Pool for additional memory allocation if required.
1799
* @param mem Pre-allocated memory to be initialized as the header.
1801
* @return The header instance, which points to the same memory
1802
* location as the mem argument.
1804
PJ_DECL(pjsip_supported_hdr*) pjsip_supported_hdr_init( pj_pool_t *pool,
1807
/* **************************************************************************/
1809
* Unsupported header.
1811
typedef pjsip_generic_array_hdr pjsip_unsupported_hdr;
1814
* Create new Unsupported header instance.
1816
* @param pool The pool.
1818
* @return New Unsupported header instance.
1820
PJ_DECL(pjsip_unsupported_hdr*) pjsip_unsupported_hdr_create(pj_pool_t *pool);
1823
* Initialize a preallocated memory with the header structure.
1825
* @param pool Pool for additional memory allocation if required.
1826
* @param mem Pre-allocated memory to be initialized as the header.
1828
* @return The header instance, which points to the same memory
1829
* location as the mem argument.
1831
PJ_DECL(pjsip_unsupported_hdr*) pjsip_unsupported_hdr_init( pj_pool_t *pool,
1834
/* **************************************************************************/
1837
* In this implementation, Via header can only have one element in each header.
1838
* If a message arrives with multiple elements in a single Via, then they will
1839
* be split up into multiple Via headers.
1841
typedef struct pjsip_via_hdr
1843
PJSIP_DECL_HDR_MEMBER(struct pjsip_via_hdr);
1844
pj_str_t transport; /**< Transport type. */
1845
pjsip_host_port sent_by; /**< Host and optional port */
1846
int ttl_param; /**< TTL parameter, or -1 if it's not specified. */
1847
int rport_param; /**< "rport" parameter, 0 to specify without
1848
port number, -1 means doesn't exist. */
1849
pj_str_t maddr_param; /**< "maddr" parameter. */
1850
pj_str_t recvd_param; /**< "received" parameter. */
1851
pj_str_t branch_param; /**< "branch" parameter. */
1852
pjsip_param other_param; /**< Other parameters, concatenated as single string. */
1853
pj_str_t comment; /**< Comment. */
1857
* Create a new Via header.
1859
* @param pool The pool.
1860
* @return A new "Via" header instance.
1862
PJ_DECL(pjsip_via_hdr*) pjsip_via_hdr_create( pj_pool_t *pool );
1865
* Initialize a preallocated memory with the header structure.
1867
* @param pool Pool for additional memory allocation if required.
1868
* @param mem Pre-allocated memory to be initialized as the header.
1870
* @return The header instance, which points to the same memory
1871
* location as the mem argument.
1873
PJ_DECL(pjsip_via_hdr*) pjsip_via_hdr_init( pj_pool_t *pool,
1876
/* **************************************************************************/
1878
* SIP Warning header.
1879
* In this version, Warning header is just a typedef for generic string
1882
typedef pjsip_generic_string_hdr pjsip_warning_hdr;
1885
* Create a warning header with the specified contents.
1887
* @param pool Pool to allocate memory from.
1888
* @param code Warning code, 300-399.
1889
* @param host The host portion of the Warning header.
1890
* @param text The warning text, which MUST not be quoted with
1893
* @return The Warning header field.
1895
PJ_DECL(pjsip_warning_hdr*) pjsip_warning_hdr_create( pj_pool_t *pool,
1897
const pj_str_t *host,
1898
const pj_str_t *text);
1901
* Create a warning header and initialize the contents from the error
1902
* message for the specified status code. The warning code will be
1905
* @param pool Pool to allocate memory from.
1906
* @param host The host portion of the Warning header.
1907
* @param status The error status code, which error text will be
1908
* put in as the Warning text.
1910
* @return The Warning header field.
1912
PJ_DECL(pjsip_warning_hdr*)
1913
pjsip_warning_hdr_create_from_status( pj_pool_t *pool,
1914
const pj_str_t *host,
1915
pj_status_t status);
1917
/* **************************************************************************/
1918
/** Accept-Encoding header. */
1919
typedef pjsip_generic_string_hdr pjsip_accept_encoding_hdr;
1921
/** Create Accept-Encoding header. */
1922
#define pjsip_accept_encoding_hdr_create pjsip_generic_string_hdr_create
1924
/** Accept-Language header. */
1925
typedef pjsip_generic_string_hdr pjsip_accept_lang_hdr;
1927
/** Create Accept-Language header. */
1928
#define pjsip_accept_lang_hdr_create pjsip_generic_string_hdr_create
1930
/** Alert-Info header. */
1931
typedef pjsip_generic_string_hdr pjsip_alert_info_hdr;
1933
/** Create Alert-Info header. */
1934
#define pjsip_alert_info_hdr_create pjsip_generic_string_hdr_create
1936
/** Authentication-Info header. */
1937
typedef pjsip_generic_string_hdr pjsip_auth_info_hdr;
1939
/** Create Authentication-Info header. */
1940
#define pjsip_auth_info_hdr_create pjsip_generic_string_hdr_create
1942
/** Call-Info header. */
1943
typedef pjsip_generic_string_hdr pjsip_call_info_hdr;
1945
/** Create Call-Info header. */
1946
#define pjsip_call_info_hdr_create pjsip_generic_string_hdr_create
1948
/** Content-Disposition header. */
1949
typedef pjsip_generic_string_hdr pjsip_content_disposition_hdr;
1951
/** Create Content-Disposition header. */
1952
#define pjsip_content_disposition_hdr_create pjsip_generic_string_hdr_create
1954
/** Content-Encoding header. */
1955
typedef pjsip_generic_string_hdr pjsip_content_encoding_hdr;
1957
/** Create Content-Encoding header. */
1958
#define pjsip_content_encoding_hdr_create pjsip_generic_string_hdr_create
1960
/** Content-Language header. */
1961
typedef pjsip_generic_string_hdr pjsip_content_lang_hdr;
1963
/** Create Content-Language header. */
1964
#define pjsip_content_lang_hdr_create pjsip_generic_string_hdr_create
1967
typedef pjsip_generic_string_hdr pjsip_date_hdr;
1969
/** Create Date header. */
1970
#define pjsip_date_hdr_create pjsip_generic_string_hdr_create
1972
/** Error-Info header. */
1973
typedef pjsip_generic_string_hdr pjsip_err_info_hdr;
1975
/** Create Error-Info header. */
1976
#define pjsip_err_info_hdr_create pjsip_generic_string_hdr_create
1978
/** In-Reply-To header. */
1979
typedef pjsip_generic_string_hdr pjsip_in_reply_to_hdr;
1981
/** Create In-Reply-To header. */
1982
#define pjsip_in_reply_to_hdr_create pjsip_generic_string_hdr_create
1984
/** MIME-Version header. */
1985
typedef pjsip_generic_string_hdr pjsip_mime_version_hdr;
1987
/** Create MIME-Version header. */
1988
#define pjsip_mime_version_hdr_create pjsip_generic_string_hdr_create
1990
/** Organization header. */
1991
typedef pjsip_generic_string_hdr pjsip_organization_hdr;
1993
/** Create Organization header. */
1994
#define pjsip_organization_hdr_create pjsip_genric_string_hdr_create
1996
/** Priority header. */
1997
typedef pjsip_generic_string_hdr pjsip_priority_hdr;
1999
/** Create Priority header. */
2000
#define pjsip_priority_hdr_create pjsip_generic_string_hdr_create
2002
/** Proxy-Require header. */
2003
typedef pjsip_generic_string_hdr pjsip_proxy_require_hdr;
2005
/** Reply-To header. */
2006
typedef pjsip_generic_string_hdr pjsip_reply_to_hdr;
2008
/** Create Reply-To header. */
2009
#define pjsip_reply_to_hdr_create pjsip_generic_string_hdr_create
2011
/** Server header. */
2012
typedef pjsip_generic_string_hdr pjsip_server_hdr;
2014
/** Create Server header. */
2015
#define pjsip_server_hdr_create pjsip_generic_string_hdr_create
2017
/** Subject header. */
2018
typedef pjsip_generic_string_hdr pjsip_subject_hdr;
2020
/** Create Subject header. */
2021
#define pjsip_subject_hdr_create pjsip_generic_string_hdr_create
2023
/** Timestamp header. */
2024
typedef pjsip_generic_string_hdr pjsip_timestamp_hdr;
2026
/** Create Timestamp header. */
2027
#define pjsip_timestamp_hdr_create pjsip_generic_string_hdr_create
2029
/** User-Agent header. */
2030
typedef pjsip_generic_string_hdr pjsip_user_agent_hdr;
2032
/** Create User-Agent header. */
2033
#define pjsip_user_agent_hdr_create pjsip_generic_string_hdr_create
2047
#endif /* __PJSIP_SIP_MSG_H__ */