support line= URI parameter
This commit is contained in:
parent
927223b12b
commit
5ec3974cac
@ -1,5 +1,8 @@
|
||||
0.8.2
|
||||
=====
|
||||
12-Jul-2015: - better handling of URI params (SNOM: ;line=xxxx in Contact
|
||||
header) - URI params are now taken into consideration when
|
||||
masquerading / un-masquerading.
|
||||
02-Jul-2015: - fixed a possible SEGV in sip_find_direction()
|
||||
- plugin_stripheader: may now strip just a particular value
|
||||
from the headers
|
||||
|
||||
41
src/proxy.c
41
src/proxy.c
@ -80,7 +80,6 @@ int proxy_request (sip_ticket_t *ticket) {
|
||||
int sts;
|
||||
int type;
|
||||
struct in_addr sendto_addr;
|
||||
osip_uri_t *url;
|
||||
int port;
|
||||
char *buffer;
|
||||
size_t buflen;
|
||||
@ -128,9 +127,6 @@ int proxy_request (sip_ticket_t *ticket) {
|
||||
*/
|
||||
/* nothing to do here, copy is ready in 'request'*/
|
||||
|
||||
/* get destination address */
|
||||
url=osip_message_get_uri(request);
|
||||
|
||||
switch (type) {
|
||||
/*
|
||||
* from an external host to the internal masqueraded host
|
||||
@ -197,8 +193,8 @@ sts=sip_obscure_callid(ticket);
|
||||
request->sip_method? request->sip_method:"*NULL*",
|
||||
request->from->url->username? request->from->url->username:"*NULL*",
|
||||
request->from->url->host? request->from->url->host : "*NULL*",
|
||||
url->username? url->username : "*NULL*",
|
||||
url->host? url->host : "*NULL*");
|
||||
request->req_uri->username? request->req_uri->username : "*NULL*",
|
||||
request->req_uri->host? request->req_uri->host : "*NULL*");
|
||||
|
||||
sip_gen_response(ticket, 403 /*forbidden*/);
|
||||
|
||||
@ -238,8 +234,8 @@ sts=sip_obscure_callid(ticket);
|
||||
request->sip_method? request->sip_method:"*NULL*",
|
||||
request->from->url->username? request->from->url->username:"*NULL*",
|
||||
request->from->url->host? request->from->url->host : "*NULL*",
|
||||
url->username? url->username : "*NULL*",
|
||||
url->host? url->host : "*NULL*");
|
||||
request->req_uri->username? request->req_uri->username : "*NULL*",
|
||||
request->req_uri->host? request->req_uri->host : "*NULL*");
|
||||
|
||||
/*
|
||||
* we may end up here for two reasons:
|
||||
@ -383,21 +379,21 @@ In a first implementation we may just try to get the lowest priority,
|
||||
max weighted '_sip._udp.domain' entry and port number.
|
||||
No load balancing and no failover are supported with this.
|
||||
&&&*/
|
||||
sts = get_ip_by_host(url->host, &sendto_addr);
|
||||
sts = get_ip_by_host(request->req_uri->host, &sendto_addr);
|
||||
if (sts == STS_FAILURE) {
|
||||
DEBUGC(DBCLASS_PROXY, "proxy_request: cannot resolve URI [%s]",
|
||||
url->host);
|
||||
request->req_uri->host);
|
||||
return STS_FAILURE;
|
||||
}
|
||||
|
||||
if (url->port) {
|
||||
port=atoi(url->port);
|
||||
if (request->req_uri->port) {
|
||||
port=atoi(request->req_uri->port);
|
||||
if ((port<=0) || (port>65535)) port=SIP_PORT;
|
||||
} else {
|
||||
port=SIP_PORT;
|
||||
}
|
||||
DEBUGC(DBCLASS_PROXY, "proxy_request: have SIP URI to %s:%i",
|
||||
url->host, port);
|
||||
request->req_uri->host, port);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1190,6 +1186,9 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
|
||||
char *host;
|
||||
char *port;
|
||||
osip_uri_t *url;
|
||||
int sts;
|
||||
char *tmp1=NULL;
|
||||
char *tmp2=NULL;
|
||||
|
||||
if ((idx >= URLMAP_SIZE) || (idx < 0)) {
|
||||
WARN("proxy_rewrite_request_uri: called with invalid index");
|
||||
@ -1199,6 +1198,7 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
|
||||
DEBUGC(DBCLASS_PROXY,"rewriting incoming Request URI");
|
||||
url=osip_message_get_uri(mymsg);
|
||||
|
||||
#if 0
|
||||
/* set the true scheme */
|
||||
if (url->scheme) {osip_free(url->scheme);url->scheme=NULL;}
|
||||
if (urlmap[idx].true_url->scheme) {
|
||||
@ -1244,6 +1244,21 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
|
||||
port[strlen(urlmap[idx].true_url->port)]='\0';
|
||||
osip_uri_set_port(url, port);
|
||||
}
|
||||
#else
|
||||
osip_uri_to_str(url, &tmp1);
|
||||
osip_uri_to_str(urlmap[idx].true_url, &tmp2);
|
||||
DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: %s -> %s", tmp1, tmp2);
|
||||
|
||||
osip_uri_free(url);
|
||||
url=NULL;
|
||||
osip_message_set_uri(mymsg, url);
|
||||
sts = osip_uri_clone(urlmap[idx].true_url, &url);
|
||||
if (sts != 0) {
|
||||
ERROR("osip_uri_clone failed");
|
||||
}
|
||||
osip_message_set_uri(mymsg, url);
|
||||
#endif
|
||||
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ extern int errno;
|
||||
void register_init(void) {
|
||||
FILE *stream;
|
||||
int sts, i;
|
||||
size_t len;
|
||||
// size_t len;
|
||||
char buff[128];
|
||||
char *c;
|
||||
|
||||
@ -73,42 +73,40 @@ void register_init(void) {
|
||||
WARN("registration file not found, starting with empty table");
|
||||
} else {
|
||||
/* read the url table from file */
|
||||
DEBUGC(DBCLASS_REG,"loading registration table");
|
||||
for (i=0;i < URLMAP_SIZE; i++) {
|
||||
c=fgets(buff, sizeof(buff), stream);
|
||||
sts=sscanf(buff, "***:%i:%i", &urlmap[i].active, &urlmap[i].expires);
|
||||
sts=sscanf(buff, "****:%i:%i", &urlmap[i].active, &urlmap[i].expires);
|
||||
if (sts == 0) break; /* format error */
|
||||
if (urlmap[i].active) {
|
||||
osip_uri_init(&urlmap[i].true_url);
|
||||
osip_uri_init(&urlmap[i].masq_url);
|
||||
osip_uri_init(&urlmap[i].reg_url);
|
||||
|
||||
#define R(X) {\
|
||||
c=fgets(buff, sizeof(buff), stream);\
|
||||
buff[sizeof(buff)-1]='\0';\
|
||||
if (strchr(buff, 10)) *strchr(buff, 10)='\0';\
|
||||
if (strchr(buff, 13)) *strchr(buff, 13)='\0';\
|
||||
if (strlen(buff) > 0) {\
|
||||
len = strlen(buff);\
|
||||
X =(char*)malloc(len+1);\
|
||||
sts=sscanf(buff,"%s",X);\
|
||||
if (sts == 0) break;\
|
||||
} else {\
|
||||
X = NULL;\
|
||||
}\
|
||||
sts=osip_uri_init(&X); \
|
||||
if (sts == 0) { \
|
||||
c=fgets(buff, sizeof(buff), stream);\
|
||||
buff[sizeof(buff)-1]='\0';\
|
||||
if (strchr(buff, 10)) *strchr(buff, 10)='\0';\
|
||||
if (strchr(buff, 13)) *strchr(buff, 13)='\0';\
|
||||
if (strlen(buff) > 0) {\
|
||||
sts = osip_uri_parse(X, buff); \
|
||||
if (sts != 0) { \
|
||||
ERROR("Unable to parse To URI: %s", buff); \
|
||||
osip_uri_free(X); \
|
||||
X = NULL; \
|
||||
} \
|
||||
} else { \
|
||||
DEBUGC(DBCLASS_BABBLE, "empty URI"); \
|
||||
osip_uri_free(X); \
|
||||
X = NULL; \
|
||||
} \
|
||||
} else { \
|
||||
ERROR("Unable to initialize URI structure"); \
|
||||
} \
|
||||
}
|
||||
|
||||
R(urlmap[i].true_url->scheme);
|
||||
R(urlmap[i].true_url->username);
|
||||
R(urlmap[i].true_url->host);
|
||||
R(urlmap[i].true_url->port);
|
||||
R(urlmap[i].masq_url->scheme);
|
||||
R(urlmap[i].masq_url->username);
|
||||
R(urlmap[i].masq_url->host);
|
||||
R(urlmap[i].masq_url->port);
|
||||
R(urlmap[i].reg_url->scheme);
|
||||
R(urlmap[i].reg_url->username);
|
||||
R(urlmap[i].reg_url->host);
|
||||
R(urlmap[i].reg_url->port);
|
||||
R(urlmap[i].true_url);
|
||||
R(urlmap[i].masq_url);
|
||||
R(urlmap[i].reg_url);
|
||||
|
||||
}
|
||||
}
|
||||
fclose(stream);
|
||||
@ -152,22 +150,22 @@ void register_save(void) {
|
||||
}
|
||||
|
||||
for (i=0;i < URLMAP_SIZE; i++) {
|
||||
fprintf(stream, "***:%i:%i\n", urlmap[i].active, urlmap[i].expires);
|
||||
fprintf(stream, "****:%i:%i\n", urlmap[i].active, urlmap[i].expires);
|
||||
if (urlmap[i].active) {
|
||||
#define W(X) fprintf(stream, "%s\n", (X)? X:"");
|
||||
#define W(X) { \
|
||||
char *tmp=NULL; \
|
||||
osip_uri_to_str(X, &tmp); \
|
||||
fprintf(stream, "%s\n", (tmp)? tmp:""); \
|
||||
if (tmp) osip_free(tmp); \
|
||||
}
|
||||
|
||||
// true_url
|
||||
W(urlmap[i].true_url);
|
||||
// masq_url
|
||||
W(urlmap[i].masq_url);
|
||||
// reg_url
|
||||
W(urlmap[i].reg_url);
|
||||
|
||||
W(urlmap[i].true_url->scheme);
|
||||
W(urlmap[i].true_url->username);
|
||||
W(urlmap[i].true_url->host);
|
||||
W(urlmap[i].true_url->port);
|
||||
W(urlmap[i].masq_url->scheme);
|
||||
W(urlmap[i].masq_url->username);
|
||||
W(urlmap[i].masq_url->host);
|
||||
W(urlmap[i].masq_url->port);
|
||||
W(urlmap[i].reg_url->scheme);
|
||||
W(urlmap[i].reg_url->username);
|
||||
W(urlmap[i].reg_url->host);
|
||||
W(urlmap[i].reg_url->port);
|
||||
}
|
||||
}
|
||||
fclose(stream);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user