1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2006 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef OUTBOUND_H
26 /** Defined when <outbound.h> has been included. */
27 #define OUTBOUND_H
28 /**@IFILE outbound.h
29  *
30  * @brief Interface to SIP NAT traversal and outbound
31  *
32  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
33  *
34  * @date Created: Wed May 10 12:01:38 EEST 2006 ppessi
35  */
36 
37 #ifndef SU_CONFIG_H
38 #include <sofia-sip/su_config.h>
39 #endif
40 #ifndef NTA_H
41 #include <sofia-sip/nta.h>
42 #endif
43 #ifndef AUTH_CLIENT_H
44 #include <sofia-sip/auth_client.h>
45 #endif
46 
47 SOFIA_BEGIN_DECLS
48 
49 /* ====================================================================== */
50 /* Outbound connection */
51 
52 #ifndef OUTBOUND_OWNER_T
53 #define OUTBOUND_OWNER_T struct nua_handle_s /* Just for now */
54 #endif
55 
56 typedef struct outbound outbound_t;
57 typedef struct outbound_owner_vtable outbound_owner_vtable;
58 typedef OUTBOUND_OWNER_T outbound_owner_t;
59 
60 outbound_t *outbound_new(outbound_owner_t *owner,
61 			 outbound_owner_vtable const *owner_methods,
62 			 su_root_t *root,
63 			 nta_agent_t *agent,
64 			 char const *instance);
65 
66 void outbound_unref(outbound_t *ob);
67 
68 int outbound_set_options(outbound_t *ob,
69 			 char const *options,
70 			 unsigned dgram_interval,
71 			 unsigned stream_interval);
72 
73 int outbound_set_proxy(outbound_t *ob,
74 		       url_string_t *proxy);
75 
76 int outbound_get_contacts(outbound_t *ob,
77 			  sip_contact_t **return_current_contact,
78 			  sip_contact_t **return_previous_contact);
79 
80 int outbound_start_registering(outbound_t *ob);
81 
82 int outbound_register_response(outbound_t *ob,
83 			       int terminating,
84 			       sip_t const *request,
85 			       sip_t const *response);
86 
87 /** Return values for outbound_register_response(). */
88 enum {
89   ob_register_error = -1,	/* Or anything below zero */
90   ob_register_ok = 0,		/* No need to re-register */
91   ob_reregister = 1,		/* Re-register when oo_refresh() is called */
92   ob_reregister_now = 2		/* Re-register immediately */
93 };
94 
95 int outbound_set_contact(outbound_t *ob,
96 			 sip_contact_t const *application_contact,
97 			 sip_via_t const *v,
98 			 int terminating);
99 
100 sip_contact_t const *outbound_dialog_contact(outbound_t const *ob);
101 
102 sip_contact_t const *outbound_dialog_gruu(outbound_t const *ob);
103 
104 int outbound_gruuize(outbound_t *ob, sip_t const *sip);
105 
106 void outbound_start_keepalive(outbound_t *ob,
107 			      nta_outgoing_t *register_trans);
108 
109 void outbound_stop_keepalive(outbound_t *ob);
110 
111 int outbound_targeted_request(sip_t const *sip);
112 
113 int outbound_process_request(outbound_t *ob,
114 			     nta_incoming_t *irq,
115 			     sip_t const *sip);
116 
117 void outbound_peer_info(outbound_t *ob, sip_t const *sip);
118 
119 struct outbound_owner_vtable
120 {
121   int oo_size;
122   sip_contact_t *(*oo_contact)(outbound_owner_t *,
123 			       su_home_t *home,
124 			       int used_in_dialog,
125 			       sip_via_t const *v,
126 			       char const *transport,
127 			       char const *m_param,
128 			       ...);
129   int (*oo_refresh)(outbound_owner_t *, outbound_t *ob);
130   int (*oo_status)(outbound_owner_t *, outbound_t *ob,
131 		   int status, char const *phrase,
132 		   tag_type_t tag, tag_value_t value, ...);
133   int (*oo_probe_error)(outbound_owner_t *, outbound_t *ob,
134 			int status, char const *phrase,
135 			tag_type_t tag, tag_value_t value, ...);
136   int (*oo_keepalive_error)(outbound_owner_t *, outbound_t *ob,
137 			    int status, char const *phrase,
138 			    tag_type_t tag, tag_value_t value, ...);
139   int (*oo_credentials)(outbound_owner_t *, auth_client_t **auc);
140 };
141 
142 SOFIA_END_DECLS
143 
144 #endif /* OUTBOUND_H */
145