outbound.h 4.23 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
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2006 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
 *
 */

25 26
#ifndef OUTBOUND_H
/** Defined when <outbound.h> has been included. */
27 28 29 30 31 32 33 34 35 36 37
#define OUTBOUND_H
/**@IFILE outbound.h 
 *
 * @brief Interface to SIP NAT traversal and outbound
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 *
 * @date Created: Wed May 10 12:01:38 EEST 2006 ppessi
 */

#ifndef SU_CONFIG_H
38
#include <sofia-sip/su_config.h>
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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
#endif
#ifndef NTA_H
#include <sofia-sip/nta.h>
#endif
#ifndef AUTH_CLIENT_H
#include <sofia-sip/auth_client.h>
#endif

SOFIA_BEGIN_DECLS

/* ====================================================================== */
/* Outbound connection */

#ifndef OUTBOUND_OWNER_T
#define OUTBOUND_OWNER_T struct nua_handle_s /* Just for now */
#endif

typedef struct outbound outbound_t;
typedef struct outbound_owner_vtable outbound_owner_vtable;
typedef OUTBOUND_OWNER_T outbound_owner_t;

outbound_t *outbound_new(outbound_owner_t *owner,
			 outbound_owner_vtable const *owner_methods,
			 su_root_t *root,
			 nta_agent_t *agent,
			 char const *instance);

void outbound_unref(outbound_t *ob);

int outbound_set_options(outbound_t *ob,
			 char const *options,
			 unsigned dgram_interval,
			 unsigned stream_interval);

int outbound_set_features(outbound_t *ob, char *features);

nta_outgoing_t *outbound_register_request(outbound_t *ob, int terminating, 
					  sip_contact_t *stack_contact,
					  nta_agent_t *nta,
					  nta_response_f *callback,
					  nta_outgoing_magic_t *magic,
					  url_string_t *next_hop,
					  msg_t *msg,
					  tag_type_t tag, tag_value_t value,
					  ...);

int outbound_register_response(outbound_t *ob,
			       int terminating,
			       sip_t const *request,
			       sip_t const *response);

/** Return values for outbound_register_response(). */
enum {
  ob_register_error = -1,	/* Or anything below zero */
  ob_register_ok = 0,		/* No need to re-register */
  ob_reregister = 1,		/* Re-register when oo_refresh() is called */
  ob_reregister_now = 2		/* Re-register immediately */
};

int outbound_set_contact(outbound_t *ob,
			 sip_contact_t const *application_contact,
100
			 sip_via_t const *v,
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
			 int terminating);

sip_contact_t const *outbound_dialog_contact(outbound_t const *ob);

int outbound_gruuize(outbound_t *ob, sip_t const *sip);

void outbound_start_keepalive(outbound_t *ob,
			      nta_outgoing_t *register_trans);

void outbound_stop_keepalive(outbound_t *ob);

int outbound_targeted_request(sip_t const *sip);

int outbound_process_request(outbound_t *ob, 
			     nta_incoming_t *irq,
			     sip_t const *sip);

void outbound_peer_info(outbound_t *ob, sip_t const *sip);

struct outbound_owner_vtable
{
  int oo_size;
123 124 125 126 127 128 129
  sip_contact_t *(*oo_contact)(outbound_owner_t *,
			       su_home_t *home,
			       char const *extra_username,
			       sip_via_t const *v,
			       char const *transport,
			       char const *m_param,
			       ...);
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
  int (*oo_refresh)(outbound_owner_t *, outbound_t *ob);
  int (*oo_status)(outbound_owner_t *, outbound_t *ob,
		   int status, char const *phrase,
		   tag_type_t tag, tag_value_t value, ...);
  int (*oo_probe_error)(outbound_owner_t *, outbound_t *ob,
			int status, char const *phrase,
			tag_type_t tag, tag_value_t value, ...);
  int (*oo_keepalive_error)(outbound_owner_t *, outbound_t *ob,
			    int status, char const *phrase,
			    tag_type_t tag, tag_value_t value, ...);
  int (*oo_credentials)(outbound_owner_t *, auth_client_t **auc);
};

SOFIA_END_DECLS

#endif /* OUTBOUND_H */