- Working on code that that will allow siproxd to use
separate interfaces in its "in front of NAT routes" setup. ( UA1[LAN0]--siproxd--LAN1--NAT--Internet--UA2 )
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
0.6.1
|
||||
=====
|
||||
22-Nov-2007: - Working on code that that will allow siproxd to use
|
||||
separate interfaces in its "in front of NAT routes" setup.
|
||||
( UA1[LAN0]--siproxd--LAN1--NAT--Internet--UA2 )
|
||||
12-Nov-2007: - Small changes to compile again under OpenBSD.
|
||||
|
||||
0.6.0
|
||||
|
||||
15
src/proxy.c
15
src/proxy.c
@@ -1078,15 +1078,22 @@ if (configuration.debuglevel)
|
||||
|
||||
/*
|
||||
* Am I running in front of the routing device? Then I cannot
|
||||
* use the external IP to bind a listen socket to, so force
|
||||
* the use of my inbound IP for listening.
|
||||
* use the external IP to bind a listen socket to, but should
|
||||
* use my real IP on the outbound interface (which may legally
|
||||
* be the same as the inbound interface if only one interface
|
||||
* is used).
|
||||
*/
|
||||
if ((rtp_direction == DIR_INCOMING) &&
|
||||
(configuration.outbound_host) &&
|
||||
(strcmp(configuration.outbound_host, "")!=0)) {
|
||||
DEBUGC(DBCLASS_PROXY, "proxy_rewrite_invitation_body: "
|
||||
"in-front-of-NAT-Router");
|
||||
memcpy(&map_addr, &inside_addr, sizeof (map_addr));
|
||||
"in-front-of-NAT-Router, use real outboud IP");
|
||||
if (get_interface_real_ip(IF_OUTBOUND, &map_addr)
|
||||
!= STS_SUCCESS) {
|
||||
ERROR("cannot get my real outbound interface address");
|
||||
/* as we do not know better, take the internal address */
|
||||
memcpy(&map_addr, &inside_addr, sizeof (map_addr));
|
||||
}
|
||||
}
|
||||
|
||||
sts = rtp_start_fwd(osip_message_get_call_id(mymsg),
|
||||
|
||||
@@ -223,7 +223,7 @@ int is_via_local (osip_via_t *via) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/* check againt a possible defined 'host_outbound' */
|
||||
/* check against a possible defined 'host_outbound' */
|
||||
DEBUGC(DBCLASS_BABBLE,"resolving IP of interface ''host_outbound'");
|
||||
/* defined? */
|
||||
if (configuration.outbound_host == NULL) continue;
|
||||
|
||||
@@ -173,6 +173,7 @@ int get_ip_by_host(char *hostname, struct in_addr *addr); /*X*/
|
||||
void secure_enviroment (void);
|
||||
int get_ip_by_ifname(char *ifname, struct in_addr *retaddr); /*X*/
|
||||
int get_interface_ip(int interface, struct in_addr *retaddr); /*X*/
|
||||
int get_interface_real_ip(int interface, struct in_addr *retaddr); /*X*/
|
||||
char *utils_inet_ntoa(struct in_addr in);
|
||||
int utils_inet_aton(const char *cp, struct in_addr *inp);
|
||||
int createpidfile(char *pidfilename); /*X*/
|
||||
|
||||
35
src/utils.c
35
src/utils.c
@@ -315,19 +315,13 @@ void secure_enviroment (void) {
|
||||
/*
|
||||
* get_interface_ip:
|
||||
* fetches own IP address by interface INBOUND/OUTBOUND
|
||||
* takes into account a possible outbound_host setting.
|
||||
*
|
||||
* STS_SUCCESS on returning a valid IP and interface is UP
|
||||
* STS_FAILURE if interface is DOWN or other problem
|
||||
*/
|
||||
int get_interface_ip(int interface, struct in_addr *retaddr) {
|
||||
int sts=STS_FAILURE;
|
||||
char *tmp=NULL;
|
||||
|
||||
if (interface == IF_INBOUND) {
|
||||
tmp = configuration.inbound_if;
|
||||
} else if (interface == IF_OUTBOUND) {
|
||||
tmp = configuration.outbound_if;
|
||||
}
|
||||
|
||||
if ((interface == IF_OUTBOUND) &&
|
||||
(configuration.outbound_host) &&
|
||||
@@ -339,7 +333,32 @@ int get_interface_ip(int interface, struct in_addr *retaddr) {
|
||||
sts = STS_SUCCESS;
|
||||
}
|
||||
|
||||
} else if (tmp && (strcmp(tmp, "")!=0)) {
|
||||
} else {
|
||||
sts = get_interface_real_ip(interface, retaddr);
|
||||
}
|
||||
|
||||
return sts;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_interface_real_ip:
|
||||
* fetches the real IP address of my interface INBOUND/OUTBOUND
|
||||
*
|
||||
* STS_SUCCESS on returning a valid IP and interface is UP
|
||||
* STS_FAILURE if interface is DOWN or other problem
|
||||
*/
|
||||
int get_interface_real_ip(int interface, struct in_addr *retaddr) {
|
||||
int sts=STS_FAILURE;
|
||||
char *tmp=NULL;
|
||||
|
||||
if (interface == IF_INBOUND) {
|
||||
tmp = configuration.inbound_if;
|
||||
} else if (interface == IF_OUTBOUND) {
|
||||
tmp = configuration.outbound_if;
|
||||
}
|
||||
|
||||
if (tmp && (strcmp(tmp, "")!=0)) {
|
||||
DEBUGC(DBCLASS_DNS, "fetching interface IP by INTERFACE [%i]", interface);
|
||||
sts = get_ip_by_ifname(tmp, retaddr);
|
||||
if (sts != STS_SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user