summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-07-07 21:31:02 +0000
committerBenny Prijono <bennylp@teluu.com>2008-07-07 21:31:02 +0000
commit07852fec4400363969a010259ed304d0abeee92b (patch)
treebb84548918a47eec368c2317e2847c09dbdc481a /pjlib
parent1e3d62ad8a16f5f14a1f5d74e5234f06f3d1471b (diff)
Configuration option to include/exclude loopback interface in enum_ip_interface(), and always include loopback address in the proxy sample (thanks Filippo Zangheri for the suggestion)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2112 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/include/pj/config.h11
-rw-r--r--pjlib/src/pj/ip_helper_generic.c9
-rw-r--r--pjlib/src/pj/ip_helper_win32.c4
3 files changed, 19 insertions, 5 deletions
diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h
index 6c470b28..2940d1aa 100644
--- a/pjlib/include/pj/config.h
+++ b/pjlib/include/pj/config.h
@@ -603,6 +603,17 @@
/**
+ * Specify whether #pj_enum_ip_interface() function should exclude
+ * loopback interfaces.
+ *
+ * Default: 1
+ */
+#ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
+# define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
+#endif
+
+
+/**
* Has semaphore functionality?
*
* Default: 1
diff --git a/pjlib/src/pj/ip_helper_generic.c b/pjlib/src/pj/ip_helper_generic.c
index 6eaba54a..6a3d19e7 100644
--- a/pjlib/src/pj/ip_helper_generic.c
+++ b/pjlib/src/pj/ip_helper_generic.c
@@ -85,14 +85,17 @@ static pj_status_t if_enum_by_af(int af,
continue; /* Skip when interface is down */
}
+#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF
if (it->ifa_flags & IFF_LOOPBACK) {
TRACE_((THIS_FILE, " loopback interface"));
continue; /* Skip loopback interface */
}
+#endif
if (ad==NULL) {
TRACE_((THIS_FILE, " NULL address ignored"));
- continue; /* reported to happen on Linux 2.6.25.9 */
+ continue; /* reported to happen on Linux 2.6.25.9
+ with ppp interface */
}
if (ad->sa_family != af) {
@@ -188,10 +191,12 @@ static pj_status_t if_enum_by_af(int af,
continue; /* Skip when interface is down */
}
+#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF
if (itf->ifr_flags & IFF_LOOPBACK) {
TRACE_((THIS_FILE, " loopback interface"));
continue; /* Skip loopback interface */
}
+#endif
/* Ignore 0.0.0.0/8 address. This is a special address
* which doesn't seem to have practical use.
@@ -259,10 +264,12 @@ static pj_status_t if_enum_by_af(int af, unsigned *p_cnt, pj_sockaddr ifs[])
continue; /* Skip when interface is down */
}
+#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF
if (ifreq.ifr_flags & IFF_LOOPBACK) {
TRACE_((THIS_FILE, " loopback interface"));
continue; /* Skip loopback interface */
}
+#endif
/* Note: SIOCGIFADDR does not work for IPv6! */
if ((rc=ioctl(sock, SIOCGIFADDR, &ifreq)) != 0) {
diff --git a/pjlib/src/pj/ip_helper_win32.c b/pjlib/src/pj/ip_helper_win32.c
index 2fc64e01..122ae9b7 100644
--- a/pjlib/src/pj/ip_helper_win32.c
+++ b/pjlib/src/pj/ip_helper_win32.c
@@ -40,10 +40,6 @@
#include <pj/errno.h>
#include <pj/string.h>
-#ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
-# define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
-#endif
-
typedef DWORD (WINAPI *PFN_GetIpAddrTable)(PMIB_IPADDRTABLE pIpAddrTable,
PULONG pdwSize,
BOOL bOrder);