tport_plugins.h 4.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * 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 TPORT_PLUGINS_H
/** Defined when <sofia-sip/tport_plugins.h> has been included. */
#define TPORT_PLUGINS_H

Pekka Pessi's avatar
Pekka Pessi committed
29
/**@file sofia-sip/tport_plugins.h
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
 * @brief Transport plugin interface
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 *
 * @date Created: Fri Mar 31 12:22:22 EEST 2006 ppessi
 */

/* -- STUN Plugin ------------------------------------------------------- */

#ifndef TPORT_STUN_SERVER_T
#define TPORT_STUN_SERVER_T struct tport_stun_server_s
#endif
/** Safe type for tport server object */
typedef TPORT_STUN_SERVER_T tport_stun_server_t;

typedef struct {
  int vst_size;
  tport_stun_server_t *(*vst_create)(su_root_t *root, tagi_t const *tags);
  void (*vst_destroy)(tport_stun_server_t *);
49 50 51
  int (*vst_add_socket)(tport_stun_server_t *, su_socket_t socket);
  int (*vst_remove_socket)(tport_stun_server_t *, su_socket_t socket);
  void (*vst_request)(tport_stun_server_t *server, su_socket_t socket,
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
		     void *msg, ssize_t msglen,
		     void *addr, socklen_t addrlen);
} tport_stun_server_vtable_t;

SOFIAPUBFUN int tport_plug_in_stun_server(tport_stun_server_vtable_t const *);


/* -- SigComp Plugin ---------------------------------------------------- */

/* We already use these SigComp types in applications */

struct sigcomp_udvm;
struct sigcomp_compartment;

typedef struct tport_comp_vtable_s tport_comp_vtable_t;

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
struct tport_comp_vtable_s {
  /* NOTE: this will change! Unstable! Do not use! */
  int vsc_size;

  char const *vsc_compname;
  size_t vsc_sizeof_context;

  int (*vsc_init_comp)(tp_stack_t *,
		       tport_t *,
		       tport_compressor_t *,
		       char const *comp_name,
		       tagi_t const *tags);

  void (*vsc_deinit_comp)(tp_stack_t *,
			  tport_t *,
			  tport_compressor_t *);

  char const *(*vsc_comp_name)(tport_compressor_t const *master_sc,
			       char const *compression,
			       tagi_t const *tags);

  /* Mapping of public tport API */

  int (*vsc_can_send_comp)(tport_compressor_t const *);
  int (*vsc_can_recv_comp)(tport_compressor_t const *);

  int (*vsc_set_comp_name)(tport_t const *self, 
			   tport_compressor_t const *return_sc,
			   char const *comp);

  int (*vsc_sigcomp_option)(tport_t const *self,
			    struct sigcomp_compartment *cc,
			    char const *option);

  struct sigcomp_compartment *
  (*vsc_sigcomp_compartment)(tport_t *self,
			     char const *name, int namelen,
			     int create_if_needed);

  struct sigcomp_compartment * 
  (*vsc_compartment_incref)(struct sigcomp_compartment *cc);

  void (*vsc_compartment_decref)(struct sigcomp_compartment **pointer_to_cc);

112 113 114 115 116 117 118
  int (*vsc_set_compartment)(tport_t *self,
			     tport_compressor_t *,
			     struct sigcomp_compartment *);

  struct sigcomp_compartment *
  (*vsc_get_compartment)(tport_t const *self,
			 tport_compressor_t const *);
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

  int (*vsc_has_sigcomp_assigned)(tport_compressor_t const *comp);

  int (*vsc_sigcomp_accept)(tport_t *self,
			    tport_compressor_t const *comp,
			    struct sigcomp_compartment *cc,
			    msg_t *msg);

  int (*vsc_delivered_using_udvm)(tport_t *tp,
				  msg_t const *msg,
				  struct sigcomp_udvm **return_pointer_to_udvm,
				  int remove);

  int (*vsc_sigcomp_close)(tport_t *self,
			   struct sigcomp_compartment *cc,
			   int how);

  int (*vsc_sigcomp_lifetime)(tport_t *self,
			      struct sigcomp_compartment *,
			      unsigned lifetime_in_ms,
			      int only_expand);

  /* Internal API */

  struct sigcomp_udvm **(*vsc_get_udvm_slot)(tport_t *self);

  struct sigcomp_compartment *
  (*vsc_sigcomp_assign_if_needed)(tport_t *self,
				  struct sigcomp_compartment *cc);

  void (*vsc_accept_incomplete)(tport_t const *self, 
				tport_compressor_t *sc,
				msg_t *msg);

153 154
  int (*vsc_recv_comp)(tport_t const *self, 
		       tport_compressor_t *sc,
155 156 157
		       msg_t **in_out_msg,
		       su_sockaddr_t *from,
		       socklen_t fromlen);
158

159
  ssize_t (*vsc_send_comp)(tport_t const *self,
160 161
		       msg_t *msg, 
		       msg_iovec_t iov[], 
162
		       size_t iovused,
163 164 165 166 167 168
		       struct sigcomp_compartment *cc,
		       tport_compressor_t *sc);


};

169 170 171
SOFIAPUBFUN int tport_plug_in_comp(tport_comp_vtable_t const *);

#endif /* !defined(TPORT_PLUGINS_H) */