Loading...
Searching...
No Matches
msg.h
Go to the documentation of this file.
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef MSG_H
#define MSG_H
#include <sofia-sip/msg_types.h>
#include <sofia-sip/su_alloc.h>
SOFIA_BEGIN_DECLS
SOFIAPUBFUN msg_t *msg_create(msg_mclass_t const *mc, int flags);
SOFIAPUBFUN msg_t *msg_ref(msg_t *);
SOFIAPUBFUN void msg_unref(msg_t *);
SOFIAPUBFUN void msg_destroy(msg_t *);
SOFIAPUBFUN msg_t *msg_copy(msg_t *);
SOFIAPUBFUN msg_t *msg_dup(msg_t const *);
SOFIAPUBFUN msg_t *msg_make(msg_mclass_t const *mc, int flags,
void const *data, ssize_t len);
SOFIAPUBFUN char *msg_as_string(su_home_t *home,
msg_t *msg, msg_pub_t *pub, int flags,
size_t *return_len);
SOFIAPUBFUN void msg_set_parent(msg_t *kid, msg_t *dad);
SOFIAPUBFUN msg_t *msg_ref_create(msg_t *);
SOFIAPUBFUN void msg_ref_destroy(msg_t *);
SOFIAPUBFUN msg_pub_t *msg_public(msg_t const *msg, void *tag);
SOFIAPUBFUN msg_pub_t *msg_object(msg_t const *msg);
SOFIAPUBFUN msg_mclass_t const *msg_mclass(msg_t const *msg);
SOFIAPUBFUN int msg_extract(msg_t *msg);
SOFIAPUBFUN unsigned msg_extract_errors(msg_t const *msg);
SOFIAPUBFUN int msg_is_complete(msg_t const *msg);
SOFIAPUBFUN int msg_has_error(msg_t const *msg);
SOFIAPUBFUN msg_header_t **msg_chain_head(msg_t const *msg);
SOFIAPUBFUN int msg_serialize(msg_t *msg, msg_pub_t *mo);
SOFIAPUBFUN int msg_prepare(msg_t *msg);
SOFIAPUBFUN void msg_unprepare(msg_t *msg);
SOFIAPUBFUN int msg_is_prepared(msg_t const *msg);
SOFIAPUBFUN usize_t msg_size(msg_t const *msg);
SOFIAPUBFUN usize_t msg_maxsize(msg_t *msg, usize_t maxsize);
#define msg_home(h) ((su_home_t*)(h))
enum msg_streaming_status {
msg_stop_streaming = 0,
msg_start_streaming = 1
};
SOFIAPUBFUN int msg_is_streaming(msg_t const *msg);
SOFIAPUBFUN void msg_set_streaming(msg_t *msg, enum msg_streaming_status what);
SOFIAPUBFUN unsigned msg_mark_as_complete(msg_t *msg, unsigned mask);
SOFIAPUBFUN unsigned msg_get_flags(msg_t const *msg, unsigned mask);
SOFIAPUBFUN unsigned msg_set_flags(msg_t *msg, unsigned mask);
SOFIAPUBFUN unsigned msg_zap_flags(msg_t *msg, unsigned mask);
enum msg_flg_user {
MSG_FLG_COMPACT = (1<<0),
MSG_FLG_CANONIC = (1<<1),
MSG_FLG_EXTRACT_COPY = (1<<2),
MSG_FLG_COMMA_LISTS = (1<<3),
MSG_FLG_MAILBOX = (1<<4),
MSG_FLG_CHUNKING = (1<<5),
MSG_FLG_STREAMING = (1<<6),
MSG_FLG_THRDSAFE = (1<<15),
MSG_FLG_USERMASK = (1<<16) - 1
};
enum msg_flg_parser {
MSG_FLG_HEADERS = (1<<16),
MSG_FLG_BODY = (1<<17),
MSG_FLG_CHUNKS = (1<<18),
MSG_FLG_TRAILERS = (1<<19),
MSG_FLG_FRAGS = (1<<20),
MSG_FLG_COMPLETE = (1<<24),
MSG_FLG_ERROR = (1<<25),
MSG_FLG_TOOLARGE = (1<<26),
MSG_FLG_TRUNC = (1<<27),
MSG_FLG_TIMEOUT = (1<<28),
MSG_FLG_PARSERMASK = ((-1) ^ ((1<<16) - 1))
};
#define MSG_DO_COMPACT MSG_FLG_COMPACT
#define MSG_DO_CANONIC MSG_FLG_CANONIC
#define MSG_DO_EXTRACT_COPY MSG_FLG_EXTRACT_COPY
#define MSG_FLAGS(f, v) (((f) & (v)) == v)
#define MSG_IS_COMPACT(f) MSG_FLAGS((f), MSG_FLG_COMPACT)
#define MSG_IS_CANONIC(f) MSG_FLAGS((f), MSG_FLG_CANONIC)
#define MSG_IS_EXTRACT_COPY(f) MSG_FLAGS((f), MSG_FLG_EXTRACT_COPY)
#define MSG_IS_COMMA_LISTS(f) MSG_FLAGS((f), MSG_FLG_COMMA_LISTS)
#define MSG_IS_MAILBOX(f) MSG_FLAGS((f), MSG_FLG_MAILBOX)
#define MSG_HAS_COMPLETE(f) MSG_FLAGS((f), MSG_FLG_COMPLETE)
#define MSG_HAS_ERROR(f) MSG_FLAGS((f), MSG_FLG_ERROR)
#define MSG_IS_COMPLETE(mo) (((mo)->msg_flags & MSG_FLG_COMPLETE) != 0)
SOFIA_END_DECLS
#endif /* MSG_H */
msg_unprepare
void msg_unprepare(msg_t *msg)
Clear 'prepared' flag.
Definition msg_parser.c:1568
msg_create
msg_t * msg_create(msg_mclass_t const *mc, int flags)
Create a message.
Definition msg.c:100
msg_set_flags
unsigned msg_set_flags(msg_t *msg, unsigned mask)
Set message flags.
Definition msg_parser.c:96
msg_mark_as_complete
unsigned msg_mark_as_complete(msg_t *msg, unsigned mask)
Mark message as complete.
Definition msg_parser.c:649
msg_is_streaming
int msg_is_streaming(msg_t const *msg)
Test if streaming is in progress.
Definition msg_parser.c:108
msg_extract_errors
unsigned msg_extract_errors(msg_t const *msg)
Get error classification flags.
Definition msg.c:405
msg_serialize
int msg_serialize(msg_t *msg, msg_pub_t *mo)
Serialize headers into the fragment chain.
Definition msg_parser.c:1904
msg_streaming_status
msg_streaming_status
Streaming state of a msg_t object.
Definition msg.h:85
msg_start_streaming
@ msg_start_streaming
Enable streaming.
Definition msg.h:89
msg_stop_streaming
@ msg_stop_streaming
Disable streaming.
Definition msg.h:87
msg_maxsize
usize_t msg_maxsize(msg_t *msg, usize_t maxsize)
Set the maximum size of a message.
Definition msg_parser.c:698
msg_mclass
msg_mclass_t const * msg_mclass(msg_t const *msg)
Retrieve message class.
Definition msg.c:251
msg_is_prepared
int msg_is_prepared(msg_t const *msg)
Return true if message is prepared.
Definition msg_parser.c:1574
msg_destroy
void msg_destroy(msg_t *)
Destroy a reference to a message.
Definition msg.c:193
msg_extract
int msg_extract(msg_t *msg)
Extract and parse a message from internal buffer.
Definition msg_parser.c:850
msg_as_string
char * msg_as_string(su_home_t *home, msg_t *msg, msg_pub_t *pub, int flags, size_t *return_len)
Convert a message to a string.
Definition msg_parser.c:1788
msg_unref
void msg_unref(msg_t *)
Decrease the reference count.
Definition msg.c:87
msg_set_streaming
void msg_set_streaming(msg_t *msg, enum msg_streaming_status what)
Enable/disable streaming.
Definition msg_parser.c:114
msg_copy
msg_t * msg_copy(msg_t *)
Copy a message shallowly.
Definition msg_header_copy.c:380
msg_chain_head
msg_header_t ** msg_chain_head(msg_t const *msg)
Return head of the fragment chain.
Definition msg_parser.c:1875
msg_flg_user
msg_flg_user
Flags controlling parser/printer.
Definition msg.h:102
MSG_FLG_EXTRACT_COPY
@ MSG_FLG_EXTRACT_COPY
Cache a copy of headers when parsing.
Definition msg.h:108
MSG_FLG_STREAMING
@ MSG_FLG_STREAMING
Enable streaming - parser gives completed message fragments when they are ready to upper layers.
Definition msg.h:122
MSG_FLG_CHUNKING
@ MSG_FLG_CHUNKING
Use multiple parts for message body.
Definition msg.h:118
MSG_FLG_COMMA_LISTS
@ MSG_FLG_COMMA_LISTS
Print comma-separated lists instead of separate headers.
Definition msg.h:110
MSG_FLG_COMPACT
@ MSG_FLG_COMPACT
Use compact form when printing.
Definition msg.h:104
MSG_FLG_MAILBOX
@ MSG_FLG_MAILBOX
Use mailbox format when parsing - in mailbox format message has no body unless Content-Length header ...
Definition msg.h:115
MSG_FLG_THRDSAFE
@ MSG_FLG_THRDSAFE
Make messages threadsafe.
Definition msg.h:125
MSG_FLG_CANONIC
@ MSG_FLG_CANONIC
Use canonic representation when printing.
Definition msg.h:106
msg_has_error
int msg_has_error(msg_t const *msg)
Return true if message has parsing errors.
Definition msg_parser.c:673
msg_public
msg_pub_t * msg_public(msg_t const *msg, void *tag)
Retrieve public message structure of given type.
Definition msg.c:231
msg_flg_parser
msg_flg_parser
Flags used by parser.
Definition msg.h:131
MSG_FLG_COMPLETE
@ MSG_FLG_COMPLETE
This message has been completely extracted.
Definition msg.h:143
MSG_FLG_CHUNKS
@ MSG_FLG_CHUNKS
Extract chunks for this message.
Definition msg.h:137
MSG_FLG_TOOLARGE
@ MSG_FLG_TOOLARGE
This message is too large.
Definition msg.h:148
MSG_FLG_TIMEOUT
@ MSG_FLG_TIMEOUT
This message has timeout.
Definition msg.h:152
MSG_FLG_TRAILERS
@ MSG_FLG_TRAILERS
Extract trailers for this message.
Definition msg.h:139
MSG_FLG_FRAGS
@ MSG_FLG_FRAGS
Extract last component of this message.
Definition msg.h:141
MSG_FLG_BODY
@ MSG_FLG_BODY
Extract body for this message.
Definition msg.h:135
MSG_FLG_TRUNC
@ MSG_FLG_TRUNC
This message is truncated.
Definition msg.h:150
MSG_FLG_ERROR
@ MSG_FLG_ERROR
This message has parsing errors.
Definition msg.h:146
MSG_FLG_HEADERS
@ MSG_FLG_HEADERS
Extract headers for this message.
Definition msg.h:133
msg_ref
msg_t * msg_ref(msg_t *)
Increment the reference count.
Definition msg.c:63
msg_set_parent
void msg_set_parent(msg_t *kid, msg_t *dad)
Set a message parent.
Definition msg.c:162
msg_dup
msg_t * msg_dup(msg_t const *)
Deep copy a message.
Definition msg_header_copy.c:456
msg_prepare
int msg_prepare(msg_t *msg)
Encode all message fragments.
Definition msg_parser.c:1547
msg_make
msg_t * msg_make(msg_mclass_t const *mc, int flags, void const *data, ssize_t len)
Parse a message.
Definition msg_parser_util.c:2019
msg_zap_flags
unsigned msg_zap_flags(msg_t *msg, unsigned mask)
Clear message flags.
Definition msg_parser.c:102
msg_is_complete
int msg_is_complete(msg_t const *msg)
Return true if message is complete.
Definition msg_parser.c:664
msg_size
usize_t msg_size(msg_t const *msg)
Total size of message.
Definition msg_parser.c:682
msg_get_flags
unsigned msg_get_flags(msg_t const *msg, unsigned mask)
Get message flags.
Definition msg_parser.c:90
msg_ref_create
msg_t * msg_ref_create(msg_t *)
Increment the reference count.
Definition msg.c:146
msg_ref_destroy
void msg_ref_destroy(msg_t *)
Destroy a reference to a message.
Definition msg.c:182
msg_object
msg_pub_t * msg_object(msg_t const *msg)
Retrieve public message structure.
Definition msg.c:209
msg_types.h
Types for messages and common headers.
msg_header_t
MSG_HDR_T msg_header_t
Any protocol-specific header object.
Definition msg_types.h:87
msg_t
struct msg_s msg_t
Message object.
Definition msg_types.h:54
msg_pub_t
MSG_PUB_T msg_pub_t
Public protocol-specific message structure for accessing the message.
Definition msg_types.h:81
msg_mclass_t
struct msg_mclass_s msg_mclass_t
Message class.
Definition msg_types.h:45
su_alloc.h
su_home_t
SU_HOME_T su_home_t
SOFIAPUBFUN
#define SOFIAPUBFUN

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