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 {
00041 #endif
00042 
00046   int parser_init (void);
00047 
00052   int osip_message_fix_last_via_header (osip_message_t * request,
00053                                         const char *ip_addr, int port);
00054 
00055 
00066   int osip_message_get__property (const osip_message_t * sip);
00067 
00072   int osip_message_force_update (osip_message_t * sip);
00073 
00078   const char *osip_message_get_reason (int status_code);
00079 
00085 #ifndef MINISIZE
00086   int osip_message_set_accept (osip_message_t * sip, const char *hvalue);
00087 #else
00088 #define osip_message_set_accept(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Accept",value)
00089 #endif
00090 
00096 #ifndef MINISIZE
00097   int osip_message_get_accept (const osip_message_t * sip, int pos,
00098                                osip_accept_t ** dest);
00099 #else
00100 #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)
00101 #endif
00102 
00107 #ifndef MINISIZE
00108   int osip_message_set_accept_encoding (osip_message_t * sip, const char *hvalue);
00109 #else
00110 #define osip_message_set_accept_encoding(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Accept-Encoding",value)
00111 #endif
00112 
00118 #ifndef MINISIZE
00119   int osip_message_get_accept_encoding (const osip_message_t * sip, int pos,
00120                                         osip_accept_encoding_t ** dest);
00121 #else
00122 #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)
00123 #endif
00124 
00129 #ifndef MINISIZE
00130   int osip_message_set_accept_language (osip_message_t * sip, const char *hvalue);
00131 #else
00132 #define osip_message_set_accept_language(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Accept-Language",value)
00133 #endif
00134 
00140 #ifndef MINISIZE
00141   int osip_message_get_accept_language (const osip_message_t * sip, int pos,
00142                                         osip_accept_language_t ** dest);
00143 #else
00144 #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)
00145 #endif
00146 
00151 #ifndef MINISIZE
00152   int osip_message_set_alert_info (osip_message_t * sip, const char *hvalue);
00153 #else
00154 #define osip_message_set_alert_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Alert-Info",value)
00155 #endif
00156 
00162 #ifndef MINISIZE
00163   int osip_message_get_alert_info (const osip_message_t * sip, int pos,
00164                                    osip_alert_info_t ** dest);
00165 #else
00166 #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)
00167 #endif
00168 
00173 #ifndef MINISIZE
00174   int osip_message_set_allow (osip_message_t * sip, const char *hvalue);
00175 #else
00176 #define osip_message_set_allow(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Allow",value)
00177 #endif
00178 
00184 #ifndef MINISIZE
00185   int osip_message_get_allow (const osip_message_t * sip, int pos,
00186                               osip_allow_t ** dest);
00187 #else
00188 #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)
00189 #endif
00190 
00195 #ifndef MINISIZE
00196   int osip_message_set_authentication_info (osip_message_t * sip,
00197                                             const char *hvalue);
00198 #else
00199 #define osip_message_set_authentication_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Authentication-Info",value)
00200 #endif
00201 
00207 #ifndef MINISIZE
00208   int osip_message_get_authentication_info (const osip_message_t * sip,
00209                                             int pos,
00210                                             osip_authentication_info_t ** dest);
00211 #else
00212 #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)
00213 #endif
00214 
00219   int osip_message_set_authorization (osip_message_t * sip, const char *hvalue);
00226 #ifndef MINISIZE
00227   int osip_message_get_authorization (const osip_message_t * sip, int pos,
00228                                       osip_authorization_t ** dest);
00229 #else
00230 #define osip_message_get_authorization(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->authorizations), pos, (void **)(dest))
00231 #endif
00232 
00237   int osip_message_set_call_id (osip_message_t * sip, const char *hvalue);
00242 #ifndef MINISIZE
00243   osip_call_id_t *osip_message_get_call_id (const osip_message_t * sip);
00244 #else
00245 #define osip_message_get_call_id(sip)   ((sip)->call_id)
00246 #endif
00247 
00252 #ifndef MINISIZE
00253   int osip_message_set_call_info (osip_message_t * sip, const char *hvalue);
00254 #else
00255 #define osip_message_set_call_info(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Call-Info",value)
00256 #endif
00257 
00263 #ifndef MINISIZE
00264   int osip_message_get_call_info (const osip_message_t * sip, int pos,
00265                                   osip_call_info_t ** dest);
00266 #else
00267 #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)
00268 #endif
00269 
00274   int osip_message_set_contact (osip_message_t * sip, const char *hvalue);
00281 #ifndef MINISIZE
00282   int osip_message_get_contact (const osip_message_t * sip, int pos,
00283                                 osip_contact_t ** dest);
00284 #else
00285 #define osip_message_get_contact(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->contacts), pos, (void **)(dest)) 
00286 #endif
00287 
00292 #ifndef MINISIZE
00293   int osip_message_set_content_encoding (osip_message_t * sip, 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, const char *hvalue);
00559 #ifndef MINISIZE
00560   int osip_message_get_www_authenticate (const osip_message_t * sip, int pos,
00561                                          osip_www_authenticate_t ** dest);
00562 #else
00563 #define osip_message_get_www_authenticate(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->www_authenticates), pos, (void **)(dest)) 
00564 #endif
00565 #ifndef DOXYGEN
00566 
00572   int osip_message_set_multiple_header (osip_message_t * sip, char *hname,
00573                                         char *hvalue);
00574 #endif
00575 
00581   int osip_message_set_header (osip_message_t * sip, const char *hname,
00582                                const char *hvalue);
00589   int osip_message_replace_header (osip_message_t * sip, const char *hname,
00590                                    const char *hvalue);
00591 #ifndef MINISIZE
00592 
00599   int osip_message_set_topheader (osip_message_t * sip, const char *hname,
00600                                   const char *hvalue);
00601 #endif
00602 
00609   int osip_message_header_get_byname (const osip_message_t * sip,
00610                                       const char *hname, int pos,
00611                                       osip_header_t ** dest);
00618 #ifndef MINISZE
00619   int osip_message_get_header (const osip_message_t * sip, int pos,
00620                                osip_header_t ** dest);
00621 #else
00622 #define osip_message_get_header(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->headers), pos, (void **)(dest)) 
00623 #endif
00624 
00630   int osip_message_set_body (osip_message_t * sip, const char *buf, size_t length);
00637   int osip_message_set_body_mime (osip_message_t * sip, const char *buf,
00638                                   size_t length);
00645 #ifndef MINISIZE
00646   int osip_message_get_body (const osip_message_t * sip, int pos,
00647                              osip_body_t ** dest);
00648 #else
00649 #define osip_message_get_body(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->bodies), pos, (void **)(dest)) 
00650 #endif
00651 
00652 
00653 
00654 /* trace facilities */
00655 #ifndef DOXYGEN                 /* avoid DOXYGEN warning */
00656 #ifdef ENABLE_TRACE
00657   void msg_logrequest (osip_message_t * sip, char *fmt);
00658   void msg_logresponse (osip_message_t * sip, char *fmt);
00659 #else
00660 #define msg_logrequest(P,Q) ;
00661 #define msg_logresponse(P,Q) ;
00662 #endif
00663 #endif
00664 
00670 #define osip_message_set_date(sip,value)            osip_message_set_header((osip_message_t *)sip,(const char *)"Date",value)
00671 
00677 #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)
00678 
00683 #define osip_message_set_encryption(sip,value)      osip_message_set_header((osip_message_t *)sip,(const char *)"Encryption",value)
00684 
00690 #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)
00691 
00696 #define osip_message_set_organization(sip,value)    osip_message_set_header((osip_message_t *)sip,(const char *)"Organization",value)
00697 
00703 #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)
00704 
00709 #define osip_message_set_require(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Require",value)
00710 
00716 #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)
00717 
00722 #define osip_message_set_supported(sip,value)       osip_message_set_header((osip_message_t *)sip,(const char *)"Supported",value)
00723 
00729 #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)
00730 
00735 #define osip_message_set_timestamp(sip,value)       osip_message_set_header((osip_message_t *)sip,(const char *)"Timestamp",value)
00736 
00742 #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)
00743 
00748 #define osip_message_set_user_agent(sip,value)      osip_message_set_header((osip_message_t *)sip,(const char *)"User-Agent",value)
00749 
00755 #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)
00756 
00761 #define osip_message_set_content_language(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Content-Language",value)
00762 
00768 #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)
00769 
00774 #define osip_message_set_expires(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Expires",value)
00775 
00781 #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)
00782 
00787 #define osip_message_set_in_reply_to(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"In-Reply-To",value)
00788 
00794 #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)
00795 
00800 #define osip_message_set_max_forwards(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"Max-Forwards",value)
00801 
00807 #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)
00808 
00813 #define osip_message_set_priority(sip,value)        osip_message_set_header((osip_message_t *)sip,(const char *)"Priority",value)
00814 
00820 #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)
00821 
00826 #define osip_message_set_proxy_require(sip,value)   osip_message_set_header((osip_message_t *)sip,(const char *)"Proxy-Require",value)
00827 
00833 #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)
00834 
00839 #define osip_message_set_response_key(sip,value)    osip_message_set_header((osip_message_t *)sip,(const char *)"Response-Key",value)
00840 
00846 #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)
00847 
00852 #define osip_message_set_subject(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Subject",value)
00853 
00859 #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)
00860 
00865 #define osip_message_set_retry_after(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"Retry-After",value)
00866 
00872 #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)
00873 
00878 #define osip_message_set_server(sip,value)          osip_message_set_header((osip_message_t *)sip,(const char *)"Server",value)
00879 
00885 #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)
00886 
00891 #define osip_message_set_unsupported(sip,value)     osip_message_set_header((osip_message_t *)sip,(const char *)"Unsupported",value)
00892 
00898 #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)
00899 
00904 #define osip_message_set_warning(sip,value)         osip_message_set_header((osip_message_t *)sip,(const char *)"Warning",value)
00905 
00911 #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)
00912 
00916 #ifdef __cplusplus
00917 }
00918 #endif
00919 
00920 #endif

Generated on Wed Feb 13 01:03:29 2008 for libosip by  doxygen 1.5.4