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 TPORT_H
00026
00027 #define TPORT_H
00028
00036 #ifndef SU_H
00037 #include <sofia-sip/su.h>
00038 #endif
00039 #ifndef SU_STRLST_H
00040 #include <sofia-sip/su_strlst.h>
00041 #endif
00042 #ifndef SU_WAIT_H
00043 #include <sofia-sip/su_wait.h>
00044 #endif
00045 #ifndef MSG_H
00046 #include <sofia-sip/msg.h>
00047 #endif
00048 #ifndef URL_H
00049 #include <sofia-sip/url.h>
00050 #endif
00051 #ifndef TPORT_TAG_H
00052 #include <sofia-sip/tport_tag.h>
00053 #endif
00054
00055 SOFIA_BEGIN_DECLS
00056
00057 struct tport_s;
00058 #ifndef TPORT_T
00059 #define TPORT_T struct tport_s
00060 typedef TPORT_T tport_t;
00061 #endif
00062
00063 #ifndef TP_STACK_T
00064 #ifndef TP_AGENT_T
00065 #define TP_STACK_T struct tp_stack_s
00066 #else
00067 #define TP_STACK_T TP_AGENT_T
00068 #endif
00069 #endif
00070
00071 typedef TP_STACK_T tp_stack_t;
00072
00073 #ifndef TP_MAGIC_T
00074
00075 #define TP_MAGIC_T struct tp_magic_s
00076 #endif
00077
00078 typedef TP_MAGIC_T tp_magic_t;
00079
00080 #ifndef TP_CLIENT_T
00081 #define TP_CLIENT_T struct tp_client_s
00082 #endif
00083
00087 typedef TP_CLIENT_T tp_client_t;
00088
00089 struct sigcomp_compartment;
00090 struct sigcomp_udvm;
00091
00093 typedef struct {
00094 int tpac_size;
00095
00097 void (*tpac_recv)(tp_stack_t *, tport_t *, msg_t *msg, tp_magic_t *magic,
00098 su_time_t received);
00099
00101 void (*tpac_error)(tp_stack_t *, tport_t *,
00102 int errcode, char const *remote);
00103
00105 msg_t *(*tpac_alloc)(tp_stack_t *, int flags,
00106 char const [], usize_t,
00107 tport_t const *, tp_client_t *);
00108
00110 void (*tpac_address)(tp_stack_t *, tport_t *);
00111
00112 } tport_stack_class_t;
00113
00114
00115 typedef tport_stack_class_t tp_stack_class_t;
00116
00118 typedef void tport_pending_error_f(tp_stack_t *, tp_client_t *,
00119 tport_t *, msg_t *msg, int error);
00120
00121 enum {
00123 TPORT_QUEUESIZE = 64
00124 };
00125
00126
00127
00128
00130 #define TP_AI_COMPRESSED 0x01000
00131
00132 #define TP_AI_SECURE 0x02000
00133
00135 #define TP_AI_SHUTDOWN 0x04000
00136
00137 #define TP_AI_CLOSE 0x08000
00138
00140 #define TP_AI_ANY 0x80000
00141
00142 #define TP_AI_MASK 0xff000
00143
00145 #define TPORT_HOSTPORTSIZE (55)
00146
00156 typedef struct {
00157 char const *tpn_proto;
00158 char const *tpn_canon;
00159 char const *tpn_host;
00160 char const *tpn_port;
00161 char const *tpn_comp;
00162 char const *tpn_ident;
00163 } tp_name_t;
00164
00165 #define TPN_FORMAT "%s/%s:%s%s%s%s%s"
00166
00167 #define TPN_ARGS(n) \
00168 (n)->tpn_proto, (n)->tpn_host, (n)->tpn_port, \
00169 (n)->tpn_comp ? ";comp=" : "", (n)->tpn_comp ? (n)->tpn_comp : "", \
00170 (n)->tpn_ident ? "/" : "", (n)->tpn_ident ? (n)->tpn_ident : ""
00171
00173 TPORT_DLL tport_t *tport_tcreate(tp_stack_t *stack,
00174 tport_stack_class_t const *tpac,
00175 su_root_t *root,
00176 tag_type_t tag, tag_value_t value, ...);
00177
00179 TPORT_DLL int tport_tbind(tport_t *self,
00180 tp_name_t const *tpn,
00181 char const * const transports[],
00182 tag_type_t tag, tag_value_t value, ...);
00183
00185 TPORT_DLL int tport_get_params(tport_t const *, tag_type_t tag, tag_value_t value, ...);
00186
00188 TPORT_DLL int tport_set_params(tport_t *self, tag_type_t tag, tag_value_t value, ...);
00189
00191 TPORT_DLL void tport_destroy(tport_t *tport);
00192
00194 TPORT_DLL int tport_shutdown(tport_t *tport, int how);
00195
00197 TPORT_DLL tport_t *tport_ref(tport_t *tp);
00198
00200 TPORT_DLL void tport_unref(tport_t *tp);
00201
00203 TPORT_DLL tport_t *tport_incref(tport_t *tp);
00204
00206 TPORT_DLL void tport_decref(tport_t **tp);
00207
00209 TPORT_DLL tport_t *tport_tsend(tport_t *, msg_t *, tp_name_t const *,
00210 tag_type_t, tag_value_t, ...);
00211
00213 TPORT_DLL int tport_tqueue(tport_t *, msg_t *, tag_type_t, tag_value_t, ...);
00214
00216 TPORT_DLL isize_t tport_queuelen(tport_t const *self);
00217
00219 TPORT_DLL int tport_tqsend(tport_t *, msg_t *, msg_t *,
00220 tag_type_t, tag_value_t, ...);
00221
00223 TPORT_DLL int tport_stall(tport_t *self);
00224
00226 TPORT_DLL int tport_continue(tport_t *self);
00227
00229 TPORT_DLL int tport_pend(tport_t *self, msg_t *msg,
00230 tport_pending_error_f *callback, tp_client_t *client);
00231
00233 TPORT_DLL int tport_release(tport_t *self, int pendd,
00234 msg_t *msg, msg_t *reply, tp_client_t *client,
00235 int still_pending);
00236
00238 TPORT_DLL int tport_is_master(tport_t const *self);
00239
00241 TPORT_DLL int tport_is_primary(tport_t const *self);
00242
00244 TPORT_DLL int tport_is_public(tport_t const *self);
00245
00247 TPORT_DLL int tport_is_secondary(tport_t const *self);
00248
00250 TPORT_DLL int tport_is_reliable(tport_t const *tport);
00251
00253 TPORT_DLL int tport_is_stream(tport_t const *tport);
00254
00256 TPORT_DLL int tport_is_dgram(tport_t const *tport);
00257
00259 TPORT_DLL int tport_has_ip4(tport_t const *tport);
00260
00262 TPORT_DLL int tport_has_ip6(tport_t const *tport);
00263
00265 TPORT_DLL int tport_is_udp(tport_t const *self);
00266
00268 TPORT_DLL int tport_is_tcp(tport_t const *self);
00269
00271 TPORT_DLL int tport_has_tls(tport_t const *tport);
00272
00274 TPORT_DLL int tport_is_verified(tport_t const *tport);
00275
00277 TPORT_DLL int tport_is_updating(tport_t const *self);
00278
00280 TPORT_DLL int tport_is_closed(tport_t const *self);
00281
00283 TPORT_DLL int tport_is_shutdown(tport_t const *self);
00284
00286 TPORT_DLL int tport_is_connected(tport_t const *self);
00287
00289 TPORT_DLL int tport_is_clear_to_send(tport_t const *self);
00290
00292 TPORT_DLL void tport_set_magic(tport_t *self, tp_magic_t *magic);
00293
00295 TPORT_DLL tp_magic_t *tport_magic(tport_t const *tport);
00296
00298 TPORT_DLL tp_name_t const *tport_name(tport_t const *tport);
00299
00301 TPORT_DLL su_addrinfo_t const *tport_get_address(tport_t const *tport);
00302
00304 TPORT_DLL char const *tport_ident(tport_t const *self);
00305
00307 TPORT_DLL tport_t *tport_parent(tport_t const *self);
00308
00310 TPORT_DLL int tport_flush(tport_t *);
00311
00313 TPORT_DLL tport_t *tport_primaries(tport_t const *tport);
00314
00316 TPORT_DLL tport_t *tport_next(tport_t const *tport);
00317
00319 TPORT_DLL tport_t *tport_secondary(tport_t const *tport);
00320
00322 TPORT_DLL tport_t *tport_by_protocol(tport_t const *self, char const *proto);
00323
00325 TPORT_DLL tport_t *tport_primary_by_name(tport_t const *self, tp_name_t const *tpn);
00326
00328 TPORT_DLL tport_t *tport_by_name(tport_t const *self, tp_name_t const *);
00329
00331 TPORT_DLL int tport_name_by_url(su_home_t *, tp_name_t *,
00332 url_string_t const *us);
00333
00335 TPORT_DLL tport_t *tport_delivered_by(tport_t const *tp, msg_t const *msg);
00336
00338 TPORT_DLL int tport_delivered_from(tport_t *tp, msg_t const *msg,
00339 tp_name_t name[1]);
00340
00342 TPORT_DLL su_strlst_t const *tport_delivered_from_subjects(tport_t *tp,
00343 msg_t const *msg);
00344
00346 TPORT_DLL int tport_subject_search(char const *, su_strlst_t const *);
00347
00349 TPORT_DLL int tport_name_is_resolved(tp_name_t const *);
00350
00352 TPORT_DLL int tport_name_dup(su_home_t *,
00353 tp_name_t *dst, tp_name_t const *src);
00354
00356 TPORT_DLL int tport_convert_addr(su_home_t *home,
00357 tp_name_t *tpn,
00358 char const *protoname,
00359 char const *canon,
00360 su_sockaddr_t const *su);
00361
00363 TPORT_DLL char *tport_hostport(char buf[], isize_t bufsize,
00364 su_sockaddr_t const *su, int with_port);
00365
00367 TPORT_DLL int tport_keepalive(tport_t *tp, su_addrinfo_t const *ai,
00368 tag_type_t tag, tag_value_t value, ...);
00369
00370
00371
00372
00373 #ifndef TPORT_COMPRESSOR
00374 #define TPORT_COMPRESSOR struct tport_compressor
00375 #endif
00376
00377 typedef TPORT_COMPRESSOR tport_compressor_t;
00378
00379 TPORT_DLL int tport_can_send_sigcomp(tport_t const *self);
00380 TPORT_DLL int tport_can_recv_sigcomp(tport_t const *self);
00381
00382 TPORT_DLL int tport_has_compression(tport_t const *self, char const *comp);
00383 TPORT_DLL int tport_set_compression(tport_t *self, char const *comp);
00384
00386 TPORT_DLL
00387 int tport_sigcomp_option(tport_t const *self,
00388 struct sigcomp_compartment *cc,
00389 char const *option);
00390
00392 TPORT_DLL struct sigcomp_compartment *
00393 tport_sigcomp_compartment(tport_t *self,
00394 char const *name, isize_t namelen,
00395 int create_if_needed);
00396
00398 TPORT_DLL int
00399 tport_sigcomp_assign(tport_t *self, struct sigcomp_compartment *);
00400
00402 TPORT_DLL int tport_has_sigcomp_assigned(tport_t const *self);
00403
00405 TPORT_DLL int
00406 tport_sigcomp_accept(tport_t *self,
00407 struct sigcomp_compartment *cc,
00408 msg_t *msg);
00409
00411 TPORT_DLL int
00412 tport_delivered_with_comp(tport_t *tp, msg_t const *msg,
00413 tport_compressor_t **return_compressor);
00414
00416 TPORT_DLL int
00417 tport_sigcomp_close(tport_t *self,
00418 struct sigcomp_compartment *cc,
00419 int how);
00420
00422 TPORT_DLL int
00423 tport_sigcomp_lifetime(tport_t *self,
00424 struct sigcomp_compartment *,
00425 unsigned lifetime_in_ms,
00426 int only_expand);
00427
00428
00429 SOFIA_END_DECLS
00430
00431 #endif