Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages
include / osipparser2

osip_message.h

Go to the documentation of this file.
00001 /*
00002  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
00003  Copyright (C) 2001,2002,2003,2004 Aymeric MOIZARD jack@atosc.org
00004 
00005  This library is free software; you can redistribute it and/or
00006  modify it under the terms of the GNU Lesser General Public
00007  License as published by the Free Software Foundation; either
00008  version 2.1 of the License, or (at your option) any later version.
00009 
00010  This library is distributed in the hope that it will be useful,
00011  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00013  Lesser General Public License for more details.
00014 
00015  You should have received a copy of the GNU Lesser General Public
00016  License along with this library; if not, write to the Free Software
00017  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00018 */
00019 
00020 
00021 #ifndef _OSIP_MESSAGE_H_
00022 #define _OSIP_MESSAGE_H_
00023 
00024 #include <osipparser2/osip_const.h>
00025 #include <osipparser2/osip_headers.h>
00026 #include <osipparser2/osip_body.h>
00027 
00041 #ifdef __cplusplus
00042 extern "C"
00043 {
00044 #endif
00045 
00050 typedef struct osip_message osip_message_t;
00051 
00056 struct osip_message
00057 {
00058 char *sip_version; 
00059 osip_uri_t *req_uri; 
00060 char *sip_method; 
00062 int status_code; 
00063 char *reason_phrase; 
00065 osip_list_t *accepts; 
00066 osip_list_t *accept_encodings; 
00067 osip_list_t *accept_languages; 
00068 osip_list_t *alert_infos; 
00069 osip_list_t *allows; 
00070 osip_list_t *authentication_infos;
00071 osip_list_t *authorizations; 
00072 osip_call_id_t *call_id; 
00073 osip_list_t *call_infos; 
00074 osip_list_t *contacts; 
00075 osip_list_t *content_dispositions;
00076 osip_list_t *content_encodings; 
00077 osip_content_length_t *content_length; 
00078 osip_content_type_t *content_type; 
00079 osip_cseq_t *cseq; 
00080 osip_list_t *error_infos; 
00081 osip_from_t *from; 
00082 osip_mime_version_t *mime_version;
00083 osip_list_t *proxy_authenticates; 
00084 osip_list_t *proxy_authentication_infos; 
00085 osip_list_t *proxy_authorizations;
00086 osip_list_t *record_routes; 
00087 osip_list_t *routes; 
00088 osip_to_t *to; 
00089 osip_list_t *vias; 
00090 osip_list_t *www_authenticates; 
00092 osip_list_t *headers; 
00094 osip_list_t *bodies; 
00096 /*
00097  1: structure and buffer "message" are identical.
00098  2: buffer "message" is not up to date with the structure info (call osip_message_to_str to update it).
00099  */
00100 int message_property; 
00101 char *message; 
00102 size_t message_length; 
00104 void *application_data; 
00105 };
00106 
00107 #ifndef SIP_MESSAGE_MAX_LENGTH
00108 
00111 #define SIP_MESSAGE_MAX_LENGTH 4000
00112 #endif
00113 
00114 #ifndef BODY_MESSAGE_MAX_SIZE
00115 
00118 #define BODY_MESSAGE_MAX_SIZE 1000
00119 #endif
00120 
00125 int osip_message_init (osip_message_t ** sip);
00130 void osip_message_free (osip_message_t * sip);
00137 int osip_message_parse (osip_message_t * sip, const char *buf, size_t length);
00144 int osip_message_to_str (osip_message_t * sip, char **dest, size_t *message_length);
00150 int osip_message_clone (const osip_message_t * sip, osip_message_t ** dest);
00151 
00157 void osip_message_set_reason_phrase (osip_message_t * sip, char *reason);
00162 char *osip_message_get_reason_phrase (const osip_message_t * sip);
00168 void osip_message_set_status_code (osip_message_t * sip, int statuscode);
00173 int osip_message_get_status_code (const osip_message_t * sip);
00179 void osip_message_set_method (osip_message_t * sip, char *method);
00184 char *osip_message_get_method (const osip_message_t * sip);
00190 void osip_message_set_version (osip_message_t * sip, char *version);
00195 char *osip_message_get_version (const osip_message_t * sip);
00201 void osip_message_set_uri (osip_message_t * sip, osip_uri_t * uri);
00206 osip_uri_t *osip_message_get_uri (const osip_message_t * sip);
00207 
00208 
00209 /*
00210  * These are helpfull MACROs to test messages type.
00211  */
00216 #define MSG_IS_RESPONSE(msg) ((msg)->status_code!=0)
00217 
00221 #define MSG_IS_REQUEST(msg) ((msg)->status_code==0)
00222 
00227 #define MSG_IS_INVITE(msg) (MSG_IS_REQUEST(msg) && \
00228  0==strcmp((msg)->sip_method,"INVITE"))
00229 
00233 #define MSG_IS_ACK(msg) (MSG_IS_REQUEST(msg) && \
00234  0==strcmp((msg)->sip_method,"ACK"))
00235 
00239 #define MSG_IS_REGISTER(msg) (MSG_IS_REQUEST(msg) && \
00240  0==strcmp((msg)->sip_method,"REGISTER"))
00241 
00245 #define MSG_IS_BYE(msg) (MSG_IS_REQUEST(msg) && \
00246  0==strcmp((msg)->sip_method,"BYE"))
00247 
00251 #define MSG_IS_OPTIONS(msg) (MSG_IS_REQUEST(msg) && \
00252  0==strcmp((msg)->sip_method,"OPTIONS"))
00253 
00257 #define MSG_IS_INFO(msg) (MSG_IS_REQUEST(msg) && \
00258  0==strcmp((msg)->sip_method,"INFO"))
00259 
00263 #define MSG_IS_CANCEL(msg) (MSG_IS_REQUEST(msg) && \
00264  0==strcmp((msg)->sip_method,"CANCEL"))
00265 
00269 #define MSG_IS_REFER(msg) (MSG_IS_REQUEST(msg) && \
00270  0==strcmp((msg)->sip_method,"REFER"))
00271 
00275 #define MSG_IS_NOTIFY(msg) (MSG_IS_REQUEST(msg) && \
00276  0==strcmp((msg)->sip_method,"NOTIFY"))
00277 
00282 #define MSG_IS_SUBSCRIBE(msg) (MSG_IS_REQUEST(msg) && \
00283  0==strcmp((msg)->sip_method,"SUBSCRIBE"))
00284 
00288 #define MSG_IS_MESSAGE(msg) (MSG_IS_REQUEST(msg) && \
00289  0==strcmp((msg)->sip_method,"MESSAGE"))
00290 
00294 #define MSG_IS_PRACK(msg) (MSG_IS_REQUEST(msg) && \
00295  0==strcmp((msg)->sip_method,"PRACK"))
00296 
00297 
00302 #define MSG_IS_UPDATE(msg) (MSG_IS_REQUEST(msg) && \
00303  0==strcmp((msg)->sip_method,"UPDATE"))
00304 
00309 #define MSG_IS_PUBLISH(msg) (MSG_IS_REQUEST(msg) && \
00310  0==strcmp((msg)->sip_method,"PUBLISH"))
00311 
00312 
00317 #define MSG_IS_STATUS_1XX(msg) ((msg)->status_code >= 100 && \
00318  (msg)->status_code < 200)
00319 
00323 #define MSG_IS_STATUS_2XX(msg) ((msg)->status_code >= 200 && \
00324  (msg)->status_code < 300)
00325 
00329 #define MSG_IS_STATUS_3XX(msg) ((msg)->status_code >= 300 && \
00330  (msg)->status_code < 400)
00331 
00335 #define MSG_IS_STATUS_4XX(msg) ((msg)->status_code >= 400 && \
00336  (msg)->status_code < 500)
00337 
00341 #define MSG_IS_STATUS_5XX(msg) ((msg)->status_code >= 500 && \
00342  (msg)->status_code < 600)
00343 
00347 #define MSG_IS_STATUS_6XX(msg) ((msg)->status_code >= 600 && \
00348  (msg)->status_code < 700)
00349 
00354 #define MSG_TEST_CODE(msg,code) (MSG_IS_RESPONSE(msg) && \
00355  (code)==(msg)->status_code)
00356 
00361 #define MSG_IS_RESPONSE_FOR(msg,requestname) (MSG_IS_RESPONSE(msg) && \
00362  0==strcmp((msg)->cseq->method,(requestname)))
00363 
00364 
00369 #define osip_generic_param_init(GP) osip_uri_param_init(GP)
00370 
00374 #define osip_generic_param_free(GP) osip_uri_param_free(GP)
00375 
00381 #define osip_generic_param_set(GP, NAME, VALUE) osip_uri_param_set(GP, NAME, VALUE)
00382 
00387 #define osip_generic_param_clone(GP,DEST) osip_uri_param_clone(GP,DEST)
00388 #ifndef DOXYGEN
00389 /*
00390  * Free a list of a generic parameter element.
00391  * @param LIST The list of generic parameter element to free.
00392  */
00393 #define osip_generic_param_freelist(LIST) osip_uri_param_freelist(LIST)
00394 #endif
00395 
00401 #define osip_generic_param_add(LIST,NAME,VALUE) osip_uri_param_add(LIST,NAME,VALUE)
00402 
00408 #define osip_generic_param_get_byname(LIST,NAME,DEST) osip_uri_param_get_byname(LIST,NAME,DEST)
00409 
00415 void osip_generic_param_set_name (osip_generic_param_t * generic_param,
00416 char *name);
00421 char *osip_generic_param_get_name (const osip_generic_param_t *
00422 generic_param);
00428 void osip_generic_param_set_value (osip_generic_param_t * generic_param,
00429 char *value);
00434 char *osip_generic_param_get_value (const osip_generic_param_t *
00435 generic_param);
00436 
00440 #ifdef __cplusplus
00441 }
00442 #endif
00443 
00444 #endif

Generated on Tue Feb 22 00:59:47 2005 for libosip by doxygen 1.4.1

AltStyle によって変換されたページ (->オリジナル) /