Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / libosip2 / include / osipparser2 / headers / osip_via.h
1 /*
2   The oSIP library implements the Session Initiation Protocol (SIP -rfc2543-)
3   Copyright (C) 2001  Aymeric MOIZARD jack@atosc.org
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_VIA_H_
22 #define _OSIP_VIA_H_
23
24 #include <osipparser2/osip_list.h>
25
26 /**
27  * @file osip_via.h
28  * @brief oSIP osip_via header definition.
29  */
30
31 /**
32  * @defgroup oSIP_VIA oSIP via header definition.
33  * @ingroup oSIP_HEADERS
34  * @{
35  */
36
37 /**
38  * Structure for Via headers.
39  * @defvar osip_via_t
40  */
41   typedef struct osip_via osip_via_t;
42
43   struct osip_via
44   {
45     char *version;
46     char *protocol;
47     char *host;
48     char *port;
49     char *comment;
50     osip_list_t *via_params;
51   };
52
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57
58 /**
59  * Allocate a Via element.
60  * @param header The element to work on.
61  */
62   int osip_via_init (osip_via_t ** header);
63 /**
64  * Free a Via element.
65  * @param header The element to work on.
66  */
67   void osip_via_free (osip_via_t * header);
68 /**
69  * Parse a Via element.
70  * @param header The element to work on.
71  * @param hvalue The string to parse.
72  */
73   int osip_via_parse (osip_via_t * header, const char *hvalue);
74 /**
75  * Get a string representation of a Via element.
76  * @param header The element to work on.
77  * @param dest A pointer on the new allocated string.
78  */
79   int osip_via_to_str (const osip_via_t * header, char **dest);
80 /**
81  * Clone a Via element.
82  * @param header The element to work on.
83  * @param dest A pointer on the copy of the element.
84  */
85   int osip_via_clone (const osip_via_t * header, osip_via_t ** dest);
86 /**
87  * Set the SIP version in the Via element.
88  * @param header The element to work on.
89  * @param value The value of the element.
90  */
91   void via_set_version (osip_via_t * header, char *value);
92 /**
93  * Get the SIP version from a Via header.
94  * @param header The element to work on.
95  */
96   char *via_get_version (osip_via_t * header);
97 /**
98  * Set the protocol in the Via element.
99  * @param header The element to work on.
100  * @param value The value of the element.
101  */
102   void via_set_protocol (osip_via_t * header, char *value);
103 /**
104  * Get the protocol from a Via header.
105  * @param header The element to work on.
106  */
107   char *via_get_protocol (osip_via_t * header);
108 /**
109  * Set the host in the Via element.
110  * @param header The element to work on.
111  * @param value The value of the element.
112  */
113   void via_set_host (osip_via_t * header, char *value);
114 /**
115  * Get the host from a Via header.
116  * @param header The element to work on.
117  */
118   char *via_get_host (osip_via_t * header);
119 /**
120  * Set the port in the Via element.
121  * @param header The element to work on.
122  * @param value The value of the element.
123  */
124   void via_set_port (osip_via_t * header, char *value);
125 /**
126  * Get the port from a Via header.
127  * @param header The element to work on.
128  */
129   char *via_get_port (osip_via_t * header);
130 /**
131  * Set the comment in the Via element.
132  * @param header The element to work on.
133  * @param value The value of the element.
134  */
135   void via_set_comment (osip_via_t * header, char *value);
136 /**
137  * Get the comment from a Via header.
138  * @param header The element to work on.
139  */
140   char *via_get_comment (osip_via_t * header);
141
142 /**
143  * Allocate and add a hidden parameter element in a list.
144  * @param header The element to work on.
145  */
146 #define osip_via_set_hidden(header)    osip_generic_param_add((header)->via_params,osip_strdup("hidden"),NULL)
147 /**
148  * Allocate and add a ttl parameter element in a list.
149  * @param header The element to work on.
150  * @param value The token value.
151  */
152 #define osip_via_set_ttl(header,value)   osip_generic_param_add((header)->via_params,osip_strdup("ttl"),value)
153 /**
154  * Allocate and add a maddr parameter element in a list.
155  * @param header The element to work on.
156  * @param value The token value.
157  */
158 #define osip_via_set_maddr(header,value)   osip_generic_param_add((header)->via_params,osip_strdup("maddr"),value)
159 /**
160  * Allocate and add a received parameter element in a list.
161  * @param header The element to work on.
162  * @param value The token value.
163  */
164 #define osip_via_set_received(header,value) osip_generic_param_add((header)->via_params,osip_strdup("received"),value)
165 /**
166  * Allocate and add a branch parameter element in a list.
167  * @param header The element to work on.
168  * @param value The token value.
169  */
170 #define osip_via_set_branch(header,value)  osip_generic_param_add((header)->via_params,osip_strdup("branch"),value)
171
172 /**
173  * Allocate and add a generic parameter element in a list.
174  * @param header The element to work on.
175  * @param name The token name.
176  * @param value The token value.
177  */
178 #define osip_via_param_add(header,name,value)      osip_generic_param_add((header)->via_params,name,value)
179 /**
180  * Find a header parameter in a Via element.
181  * @param header The element to work on.
182  * @param name The token name to search.
183  * @param dest A pointer on the element found.
184  */
185 #define osip_via_param_get_byname(header,name,dest) osip_generic_param_get_byname((header)->via_params,name,dest)
186
187 /**
188  * Check if the Via headers match.
189  * NOTE: THIS IS AN INTERNAL METHOD ONLY
190  * @param via1 The first Via header.
191  * @param via2 The second Via header.
192  */
193   int osip_via_match (osip_via_t * via1, osip_via_t * via2);
194
195 #ifdef __cplusplus
196 }
197 #endif
198
199 /** @} */
200
201 #endif