msg 1.13.17
Loading...
Searching...
No Matches
msg_internal.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_INTERNAL_H
27#define MSG_INTERNAL_H
28
38#ifdef MSG_H
39#error "msg_internal.h" should be included before "msg.h"
40#endif
41
42#include "sofia-sip/msg.h"
43#include "sofia-sip/msg_addr.h"
45
46#ifndef SU_ALLOC_H
47#include <sofia-sip/su_alloc.h>
48#endif
49
50SOFIA_BEGIN_DECLS
51
52/* ---------------------------------------------------------------------- */
53/* Types used when handling streaming */
54
55typedef struct msg_buffer_s msg_buffer_t;
56
57/* ---------------------------------------------------------------------- */
58
59struct msg_s {
67 size_t m_maxsize;
68 size_t m_size;
75 /* Parsing/printing buffer */
76 struct msg_mbuffer_s {
77 char *mb_data;
78 usize_t mb_size;
79 usize_t mb_used;
80 usize_t mb_commit;
81 unsigned mb_eos:1;
82 unsigned :0;
83 } m_buffer[1];
84
86 size_t m_ssize;
88 unsigned short m_extract_err;
89 /* Internal flags */
90 unsigned m_set_buffer:1;
91 unsigned m_streaming:1;
92 unsigned m_prepared:1;
93 unsigned :0;
94
98 int m_refs;
101 su_sockaddr_t m_addr[1];
104};
105
116
117
118struct hep_hdr{
119 uint8_t hp_v; /* version */
120 uint8_t hp_l; /* length */
121 uint8_t hp_f; /* family */
122 uint8_t hp_p; /* protocol */
123 uint16_t hp_sport; /* source port */
124 uint16_t hp_dport; /* destination port */
125};
126
127
128struct hep_iphdr{
129 struct in_addr hp_src;
130 struct in_addr hp_dst; /* source and dest address */
131};
132
133/* HEPv2 */
134struct hep_timehdr{
135 uint32_t tv_sec; /* seconds */
136 uint32_t tv_usec; /* useconds */
137 uint16_t captid; /* Capture ID node */
138};
139
140#if SU_HAVE_IN6
141struct hep_ip6hdr {
142 struct in6_addr hp6_src; /* source address */
143 struct in6_addr hp6_dst; /* destination address */
144};
145#endif
146
147/* HEPv3 types */
148
149#if (defined __SUNPRO_CC) || defined(__SUNPRO_C) || defined(_MSC_VER)
150#define PACKED
151#endif
152#ifndef PACKED
153#define PACKED __attribute__ ((__packed__))
154#endif
155
156#ifdef _MSC_VER
157#pragma pack(push, 1)
158#endif
159
160struct hep_chunk {
161 uint16_t vendor_id;
162 uint16_t type_id;
163 uint16_t length;
164} PACKED;
165
166typedef struct hep_chunk hep_chunk_t;
167
168struct hep_chunk_uint8 {
169 hep_chunk_t chunk;
170 uint8_t data;
171} PACKED;
172
173typedef struct hep_chunk_uint8 hep_chunk_uint8_t;
174
175struct hep_chunk_uint16 {
176 hep_chunk_t chunk;
177 uint16_t data;
178} PACKED;
179
180typedef struct hep_chunk_uint16 hep_chunk_uint16_t;
181
182struct hep_chunk_uint32 {
183 hep_chunk_t chunk;
184 uint32_t data;
185} PACKED;
186
187typedef struct hep_chunk_uint32 hep_chunk_uint32_t;
188
189struct hep_chunk_str {
190 hep_chunk_t chunk;
191 char *data;
192} PACKED;
193
194typedef struct hep_chunk_str hep_chunk_str_t;
195
196struct hep_chunk_ip4 {
197 hep_chunk_t chunk;
198 struct in_addr data;
199} PACKED;
200
201typedef struct hep_chunk_ip4 hep_chunk_ip4_t;
202
203struct hep_chunk_ip6 {
204 hep_chunk_t chunk;
205 struct in6_addr data;
206} PACKED;
207
208typedef struct hep_chunk_ip6 hep_chunk_ip6_t;
209
210struct hep_chunk_payload {
211 hep_chunk_t chunk;
212 char *data;
213} PACKED;
214
215typedef struct hep_chunk_payload hep_chunk_payload_t;
216
217struct hep_ctrl {
218 char id[4];
219 uint16_t length;
220} PACKED;
221
222typedef struct hep_ctrl hep_ctrl_t;
223
224struct hep_generic {
225 hep_ctrl_t header;
226 hep_chunk_uint8_t ip_family;
227 hep_chunk_uint8_t ip_proto;
228 hep_chunk_uint16_t src_port;
229 hep_chunk_uint16_t dst_port;
230 hep_chunk_uint32_t time_sec;
231 hep_chunk_uint32_t time_usec;
232 hep_chunk_uint8_t proto_t;
233 hep_chunk_uint32_t capt_id;
234} PACKED;
235
236#ifdef _MSC_VER
237#pragma pack(pop)
238#endif
239
240typedef struct hep_generic hep_generic_t;
241
243#define MSG_SSIZE_MAX (USIZE_MAX)
244
245/* ---------------------------------------------------------------------- */
246/* Header-kind predicate functions. */
247su_inline int msg_is_single(msg_header_t const *h)
248{
249 return h->sh_class->hc_kind == msg_kind_single;
250}
251
252su_inline int msg_is_prepend(msg_header_t const *h)
253{
254 return h->sh_class->hc_kind == msg_kind_prepend;
255}
256
257su_inline int msg_is_append(msg_header_t const *h)
258{
259 return
260 h->sh_class->hc_kind == msg_kind_append ||
261 h->sh_class->hc_kind == msg_kind_non_compact_append ||
262 h->sh_class->hc_kind == msg_kind_apndlist;
263}
264
265su_inline int msg_is_list(msg_header_t const *h)
266{
267 return h->sh_class->hc_kind == msg_kind_list;
268}
269
270su_inline int msg_is_special(msg_header_t const *h)
271{
272 return h->sh_class->hc_hash < 0;
273}
274
275SOFIA_END_DECLS
276
277#endif /* MSG_INTERNAL_H */
Base message interface.
Addressing and I/O interface for messages.
Internal buffer management functions.
MSG_HDR_T msg_header_t
Any protocol-specific header object.
Definition msg_types.h:87
@ 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
Buffer for message body.
Definition msg_internal.h:107
char * b_data
Data - may contain NUL.
Definition msg_internal.h:108
size_t b_avail
Available data.
Definition msg_internal.h:111
size_t b_size
Length of message payload.
Definition msg_internal.h:109
int b_complete
This buffer completes the message.
Definition msg_internal.h:112
msg_payload_t * b_chunks
List of body chunks.
Definition msg_internal.h:114
msg_buffer_t * b_next
Next buffer.
Definition msg_internal.h:113
size_t b_used
Used data.
Definition msg_internal.h:110
Factory object for protocol messages.
Definition msg_mclass.h:97
Message payload.
Definition msg_types.h:214
Message object.
Definition msg_internal.h:59
su_home_t m_home[1]
Memory home.
Definition msg_internal.h:60
msg_buffer_t * m_stream
User-provided buffers.
Definition msg_internal.h:85
size_t m_size
Total size of fragments.
Definition msg_internal.h:68
size_t m_ssize
Stream size.
Definition msg_internal.h:86
msg_header_t ** m_tail
Tail of fragment chain.
Definition msg_internal.h:71
size_t m_maxsize
Maximum size.
Definition msg_internal.h:67
msg_header_t * m_chain
Fragment chain.
Definition msg_internal.h:70
unsigned m_set_buffer
Buffer has been set.
Definition msg_internal.h:90
unsigned m_prepared
Prepared/not.
Definition msg_internal.h:92
unsigned short m_extract_err
Bitmask of erroneous headers.
Definition msg_internal.h:88
msg_t * m_next
Next message.
Definition msg_internal.h:95
unsigned m_streaming
Use streaming with message.
Definition msg_internal.h:91
int m_oflags
Original flags.
Definition msg_internal.h:63
msg_mclass_t const * m_class
Message class.
Definition msg_internal.h:62
msg_t * m_parent
Reference to a parent message.
Definition msg_internal.h:97
su_addrinfo_t m_addrinfo
Message addressing info (protocol)
Definition msg_internal.h:100
msg_pub_t * m_object
Public view to parsed message.
Definition msg_internal.h:65
int m_refs
Number of references to this message.
Definition msg_internal.h:98
int m_errno
Errno.
Definition msg_internal.h:103
su_sockaddr_t m_addr[1]
Message address.
Definition msg_internal.h:101
msg_payload_t * m_chunk
Incomplete payload fragment.
Definition msg_internal.h:73
struct addrinfo su_addrinfo_t
SU_HOME_T su_home_t
#define su_inline
SU_U32_T uint32_t
SU_U16_T uint16_t
SU_U8_T uint8_t

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