Index: trunk/src/VBox/Devices/Network/slirp/bootp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/bootp.c	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/bootp.c	(revision 8009)
@@ -261,8 +261,8 @@
         *q++ = RFC1533_NETMASK;
         *q++ = 4;
-        *q++ = 0xff;
-        *q++ = 0xff;
-        *q++ = 0xff;
-        *q++ = 0x00;
+        *q++ = (pData->netmask & 0xff000000) >> 24;
+        *q++ = (pData->netmask & 0x00ff0000) >> 16;
+        *q++ = (pData->netmask & 0x0000ff00) >>  8;
+        *q++ = (pData->netmask & 0x000000ff);
 
         *q++ = RFC1533_GATEWAY;
Index: trunk/src/VBox/Devices/Network/slirp/ctl.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/ctl.h	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/ctl.h	(revision 8009)
@@ -5,4 +5,6 @@
 #define CTL_BROADCAST   255
 
+#if 0
 #define CTL_SPECIAL	"10.0.2.0"
 #define CTL_LOCAL	"10.0.2.15"
+#endif
Index: trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/ip_icmp.c	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/ip_icmp.c	(revision 8009)
@@ -136,7 +136,7 @@
       /* Send the packet */
       addr.sin_family = AF_INET;
-      if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
+      if ((so->so_faddr.s_addr & htonl(~pData->netmask)) == special_addr.s_addr) {
 	/* It's an alias */
-	switch(ntohl(so->so_faddr.s_addr) & 0xff) {
+	switch(ntohl(so->so_faddr.s_addr) & ~pData->netmask) {
 	case CTL_DNS:
 	  addr.sin_addr = dns_addr;
Index: trunk/src/VBox/Devices/Network/slirp/libslirp.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/libslirp.h	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/libslirp.h	(revision 8009)
@@ -27,5 +27,5 @@
 #endif
 
-int slirp_init(PNATState *, const char *, bool, const char *, const char *, void *);
+int slirp_init(PNATState *, const char *, uint32_t, bool, const char *, const char *, void *);
 void slirp_term(PNATState);
 void slirp_link_up(PNATState);
Index: trunk/src/VBox/Devices/Network/slirp/slirp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/slirp.c	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/slirp.c	(revision 8009)
@@ -195,7 +195,7 @@
 }
 
-int slirp_init(PNATState *ppData, const char *pszNetAddr, bool fPassDomain,
-               const char *pszTFTPPrefix, const char *pszBootFile,
-               void *pvUser)
+int slirp_init(PNATState *ppData, const char *pszNetAddr, uint32_t u32Netmask,
+               bool fPassDomain, const char *pszTFTPPrefix,
+               const char *pszBootFile, void *pvUser)
 {
     int fNATfailed = 0;
@@ -204,4 +204,7 @@
     if (!pData)
         return VERR_NO_MEMORY;
+    if (u32Netmask & 0x1f)
+        /* CTL is x.x.x.15, bootp passes up to 16 IPs (15..31) */
+        return VERR_INVALID_PARAMETER;
     memset(pData, '\0', sizeof(NATState));
     pData->fPassDomain = fPassDomain;
@@ -212,4 +215,5 @@
     tftp_prefix = pszTFTPPrefix;
     bootp_filename = pszBootFile;
+    pData->netmask = u32Netmask;
 
 #ifdef _WIN32
Index: trunk/src/VBox/Devices/Network/slirp/slirp_state.h
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/slirp_state.h	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/slirp_state.h	(revision 8009)
@@ -84,4 +84,5 @@
     struct in_addr dns_addr;
     struct in_addr loopback_addr;
+    uint32_t netmask;
     uint8_t client_ethaddr[6];
     struct ex_list *exec_list;
Index: trunk/src/VBox/Devices/Network/slirp/socket.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 8009)
@@ -497,10 +497,13 @@
 
         addr.sin_family = AF_INET;
-	if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
+	if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) {
 	  /* It's an alias */
-	  switch(ntohl(so->so_faddr.s_addr) & 0xff) {
+          uint32_t last_byte = ntohl(so->so_faddr.s_addr) & ~pData->netmask;
+	  switch(last_byte) {
+#if 0
+          /* handle this case at 'default:' */
           case CTL_BROADCAST:
             addr.sin_addr.s_addr = INADDR_BROADCAST;
-#if 0
+# if 0
             /* Send the packet to host to fully emulate broadcast */
             /** @todo r=klaus: on Linux host this causes the host to receive
@@ -513,6 +516,7 @@
             sendto(so->s, m->m_data, m->m_len, 0,
                   (struct sockaddr *)&host_addr, sizeof (struct sockaddr));
-#endif
+# endif
             break;
+#endif
 	  case CTL_DNS:
             if (!get_dns_addr(pData, &dns_addr))
@@ -523,5 +527,8 @@
 	  case CTL_ALIAS:
 	  default:
-	    addr.sin_addr = loopback_addr;
+            if (last_byte == ~pData->netmask)
+              addr.sin_addr.s_addr = INADDR_BROADCAST;
+            else
+	      addr.sin_addr = loopback_addr;
 	    break;
 	  }
Index: trunk/src/VBox/Devices/Network/slirp/tcp_input.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_input.c	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_input.c	(revision 8009)
@@ -624,6 +624,6 @@
 	   * tcp_ctl once connected, otherwise connect
 	   */
-	  if ((so->so_faddr.s_addr&htonl(0xffffff00)) == special_addr.s_addr) {
-	    int lastbyte=ntohl(so->so_faddr.s_addr) & 0xff;
+	  if ((so->so_faddr.s_addr&htonl(pData->netmask)) == special_addr.s_addr) {
+	    int lastbyte=ntohl(so->so_faddr.s_addr) & ~pData->netmask;
 	    if (lastbyte!=CTL_ALIAS && lastbyte!=CTL_DNS) {
 #if 0
Index: trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/tcp_subr.c	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/tcp_subr.c	(revision 8009)
@@ -391,7 +391,7 @@
 
     addr.sin_family = AF_INET;
-    if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
+    if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) {
       /* It's an alias */
-      switch(ntohl(so->so_faddr.s_addr) & 0xff) {
+      switch(ntohl(so->so_faddr.s_addr) & ~pData->netmask) {
       case CTL_DNS:
         if (!get_dns_addr(pData, &dns_addr))
Index: trunk/src/VBox/Devices/Network/slirp/udp.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/udp.c	(revision 7809)
+++ trunk/src/VBox/Devices/Network/slirp/udp.c	(revision 8009)
@@ -302,7 +302,7 @@
 
     saddr = *addr;
-    if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
+    if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) {
         saddr.sin_addr.s_addr = so->so_faddr.s_addr;
-        if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff))
+        if ((so->so_faddr.s_addr & htonl(~pData->netmask)) == htonl(~pData->netmask))
             saddr.sin_addr.s_addr = alias_addr.s_addr;
     }
