sofia-sip/tport.h

Go to the documentation of this file.
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 TPORT_H
00026 
00027 #define TPORT_H
00028 
00036 #ifndef SU_H
00037 #include <sofia-sip/su.h>
00038 #endif
00039 #ifndef SU_WAIT_H
00040 #include <sofia-sip/su_wait.h>
00041 #endif
00042 #ifndef MSG_H
00043 #include <sofia-sip/msg.h>
00044 #endif
00045 #ifndef URL_H
00046 #include <sofia-sip/url.h>
00047 #endif
00048 
00049 SOFIA_BEGIN_DECLS
00050 
00051 struct tport_s;
00052 #ifndef TPORT_T
00053 #define TPORT_T struct tport_s
00054 typedef TPORT_T tport_t;
00055 #endif
00056 
00057 #ifndef TP_STACK_T
00058 #ifndef TP_AGENT_T
00059 #define TP_STACK_T struct tp_stack_s
00060 #else
00061 #define TP_STACK_T TP_AGENT_T
00062 #endif
00063 #endif
00064 
00065 typedef TP_STACK_T tp_stack_t;
00066 
00067 #ifndef TP_MAGIC_T
00068 
00069 #define TP_MAGIC_T struct tp_magic_s
00070 #endif
00071 
00072 typedef TP_MAGIC_T tp_magic_t;
00073 
00074 #ifndef TP_CLIENT_T
00075 #define TP_CLIENT_T struct tp_client_s
00076 #endif
00077 
00081 typedef TP_CLIENT_T tp_client_t;
00082 
00083 struct sigcomp_compartment;
00084 struct sigcomp_udvm;
00085 
00087 typedef struct {
00088   int      tpac_size;
00089 
00091   void   (*tpac_recv)(tp_stack_t *, tport_t *, msg_t *msg, tp_magic_t *magic,
00092                       su_time_t received);
00093 
00095   void   (*tpac_error)(tp_stack_t *, tport_t *,
00096                        int errcode, char const *remote);
00097 
00099   msg_t *(*tpac_alloc)(tp_stack_t *, int flags,
00100                        char const [], unsigned,
00101                        tport_t const *, tp_client_t *);
00102 
00104   void (*tpac_address)(tp_stack_t *, tport_t *);
00105 
00106 } tport_stack_class_t;
00107 
00108 /* Compatibility */
00109 typedef tport_stack_class_t tp_stack_class_t;
00110 
00112 typedef void tport_pending_error_f(tp_stack_t *, tp_client_t *,
00113                                    tport_t *, msg_t *msg, int error);
00114 
00115 enum {
00117   TPORT_QUEUESIZE = 64
00118 };
00119 
00120 
00121 /* AI extension flags - these must not overlap with existing AI flags. */
00122 
00124 #define TP_AI_COMPRESSED 0x01000
00125 
00126 #define TP_AI_SECURE     0x02000
00127 
00129 #define TP_AI_SHUTDOWN   0x04000
00130 
00131 #define TP_AI_CLOSE      0x08000
00132 
00134 #define TP_AI_ANY        0x80000
00135 
00136 #define TP_AI_MASK       0xff000
00137 
00139 #define TPORT_HOSTPORTSIZE (55)
00140 
00150 typedef struct {
00151   char const *tpn_proto;        
00152   char const *tpn_canon;        
00153   char const *tpn_host;         
00154   char const *tpn_port;         
00155   char const *tpn_comp;         
00156   char const *tpn_ident;        
00157 } tp_name_t;
00158 
00159 #define TPN_FORMAT "%s/%s:%s%s%s%s%s"
00160 
00161 #define TPN_ARGS(n)                                                     \
00162   (n)->tpn_proto, (n)->tpn_host, (n)->tpn_port,                         \
00163   (n)->tpn_comp ? ";comp=" : "", (n)->tpn_comp ? (n)->tpn_comp : "",    \
00164   (n)->tpn_ident ? "/" : "", (n)->tpn_ident ? (n)->tpn_ident : ""
00165 
00166 #include <sofia-sip/tport_tag.h>
00167 
00169 TPORT_DLL tport_t *tport_tcreate(tp_stack_t *stack,
00170                                  tport_stack_class_t const *tpac,
00171                                  su_root_t *root,
00172                                  tag_type_t tag, tag_value_t value, ...);
00173 
00175 TPORT_DLL int tport_tbind(tport_t *self,
00176                           tp_name_t const *tpn,
00177                           char const * const transports[],
00178                           tag_type_t tag, tag_value_t value, ...);
00179 
00181 TPORT_DLL int tport_get_params(tport_t const *, tag_type_t tag, tag_value_t value, ...);
00182 
00184 TPORT_DLL int tport_set_params(tport_t *self, tag_type_t tag, tag_value_t value, ...);
00185 
00187 TPORT_DLL void tport_destroy(tport_t *tport);
00188 
00190 TPORT_DLL int tport_shutdown(tport_t *tport, int how);
00191 
00193 TPORT_DLL tport_t *tport_ref(tport_t *tp);
00194 
00196 TPORT_DLL void tport_unref(tport_t *tp);
00197 
00199 TPORT_DLL tport_t *tport_incref(tport_t *tp);
00200 
00202 TPORT_DLL void tport_decref(tport_t **tp);
00203 
00205 TPORT_DLL tport_t *tport_tsend(tport_t *, msg_t *, tp_name_t const *,
00206                                tag_type_t, tag_value_t, ...);
00207 
00209 TPORT_DLL int tport_tqueue(tport_t *, msg_t *, tag_type_t, tag_value_t, ...);
00210 
00212 TPORT_DLL int tport_queuelen(tport_t const *self);
00213 
00215 TPORT_DLL int tport_tqsend(tport_t *, msg_t *, msg_t *, 
00216                            tag_type_t, tag_value_t, ...);
00217 
00219 TPORT_DLL int tport_stall(tport_t *self);
00220 
00222 TPORT_DLL int tport_continue(tport_t *self);
00223 
00225 TPORT_DLL int tport_pend(tport_t *self, msg_t *msg,
00226                tport_pending_error_f *callback, tp_client_t *client);
00227 
00229 TPORT_DLL int tport_release(tport_t *self, int pendd,
00230                   msg_t *msg, msg_t *reply, tp_client_t *client,
00231                   int still_pending);
00232 
00234 TPORT_DLL int tport_is_master(tport_t const *self);
00235 
00237 TPORT_DLL int tport_is_primary(tport_t const *self);
00238 
00240 TPORT_DLL int tport_is_public(tport_t const *self);
00241 
00243 TPORT_DLL int tport_is_secondary(tport_t const *self);
00244 
00246 TPORT_DLL int tport_is_reliable(tport_t const *tport);
00247 
00249 TPORT_DLL int tport_is_stream(tport_t const *tport);
00250 
00252 TPORT_DLL int tport_is_dgram(tport_t const *tport);
00253 
00255 TPORT_DLL int tport_has_ip4(tport_t const *tport);
00256 
00258 TPORT_DLL int tport_has_ip6(tport_t const *tport);
00259 
00261 TPORT_DLL int tport_is_udp(tport_t const *self);
00262 
00264 TPORT_DLL int tport_is_tcp(tport_t const *self);
00265 
00267 TPORT_DLL int tport_has_tls(tport_t const *tport);
00268 
00270 TPORT_DLL int tport_is_updating(tport_t const *self);
00271 
00273 TPORT_DLL void tport_set_magic(tport_t *self, tp_magic_t *magic);
00274 
00276 TPORT_DLL tp_magic_t *tport_magic(tport_t const *tport);
00277 
00279 TPORT_DLL tp_name_t const *tport_name(tport_t const *tport);
00280 
00282 TPORT_DLL su_addrinfo_t const *tport_get_address(tport_t const *tport);
00283 
00285 TPORT_DLL char const *tport_ident(tport_t const *self);
00286 
00288 TPORT_DLL tport_t *tport_parent(tport_t const *self);
00289 
00291 TPORT_DLL int tport_flush(tport_t *);
00292 
00294 TPORT_DLL tport_t *tport_primaries(tport_t const *tport);
00295 
00297 TPORT_DLL tport_t *tport_next(tport_t const *tport);
00298 
00300 TPORT_DLL tport_t *tport_secondary(tport_t const *tport);
00301 
00303 TPORT_DLL tport_t *tport_by_protocol(tport_t const *self, char const *proto);
00304 
00306 TPORT_DLL tport_t *tport_primary_by_name(tport_t const *self, tp_name_t const *tpn);
00307 
00309 TPORT_DLL tport_t *tport_by_name(tport_t const *self, tp_name_t const  *);
00310 
00312 TPORT_DLL int tport_name_by_url(su_home_t *, tp_name_t *,
00313                                 url_string_t const *us);
00314 
00316 TPORT_DLL tport_t *tport_delivered_by(tport_t const *tp, msg_t const *msg);
00317 
00319 TPORT_DLL int tport_delivered_from(tport_t *tp, msg_t const *msg,
00320                                    tp_name_t name[1]);
00321 
00323 TPORT_DLL int tport_name_is_resolved(tp_name_t const *);
00324 
00326 TPORT_DLL int tport_name_dup(su_home_t *, tp_name_t *dst, tp_name_t const *src);
00327 
00329 TPORT_DLL int tport_convert_addr(su_home_t *home,
00330                        tp_name_t *tpn,
00331                        char const *protoname,
00332                        char const *canon,
00333                        su_sockaddr_t const *su);
00334 
00336 TPORT_DLL char *tport_hostport(char buf[], int bufsize,
00337                      su_sockaddr_t const *su, int with_port);
00338 
00340 TPORT_DLL int tport_keepalive(tport_t *tp, su_addrinfo_t const *ai,
00341                               tag_type_t tag, tag_value_t value, ...);
00342 
00343 /* ---------------------------------------------------------------------- */
00344 /* SigComp-related functions */
00345 
00346 #ifndef TPORT_COMPRESSOR
00347 #define TPORT_COMPRESSOR struct tport_compressor
00348 #endif
00349 
00350 typedef TPORT_COMPRESSOR tport_compressor_t;
00351 
00352 TPORT_DLL int tport_can_send_sigcomp(tport_t const *self);
00353 TPORT_DLL int tport_can_recv_sigcomp(tport_t const *self);
00354 
00355 TPORT_DLL int tport_has_compression(tport_t const *self, char const *comp);
00356 TPORT_DLL int tport_set_compression(tport_t *self, char const *comp);
00357 
00359 TPORT_DLL
00360 int tport_sigcomp_option(tport_t const *self,
00361                          struct sigcomp_compartment *cc,
00362                          char const *option);
00363 
00365 TPORT_DLL struct sigcomp_compartment *
00366 tport_sigcomp_compartment(tport_t *self,
00367                           char const *name, int namelen,
00368                           int create_if_needed);
00369 
00370 TPORT_DLL struct sigcomp_compartment *
00371 tport_compartment_incref(struct sigcomp_compartment *cc);
00372 
00373 TPORT_DLL void
00374 tport_compartment_decref(struct sigcomp_compartment **pointer_to_cc);
00375 
00377 TPORT_DLL int
00378 tport_sigcomp_assign(tport_t *self, struct sigcomp_compartment *);
00379 
00381 TPORT_DLL int tport_has_sigcomp_assigned(tport_t const *self);
00382 
00384 TPORT_DLL int
00385 tport_sigcomp_accept(tport_t *self,
00386                      struct sigcomp_compartment *cc,
00387                      msg_t *msg);
00388 
00390 TPORT_DLL int
00391 tport_delivered_with_comp(tport_t *tp, msg_t const *msg,
00392                           tport_compressor_t **return_compressor);
00393 
00395 TPORT_DLL int
00396 tport_sigcomp_close(tport_t *self,
00397                     struct sigcomp_compartment *cc,
00398                     int how);
00399 
00401 TPORT_DLL int
00402 tport_sigcomp_lifetime(tport_t *self,
00403                        struct sigcomp_compartment *,
00404                        unsigned lifetime_in_ms,
00405                        int only_expand);
00406 
00407 
00408 SOFIA_END_DECLS
00409 
00410 #endif /* TPORT_H */

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