2
The osipua library is a library based on oSIP that implements CallLeg and User Agent
4
Copyright (C) 2001 Simon MORLAT simon.morlat@free.fr
5
Aymeric MOIZARD jack@atosc.org
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
#include <osipua-config.h>
32
#include <osip/osip.h>
33
#include <osip/port.h>
34
#include <osip/smsgtypes.h>
36
#include <osip/dialog.h>
47
#include "osipmanager.h"
49
/* used by the osip_trace macro*/
50
char *make_message (const char *fmt, ...);
52
#define osip_trace(loglevel,args) do \
55
__strmsg=make_message args ; \
56
OSIP_TRACE(osip_trace(__FILE__,__LINE__,(loglevel),NULL,"%s\n",__strmsg)); \
66
char *received; /* ip address of the originator */
67
char *localip; /* local ip address to use for this dialog*/
68
/* transactions associated with call-leg */
69
transaction_t *inc_invite_tr;
70
transaction_t *out_invite_tr;
71
transaction_t *inc_bye_tr;
72
transaction_t *out_bye_tr;
73
transaction_t *inc_cancel_tr;
74
transaction_t *out_cancel_tr;
75
transaction_t *out_register_tr;
77
/* list_t incoming_transactions; */
78
/* list_t outgoing_transactions; */
80
struct _RegistrationCtxt *reg_context; /* the registration context if a registration is occuring */
84
unsigned int tag_set:1;
85
unsigned int padding:31;
87
struct _OsipUA *ua; /* the ua object that manages the call */
88
list_t body_contexts; /* the active body contexts */
92
typedef struct _OsipDialog OsipDialog;
95
typedef int (*OsipUACallbackFunc) (OsipDialog *, transaction_t *, sip_t *,
101
/* the user agent class*/
104
osip_t *config; /* the config structure driving the stack */
105
struct _OsipManager *manager; /* the manager object that manages the stack on which the ua is running */
106
contact_t *contact; /* the user agent real identity, like machin@217.0.0.128 */
107
list_t *alias; /* list of alias like machin@www-db.research.bell-labs.com, including address of records */
108
char *fromtag; /* the from tag put in all from fields of the requests */
109
char ua_ip4addr[IP4_SIZE];
112
char ua_ipaddr[IP_SIZE];
115
list_t call_list; /* the list of dialogs managed by the user agent */
116
int max_dialogs; /* the number of active dialogs of ua will process. If the limit is exceeded, it will answer BUSY HERE */
117
int dialog_count; /* number of active dialogs */
118
url_t *registrar; /* sip url of a registrar. This is also the address of the proxy if the OSIPUA_USE_PROXY flag is set */
119
char *reg_passwd; /* the password used for registration */
121
#define OSIP_UA_USE_PROXY (0x0001)
122
//struct _MediaDesc *maudio; /* a MediaDescriptor for audio*/
123
//struct _MediaDesc *mvideo; /* a MediaDescriptor for video*/
125
OsipUACallbackFunc invite;/*INVITE*/
126
OsipUACallbackFunc invite_accepted; /*INVITE_ACCEPTED *//* called to signal that media sessions can start */
127
OsipUACallbackFunc bye;/*BYE*/
128
OsipUACallbackFunc faillure; /* FAILLURE */
129
OsipUACallbackFunc informative; /*various informations */
132
/* presence management infos */
133
int presence_mode; /* 200-> accept calls
134
* 486-> answer automatic 486 Busy
135
* 600-> 600 Busy Evrywhere
136
* 480-> answar automatic 480 Temporirily unavailable
137
* 302-> Moved temporarily
138
* 380-> Alternative service */
139
int presence_delay; /* a value in seconds to ba added to Retry-After
140
* in 486 Busy or 480 Temporirily unavailable */
141
char *presence_contact_url; /* contain a sip-url for 302, 301, 380.
142
* TO BE DONE: Can also contain an email instead of url!
144
list_t body_handlers;
149
typedef struct _OsipUA OsipUA;
151
#include "bodyhandler.h"
152
#include "bodycontext.h"
154
/* initialize the osipua library */
157
/* stop the threads runned by osipua */
160
/* create new user agent with given parameters*/
161
OsipUA *osip_ua_new ();
163
/*set (or change) ua ip address*/
164
void osip_ua_set_ip4addr (OsipUA * ua, char *ip4addr, int port);
166
void osip_ua_set_ipaddr (OsipUA * ua, char *ipaddr, int port, int ua_family);
169
void osip_ua_set_max_dialogs (OsipUA * ua, int max);
171
/* change identity of an existent user agent*/
172
int osip_ua_set_contact (OsipUA * ua, char *contact);
174
/* add an alias identity to which the ua is supposed to answser */
175
int osip_ua_add_alias (OsipUA * ua, char *contact);
178
int osip_ua_remove_alias (OsipUA * ua, char *contact);
180
/* remove all aliases */
181
void osip_ua_clean_alias (OsipUA * ua);
183
/* set a default registrar where REGISTER are sent. To unset, give registrar=NULL. */
184
int osip_ua_set_registrar (OsipUA * ua, char *registrar, char *passwd);
186
/* set a proxy to which all requests are sent. It does the same as osip_ua_set_registrar() but also indicate that the registrar
188
int osip_ua_set_outbound_proxy (OsipUA * ua, char *proxy, char *passwd);
190
/* set information about presence: this let the user agent to answer automatically
192
void osip_ua_set_presence_mode (OsipUA * ua, int mode);
194
/* set contact information used by presence modes 480, 301, 380.*/
195
void osip_ua_set_presence_contact_url (OsipUA * ua, char *url);
197
/* set the retry after */
198
void osip_ua_set_presence_delay (OsipUA * ua, int delay);
200
void osip_ua_add_body_handler (OsipUA * ua, BodyHandler * info);
202
/*register callbacks to be advertised when an invite arrives, a sent invite is accepted, or a bye is received, or a faillure occured*/
203
int osip_ua_signal_connect (OsipUA * ua, char *signal,OsipUACallbackFunc func);
205
OsipDialog * osip_ua_get_dialog(OsipUA *ua, int number);
207
/* destroy and free all ressources allocated by user_agent*/
208
int osip_ua_destroy (OsipUA * ua);
212
#include "osipdialog.h"
214
/**********************************************************************************************************************************************************************/
215
/* Private Functions: do not use them in an application */
216
/***********************************************************************************************************************************************************************/
218
extern list_t ua_list;
221
/* find the user agent to which the message is destinated*/
222
OsipUA *osip_ua_find (sip_t * sipmsg);
224
BodyHandler *osip_ua_find_handler (OsipUA * ua, char *body_mime);