00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00025 #ifndef MSG_INTERNAL_H 00026 00027 #define MSG_INTERNAL_H 00028 00038 #ifdef MSG_H 00039 #error "msg_internal.h" should be included before "msg.h" 00040 #endif 00041 00042 #include "sofia-sip/msg.h" 00043 #include "sofia-sip/msg_addr.h" 00044 #include "sofia-sip/msg_buffer.h" 00045 00046 #ifndef SU_ALLOC_H 00047 #include <sofia-sip/su_alloc.h> 00048 #endif 00049 00050 SOFIA_BEGIN_DECLS 00051 00052 /* ---------------------------------------------------------------------- */ 00053 /* Types used when handling streaming */ 00054 00055 typedef struct msg_buffer_s msg_buffer_t; 00056 00057 /* ---------------------------------------------------------------------- */ 00058 00059 struct msg_s { 00060 su_home_t m_home[1]; 00062 msg_mclass_t const *m_class; 00063 int m_oflags; 00065 msg_pub_t *m_object; 00067 size_t m_maxsize; 00068 size_t m_size; 00070 msg_header_t *m_chain; 00071 msg_header_t **m_tail; 00073 msg_payload_t *m_chunk; 00075 /* Parsing/printing buffer */ 00076 struct msg_mbuffer_s { 00077 char *mb_data; 00078 usize_t mb_size; 00079 usize_t mb_used; 00080 usize_t mb_commit; 00081 unsigned mb_eos:1; 00082 unsigned :0; 00083 } m_buffer[1]; 00084 00085 msg_buffer_t *m_stream; 00086 size_t m_ssize; 00088 unsigned short m_extract_err; 00089 /* Internal flags */ 00090 unsigned m_set_buffer:1; 00091 unsigned m_streaming:1; 00092 unsigned m_prepared:1; 00093 unsigned :0; 00094 00095 msg_t *m_next; 00097 msg_t *m_parent; 00098 int m_refs; 00100 su_addrinfo_t m_addrinfo; 00101 su_sockaddr_t m_addr[1]; 00103 int m_errno; 00104 }; 00105 00107 struct msg_buffer_s { 00108 char *b_data; 00109 size_t b_size; 00110 size_t b_used; 00111 size_t b_avail; 00112 int b_complete; 00113 msg_buffer_t *b_next; 00114 msg_payload_t *b_chunks; 00115 }; 00116 00118 #define MSG_SSIZE_MAX (USIZE_MAX) 00119 00120 /* ---------------------------------------------------------------------- */ 00121 /* Header-kind predicate functions. */ 00122 su_inline int msg_is_single(msg_header_t const *h) 00123 { 00124 return h->sh_class->hc_kind == msg_kind_single; 00125 } 00126 00127 su_inline int msg_is_prepend(msg_header_t const *h) 00128 { 00129 return h->sh_class->hc_kind == msg_kind_prepend; 00130 } 00131 00132 su_inline int msg_is_append(msg_header_t const *h) 00133 { 00134 return 00135 h->sh_class->hc_kind == msg_kind_append || 00136 h->sh_class->hc_kind == msg_kind_apndlist; 00137 } 00138 00139 su_inline int msg_is_list(msg_header_t const *h) 00140 { 00141 return h->sh_class->hc_kind == msg_kind_list; 00142 } 00143 00144 su_inline int msg_is_special(msg_header_t const *h) 00145 { 00146 return h->sh_class->hc_hash < 0; 00147 } 00148 00149 SOFIA_END_DECLS 00150 00151 #endif /* MSG_INTERNAL_H */