libosip 3.6.0

osip_parser.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,2005,2006,2007 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_PARSER_H_
00022 #define _OSIP_PARSER_H_
00023 
00024 #include <osipparser2/osip_message.h>
00025 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00045         int parser_init(void);
00046 
00051         int osip_message_fix_last_via_header(osip_message_t * request,
00052                                                                                  const char *ip_addr, int port);
00053 
00054 
00065         int osip_message_get__property(const osip_message_t * sip);
00066 
00071         int osip_message_force_update(osip_message_t * sip);
00072 
00077         const char *osip_message_get_reason(int status_code);
00078 
00084 #ifndef MINISIZE
00085         int osip_message_set_accept(osip_message_t * sip, const char *hvalue);
00086 #else
00087 #define osip_message_set_accept(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Accept",value)
00088 #endif
00089 
00095 #ifndef MINISIZE
00096         int osip_message_get_accept(const osip_message_t * sip, int pos,
00097                                                                 osip_accept_t ** dest);
00098 #else
00099 #define osip_message_get_accept(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"accept",pos,(osip_header_t **)dest)
00100 #endif
00101 
00106 #ifndef MINISIZE
00107         int osip_message_set_accept_encoding(osip_message_t * sip, const char *hvalue);
00108 #else
00109 #define osip_message_set_accept_encoding(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Accept-Encoding",value)
00110 #endif
00111 
00117 #ifndef MINISIZE
00118         int osip_message_get_accept_encoding(const osip_message_t * sip, int pos,
00119                                                                                  osip_accept_encoding_t ** dest);
00120 #else
00121 #define osip_message_get_accept_encoding(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"accept-encoding",pos,(osip_header_t **)dest)
00122 #endif
00123 
00128 #ifndef MINISIZE
00129         int osip_message_set_accept_language(osip_message_t * sip, const char *hvalue);
00130 #else
00131 #define osip_message_set_accept_language(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Accept-Language",value)
00132 #endif
00133 
00139 #ifndef MINISIZE
00140         int osip_message_get_accept_language(const osip_message_t * sip, int pos,
00141                                                                                  osip_accept_language_t ** dest);
00142 #else
00143 #define osip_message_get_accept_language(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"accept-language",pos,(osip_header_t **)dest)
00144 #endif
00145 
00150 #ifndef MINISIZE
00151         int osip_message_set_alert_info(osip_message_t * sip, const char *hvalue);
00152 #else
00153 #define osip_message_set_alert_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Alert-Info",value)
00154 #endif
00155 
00161 #ifndef MINISIZE
00162         int osip_message_get_alert_info(const osip_message_t * sip, int pos,
00163                                                                         osip_alert_info_t ** dest);
00164 #else
00165 #define osip_message_get_alert_info(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"alert-info",pos,(osip_header_t **)dest)
00166 #endif
00167 
00172 #ifndef MINISIZE
00173         int osip_message_set_allow(osip_message_t * sip, const char *hvalue);
00174 #else
00175 #define osip_message_set_allow(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Allow",value)
00176 #endif
00177 
00183 #ifndef MINISIZE
00184         int osip_message_get_allow(const osip_message_t * sip, int pos,
00185                                                            osip_allow_t ** dest);
00186 #else
00187 #define osip_message_get_allow(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"allow",pos,(osip_header_t **)dest)
00188 #endif
00189 
00194 #ifndef MINISIZE
00195         int osip_message_set_authentication_info(osip_message_t * sip,
00196                                                                                          const char *hvalue);
00197 #else
00198 #define osip_message_set_authentication_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Authentication-Info",value)
00199 #endif
00200 
00206 #ifndef MINISIZE
00207         int osip_message_get_authentication_info(const osip_message_t * sip,
00208                                                                                          int pos,
00209                                                                                          osip_authentication_info_t ** dest);
00210 #else
00211 #define osip_message_get_authentication_info(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"authentication-info",pos,(osip_header_t **)dest)
00212 #endif
00213 
00218         int osip_message_set_authorization(osip_message_t * sip, const char *hvalue);
00225 #ifndef MINISIZE
00226         int osip_message_get_authorization(const osip_message_t * sip, int pos,
00227                                                                            osip_authorization_t ** dest);
00228 #else
00229 #define osip_message_get_authorization(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->authorizations), pos, (void **)(dest))
00230 #endif
00231 
00236         int osip_message_set_call_id(osip_message_t * sip, const char *hvalue);
00241 #ifndef MINISIZE
00242         osip_call_id_t *osip_message_get_call_id(const osip_message_t * sip);
00243 #else
00244 #define osip_message_get_call_id(sip)   ((sip)->call_id)
00245 #endif
00246 
00251 #ifndef MINISIZE
00252         int osip_message_set_call_info(osip_message_t * sip, const char *hvalue);
00253 #else
00254 #define osip_message_set_call_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Call-Info",value)
00255 #endif
00256 
00262 #ifndef MINISIZE
00263         int osip_message_get_call_info(const osip_message_t * sip, int pos,
00264                                                                    osip_call_info_t ** dest);
00265 #else
00266 #define osip_message_get_call_info(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"call-info",pos,(osip_header_t **)dest)
00267 #endif
00268 
00273         int osip_message_set_contact(osip_message_t * sip, const char *hvalue);
00280 #ifndef MINISIZE
00281         int osip_message_get_contact(const osip_message_t * sip, int pos,
00282                                                                  osip_contact_t ** dest);
00283 #else
00284 #define osip_message_get_contact(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->contacts), pos, (void **)(dest))
00285 #endif
00286 
00291 #ifndef MINISIZE
00292         int osip_message_set_content_encoding(osip_message_t * sip,
00293                                                                                   const char *hvalue);
00294 #else
00295 #define osip_message_set_content_encoding(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Content-Encoding",value)
00296 #endif
00297 
00303 #ifndef MINISIZE
00304         int osip_message_get_content_encoding(const osip_message_t * sip, int pos,
00305                                                                                   osip_content_encoding_t ** dest);
00306 #else
00307 #define osip_message_get_content_encoding(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"content-encoding",pos,(osip_header_t **)dest)
00308 #endif
00309 
00314         int osip_message_set_content_length(osip_message_t * sip, const char *hvalue);
00319 #ifndef MINISIZE
00320         osip_content_length_t *osip_message_get_content_length(const osip_message_t
00321                                                                                                                    * sip);
00322 #else
00323 #define osip_message_get_content_length(sip)   ((sip)->content_length)
00324 #endif
00325 
00330         int osip_message_set_content_type(osip_message_t * sip, const char *hvalue);
00335 #ifndef MINISIZE
00336         osip_content_type_t *osip_message_get_content_type(const osip_message_t * sip);
00337 #else
00338 #define osip_message_get_content_type(sip)    ((sip)->content_type)
00339 #endif
00340 
00345         int osip_message_set_cseq(osip_message_t * sip, const char *hvalue);
00350 #ifndef MINISIZE
00351         osip_cseq_t *osip_message_get_cseq(const osip_message_t * sip);
00352 #else
00353 #define osip_message_get_cseq(sip)  ((sip)->cseq)
00354 #endif
00355 
00360 #ifndef MINISIZE
00361         int osip_message_set_error_info(osip_message_t * sip, const char *hvalue);
00362 #else
00363 #define osip_message_set_error_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Error-Info",value)
00364 #endif
00365 
00371 #ifndef MINISIZE
00372         int osip_message_get_error_info(const osip_message_t * sip, int pos,
00373                                                                         osip_error_info_t ** dest);
00374 #else
00375 #define osip_message_get_error_info(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"error-info",pos,(osip_header_t **)dest)
00376 #endif
00377 
00382         int osip_message_set_from(osip_message_t * sip, const char *hvalue);
00387 #ifndef MINISIZE
00388         osip_from_t *osip_message_get_from(const osip_message_t * sip);
00389 #else
00390 #define osip_message_get_from(sip)   ((sip)->from)
00391 #endif
00392 
00397         int osip_message_set_mime_version(osip_message_t * sip, const char *hvalue);
00402 #ifndef MINISIZE
00403         osip_mime_version_t *osip_message_get_mime_version(const osip_message_t * sip);
00404 #else
00405 #define osip_message_get_mime_version(sip)   ((sip)->mime_version)
00406 #endif
00407 
00412         int osip_message_set_proxy_authenticate(osip_message_t * sip,
00413                                                                                         const char *hvalue);
00420 #ifndef MINISIZE
00421         int osip_message_get_proxy_authenticate(const osip_message_t * sip,
00422                                                                                         int pos,
00423                                                                                         osip_proxy_authenticate_t ** dest);
00424 #else
00425 #define osip_message_get_proxy_authenticate(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->proxy_authenticates), pos, (void **)(dest))
00426 #endif
00427 
00432         int osip_message_set_proxy_authorization(osip_message_t * sip,
00433                                                                                          const char *hvalue);
00440 #ifndef MINISIZE
00441         int osip_message_get_proxy_authorization(const osip_message_t * sip,
00442                                                                                          int pos,
00443                                                                                          osip_proxy_authorization_t ** dest);
00444 #else
00445 #define osip_message_get_proxy_authorization(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->proxy_authorizations), pos, (void **)(dest))
00446 #endif
00447 
00452 #ifndef MINISIZE
00453         int osip_message_set_proxy_authentication_info(osip_message_t * sip,
00454                                                                                                    const char *hvalue);
00455 #else
00456 #define osip_message_set_proxy_authentication_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Proxy-Authentication-Info",value)
00457 #endif
00458 
00464 #ifndef MINISIZE
00465         int osip_message_get_proxy_authentication_info(const osip_message_t * sip,
00466                                                                                                    int pos,
00467                                                                                                    osip_proxy_authentication_info_t
00468                                                                                                    ** dest);
00469 #else
00470 #define osip_message_get_proxy_authentication_info(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"proxy-authentication-info",pos,(osip_header_t **)dest)
00471 #endif
00472 
00477         int osip_message_set_record_route(osip_message_t * sip, const char *hvalue);
00484 #ifndef MINISIZE
00485         int osip_message_get_record_route(const osip_message_t * sip, int pos,
00486                                                                           osip_record_route_t ** dest);
00487 #else
00488 #define osip_message_get_record_route(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->record_routes), pos, (void **)(dest))
00489 #endif
00490 
00495         int osip_message_set_route(osip_message_t * sip, const char *hvalue);
00502 #ifndef MINISIZE
00503         int osip_message_get_route(const osip_message_t * sip, int pos,
00504                                                            osip_route_t ** dest);
00505 #else
00506 #define osip_message_get_route(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->routes), pos, (void **)(dest))
00507 #endif
00508 
00513         int osip_message_set_to(osip_message_t * sip, const char *hvalue);
00518 #ifndef MINISIZE
00519         osip_to_t *osip_message_get_to(const osip_message_t * sip);
00520 #else
00521 #define osip_message_get_to(sip)    ((sip)->to)
00522 #endif
00523 
00528         int osip_message_set_via(osip_message_t * sip, const char *hvalue);
00534         int osip_message_append_via(osip_message_t * sip, const char *hvalue);
00541 #ifndef MINISIZE
00542         int osip_message_get_via(const osip_message_t * sip, int pos,
00543                                                          osip_via_t ** dest);
00544 #else
00545 #define osip_message_get_via(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->vias), pos, (void **)(dest))
00546 #endif
00547 
00552         int osip_message_set_www_authenticate(osip_message_t * sip,
00553                                                                                   const char *hvalue);
00560 #ifndef MINISIZE
00561         int osip_message_get_www_authenticate(const osip_message_t * sip, int pos,
00562                                                                                   osip_www_authenticate_t ** dest);
00563 #else
00564 #define osip_message_get_www_authenticate(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->www_authenticates), pos, (void **)(dest))
00565 #endif
00566 #ifndef DOXYGEN
00567 
00573         int osip_message_set_multiple_header(osip_message_t * sip, char *hname,
00574                                                                                  char *hvalue);
00575 #endif
00576 
00582         int osip_message_set_header(osip_message_t * sip, const char *hname,
00583                                                                 const char *hvalue);
00590         int osip_message_replace_header(osip_message_t * sip, const char *hname,
00591                                                                         const char *hvalue);
00592 #ifndef MINISIZE
00593 
00600         int osip_message_set_topheader(osip_message_t * sip, const char *hname,
00601                                                                    const char *hvalue);
00602 #endif
00603 
00610         int osip_message_header_get_byname(const osip_message_t * sip,
00611                                                                            const char *hname, int pos,
00612                                                                            osip_header_t ** dest);
00619 #ifndef MINISZE
00620         int osip_message_get_header(const osip_message_t * sip, int pos,
00621                                                                 osip_header_t ** dest);
00622 #else
00623 #define osip_message_get_header(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->headers), pos, (void **)(dest))
00624 #endif
00625 
00631         int osip_message_set_body(osip_message_t * sip, const char *buf,
00632                                                           size_t length);
00639         int osip_message_set_body_mime(osip_message_t * sip, const char *buf,
00640                                                                    size_t length);
00647 #ifndef MINISIZE
00648         int osip_message_get_body(const osip_message_t * sip, int pos,
00649                                                           osip_body_t ** dest);
00650 #else
00651 #define osip_message_get_body(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->bodies), pos, (void **)(dest))
00652 #endif
00653 
00654 
00655 
00656 /* trace facilities */
00657 #ifndef DOXYGEN                                 /* avoid DOXYGEN warning */
00658 #ifdef ENABLE_TRACE
00659         void msg_logrequest(osip_message_t * sip, char *fmt);
00660         void msg_logresponse(osip_message_t * sip, char *fmt);
00661 #else
00662 #define msg_logrequest(P,Q) ;
00663 #define msg_logresponse(P,Q) ;
00664 #endif
00665 #endif
00666 
00672 #define osip_message_set_date(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Date",value)
00673 
00679 #define osip_message_get_date(sip,pos,dest)          osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"date",pos,(osip_header_t **)dest)
00680 
00685 #define osip_message_set_encryption(sip,value)      osip_message_set_header((osip_message_t *)sip,(const char *)"Encryption",value)
00686 
00692 #define osip_message_get_encryption(sip,pos,dest)    osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"encryption",pos,(osip_header_t **)dest)
00693 
00698 #define osip_message_set_organization(sip,value)    osip_message_set_header((osip_message_t *)sip,(const char *)"Organization",value)
00699 
00705 #define osip_message_get_organization(sip,pos,dest)  osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"organization",pos,(osip_header_t **)dest)
00706 
00711 #define osip_message_set_require(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Require",value)
00712 
00718 #define osip_message_get_require(sip,pos,dest)       osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"require",pos,(osip_header_t **)dest)
00719 
00724 #define osip_message_set_supported(sip,value)       osip_message_set_header((osip_message_t *)sip,(const char *)"Supported",value)
00725 
00731 #define osip_message_get_supported(sip,pos,dest)     osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"supported",pos,(osip_header_t **)dest)
00732 
00737 #define osip_message_set_timestamp(sip,value)       osip_message_set_header((osip_message_t *)sip,(const char *)"Timestamp",value)
00738 
00744 #define osip_message_get_timestamp(sip,pos,dest)     osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"timestamp",pos,(osip_header_t **)dest)
00745 
00750 #define osip_message_set_user_agent(sip,value)      osip_message_set_header((osip_message_t *)sip,(const char *)"User-Agent",value)
00751 
00757 #define osip_message_get_user_agent(sip,pos,dest)    osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"user-agent",pos,(osip_header_t **)dest)
00758 
00763 #define osip_message_set_content_language(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Content-Language",value)
00764 
00770 #define osip_message_get_content_language(sip,pos,dest) osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"content-language",pos,(osip_header_t **)dest)
00771 
00776 #define osip_message_set_expires(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Expires",value)
00777 
00783 #define osip_message_get_expires(sip,pos,dest)       osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"expires",pos,(osip_header_t **)dest)
00784 
00789 #define osip_message_set_in_reply_to(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"In-Reply-To",value)
00790 
00796 #define osip_message_get_in_reply_to(sip,pos,dest)   osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"in-reply-to",pos,(osip_header_t **)dest)
00797 
00802 #define osip_message_set_max_forwards(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"Max-Forwards",value)
00803 
00809 #define osip_message_get_max_forwards(sip,pos,dest)   osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"max-forwards",pos,(osip_header_t **)dest)
00810 
00815 #define osip_message_set_priority(sip,value)        osip_message_set_header((osip_message_t *)sip,(const char *)"Priority",value)
00816 
00822 #define osip_message_get_priority(sip,pos,dest)      osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"priority",pos,(osip_header_t **)dest)
00823 
00828 #define osip_message_set_proxy_require(sip,value)   osip_message_set_header((osip_message_t *)sip,(const char *)"Proxy-Require",value)
00829 
00835 #define osip_message_get_proxy_require(sip,pos,dest) osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"proxy-require",pos,(osip_header_t **)dest)
00836 
00841 #define osip_message_set_response_key(sip,value)    osip_message_set_header((osip_message_t *)sip,(const char *)"Response-Key",value)
00842 
00848 #define osip_message_get_response_key(sip,pos,dest)  osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"response-key",pos,(osip_header_t **)dest)
00849 
00854 #define osip_message_set_subject(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Subject",value)
00855 
00861 #define osip_message_get_subject(sip,pos,dest)       osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"subject",pos,(osip_header_t **)dest)
00862 
00867 #define osip_message_set_retry_after(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"Retry-After",value)
00868 
00874 #define osip_message_get_retry_after(sip,pos,dest)   osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"retry-after",pos,(osip_header_t **)dest)
00875 
00880 #define osip_message_set_server(sip,value)          osip_message_set_header((osip_message_t *)sip,(const char *)"Server",value)
00881 
00887 #define osip_message_get_server(sip,pos,dest)        osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"server",pos,(osip_header_t **)dest)
00888 
00893 #define osip_message_set_unsupported(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"Unsupported",value)
00894 
00900 #define osip_message_get_unsupported(sip,pos,dest)   osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"unsupported",pos,(osip_header_t **)dest)
00901 
00906 #define osip_message_set_warning(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Warning",value)
00907 
00913 #define osip_message_get_warning(sip,pos,dest)       osip_message_header_get_byname(( osip_message_t *)sip,(const char *)"warning",pos,(osip_header_t **)dest)
00914 
00918 #ifdef __cplusplus
00919 }
00920 #endif
00921 #endif