msg  1.13.17
msg_types.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef MSG_TYPES_H
27 #define MSG_TYPES_H
28 
38 #ifndef SU_TYPES_H
39 #include <sofia-sip/su_types.h>
40 #endif
41 
42 SOFIA_BEGIN_DECLS
43 
45 typedef struct msg_mclass_s msg_mclass_t;
46 
48 typedef struct msg_hclass_s const msg_hclass_t;
49 
51 typedef struct msg_href_s msg_href_t;
52 
54 typedef struct msg_s msg_t;
55 
56 #ifndef MSG_TIME_T_DEFINED
57 #define MSG_TIME_T_DEFINED
59 typedef unsigned long msg_time_t;
60 #endif
61 
62 #ifndef MSG_TIME_MAX
64 #define MSG_TIME_MAX ((msg_time_t)ULONG_MAX)
65 #endif
66 
67 #ifndef MSG_PUB_T
68 #ifdef MSG_OBJ_T
69 #define MSG_PUB_T MSG_OBJ_T
70 #else
71 #define MSG_PUB_T struct msg_pub_s
72 #endif
73 #endif
74 
81 typedef MSG_PUB_T msg_pub_t;
82 
83 #ifndef MSG_HDR_T
84 #define MSG_HDR_T union msg_header_u
85 #endif
87 typedef MSG_HDR_T msg_header_t;
88 
89 typedef struct msg_common_s msg_common_t;
90 
91 typedef struct msg_separator_s msg_separator_t;
92 typedef struct msg_payload_s msg_payload_t;
93 typedef struct msg_unknown_s msg_unknown_t;
94 typedef struct msg_error_s msg_error_t;
95 
96 typedef msg_common_t msg_frg_t;
97 
98 typedef char const *msg_param_t;
99 typedef struct msg_numeric_s msg_numeric_t;
100 typedef struct msg_generic_s msg_generic_t;
101 typedef struct msg_list_s msg_list_t;
102 typedef struct msg_auth_s msg_auth_t;
103 typedef struct msg_auth_info_s msg_auth_info_t;
104 
105 #define MSG_HEADER_N 16377
106 
111 struct msg_common_s {
115  void const *h_data;
116  usize_t h_len;
117 };
118 
119 
121 struct msg_pub_s {
123  msg_pub_t *msg_next;
124  void *msg_user;
125  unsigned msg_size;
126  unsigned msg_flags;
127  msg_error_t *msg_error;
128  msg_header_t *msg_request;
129  msg_header_t *msg_status;
130  msg_header_t *msg_headers[MSG_HEADER_N];
131 };
132 
133 #define msg_ident msg_common->h_class
134 
143  unsigned long x_value;
144 };
145 
154  char const *g_string;
155 };
156 
161 struct msg_list_s {
164  msg_param_t *k_items;
165 };
166 
172 struct msg_auth_s {
175  char const *au_scheme;
176  msg_param_t const *au_params;
177 };
178 
184 {
187  msg_param_t const *ai_params;
188 };
189 
194  char const *un_name;
195  char const *un_value;
196 };
197 
199 struct msg_error_s {
202  char const *er_name;
203 };
204 
205 
210  char sep_data[4];
211 };
212 
217  char *pl_data;
218  usize_t pl_len;
219 };
220 
224  struct {
225  msg_common_t shn_common;
226  msg_header_t *shn_next;
227  } sh_header_next[1];
228 #define sh_next sh_header_next->shn_next
229 #define sh_class sh_common->h_class
230 #define sh_succ sh_common->h_succ
231 #define sh_prev sh_common->h_prev
232 #define sh_data sh_common->h_data
233 #define sh_len sh_common->h_len
234 
235  msg_generic_t sh_generic[1];
236  msg_numeric_t sh_numeric[1];
237  msg_list_t sh_list[1];
238  msg_auth_t sh_auth[1];
239  msg_separator_t sh_separator[1];
240  msg_payload_t sh_payload[1];
241  msg_unknown_t sh_unknown[1];
242  msg_error_t sh_error[1];
243 };
244 
245 /* ====================================================================== */
246 
250 typedef enum {
253  msg_kind_list,
259 
260 #define MSG_KIND_IS_COMPACT(f) (f != msg_kind_non_compact_append)
261 
262 struct su_home_s;
263 
264 typedef issize_t msg_parse_f(struct su_home_s *, msg_header_t *, char *, isize_t);
265 typedef issize_t msg_print_f(char buf[], isize_t bufsiz,
266  msg_header_t const *, int flags);
267 typedef char *msg_dup_f(msg_header_t *dst, msg_header_t const *src,
268  char *buf, isize_t bufsiz);
269 typedef isize_t msg_xtra_f(msg_header_t const *h, isize_t offset);
270 
271 typedef int msg_update_f(msg_common_t *, char const *name, isize_t namelen,
272  char const *value);
273 
282 {
283  /* XXX size of header class missing. Someone has saved bits in wrong place. */
284  int hc_hash;
285  msg_parse_f *hc_parse;
286  msg_print_f *hc_print;
287  msg_xtra_f *hc_dxtra;
288  msg_dup_f *hc_dup_one;
289  msg_update_f *hc_update;
290  char const *hc_name;
291  short hc_len;
292  char hc_short[2];
293  unsigned char hc_size;
294  unsigned char hc_params;
295  unsigned hc_kind:3;
297  unsigned hc_critical:1;
298  unsigned /*pad*/:0;
299 };
300 
301 #define HC_LEN_MAX SHRT_MAX
302 
303 SOFIA_END_DECLS
304 
305 #endif /* !defined MSG_TYPES_H */
struct msg_hclass_s const msg_hclass_t
Header class.
Definition: msg_types.h:48
unsigned long msg_time_t
Time in seconds since epoch (1900-Jan-01 00:00:00).
Definition: msg_types.h:59
MSG_HDR_T msg_header_t
Any protocol-specific header object.
Definition: msg_types.h:87
msg_header_kind_t
Define how to handle existing headers when a new header is added to a message.
Definition: msg_types.h:250
@ msg_kind_prepend
New header is prepended.
Definition: msg_types.h:256
@ msg_kind_list
A token list header, new header is combined with old one.
Definition: msg_types.h:253
@ msg_kind_single
Only one header is allowed.
Definition: msg_types.h:251
@ msg_kind_append
New header is appended.
Definition: msg_types.h:252
@ msg_kind_non_compact_append
Non-compact New header is appended.
Definition: msg_types.h:257
@ msg_kind_apndlist
A complex list header.
Definition: msg_types.h:255
MSG_PUB_T msg_pub_t
Public protocol-specific message structure for accessing the message.
Definition: msg_types.h:81
Authentication-Info header.
Definition: msg_types.h:184
msg_common_t ai_common[1]
Common fragment info.
Definition: msg_types.h:185
msg_error_t * ai_next
Dummy link to next.
Definition: msg_types.h:186
msg_param_t const * ai_params
List of ainfo.
Definition: msg_types.h:187
Authentication header.
Definition: msg_types.h:172
char const * au_scheme
Auth-scheme like Basic or Digest.
Definition: msg_types.h:175
msg_param_t const * au_params
Comma-separated parameters.
Definition: msg_types.h:176
msg_auth_t * au_next
Link to next header.
Definition: msg_types.h:174
msg_common_t au_common[1]
Common fragment info.
Definition: msg_types.h:173
Common part of the header objects (or message fragments).
Definition: msg_types.h:111
msg_header_t ** h_prev
Pointer to preceeding fragment.
Definition: msg_types.h:113
void const * h_data
Fragment data.
Definition: msg_types.h:115
usize_t h_len
Fragment length (including CRLF)
Definition: msg_types.h:116
msg_header_t * h_succ
Pointer to succeeding fragment.
Definition: msg_types.h:112
msg_hclass_t * h_class
Header class.
Definition: msg_types.h:114
Erroneus header.
Definition: msg_types.h:199
char const * er_name
Name of bad header (if any).
Definition: msg_types.h:202
msg_common_t er_common[1]
Common fragment info.
Definition: msg_types.h:200
msg_error_t * er_next
Link to next header.
Definition: msg_types.h:201
Generic header.
Definition: msg_types.h:151
msg_common_t g_common[1]
Common fragment info.
Definition: msg_types.h:152
char const * g_string
Header value.
Definition: msg_types.h:154
msg_generic_t * g_next
Link to next header.
Definition: msg_types.h:153
Factory object for a header.
Definition: msg_types.h:282
msg_parse_f * hc_parse
Parse header.
Definition: msg_types.h:285
msg_print_f * hc_print
Print header.
Definition: msg_types.h:286
unsigned char hc_size
Size of header structure.
Definition: msg_types.h:293
msg_xtra_f * hc_dxtra
Calculate extra size for dup.
Definition: msg_types.h:287
unsigned hc_critical
True if header is critical.
Definition: msg_types.h:297
int hc_hash
Header name hash or ID.
Definition: msg_types.h:284
char const * hc_name
Full name.
Definition: msg_types.h:290
msg_update_f * hc_update
Update parameter(s)
Definition: msg_types.h:289
msg_dup_f * hc_dup_one
Duplicate one header.
Definition: msg_types.h:288
unsigned char hc_params
Offset of parameter list.
Definition: msg_types.h:294
short hc_len
Length of hc_name.
Definition: msg_types.h:291
unsigned hc_kind
Kind of header (msg_header_kind_t): single, append, list, apndlist, prepend.
Definition: msg_types.h:295
char hc_short[2]
Short name, if any.
Definition: msg_types.h:292
Header reference.
Definition: msg_mclass.h:63
List header.
Definition: msg_types.h:161
msg_common_t k_common[1]
Common fragment info.
Definition: msg_types.h:162
msg_list_t * k_next
Link to next header.
Definition: msg_types.h:163
msg_param_t * k_items
List of items.
Definition: msg_types.h:164
Factory object for protocol messages.
Definition: msg_mclass.h:97
Numeric header.
Definition: msg_types.h:140
msg_numeric_t * x_next
Link to next header.
Definition: msg_types.h:142
msg_common_t x_common[1]
Common fragment info.
Definition: msg_types.h:141
unsigned long x_value
Numeric header value.
Definition: msg_types.h:143
Message payload.
Definition: msg_types.h:214
msg_payload_t * pl_next
Next payload chunk.
Definition: msg_types.h:216
usize_t pl_len
Length of message payload.
Definition: msg_types.h:218
char * pl_data
Data - may contain NUL.
Definition: msg_types.h:217
msg_common_t pl_common[1]
Common fragment info.
Definition: msg_types.h:215
Message object, common view.
Definition: msg_types.h:121
msg_common_t msg_common[1]
Recursive.
Definition: msg_types.h:122
Message object.
Definition: msg_internal.h:59
Separator.
Definition: msg_types.h:207
msg_error_t * sep_next
Dummy link to next header.
Definition: msg_types.h:209
msg_common_t sep_common[1]
Common fragment info.
Definition: msg_types.h:208
char sep_data[4]
NUL-terminated separator.
Definition: msg_types.h:210
Unknown header.
Definition: msg_types.h:191
msg_common_t un_common[1]
Common fragment info.
Definition: msg_types.h:192
msg_unknown_t * un_next
Link to next unknown header.
Definition: msg_types.h:193
char const * un_name
Header name.
Definition: msg_types.h:194
char const * un_value
Header field value.
Definition: msg_types.h:195
Any header.
Definition: msg_types.h:222
msg_common_t sh_common[1]
Common fragment info.
Definition: msg_types.h:223

Sofia-SIP 1.13.17 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.