libosip  4.0.0
osip_parser.h
Go to the documentation of this file.
1 /*
2  The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3  Copyright (C) 2001-2012 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_PARSER_H_
22 #define _OSIP_PARSER_H_
23 
25 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
45  int parser_init (void);
46 
51  int osip_message_fix_last_via_header (osip_message_t * request, const char *ip_addr, int port);
52 
53 
65 
71 
76  const char *osip_message_get_reason (int status_code);
77 
83 #ifndef MINISIZE
84  int osip_message_set_accept (osip_message_t * sip, const char *hvalue);
85 #else
86 #define osip_message_set_accept(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Accept",value)
87 #endif
88 
94 #ifndef MINISIZE
95  int osip_message_get_accept (const osip_message_t * sip, int pos, osip_accept_t ** dest);
96 #else
97 #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)
98 #endif
99 
104 #ifndef MINISIZE
105  int osip_message_set_accept_encoding (osip_message_t * sip, const char *hvalue);
106 #else
107 #define osip_message_set_accept_encoding(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Accept-Encoding",value)
108 #endif
109 
115 #ifndef MINISIZE
116  int osip_message_get_accept_encoding (const osip_message_t * sip, int pos, osip_accept_encoding_t ** dest);
117 #else
118 #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)
119 #endif
120 
125 #ifndef MINISIZE
126  int osip_message_set_accept_language (osip_message_t * sip, const char *hvalue);
127 #else
128 #define osip_message_set_accept_language(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Accept-Language",value)
129 #endif
130 
136 #ifndef MINISIZE
137  int osip_message_get_accept_language (const osip_message_t * sip, int pos, osip_accept_language_t ** dest);
138 #else
139 #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)
140 #endif
141 
146 #ifndef MINISIZE
147  int osip_message_set_alert_info (osip_message_t * sip, const char *hvalue);
148 #else
149 #define osip_message_set_alert_info(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Alert-Info",value)
150 #endif
151 
157 #ifndef MINISIZE
158  int osip_message_get_alert_info (const osip_message_t * sip, int pos, osip_alert_info_t ** dest);
159 #else
160 #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)
161 #endif
162 
167 #ifndef MINISIZE
168  int osip_message_set_allow (osip_message_t * sip, const char *hvalue);
169 #else
170 #define osip_message_set_allow(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Allow",value)
171 #endif
172 
178 #ifndef MINISIZE
179  int osip_message_get_allow (const osip_message_t * sip, int pos, osip_allow_t ** dest);
180 #else
181 #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)
182 #endif
183 
188 #ifndef MINISIZE
189  int osip_message_set_authentication_info (osip_message_t * sip, const char *hvalue);
190 #else
191 #define osip_message_set_authentication_info(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Authentication-Info",value)
192 #endif
193 
199 #ifndef MINISIZE
201 #else
202 #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)
203 #endif
204 
209  int osip_message_set_authorization (osip_message_t * sip, const char *hvalue);
216 #ifndef MINISIZE
217  int osip_message_get_authorization (const osip_message_t * sip, int pos, osip_authorization_t ** dest);
218 #else
219 #define osip_message_get_authorization(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->authorizations), pos, (void **)(dest))
220 #endif
221 
226  int osip_message_set_call_id (osip_message_t * sip, const char *hvalue);
231 #ifndef MINISIZE
233 #else
234 #define osip_message_get_call_id(sip) ((sip)->call_id)
235 #endif
236 
241 #ifndef MINISIZE
242  int osip_message_set_call_info (osip_message_t * sip, const char *hvalue);
243 #else
244 #define osip_message_set_call_info(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Call-Info",value)
245 #endif
246 
252 #ifndef MINISIZE
253  int osip_message_get_call_info (const osip_message_t * sip, int pos, osip_call_info_t ** dest);
254 #else
255 #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)
256 #endif
257 
262  int osip_message_set_contact (osip_message_t * sip, const char *hvalue);
269 #ifndef MINISIZE
270  int osip_message_get_contact (const osip_message_t * sip, int pos, osip_contact_t ** dest);
271 #else
272 #define osip_message_get_contact(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->contacts), pos, (void **)(dest))
273 #endif
274 
279 #ifndef MINISIZE
280  int osip_message_set_content_encoding (osip_message_t * sip, const char *hvalue);
281 #else
282 #define osip_message_set_content_encoding(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Content-Encoding",value)
283 #endif
284 
290 #ifndef MINISIZE
292 #else
293 #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)
294 #endif
295 
300  int osip_message_set_content_length (osip_message_t * sip, const char *hvalue);
305 #ifndef MINISIZE
307 #else
308 #define osip_message_get_content_length(sip) ((sip)->content_length)
309 #endif
310 
315  int osip_message_set_content_type (osip_message_t * sip, const char *hvalue);
320 #ifndef MINISIZE
322 #else
323 #define osip_message_get_content_type(sip) ((sip)->content_type)
324 #endif
325 
330  int osip_message_set_cseq (osip_message_t * sip, const char *hvalue);
335 #ifndef MINISIZE
337 #else
338 #define osip_message_get_cseq(sip) ((sip)->cseq)
339 #endif
340 
345 #ifndef MINISIZE
346  int osip_message_set_error_info (osip_message_t * sip, const char *hvalue);
347 #else
348 #define osip_message_set_error_info(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Error-Info",value)
349 #endif
350 
356 #ifndef MINISIZE
357  int osip_message_get_error_info (const osip_message_t * sip, int pos, osip_error_info_t ** dest);
358 #else
359 #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)
360 #endif
361 
366  int osip_message_set_from (osip_message_t * sip, const char *hvalue);
371 #ifndef MINISIZE
373 #else
374 #define osip_message_get_from(sip) ((sip)->from)
375 #endif
376 
381  int osip_message_set_mime_version (osip_message_t * sip, const char *hvalue);
386 #ifndef MINISIZE
388 #else
389 #define osip_message_get_mime_version(sip) ((sip)->mime_version)
390 #endif
391 
396  int osip_message_set_proxy_authenticate (osip_message_t * sip, const char *hvalue);
403 #ifndef MINISIZE
405 #else
406 #define osip_message_get_proxy_authenticate(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->proxy_authenticates), pos, (void **)(dest))
407 #endif
408 
413  int osip_message_set_proxy_authorization (osip_message_t * sip, const char *hvalue);
420 #ifndef MINISIZE
422 #else
423 #define osip_message_get_proxy_authorization(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->proxy_authorizations), pos, (void **)(dest))
424 #endif
425 
430 #ifndef MINISIZE
431  int osip_message_set_proxy_authentication_info (osip_message_t * sip, const char *hvalue);
432 #else
433 #define osip_message_set_proxy_authentication_info(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Proxy-Authentication-Info",value)
434 #endif
435 
441 #ifndef MINISIZE
443 #else
444 #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)
445 #endif
446 
451  int osip_message_set_record_route (osip_message_t * sip, const char *hvalue);
458 #ifndef MINISIZE
459  int osip_message_get_record_route (const osip_message_t * sip, int pos, osip_record_route_t ** dest);
460 #else
461 #define osip_message_get_record_route(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->record_routes), pos, (void **)(dest))
462 #endif
463 
468  int osip_message_set_route (osip_message_t * sip, const char *hvalue);
475 #ifndef MINISIZE
476  int osip_message_get_route (const osip_message_t * sip, int pos, osip_route_t ** dest);
477 #else
478 #define osip_message_get_route(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->routes), pos, (void **)(dest))
479 #endif
480 
485  int osip_message_set_to (osip_message_t * sip, const char *hvalue);
490 #ifndef MINISIZE
492 #else
493 #define osip_message_get_to(sip) ((sip)->to)
494 #endif
495 
500  int osip_message_set_via (osip_message_t * sip, const char *hvalue);
506  int osip_message_append_via (osip_message_t * sip, const char *hvalue);
513 #ifndef MINISIZE
514  int osip_message_get_via (const osip_message_t * sip, int pos, osip_via_t ** dest);
515 #else
516 #define osip_message_get_via(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->vias), pos, (void **)(dest))
517 #endif
518 
523  int osip_message_set_www_authenticate (osip_message_t * sip, const char *hvalue);
530 #ifndef MINISIZE
532 #else
533 #define osip_message_get_www_authenticate(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->www_authenticates), pos, (void **)(dest))
534 #endif
535 #ifndef DOXYGEN
536 
542  int osip_message_set_multiple_header (osip_message_t * sip, char *hname, char *hvalue);
543 #endif
544 
550  int osip_message_set_header (osip_message_t * sip, const char *hname, const char *hvalue);
557  int osip_message_replace_header (osip_message_t * sip, const char *hname, const char *hvalue);
558 #ifndef MINISIZE
559 
566  int osip_message_set_topheader (osip_message_t * sip, const char *hname, const char *hvalue);
567 #endif
568 
575  int osip_message_header_get_byname (const osip_message_t * sip, const char *hname, int pos, osip_header_t ** dest);
582 #ifndef MINISZE
583  int osip_message_get_header (const osip_message_t * sip, int pos, osip_header_t ** dest);
584 #else
585 #define osip_message_get_header(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->headers), pos, (void **)(dest))
586 #endif
587 
593  int osip_message_set_body (osip_message_t * sip, const char *buf, size_t length);
600  int osip_message_set_body_mime (osip_message_t * sip, const char *buf, size_t length);
607 #ifndef MINISIZE
608  int osip_message_get_body (const osip_message_t * sip, int pos, osip_body_t ** dest);
609 #else
610 #define osip_message_get_body(sip, pos, dest) osip_message_get_knownheaderlist((&(sip)->bodies), pos, (void **)(dest))
611 #endif
612 
613 
614 
615 /* trace facilities */
616 #ifndef DOXYGEN /* avoid DOXYGEN warning */
617 #ifdef ENABLE_TRACE
618  void msg_logrequest (osip_message_t * sip, char *fmt);
619  void msg_logresponse (osip_message_t * sip, char *fmt);
620 #else
621 #define msg_logrequest(P,Q) ;
622 #define msg_logresponse(P,Q) ;
623 #endif
624 #endif
625 
631 #define osip_message_set_date(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Date",value)
632 
638 #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)
639 
644 #define osip_message_set_encryption(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Encryption",value)
645 
651 #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)
652 
657 #define osip_message_set_organization(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Organization",value)
658 
664 #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)
665 
670 #define osip_message_set_require(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Require",value)
671 
677 #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)
678 
683 #define osip_message_set_supported(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Supported",value)
684 
690 #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)
691 
696 #define osip_message_set_timestamp(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Timestamp",value)
697 
703 #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)
704 
709 #define osip_message_set_user_agent(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"User-Agent",value)
710 
716 #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)
717 
722 #define osip_message_set_content_language(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Content-Language",value)
723 
729 #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)
730 
735 #define osip_message_set_expires(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Expires",value)
736 
742 #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)
743 
748 #define osip_message_set_in_reply_to(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"In-Reply-To",value)
749 
755 #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)
756 
761 #define osip_message_set_max_forwards(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Max-Forwards",value)
762 
768 #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)
769 
774 #define osip_message_set_priority(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Priority",value)
775 
781 #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)
782 
787 #define osip_message_set_proxy_require(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Proxy-Require",value)
788 
794 #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)
795 
800 #define osip_message_set_response_key(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Response-Key",value)
801 
807 #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)
808 
813 #define osip_message_set_subject(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Subject",value)
814 
820 #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)
821 
826 #define osip_message_set_retry_after(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Retry-After",value)
827 
833 #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)
834 
839 #define osip_message_set_server(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Server",value)
840 
846 #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)
847 
852 #define osip_message_set_unsupported(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Unsupported",value)
853 
859 #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)
860 
865 #define osip_message_set_warning(sip,value) osip_message_set_header((osip_message_t *)sip,(const char *)"Warning",value)
866 
872 #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)
873 
877 #ifdef __cplusplus
878 }
879 #endif
880 #endif