release 0.2.4
This commit is contained in:
+13
-3
@@ -492,9 +492,15 @@ int proxy_add_myvia (sip_t *request, int interface) {
|
||||
int sts;
|
||||
|
||||
if (interface == 0) {
|
||||
sts = get_ip_by_host(configuration.outboundhost, &addr);
|
||||
sts = get_ip_by_ifname(configuration.outbound_if, &addr);
|
||||
if (sts == STS_FAILURE) {
|
||||
sts = get_ip_by_host(configuration.outboundhost, &addr);
|
||||
}
|
||||
} else {
|
||||
sts = get_ip_by_host(configuration.inboundhost, &addr);
|
||||
sts = get_ip_by_ifname(configuration.inbound_if, &addr);
|
||||
if (sts == STS_FAILURE) {
|
||||
sts = get_ip_by_host(configuration.inboundhost, &addr);
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(tmp, "SIP/2.0/UDP %s:%i", inet_ntoa(addr),
|
||||
@@ -586,7 +592,11 @@ int proxy_rewrite_invitation_body(sip_t *mymsg){
|
||||
* RTP proxy: get ready and start forwarding
|
||||
*/
|
||||
sts = get_ip_by_host(sdp_c_addr_get(sdp,-1,0), &lcl_clnt_addr);
|
||||
sts = get_ip_by_host(configuration.outboundhost, &outb_addr);
|
||||
sts = get_ip_by_ifname(configuration.outbound_if, &outb_addr);
|
||||
if (sts == STS_FAILURE) {
|
||||
sts = get_ip_by_host(configuration.outboundhost, &outb_addr);
|
||||
}
|
||||
|
||||
inb_clnt_port = atoi(sdp_m_port_get(sdp,0));
|
||||
/* start an RTP proxying stream */
|
||||
rtp_start_fwd(msg_getcall_id(mymsg),
|
||||
|
||||
+19
-15
@@ -114,8 +114,9 @@ static int parse_config (FILE *configfile) {
|
||||
char buff[128];
|
||||
char *ptr;
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int num;
|
||||
char *tmpptr;
|
||||
|
||||
struct cfgopts {
|
||||
char *keyword;
|
||||
@@ -127,6 +128,8 @@ static int parse_config (FILE *configfile) {
|
||||
{ "daemonize", TYP_INT4, &configuration.daemonize },
|
||||
{ "host_inbound", TYP_STRING, &configuration.inboundhost },
|
||||
{ "host_outbound", TYP_STRING, &configuration.outboundhost },
|
||||
{ "if_inbound", TYP_STRING, &configuration.inbound_if },
|
||||
{ "if_outbound", TYP_STRING, &configuration.outbound_if },
|
||||
{ "rtp_port_low", TYP_INT4, &configuration.rtp_port_low },
|
||||
{ "rtp_port_high", TYP_INT4, &configuration.rtp_port_high },
|
||||
{ "rtp_timeout", TYP_INT4, &configuration.rtp_timeout },
|
||||
@@ -165,16 +168,16 @@ static int parse_config (FILE *configfile) {
|
||||
DEBUGC(DBCLASS_CONFIG,"pc:\"%s\"",buff);
|
||||
|
||||
/* scan for known keyword */
|
||||
for (j=0; configoptions[j].keyword != NULL; j++) {
|
||||
if ((ptr=strstr(buff, configoptions[j].keyword)) != NULL) {
|
||||
ptr += strlen(configoptions[j].keyword);
|
||||
for (k=0; configoptions[k].keyword != NULL; k++) {
|
||||
if ((ptr=strstr(buff, configoptions[k].keyword)) != NULL) {
|
||||
ptr += strlen(configoptions[k].keyword);
|
||||
DEBUGC(DBCLASS_CONFIG,"got keyword:\"%s\"",
|
||||
configoptions[j].keyword);
|
||||
configoptions[k].keyword);
|
||||
|
||||
/* check for argument separated by '=' */
|
||||
if ((ptr=strchr(ptr,'=')) == NULL) {;
|
||||
ERROR("argument missing to config parameter %s",
|
||||
configoptions[j].keyword);
|
||||
configoptions[k].keyword);
|
||||
break;
|
||||
}
|
||||
do {ptr++;} while (*ptr == ' '); /* skip spaces after '=' */
|
||||
@@ -182,23 +185,25 @@ static int parse_config (FILE *configfile) {
|
||||
DEBUGC(DBCLASS_CONFIG,"got argument:\"%s\"",ptr);
|
||||
|
||||
num=0;
|
||||
switch (configoptions[j].type) {
|
||||
switch (configoptions[k].type) {
|
||||
case TYP_INT4:
|
||||
num=sscanf(ptr,"%i",(int*)configoptions[j].dest);
|
||||
DEBUGC(DBCLASS_BABBLE,"INT4=%i",*(int*)configoptions[j].dest);
|
||||
num=sscanf(ptr,"%i",(int*)configoptions[k].dest);
|
||||
DEBUGC(DBCLASS_BABBLE,"INT4=%i",*(int*)configoptions[k].dest);
|
||||
break;
|
||||
|
||||
case TYP_STRING:
|
||||
/* the %as within sscanf seems to be not too portable.
|
||||
* it is supposed to allocate the memory
|
||||
* num=sscanf(ptr,"%as",(char**)configoptions[j].dest);
|
||||
* num=sscanf(ptr,"%as",(char**)configoptions[k].dest);
|
||||
*/
|
||||
|
||||
/* figure out the amount of space we need */
|
||||
num=strlen(ptr);
|
||||
configoptions[j].dest=(char*)malloc(num);
|
||||
num=sscanf(ptr,"%s",(char*)configoptions[j].dest);
|
||||
DEBUGC(DBCLASS_BABBLE,"STRING=%s",(char*)configoptions[j].dest);
|
||||
num=strlen(ptr)+1; /* include terminating zero!*/
|
||||
tmpptr=(char*)malloc(num);
|
||||
memcpy(configoptions[k].dest, &tmpptr, sizeof(tmpptr));
|
||||
num=sscanf(ptr,"%s",tmpptr);
|
||||
DEBUGC(DBCLASS_BABBLE,"STRING=%s",
|
||||
*(char**)configoptions[k].dest);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -212,6 +217,5 @@ static int parse_config (FILE *configfile) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -146,10 +146,6 @@ int main (int argc, char *argv[])
|
||||
/* initialize the registration facility */
|
||||
register_init();
|
||||
|
||||
/*
|
||||
*TEST
|
||||
*/
|
||||
get_ip_by_ifname("ppp0");
|
||||
/* listen for incomming messages */
|
||||
sts=sipsock_listen();
|
||||
if (sts == STS_FAILURE) {
|
||||
|
||||
@@ -49,6 +49,7 @@ int is_via_local (via_t *via); /*X*/
|
||||
int get_ip_by_host(char *hostname, struct in_addr *addr); /*X*/
|
||||
int compare_url(url_t *url1, url_t *url2); /*X*/
|
||||
void secure_enviroment (void);
|
||||
int get_ip_by_ifname(char *ifname, struct in_addr *retaddr); /*X*/
|
||||
|
||||
/* readconf.c */
|
||||
int read_config(char *name, int search); /*X*/
|
||||
@@ -91,6 +92,8 @@ struct siproxd_config {
|
||||
int debuglevel;
|
||||
char *inboundhost;
|
||||
char *outboundhost;
|
||||
char *inbound_if;
|
||||
char *outbound_if;
|
||||
int sip_listen_port;
|
||||
int daemonize;
|
||||
int rtp_port_low;
|
||||
|
||||
+34
-11
@@ -137,7 +137,9 @@ int is_via_local (via_t *via) {
|
||||
int sts;
|
||||
struct in_addr addr_via, addr_myself;
|
||||
char *my_hostnames[]=
|
||||
{ configuration.inboundhost, configuration.outboundhost, NULL };
|
||||
{ configuration.inboundhost, configuration.outboundhost, (char*)-1 };
|
||||
char *my_interfaces[]=
|
||||
{ configuration.inbound_if, configuration.outbound_if, (char*)-1 };
|
||||
int port;
|
||||
int i;
|
||||
char *ptr;
|
||||
@@ -150,13 +152,33 @@ int is_via_local (via_t *via) {
|
||||
|
||||
sts=0;
|
||||
for (i=0; ; i++) {
|
||||
ptr=my_hostnames[i];
|
||||
if (ptr==NULL) break;
|
||||
/*
|
||||
* try to search by interface name first
|
||||
*/
|
||||
ptr=my_interfaces[i];
|
||||
if (ptr==(char*)-1) break; /* end of list mark */
|
||||
|
||||
if (ptr) {
|
||||
DEBUGC(DBCLASS_BABBLE,"resolving IP of interface %s",ptr);
|
||||
sts = get_ip_by_ifname(ptr, &addr_myself);
|
||||
} else {
|
||||
/*
|
||||
* seems to be the old style config...
|
||||
*/
|
||||
ptr=my_hostnames[i];
|
||||
if (ptr==NULL) {
|
||||
ERROR("Could not find my local IP/interface configuration");
|
||||
break;
|
||||
}
|
||||
DEBUGC(DBCLASS_BABBLE,"resolving IP of local name %s",ptr);
|
||||
WARN("using hostnames for inbound/outbound interfaces is");
|
||||
WARN("deprechiated - use interface names instead!");
|
||||
sts = get_ip_by_host(ptr, &addr_myself);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DEBUGC(DBCLASS_BABBLE,"local name %s",ptr);
|
||||
/* check the extracted VIA against my own host addresses */
|
||||
sts = get_ip_by_host(ptr, &addr_myself);
|
||||
|
||||
if (via->port) port=atoi(via->port);
|
||||
else port=SIP_PORT;
|
||||
|
||||
@@ -371,8 +393,8 @@ void secure_enviroment (void) {
|
||||
* fetches own IP address by its interface name
|
||||
*/
|
||||
#define MAX_IF 32
|
||||
struct in_addr* get_ip_by_ifname(char *ifname) {
|
||||
static struct in_addr addr;
|
||||
int get_ip_by_ifname(char *ifname, struct in_addr *retaddr) {
|
||||
struct in_addr addr;
|
||||
int sock, err, i, found;
|
||||
struct ifconf netconf;
|
||||
char buffer[sizeof(struct ifreq)*MAX_IF];
|
||||
@@ -381,7 +403,7 @@ struct in_addr* get_ip_by_ifname(char *ifname) {
|
||||
|
||||
if (ifname == NULL) {
|
||||
ERROR("get_ip_by_ifname: got NULL ifname passed");
|
||||
return NULL;
|
||||
return STS_FAILURE;
|
||||
}
|
||||
|
||||
netconf.ifc_len=sizeof(struct ifreq)*MAX_IF;
|
||||
@@ -438,9 +460,10 @@ struct in_addr* get_ip_by_ifname(char *ifname) {
|
||||
if (found==1) {
|
||||
DEBUGC(DBCLASS_DNS, "get_ip_by_ifname: interface %s has IP: %s",
|
||||
ifname, inet_ntoa(addr));
|
||||
return &addr;
|
||||
if (retaddr) memcpy(retaddr, &addr, sizeof(addr));
|
||||
return STS_SUCCESS;
|
||||
} else {
|
||||
ERROR("get_ip_by_ifname: interface %s does not exist", ifname);
|
||||
return NULL;
|
||||
return STS_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user