Hi!
I've coded a small patch which allows using different addresses for
sip-registrar and sip-proxy.
Only in the console version - as I'm not a programmer and do not have a
gnome environment to test it.
The options:
use_proxy=[0|1] ............ use an proxy
proxy=sip:<IPADDRESS> ...... IP/HOSTNAME of the Proxy to use
Note: Option as_proxy has gone.
Simply use
use_proxy=1
proxy=
this will behave like the old "as_proxy" option as the "registrar" is
entered automaticly into "proxy".
Example Scenario:
PCa .............. FW ................ Registrar
PCa is running linphone
FW is a Linux-FW with NAT (Internal IP 192.168.0.254, HostMame voip.com)
Registrar is e.g. sipgate.de
Install siproxy (http://freshmeat.net/projects/siproxd/) on the FW and
configure linphone as follows:
###
[sip]
sip_port=5060
username=123456789
hostname=voip.com
passwd=<sipgate-PW>
reg_expires=900
expires=900
use_registrar=1
registrar=sip:sipgate.de
addr_of_rec=sip:address@hidden
use_proxy=1
proxy=sip:192.168.0.254
[net]
if_name=eth0
con_type=3
use_nat=0
nat_address=
###
Hope this helps
Kianusch
------------------------------------------------------------------------
diff -Nur coreapi_orig/linphonecore.c coreapi/linphonecore.c
--- coreapi_orig/linphonecore.c Thu Nov 6 16:27:42 2003
+++ coreapi/linphonecore.c Wed Mar 24 11:15:57 2004
@@ -416,9 +416,12 @@
tmpstr=gnome_config_get_string_with_default("sip/passwd",&def);
if (def) tmpstr=NULL;
linphone_core_set_registrar_passwd(lc,tmpstr);
+ tmpstr=gnome_config_get_string_with_default("sip/proxy",&def);
+ if (def) tmpstr=NULL;
+ linphone_core_set_proxy_addr(lc,tmpstr);
tmp1=gnome_config_get_int_with_default("sip/use_registrar",&def);
if (def) tmp1=0;
- tmp2=gnome_config_get_int_with_default("sip/as_proxy",&def);
+ tmp2=gnome_config_get_int_with_default("sip/use_proxy",&def);
if (def) tmp2=0;
tmp3=gnome_config_get_int_with_default("sip/expires",&def);
if (def) tmp3=15*60;
@@ -728,7 +731,7 @@
url_init(&surl);
err=url_parse(surl,url);
if (err<0){
- g_warning("Bad proxy or registrar url:%s",url);
+ g_warning("Bad registrar url:%s",url);
goto end;
}
if (addr_of_rec!=NULL){
@@ -767,6 +770,31 @@
return err;
}
+int linphone_core_set_proxy_addr(LinphoneCore *lc,char *url)
+{
+ url_t *surl=NULL;
+ int err=0;
+ if (url==NULL || strlen(url)==0) {
+ url=lc->sip_conf.reg_conf.registrar;
+ }
+ if (url==NULL || strlen(url)==0) return;
+ url_init(&surl);
+ err=url_parse(surl,url);
+ if (err<0){
+ g_warning("Bad proxy url:%s",url);
+ goto end;
+ }
+ if (lc->sip_conf.reg_conf.proxy!=NULL){
+ g_free(lc->sip_conf.reg_conf.proxy);
+ }
+ lc->sip_conf.reg_conf.proxy=g_strdup(url);
+
+ end:
+ url_free(surl);
+ sfree(surl);
+ return err;
+}
+
char *linphone_core_get_addr_of_rec(LinphoneCore *lc)
{
return g_strdup(lc->sip_conf.reg_conf.addr_of_rec);
@@ -801,7 +829,7 @@
void linphone_core_get_registrar_usage(LinphoneCore *lc,gboolean *reg, gboolean
*proxy, gint *expires)
{
if (reg!=NULL) *reg= lc->sip_conf.reg_conf.use_registrar;
- if (proxy!=NULL) *proxy=lc->sip_conf.reg_conf.as_proxy;
+ if (proxy!=NULL) *proxy=lc->sip_conf.reg_conf.use_proxy;
if (expires!=NULL) *expires=lc->sip_conf.reg_conf.expires;
}
@@ -817,15 +845,25 @@
}
if (expires<=0) lc->sip_conf.reg_conf.expires=15*60;
else lc->sip_conf.reg_conf.expires=expires;
+ if ((lc->sip_conf.reg_conf.proxy!=NULL) &&
(strlen(lc->sip_conf.reg_conf.proxy)!=0)){
+ if (outbound_proxy)
+
osip_ua_set_outbound_proxy(lc->ua,lc->sip_conf.reg_conf.proxy,lc->sip_conf.reg_conf.passwd);
+ else
+ osip_ua_set_outbound_proxy(lc->ua,NULL,NULL);
+ }
if ((lc->sip_conf.reg_conf.registrar!=NULL) &&
(strlen(lc->sip_conf.reg_conf.registrar)!=0)){
if (use){
+/*
if (outbound_proxy)
osip_ua_set_outbound_proxy(lc->ua,lc->sip_conf.reg_conf.registrar,lc->sip_conf.reg_conf.passwd);
else osip_ua_set_outbound_proxy(lc->ua,NULL,NULL);
+*/
do_registration(lc,1);
/* TODO: setup a timeout to re-register after expires */
}else{
+/*
osip_ua_set_outbound_proxy(lc->ua,NULL,NULL);
+*/
if (lc->sip_conf.reg_conf.use_registrar){
/* the proxy is no more used, we need to
unregister */
do_registration(lc,0);
@@ -833,7 +871,7 @@
}
}
lc->sip_conf.reg_conf.use_registrar=use;
- lc->sip_conf.reg_conf.as_proxy=outbound_proxy;
+ lc->sip_conf.reg_conf.use_proxy=outbound_proxy;
}
GList * linphone_core_get_net_interfaces(LinphoneCore *lc)
@@ -1277,8 +1315,9 @@
void registrar_config_uninit(registrar_config_t *config)
{
gnome_config_set_int("sip/use_registrar",config->use_registrar);
- gnome_config_set_int("sip/as_proxy",config->as_proxy);
+ gnome_config_set_int("sip/use_proxy",config->use_proxy);
gnome_config_set_string("sip/registrar",config->registrar);
+ gnome_config_set_string("sip/proxy",config->proxy);
gnome_config_set_string("sip/passwd",config->passwd);
gnome_config_set_string("sip/addr_of_rec",config->addr_of_rec);
gnome_config_set_int("sip/expires",config->expires);
diff -Nur coreapi_orig/linphonecore.h coreapi/linphonecore.h
--- coreapi_orig/linphonecore.h Tue Oct 21 17:49:39 2003
+++ coreapi/linphonecore.h Wed Mar 24 10:24:58 2004
@@ -72,13 +72,14 @@
typedef struct registrar_config
{
- char *registrar; /*or proxy */
+ char *registrar;
+ char *proxy;
char *passwd;
char *addr_of_rec;
guint expires;
GTimer *timer;
guint32 use_registrar:1; /* general flag */
- guint32 as_proxy:1; /* is the registrar also an
outbound proxy */
+ guint32 use_proxy:1; /* is the registrar also an
outbound proxy */
guint32 padding:30;
} registrar_config_t;
@@ -308,11 +309,13 @@
int linphone_core_set_registrar_addr(LinphoneCore *lc, char
*url,char*addr_of_rec);
+int linphone_core_set_proxy_addr(LinphoneCore *lc, char *url);
+
int linphone_core_register(LinphoneCore *lc, char *url);
-void linphone_core_get_registrar_usage(LinphoneCore *lc, gboolean *enabled,
gboolean *as_proxy, gint*expires);
+void linphone_core_get_registrar_usage(LinphoneCore *lc, gboolean *enabled,
gboolean *use_proxy, gint*expires);
-void linphone_core_set_registrar_usage(LinphoneCore *lc, gboolean enabled,
gboolean as_proxy, gint expires);
+void linphone_core_set_registrar_usage(LinphoneCore *lc, gboolean enabled,
gboolean use_proxy, gint expires);
int linphone_core_get_audio_jittcomp(LinphoneCore *lc);