1 /*
2 The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3 Copyright (C) 2001-2015 Aymeric MOIZARD amoizard@antisip.com
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20
21 #ifndef _OSIP_MESSAGE_H_
22 #define _OSIP_MESSAGE_H_
23
27
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
50
63 #ifndef MINISIZE
70 #endif
75 #ifndef MINISIZE
77 #endif
81 #ifndef MINISIZE
83 #endif
87 #ifndef MINISIZE
89 #endif
101 /*
102 1: structure and buffer "message" are identical.
103 2: buffer "message" is not up to date with the structure info (call osip_message_to_str to update it).
104 */
110 };
111
112 #ifndef SIP_MESSAGE_MAX_LENGTH
113
116 #define SIP_MESSAGE_MAX_LENGTH 8000
117 #endif
118
119 #ifndef BODY_MESSAGE_MAX_SIZE
120
123 #define BODY_MESSAGE_MAX_SIZE 4000
124 #endif
125
175
231
232
233 /*
234 * These are helpfull MACROs to test messages type.
235 */
240 #define MSG_IS_RESPONSE(msg) ((msg)->status_code!=0)
241
245 #define MSG_IS_REQUEST(msg) ((msg)->status_code==0)
246
251 #define MSG_IS_INVITE(msg) (MSG_IS_REQUEST(msg) && \
252 0==strcmp((msg)->sip_method,"INVITE"))
253
257 #define MSG_IS_ACK(msg) (MSG_IS_REQUEST(msg) && \
258 0==strcmp((msg)->sip_method,"ACK"))
259
263 #define MSG_IS_REGISTER(msg) (MSG_IS_REQUEST(msg) && \
264 0==strcmp((msg)->sip_method,"REGISTER"))
265
269 #define MSG_IS_BYE(msg) (MSG_IS_REQUEST(msg) && \
270 0==strcmp((msg)->sip_method,"BYE"))
271
275 #define MSG_IS_OPTIONS(msg) (MSG_IS_REQUEST(msg) && \
276 0==strcmp((msg)->sip_method,"OPTIONS"))
277
281 #define MSG_IS_INFO(msg) (MSG_IS_REQUEST(msg) && \
282 0==strcmp((msg)->sip_method,"INFO"))
283
287 #define MSG_IS_CANCEL(msg) (MSG_IS_REQUEST(msg) && \
288 0==strcmp((msg)->sip_method,"CANCEL"))
289
293 #define MSG_IS_REFER(msg) (MSG_IS_REQUEST(msg) && \
294 0==strcmp((msg)->sip_method,"REFER"))
295
299 #define MSG_IS_NOTIFY(msg) (MSG_IS_REQUEST(msg) && \
300 0==strcmp((msg)->sip_method,"NOTIFY"))
301
306 #define MSG_IS_SUBSCRIBE(msg) (MSG_IS_REQUEST(msg) && \
307 0==strcmp((msg)->sip_method,"SUBSCRIBE"))
308
312 #define MSG_IS_MESSAGE(msg) (MSG_IS_REQUEST(msg) && \
313 0==strcmp((msg)->sip_method,"MESSAGE"))
314
318 #define MSG_IS_PRACK(msg) (MSG_IS_REQUEST(msg) && \
319 0==strcmp((msg)->sip_method,"PRACK"))
320
321
326 #define MSG_IS_UPDATE(msg) (MSG_IS_REQUEST(msg) && \
327 0==strcmp((msg)->sip_method,"UPDATE"))
328
333 #define MSG_IS_PUBLISH(msg) (MSG_IS_REQUEST(msg) && \
334 0==strcmp((msg)->sip_method,"PUBLISH"))
335
336
341 #define MSG_IS_STATUS_1XX(msg) ((msg)->status_code >= 100 && \
342 (msg)->status_code < 200)
343
347 #define MSG_IS_STATUS_2XX(msg) ((msg)->status_code >= 200 && \
348 (msg)->status_code < 300)
349
353 #define MSG_IS_STATUS_3XX(msg) ((msg)->status_code >= 300 && \
354 (msg)->status_code < 400)
355
359 #define MSG_IS_STATUS_4XX(msg) ((msg)->status_code >= 400 && \
360 (msg)->status_code < 500)
361
365 #define MSG_IS_STATUS_5XX(msg) ((msg)->status_code >= 500 && \
366 (msg)->status_code < 600)
367
371 #define MSG_IS_STATUS_6XX(msg) ((msg)->status_code >= 600 && \
372 (msg)->status_code < 700)
373
378 #define MSG_TEST_CODE(msg,code) (MSG_IS_RESPONSE(msg) && \
379 (code)==(msg)->status_code)
380
385 #define MSG_IS_RESPONSE_FOR(msg,requestname) (MSG_IS_RESPONSE(msg) && \
386 0==strcmp((msg)->cseq->method,(requestname)))
387
388
393 #define osip_generic_param_init(GP) osip_uri_param_init(GP)
394
398 #define osip_generic_param_free(GP) osip_uri_param_free(GP)
399
405 #define osip_generic_param_set(GP, NAME, VALUE) osip_uri_param_set(GP, NAME, VALUE)
406
411 #define osip_generic_param_clone osip_uri_param_clone
412 #ifndef DOXYGEN
413 /*
414 * Free a list of a generic parameter element.
415 * @param LIST The list of generic parameter element to free.
416 */
417 #define osip_generic_param_freelist(LIST) osip_uri_param_freelist(LIST)
418 #endif
419
425 #define osip_generic_param_add(LIST,NAME,VALUE) osip_uri_param_add(LIST,NAME,VALUE)
426
432 #define osip_generic_param_get_byname(LIST,NAME,DEST) osip_uri_param_get_byname(LIST,NAME,DEST)
433
456
457
465
469 #ifdef __cplusplus
470 }
471 #endif
472 #endif
Structure for referencing a list of elements.
Structure for SIP Message (REQUEST and RESPONSE).
void osip_message_set_method(osip_message_t *sip, char *method)
Set the method.
osip_list_t contacts
Contacts headers.
Definition of the CSeq header.
osip_list_t routes
Route headers.
osip_list_t content_encodings
Content-Encodings headers.
char * osip_message_get_version(const osip_message_t *sip)
Get the SIP version.
osip_list_t allows
Allows headers.
Definition of the Content-Length header.
char * reason_phrase
Reason Phrase (SIP answer only)
char * osip_message_get_reason_phrase(const osip_message_t *sip)
Get the reason phrase.
oSIP SIP Message Body Routines
void osip_message_set_version(osip_message_t *sip, char *version)
Set the SIP version used.
osip_content_length_t * content_length
Content-Length header.
osip_list_t record_routes
Record-Route headers.
size_t message_length
internal value
void * application_data
can be used by upper layer
void osip_generic_param_set_value(osip_generic_param_t *generic_param, char *value)
Set the value of a generic parameter element.
osip_from_t * from
From header.
int osip_message_get_knownheaderlist(osip_list_t *header_list, int pos, void **dest)
Get the a known header from a list of known header.
osip_list_t accept_languages
Accept-Language headers.
osip_content_type_t * content_type
Content-Type header.
Definition of the Content-Type header.
int osip_message_get_status_code(const osip_message_t *sip)
Get the status code.
osip_list_t authorizations
Authorizations headers.
int message_property
internal value
char * osip_message_get_method(const osip_message_t *sip)
Get the method name.
void osip_message_free(osip_message_t *sip)
Free all resource in a osip_message_t element.
void osip_message_set_reason_phrase(osip_message_t *sip, char *reason)
Set the reason phrase.
osip_uri_t * req_uri
Request-Uri (SIP request only)
osip_cseq_t * cseq
CSeq header.
void osip_generic_param_set_name(osip_generic_param_t *generic_param, char *name)
Set the name of a generic parameter element.
osip_list_t proxy_authorizations
Proxy-authorization headers.
osip_uri_t * osip_message_get_uri(const osip_message_t *sip)
Get the Request-URI.
int osip_message_clone(const osip_message_t *sip, osip_message_t **dest)
Clone a osip_message_t element.
char * message
internal value
Definition of the From header.
int osip_message_parse(osip_message_t *sip, const char *buf, size_t length)
Parse a osip_message_t element.
char * sip_version
SIP version (SIP request only)
void osip_message_set_uri(osip_message_t *sip, osip_uri_t *uri)
Set the Request-URI.
osip_list_t www_authenticates
WWW-Authenticate headers.
osip_list_t accept_encodings
Accept-Encoding headers.
int osip_message_to_str(osip_message_t *sip, char **dest, size_t *message_length)
Get a string representation of a osip_message_t element.
int osip_message_parse_sipfrag(osip_message_t *sip, const char *buf, size_t length)
Parse a message/sipfrag part and store it in an osip_message_t element.
osip_list_t accepts
Accept headers.
char * osip_generic_param_get_value(const osip_generic_param_t *generic_param)
Get the value of a generic parameter element.
osip_list_t proxy_authentication_infos
P-Authentication-Info headers.
osip_list_t vias
Vias headers.
void osip_message_set_status_code(osip_message_t *sip, int statuscode)
Set the status code.
osip_list_t proxy_authenticates
Proxy-Authenticate headers.
osip_list_t alert_infos
Alert-Info headers.
int osip_message_to_str_sipfrag(osip_message_t *sip, char **dest, size_t *message_length)
Get a string representation of a message/sipfrag part stored in an osip_message_t element...
int status_code
Status Code (SIP answer only)
osip_mime_version_t * mime_version
Mime-Version header.
Definition of the Call-Id header.
Structure for referencing url parameters.
char * sip_method
METHOD (SIP request only)
osip_call_id_t * call_id
Call-ID header.
Structure for referencing SIP urls.
char * osip_generic_param_get_name(const osip_generic_param_t *generic_param)
Get the name of a generic parameter element.
int osip_message_init(osip_message_t **sip)
Allocate a osip_message_t element.
osip_list_t call_infos
Call-Infos header.
osip_list_t bodies
List of attachements.
osip_list_t authentication_infos
authentication_info headers
osip_list_t headers
Other headers.
osip_list_t error_infos
Error-Info headers.