summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/socket_wrapper.17
-rw-r--r--doc/socket_wrapper.1.txt18
-rw-r--r--src/socket_wrapper.c27
3 files changed, 42 insertions, 10 deletions
diff --git a/doc/socket_wrapper.1 b/doc/socket_wrapper.1
index b62fb6f..e244f10 100644
--- a/doc/socket_wrapper.1
+++ b/doc/socket_wrapper.1
@@ -75,9 +75,14 @@ Ability to capture network traffic in pcap format\&.
The user defines a directory where to put all the unix sockets using the environment variable "SOCKET_WRAPPER_DIR=/path/to/socket_dir"\&. When a server opens a port or a client wants to connect, socket_wrapper will translate IP addresses to a special socket_wrapper name and look for the relevant Unix socket in the SOCKET_WRAPPER_DIR\&.
.RE
.PP
+\fBSOCKET_WRAPPER_IPV4_NETWORK\fR
+.RS 4
+By default the loopback IPv4 network "127\&.0\&.0\&.0/8" and the "127\&.0\&.0\&.x" can be used\&. In order to make more realistic testing possible it is possible to use the "10\&.0\&.0\&.0/8" IPv4 network instead\&. But note within "10\&.0\&.0\&.0/8" only "10\&.53\&.57\&.<ID>" can be used, but the broadcast address is "10\&.255\&.255\&.255"\&. The following two value are allowed: SOCKET_WRAPPER_IPV4_NETWORK="127\&.0\&.0\&.0" (the default) and SOCKET_WRAPPER_IPV4_NETWORK="10\&.53\&.57\&.0"\&.
+.RE
+.PP
\fBSOCKET_WRAPPER_DEFAULT_IFACE\fR
.RS 4
-Additionally, the default interface to be used by an application is defined with "SOCKET_WRAPPER_DEFAULT_IFACE=<ID>" where the valid range for <ID> starts with 1 (the default) and ends with 64\&. This is analogous to use the IPv4 addresses "127\&.0\&.0\&.<ID>" or IPv6 addresses "fd00::5357:5f<IDx>" (where <IDx> is a hexadecimal presentation of <ID>)\&. You should always set the default interface\&. If you listen on INADDR_ANY then it will use the default interface to listen on\&.
+Additionally, the default interface to be used by an application is defined with "SOCKET_WRAPPER_DEFAULT_IFACE=<ID>" where the valid range for <ID> starts with 1 (the default) and ends with 64\&. This is analogous to use the IPv4 addresses "127\&.0\&.0\&.<ID>"/"10\&.53\&.57\&.<ID>" or IPv6 addresses "fd00::5357:5f<IDx>" (where <IDx> is a hexadecimal presentation of <ID>)\&. You should always set the default interface\&. If you listen on INADDR_ANY then it will use the default interface to listen on\&.
.RE
.PP
\fBSOCKET_WRAPPER_PCAP_FILE\fR
diff --git a/doc/socket_wrapper.1.txt b/doc/socket_wrapper.1.txt
index 15b99bf..c00d582 100644
--- a/doc/socket_wrapper.1.txt
+++ b/doc/socket_wrapper.1.txt
@@ -36,14 +36,26 @@ opens a port or a client wants to connect, socket_wrapper will translate IP
addresses to a special socket_wrapper name and look for the relevant Unix
socket in the SOCKET_WRAPPER_DIR.
+*SOCKET_WRAPPER_IPV4_NETWORK*::
+
+By default the loopback IPv4 network "127.0.0.0/8" and the
+"127.0.0.x" can be used. In order to make more realistic testing
+possible it is possible to use the "10.0.0.0/8" IPv4 network instead.
+But note within "10.0.0.0/8" only "10.53.57.<ID>" can be used,
+but the broadcast address is "10.255.255.255".
+The following two value are allowed:
+SOCKET_WRAPPER_IPV4_NETWORK="127.0.0.0" (the default) and
+SOCKET_WRAPPER_IPV4_NETWORK="10.53.57.0".
+
*SOCKET_WRAPPER_DEFAULT_IFACE*::
Additionally, the default interface to be used by an application is defined with
"SOCKET_WRAPPER_DEFAULT_IFACE=<ID>" where the valid range for <ID> starts with 1
(the default) and ends with 64. This is analogous to use the IPv4 addresses
-"127.0.0.<ID>" or IPv6 addresses "fd00::5357:5f<IDx>" (where <IDx> is a
-hexadecimal presentation of <ID>). You should always set the default interface.
-If you listen on INADDR_ANY then it will use the default interface to listen on.
+"127.0.0.<ID>"/"10.53.57.<ID>" or IPv6 addresses "fd00::5357:5f<IDx>" (where
+<IDx> is a hexadecimal presentation of <ID>). You should always set the default
+interface. If you listen on INADDR_ANY then it will use the default interface to
+listen on.
*SOCKET_WRAPPER_PCAP_FILE*::
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index d05182f..cee7c51 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1193,13 +1193,18 @@ static void swrap_bind_symbol_all(void)
*********************************************************/
/*
- * For now we return 127.0.0.0
+ * We return 127.0.0.0 (default) or 10.53.57.0.
+ *
+ * This can be controlled by:
+ * SOCKET_WRAPPER_IPV4_NETWORK=127.0.0.0 (default)
+ * or
+ * SOCKET_WRAPPER_IPV4_NETWORK=10.53.57.0
*/
static in_addr_t swrap_ipv4_net(void)
{
static int initialized;
static in_addr_t hv;
- const char *net_str = "127.0.0.0";
+ const char *net_str = NULL;
struct in_addr nv;
int ret;
@@ -1208,6 +1213,11 @@ static in_addr_t swrap_ipv4_net(void)
}
initialized = 1;
+ net_str = getenv("SOCKET_WRAPPER_IPV4_NETWORK");
+ if (net_str == NULL) {
+ net_str = "127.0.0.0";
+ }
+
ret = inet_pton(AF_INET, net_str, &nv);
if (ret <= 0) {
SWRAP_LOG(SWRAP_LOG_ERROR,
@@ -1237,7 +1247,7 @@ static in_addr_t swrap_ipv4_net(void)
}
/*
- * This returns 127.255.255.255
+ * This returns 127.255.255.255 or 10.255.255.255
*/
static in_addr_t swrap_ipv4_bcast(void)
{
@@ -1250,7 +1260,7 @@ static in_addr_t swrap_ipv4_bcast(void)
}
/*
- * This returns 127.0.0.${iface}
+ * This returns 127.0.0.${iface} or 10.53.57.${iface}
*/
static in_addr_t swrap_ipv4_iface(unsigned int iface)
{
@@ -1846,12 +1856,17 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i
type = a_type;
iface = socket_wrapper_default_iface();
} else if (b_type && addr == sw_bcast_addr) {
- /* 127.255.255.255 only udp */
+ /*
+ * 127.255.255.255
+ * or
+ * 10.255.255.255
+ * only udp
+ */
is_bcast = 1;
type = b_type;
iface = socket_wrapper_default_iface();
} else if ((addr & 0xFFFFFF00) == sw_net_addr) {
- /* 127.0.0.X */
+ /* 127.0.0.X or 10.53.57.X */
is_bcast = 0;
type = u_type;
iface = (addr & 0x000000FF);