00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SIP_HEADER_H
00026
00027 #define SIP_HEADER_H
00028
00038 #ifndef SU_ALLOC_H
00039 #include <sofia-sip/su_alloc.h>
00040 #endif
00041
00042 #ifndef SU_TAG_H
00043 #include <sofia-sip/su_tag.h>
00044 #endif
00045
00046 #ifndef SIP_H
00047 #include <sofia-sip/sip.h>
00048 #endif
00049
00050 #ifndef MSG_HEADER_H
00051 #include <sofia-sip/msg_header.h>
00052 #endif
00053
00054 #ifndef _STRING_H
00055 #include <string.h>
00056 #endif
00057
00058 SOFIA_BEGIN_DECLS
00059
00061 SOFIAPUBFUN msg_mclass_t *sip_default_mclass(void);
00062
00064 #define sip_is_sip(sip) ((sip) && (sip)->sip_ident == SIP_PROTOCOL_TAG)
00065
00067 #define SIP_HDR_INIT(name) {{{ 0, 0, sip_##name##_class }}}
00068
00070 #define SIP_HEADER_INIT(h, sip_class, size) \
00071 (memset((h), 0, (size)), ((sip_common_t *)(h))->h_class = (sip_class), (h))
00072
00074 SOFIAPUBFUN int sip_serialize(msg_t *msg, sip_t *sip);
00075
00077 SOFIAPUBFUN int sip_e(sip_t const *sip, int flags, char b[], int size);
00078
00080 SOFIAPUBFUN int sip_is_header(sip_header_t const *header);
00081
00083 SOFIAPUBFUN char *sip_header_as_string(su_home_t *home, sip_header_t *h);
00084
00086 SOFIAPUBFUN int sip_add_dup(msg_t *, sip_t *, sip_header_t const *);
00087
00089 SOFIAPUBFUN int sip_add_dup_as(msg_t *msg, sip_t *sip,
00090 msg_hclass_t *hc, sip_header_t const *o);
00091
00093 SOFIAPUBFUN int sip_add_headers(msg_t *msg, sip_t *sip,
00094 void const *extra, va_list headers);
00095
00097 SOFIAPUBFUN int sip_add_tl(msg_t *msg, sip_t *sip,
00098 tag_type_t tag, tag_value_t value, ...);
00099
00101 SOFIAPUBFUN int sip_add_tagis(msg_t *, sip_t *, tagi_t const **inout_list);
00102
00104 SOFIAPUBFUN int sip_add_make(msg_t *, sip_t *, msg_hclass_t *hc, char const *s);
00105
00107 SOFIAPUBFUN int sip_complete_message(msg_t *msg);
00108
00110 #define sip_fragment_clear(a) ((a)->h_data = NULL, (a)->h_len = 0)
00111
00112
00113 #if !defined(__GNUC__) && !defined(__attribute__)
00114 #define __attribute__(x)
00115 #endif
00116
00118 SOFIAPUBFUN sip_header_t *sip_header_format(su_home_t *home,
00119 msg_hclass_t *hc,
00120 char const *fmt,
00121 ...)
00122 __attribute__((__format__ (printf, 3, 4)));
00123
00125 SOFIAPUBFUN sip_time_t sip_now(void);
00126
00127 SOFIAPUBVAR char const sip_method_name_ack[];
00128 SOFIAPUBVAR char const sip_method_name_bye[];
00129 SOFIAPUBVAR char const sip_method_name_cancel[];
00130 SOFIAPUBVAR char const sip_method_name_invite[];
00131 SOFIAPUBVAR char const sip_method_name_options[];
00132 SOFIAPUBVAR char const sip_method_name_register[];
00133 SOFIAPUBVAR char const sip_method_name_info[];
00134 SOFIAPUBVAR char const sip_method_name_prack[];
00135 SOFIAPUBVAR char const sip_method_name_comet[];
00136 SOFIAPUBVAR char const sip_method_name_message[];
00137 SOFIAPUBVAR char const sip_method_name_subscribe[];
00138 SOFIAPUBVAR char const sip_method_name_notify[];
00139 SOFIAPUBVAR char const sip_method_name_refer[];
00140
00142 SOFIAPUBVAR char const sip_transport_udp[];
00144 SOFIAPUBVAR char const sip_transport_tcp[];
00146 SOFIAPUBVAR char const sip_transport_sctp[];
00148 SOFIAPUBVAR char const sip_transport_tls[];
00150 SOFIAPUBVAR char const sip_version_2_0[];
00151
00152 #define SIP_VERSION_CURRENT sip_version_2_0
00153
00155 SOFIAPUBVAR char const sip_parser_version[];
00156
00158 #define SIP_PORT(s) ((s) ? (s) : "5060")
00159
00161 #define SIPS_PORT(s) ((s) ? (s) : "5061")
00162
00164 SOFIAPUBFUN char const *sip_method_name(sip_method_t method, char const *name);
00165
00167 SOFIAPUBFUN sip_method_t sip_method_code(char const *name);
00168
00169 SOFIAPUBVAR char const * const sip_method_names[];
00170
00171 #define SIP_METHOD_NAME(method, name) \
00172 ((method) == sip_method_unknown ? (name) : sip_method_name(method, name))
00173
00174 #define sip_header_make(h, c, s) \
00175 ((sip_header_t *)msg_header_make((h), (c), (s)))
00176 #define sip_header_vformat(h, c, f, a) \
00177 ((sip_header_t *)msg_header_vformat((h), (c), (f), (a)))
00178
00179 #include <sofia-sip/sip_protos.h>
00180
00182 SOFIAPUBFUN
00183 sip_request_t *sip_request_create(su_home_t *home,
00184 sip_method_t method, const char *name,
00185 url_string_t const *url,
00186 char const *version);
00187
00189 SOFIAPUBFUN
00190 sip_status_t *sip_status_create(su_home_t *home,
00191 unsigned status,
00192 char const *phrase,
00193 char const *version);
00194
00196 SOFIAPUBFUN sip_call_id_t *sip_call_id_create(su_home_t *home,
00197 char const *domain);
00198
00200 SOFIAPUBFUN sip_cseq_t *sip_cseq_create(su_home_t *, uint32_t seq,
00201 unsigned method, char const *name);
00202
00204 SOFIAPUBFUN sip_contact_t * sip_contact_create(su_home_t *,
00205 url_string_t const *url,
00206 char const *param,
00207
00208 ...);
00209
00211 SOFIAPUBFUN sip_time_t sip_contact_expires(sip_contact_t const *m,
00212 sip_expires_t const *ex,
00213 sip_date_t const *date,
00214 sip_time_t def,
00215 sip_time_t now);
00216
00218 SOFIAPUBFUN
00219 sip_content_length_t *sip_content_length_create(su_home_t *, uint32_t n);
00220
00222 SOFIAPUBFUN sip_date_t *sip_date_create(su_home_t *, sip_time_t t);
00223
00225 SOFIAPUBFUN sip_expires_t *sip_expires_create(su_home_t *, sip_time_t delta);
00226
00228 SOFIAPUBFUN sip_route_t *sip_route_create(su_home_t *home, url_t const *url,
00229 url_t const *maddr);
00230
00232 SOFIAPUBFUN sip_record_route_t *sip_record_route_create(su_home_t *,
00233 url_t const *rq_url,
00234 url_t const *m_url);
00235
00237 SOFIAPUBFUN sip_from_t *sip_from_create(su_home_t *, url_string_t const *url);
00238
00239 SOFIAPUBFUN int sip_from_tag(su_home_t *, sip_from_t *from, char const *tag);
00240
00242 SOFIAPUBFUN sip_to_t *sip_to_create(su_home_t *, url_string_t const *url);
00243
00244 SOFIAPUBFUN int sip_to_tag(su_home_t *, sip_to_t *to, char const *tag);
00245
00247 SOFIAPUBFUN sip_via_t *sip_via_create(su_home_t *h,
00248 char const *host,
00249 char const *port,
00250 char const *transport,
00251
00252 ...);
00253
00255 #if SU_HAVE_INLINE
00256 su_inline char const *sip_via_transport(sip_via_t const *v)
00257 {
00258 char const *tp = v->v_protocol;
00259 if (tp) {
00260 tp = strchr(tp, '/');
00261 if (tp) {
00262 tp = strchr(tp + 1, '/');
00263 if (tp)
00264 return tp + 1;
00265 }
00266 }
00267 return NULL;
00268 }
00269 #else
00270 char const *sip_via_transport(sip_via_t const *v);
00271 #endif
00272
00273 SOFIAPUBFUN char const *sip_via_port(sip_via_t const *v, int *using_rport);
00274
00275 SOFIAPUBFUN
00276 sip_payload_t *sip_payload_create(su_home_t *, void const *data, int len);
00277
00295 #define SIP_PAYLOAD_INIT2(data, length) \
00296 {{{ 0, 0, sip_payload_class, data, length }, NULL, data, length }}
00297
00299 SOFIAPUBFUN sip_separator_t *sip_separator_create(su_home_t *home);
00300
00302 SOFIAPUBFUN
00303 sip_unsupported_t *sip_has_unsupported(su_home_t *,
00304 sip_supported_t const *support,
00305 sip_require_t const *require);
00306
00307 SOFIAPUBFUN
00308 sip_unsupported_t *sip_has_unsupported2(su_home_t *,
00309 sip_supported_t const *support,
00310 sip_require_t const *by_require,
00311 sip_require_t const *require);
00312
00313 SOFIAPUBFUN
00314 sip_unsupported_t *
00315 sip_has_unsupported_any(su_home_t *,
00316 sip_supported_t const *support,
00317 sip_require_t const *by_require,
00318 sip_proxy_require_t const *by_proxy_require,
00319 sip_require_t const *require,
00320 sip_require_t const *require2,
00321 sip_require_t const *require3);
00322
00324 SOFIAPUBFUN
00325 int sip_has_supported(sip_supported_t const *support, char const *feature);
00326
00328 SOFIAPUBFUN
00329 int sip_has_feature(msg_list_t const *supported, char const *feature);
00330
00331
00332
00333
00334 enum {
00335 sip_mask_request = 1,
00336 sip_mask_response = 2,
00337 sip_mask_ua = 4,
00338 sip_mask_proxy = 8,
00339 sip_mask_registrar = 16,
00340 sip_mask_100rel = 32,
00341 sip_mask_events = 64,
00342 sip_mask_timer = 128,
00343 sip_mask_privacy = 256,
00344 sip_mask_pref = 512,
00345 sip_mask_publish = 1024
00346 };
00347
00348
00349
00350
00351
00353 SOFIAPUBFUN int sip_header_e(char[], int, sip_header_t const *, int);
00354
00356 SOFIAPUBFUN
00357 sip_header_t *sip_header_d(su_home_t *, msg_t const *, char const *);
00358
00360 SOFIAPUBFUN int sip_header_field_e(char[], int, sip_header_t const *, int);
00361
00363 SOFIAPUBFUN int sip_header_field_d(su_home_t *, sip_header_t *, char *, int);
00364
00366 SOFIAPUBFUN int sip_header_size(sip_header_t const *h);
00367
00369 SOFIAPUBFUN sip_header_t *sip_header_dup(su_home_t *, sip_header_t const *);
00370
00372 SOFIAPUBFUN sip_header_t *sip_header_copy(su_home_t *, sip_header_t const *o);
00373
00375 SOFIAPUBFUN int sip_allow_events_add(su_home_t *,
00376 sip_allow_events_t *ae,
00377 char const *e);
00378
00380 SOFIAPUBFUN int sip_contact_add_param(su_home_t *, sip_contact_t *,
00381 char const *param);
00382
00383 SOFIAPUBFUN int sip_to_add_param(su_home_t *, sip_to_t *, char const *);
00384
00385 SOFIAPUBFUN int sip_from_add_param(su_home_t *, sip_from_t *, char const *);
00386
00388 SOFIAPUBFUN int sip_via_add_param(su_home_t *, sip_via_t *, char const *);
00389
00390 #define sip_from_make_url sip_from_create
00391 #define sip_to_make_url sip_to_create
00392 #define sip_params_find msg_params_find
00393
00394 SOFIA_END_DECLS
00395
00396 #endif