~ubuntu-branches/ubuntu/quantal/linphone/quantal

« back to all changes in this revision

Viewing changes to osipua/src/osipua.h

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2004-06-30 13:58:16 UTC
  • Revision ID: james.westby@ubuntu.com-20040630135816-wwx75gdlodkqbabb
Tags: upstream-0.12.2
ImportĀ upstreamĀ versionĀ 0.12.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  The osipua library is a library based on oSIP that implements CallLeg and User Agent
 
3
  level.
 
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.
 
10
 
 
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.
 
15
 
 
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
 
19
*/
 
20
 
 
21
 
 
22
#ifndef OSIPUA_H
 
23
#define OSIPUA_H
 
24
 
 
25
 
 
26
#include <stdio.h>
 
27
#undef PACKAGE
 
28
#undef VERSION
 
29
#undef HAVE_CONFIG_H
 
30
#include <osipua-config.h>
 
31
 
 
32
#include <osip/osip.h>
 
33
#include <osip/port.h>
 
34
#include <osip/smsgtypes.h>
 
35
#include <osip/sdp.h>
 
36
#include <osip/dialog.h>
 
37
 
 
38
#define IP4_SIZE 20
 
39
#ifdef INET6
 
40
#define IP_SIZE 40
 
41
#endif
 
42
 
 
43
#ifdef __cplusplus
 
44
extern "C"{
 
45
#endif
 
46
 
 
47
#include "osipmanager.h"
 
48
 
 
49
/* used by the osip_trace macro*/
 
50
char *make_message (const char *fmt, ...);
 
51
 
 
52
#define osip_trace(loglevel,args)  do        \
 
53
{                       \
 
54
        char *__strmsg;  \
 
55
        __strmsg=make_message args ;    \
 
56
        OSIP_TRACE(osip_trace(__FILE__,__LINE__,(loglevel),NULL,"%s\n",__strmsg)); \
 
57
        sfree (__strmsg);        \
 
58
}while (0);
 
59
 
 
60
struct _OsipDialog
 
61
{
 
62
        from_t *from;
 
63
        int status;
 
64
        url_t *registrar;
 
65
        dialog_t *dialog;
 
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;
 
76
 
 
77
        /* list_t incoming_transactions; */
 
78
        /* list_t outgoing_transactions; */
 
79
 
 
80
        struct _RegistrationCtxt *reg_context;  /* the registration context if a registration is occuring */
 
81
        int inv_auth_count;
 
82
        int reg_auth_count;
 
83
        int resp180_count;
 
84
        unsigned int tag_set:1;
 
85
        unsigned int padding:31;
 
86
 
 
87
        struct _OsipUA *ua;     /* the ua object that manages the call */
 
88
        list_t body_contexts;   /* the active body contexts */
 
89
        void *data;
 
90
};
 
91
 
 
92
typedef struct _OsipDialog OsipDialog;
 
93
 
 
94
 
 
95
typedef int (*OsipUACallbackFunc) (OsipDialog *, transaction_t *, sip_t *,
 
96
                                   void *);
 
97
 
 
98
 
 
99
        
 
100
 
 
101
/* the user agent class*/
 
102
struct _OsipUA
 
103
{
 
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];
 
110
#ifdef INET6
 
111
        int ua_family;
 
112
        char ua_ipaddr[IP_SIZE];
 
113
#endif
 
114
        int ua_port;
 
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 */
 
120
        unsigned int flags;
 
121
#define OSIP_UA_USE_PROXY (0x0001)
 
122
        //struct _MediaDesc *maudio;     /* a MediaDescriptor for audio*/
 
123
        //struct _MediaDesc *mvideo;     /* a MediaDescriptor for video*/
 
124
        /*signals */
 
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 */
 
130
        FILE *dbg;
 
131
 
 
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!
 
143
                                         */
 
144
        list_t body_handlers;
 
145
        void *data;
 
146
};
 
147
 
 
148
 
 
149
typedef struct _OsipUA OsipUA;
 
150
 
 
151
#include "bodyhandler.h"
 
152
#include "bodycontext.h"
 
153
 
 
154
/* initialize the osipua library */
 
155
void osipua_init ();
 
156
 
 
157
/* stop the threads runned by osipua */
 
158
void osipua_exit ();
 
159
 
 
160
/* create new user agent with given parameters*/
 
161
OsipUA *osip_ua_new ();
 
162
 
 
163
/*set (or change) ua ip address*/
 
164
void osip_ua_set_ip4addr (OsipUA * ua, char *ip4addr, int port);
 
165
#ifdef INET6
 
166
void osip_ua_set_ipaddr (OsipUA * ua, char *ipaddr, int port, int ua_family);
 
167
#endif
 
168
 
 
169
void osip_ua_set_max_dialogs (OsipUA * ua, int max);
 
170
 
 
171
/* change identity of an existent user agent*/
 
172
int osip_ua_set_contact (OsipUA * ua, char *contact);
 
173
 
 
174
/* add an alias identity to which the ua is supposed to answser */
 
175
int osip_ua_add_alias (OsipUA * ua, char *contact);
 
176
 
 
177
/* remove an alias*/
 
178
int osip_ua_remove_alias (OsipUA * ua, char *contact);
 
179
 
 
180
/* remove all aliases */
 
181
void osip_ua_clean_alias (OsipUA * ua);
 
182
 
 
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);
 
185
 
 
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
 
187
is also a proxy */
 
188
int osip_ua_set_outbound_proxy (OsipUA * ua, char *proxy, char *passwd);
 
189
 
 
190
/* set information about presence: this let the user agent to answer automatically
 
191
to incoming calls */
 
192
void osip_ua_set_presence_mode (OsipUA * ua, int mode);
 
193
 
 
194
/* set contact information used by presence modes 480, 301, 380.*/
 
195
void osip_ua_set_presence_contact_url (OsipUA * ua, char *url);
 
196
 
 
197
/* set the retry after */
 
198
void osip_ua_set_presence_delay (OsipUA * ua, int delay);
 
199
 
 
200
void osip_ua_add_body_handler (OsipUA * ua, BodyHandler * info);
 
201
 
 
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);
 
204
 
 
205
OsipDialog * osip_ua_get_dialog(OsipUA *ua, int number);
 
206
 
 
207
/* destroy and free all ressources allocated by user_agent*/
 
208
int osip_ua_destroy (OsipUA * ua);
 
209
 
 
210
 
 
211
 
 
212
#include "osipdialog.h"
 
213
 
 
214
/**********************************************************************************************************************************************************************/
 
215
/*                                                                                                                                                              Private Functions: do not use them in an application                                                                                                                                                                            */
 
216
/***********************************************************************************************************************************************************************/
 
217
 
 
218
extern list_t ua_list;
 
219
 
 
220
 
 
221
/* find the user agent to which the message is destinated*/
 
222
OsipUA *osip_ua_find (sip_t * sipmsg);
 
223
 
 
224
BodyHandler *osip_ua_find_handler (OsipUA * ua, char *body_mime);
 
225
 
 
226
#ifdef __cplusplus
 
227
}
 
228
#endif
 
229
 
 
230
#endif