slirp.c revision 55c6dd0c4e495858f1681a45e28e04c791ef066e
/* $Id$ */
/** @file
* NAT - slirp glue.
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*
* This code is based on:
*
* libslirp glue
*
* Copyright (c) 2004-2008 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "slirp.h"
#ifdef RT_OS_OS2
# include <paths.h>
#endif
#ifndef RT_OS_WINDOWS
# include <poll.h>
#else
# include <Winnls.h>
# define _WINSOCK2API_
# include <IPHlpApi.h>
#endif
#include <alias.h>
#ifndef RT_OS_WINDOWS
do { \
{ \
break; \
} \
poll_index++; \
} while (0)
do { \
{ \
break; \
} \
poll_index++; \
} while (0)
/*
* DO_CHECK_FD_SET is used in dumping events on socket, including POLLNVAL.
* gcc warns about attempts to log POLLNVAL so construction in a last to lines
* used to catch POLLNVAL while logging and return false in case of error while
* normal usage.
*/
/* specific for Windows Winsock API */
# ifndef RT_OS_LINUX
# define readfds_poll (POLLRDNORM)
# define writefds_poll (POLLWRNORM)
# else
# define readfds_poll (POLLIN)
# define writefds_poll (POLLOUT)
# endif
# define closefds_poll (POLLHUP)
# define rderr_poll (POLLERR)
# if 0 /* unused yet */
# define rdhup_poll (POLLHUP)
# endif
do { \
} while (0)
#else /* RT_OS_WINDOWS */
/*
* On Windows, we will be notified by IcmpSendEcho2() when the response arrives.
* So no call to WSAEventSelect necessary.
*/
/*
* On Windows we use FD_ALL_EVENTS to ensure that we don't miss any event.
*/
do { \
if (rc == SOCKET_ERROR) \
{ \
/* This should not happen */ \
error = WSAGetLastError(); \
} \
} while (0); \
if ((rc) == SOCKET_ERROR) \
{ \
(error) = WSAGetLastError(); \
}
# define acceptds_win FD_ACCEPT
# define acceptds_win_bit FD_ACCEPT_BIT
# define readfds_win FD_READ
# define readfds_win_bit FD_READ_BIT
# define writefds_win FD_WRITE
# define writefds_win_bit FD_WRITE_BIT
# define xfds_win_bit FD_OOB_BIT
# define closefds_win FD_CLOSE
# define closefds_win_bit FD_CLOSE_BIT
# define connectfds_win FD_CONNECT
# define connectfds_win_bit FD_CONNECT_BIT
# define closefds_win FD_CLOSE
# define closefds_win_bit FD_CLOSE_BIT
#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_WINDOWS
#endif
/*
* Loging macros
*/
# if defined(RT_OS_WINDOWS)
do { \
} while (0)
# else /* !RT_OS_WINDOWS */
do { \
} while (0)
# endif /* !RT_OS_WINDOWS */
#else /* !VBOX_WITH_DEBUG_NAT_SOCKETS */
#endif /* !VBOX_WITH_DEBUG_NAT_SOCKETS */
{
0x52, 0x54, 0x00, 0x12, 0x35, 0x00
};
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};
/**
* This helper routine do the checks in descriptions to
* ''fUnderPolling'' and ''fShouldBeRemoved'' flags
* @returns 1 if socket removed and 0 if no changes was made.
*/
{
AssertPtrReturn(pData, 0);
AssertPtrReturn(pSocket, 0);
if (pSocket->fShouldBeRemoved)
{
pSocket->fUnderPolling = 0;
/* pSocket is PHANTOM, now */
return 1;
}
return 0;
}
int iIcmpCacheLimit, void *pvUser)
{
int rc;
if (u32Netmask & 0x1f)
/* CTL is x.x.x.15, bootp passes up to 16 IPs (15..31) */
return VERR_INVALID_PARAMETER;
if (!pData)
return VERR_NO_MEMORY;
/* sockets & TCP defaults */
/*
* Use the same default here as in DevNAT.cpp (SoMaxConnection CFGM value)
* to avoid release log noise.
*/
#ifdef RT_OS_WINDOWS
{
}
#endif
link_up = 1;
if (RT_FAILURE(rc))
{
Log(("NAT: DHCP server initialization failed\n"));
return rc;
}
/* Initialise mbufs *after* setting the MTU */
/* @todo: add ability to configure this staff */
/* set default addresses */
if (!fUseHostResolver)
{
}
{
i32AliasMode = 0;
}
{
int flags = 0;
struct in_addr proxy_addr;
{
Log(("NAT: LibAlias default rule wasn't initialized\n"));
AssertMsgFailed(("NAT: LibAlias default rule wasn't initialized\n"));
}
#ifndef NO_FW_PUNCH
#endif
if (pData->fUseHostResolver)
}
#ifdef VBOX_WITH_NAT_SEND2HOME
/* @todo: we should know all interfaces available on host. */
# ifdef RT_OS_DARWIN
# endif
#endif
return VINF_SUCCESS;
}
/**
* Register statistics.
*/
{
#ifdef VBOX_WITH_STATISTICS
# define PROFILE_COUNTER(name, dsc) REGISTER_COUNTER(name, pData, STAMTYPE_PROFILE, STAMUNIT_TICKS_PER_CALL, dsc)
# define COUNTING_COUNTER(name, dsc) REGISTER_COUNTER(name, pData, STAMTYPE_COUNTER, STAMUNIT_COUNT, dsc)
# include "counters.h"
/** @todo register statistics for the variables dumped by:
* ipstats(pData); tcpstats(pData); udpstats(pData); icmpstats(pData);
* mbufstats(pData); sockstats(pData); */
#else /* VBOX_WITH_STATISTICS */
#endif /* !VBOX_WITH_STATISTICS */
}
/**
* Deregister statistics.
*/
{
return;
#ifdef VBOX_WITH_STATISTICS
# include "counters.h"
#else /* VBOX_WITH_STATISTICS */
#endif /* !VBOX_WITH_STATISTICS */
}
/**
* Marks the link as up, making it possible to establish new connections.
*/
{
struct arp_cache_entry *ac;
link_up = 1;
return;
{
}
}
/**
* Marks the link as down and cleans up the current connections.
*/
{
struct port_forward_rule *rule;
{
/* Don't miss TCB releasing */
|| so->s == -1))
else
}
/*
* Clear the active state of port-forwarding rules to force
* re-setup on restoration of communications.
*/
{
}
pData->cRedirectionsActive = 0;
link_up = 0;
}
/**
* Terminates the slirp component.
*/
{
return;
if (pData->fUseHostResolver)
{
{
}
#endif
}
while (!LIST_EMPTY(&instancehead))
{
/* libalias do all clean up */
}
{
}
#ifdef RT_OS_WINDOWS
WSACleanup();
#endif
#ifndef VBOX_WITH_SLIRP_BSD_SBUF
#ifdef LOG_ENABLED
Log(("\n"
"NAT statistics\n"
"--------------\n"
"\n"));
Log(("\n"
"\n"
"\n"));
#endif
#endif
}
#define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
/*
* curtime kept to an accuracy of 1ms
*/
{
#ifdef RT_OS_WINDOWS
#else
gettimeofday(&tt, 0);
curtime++;
#endif
}
#ifdef RT_OS_WINDOWS
#else /* RT_OS_WINDOWS */
#endif /* !RT_OS_WINDOWS */
{
int nfds;
#if defined(RT_OS_WINDOWS)
int rc;
int error;
#else
int poll_index = 0;
#endif
int i;
/*
* First, TCP sockets
*/
do_slowtimo = 0;
if (!link_up)
goto done;
/*
* *_slowtimo needs calling if there are IP fragments
* in the fragment queue, or there are TCP connections active
*/
/* XXX:
* triggering of fragment expiration should be the same but use new macroses
*/
if (!do_slowtimo)
{
for (i = 0; i < IPREASS_NHASH; i++)
{
if (!TAILQ_EMPTY(&ipq[i]))
{
do_slowtimo = 1;
break;
}
}
}
/* always add the ICMP socket */
#ifndef RT_OS_WINDOWS
#endif
/* { */
#if !defined(RT_OS_WINDOWS)
#endif
/* TCP socket can't be cloned */
#endif
/*
* See if we need a tcp_fasttimo
*/
if ( time_fasttimo == 0
{
}
/*
* NOFDREF can include still connecting to local-host,
* newly socreated() sockets etc. Don't want to select these.
*/
/*
* Set for reading sockets which are accepting
*/
{
}
/*
* Set for writing sockets which are connecting
*/
{
#ifdef RT_OS_WINDOWS
#else
#endif
}
/*
* Set for writing if we are connected, can send more, and
* we have something to send
*/
{
}
/*
* Set for reading (and urgent data) if we are connected, can
* receive more, and we have room for it XXX /2 ?
*/
/* @todo: vvl - check which predicat here will be more useful here in rerm of new sbufs. */
if ( CONN_CANFRCV(so)
#ifdef RT_OS_WINDOWS
#endif
)
{
}
}
/*
* UDP sockets
*/
/* { */
#if !defined(RT_OS_WINDOWS)
#endif
/*
* See if it's timed out
*/
{
{
{
/* so_timeout - might change the so_expire value or
* drop so_timeout* from so.
*/
/* on 4.2 so->
*/
}
}
}
if (so->so_cloneOf)
#endif
/*
* When UDP packets are received from over the link, they're
* sendto()'d straight away, so no need for setting for writing
* Limit the number of packets queued by this session to 4.
* Note that even though we try and limit this to 4 packets,
* the session could have more queued if the packets needed
* to be fragmented.
*
* (XXX <= 4 ?)
*/
{
}
}
done:
#if defined(RT_OS_WINDOWS)
#else /* RT_OS_WINDOWS */
*pnfds = poll_index;
#endif /* !RT_OS_WINDOWS */
}
/**
* This function do Connection or sending tcp sequence to.
* @returns if true operation completed
* @note: functions call tcp_input that potentially could lead to tcp_drop
*/
{
int ret;
/*
* Check for non-blocking, still-connecting sockets
*/
{
/* Connected */
/*
* This should be probably guarded by PROBE_CONN too. Anyway,
* we disable it on OS/2 because the below send call returns
* EFAULT which causes the opened TCP socket to close right
* after it has been opened and connected.
*/
#ifndef RT_OS_OS2
if (ret < 0)
{
/* XXXXX Must fix, zero bytes is a NOP */
if ( soIgnorableErrorCode(errno)
{
LogFlowFunc(("LEAVE: false\n"));
return false;
}
/* else failed */
}
/* else so->so_state &= ~SS_ISFCONNECTING; */
#endif
/*
* Continue tcp_input
*/
/* continue; */
}
else if (!fConnectOnly)
/*
* XXX If we wrote something (a lot), there could be the need
* for a window update. In the worst case, the remote will send
* a window probe to get things going again.
*/
LogFlowFunc(("LEAVE: true\n"));
return true;
}
#if defined(RT_OS_WINDOWS)
#else /* RT_OS_WINDOWS */
#endif /* !RT_OS_WINDOWS */
{
int ret;
#if defined(RT_OS_WINDOWS)
int rc;
int error;
#endif
/* Update time */
/*
* See if anything has timed out
*/
if (link_up)
{
{
time_fasttimo = 0;
}
{
}
}
#if defined(RT_OS_WINDOWS)
if (fTimeout)
return; /* only timer update */
#endif
/*
* Check sockets
*/
if (!link_up)
goto done;
#if defined(RT_OS_WINDOWS)
/*XXX: before renaming please make see define
* fIcmp in slirp_state.h
*/
if (fIcmp)
#else
#endif
/*
* Check TCP sockets
*/
/* { */
/* TCP socket can't be cloned */
#endif
/*
* FD_ISSET is meaningless on these sockets
* (and they can crash the program)
*/
{
so->fUnderPolling = 0;
}
/*
* Check for URG data
* This will soread as well, so no need to
* test for readfds below if this succeeds
*/
/* out-of-band data */
#ifdef RT_OS_DARWIN
/* Darwin and probably BSD hosts generates POLLPRI|POLLHUP event on receiving TCP.flags.{ACK|URG|FIN} this
* combination on other Unixs hosts doesn't enter to this branch
*/
#endif
#ifdef RT_OS_WINDOWS
/**
* In some cases FD_CLOSE comes with FD_OOB, that confuse tcp processing.
*/
#endif
)
{
}
/*
* Check sockets for reading
*/
{
#ifdef RT_OS_WINDOWS
{
/* Finish connection first */
/* should we ignore return value? */
}
#endif
/*
* Check for incoming connections
*/
{
{
so->fUnderPolling = 0;
}
}
/* Output it if we read something */
}
/*
* Check for FD_CLOSE events.
* in some cases once FD_CLOSE engaged on socket it could be flashed latter (for some reasons)
*/
{
/*
* drain the socket
*/
{
break;
if (ret > 0)
{
break;
}
}
/* if socket freed ''so'' is PHANTOM and next socket isn't points on it */
{
/* mark the socket for termination _after_ it was drained */
/* No idea about Windows but on Posix, POLLHUP means that we can't send more.
* Actually in the specific error scenario, POLLERR is set as well. */
#ifndef RT_OS_WINDOWS
#endif
}
so->fUnderPolling = 0;
}
/*
* Check sockets for writing
*/
#ifdef RT_OS_WINDOWS
#endif
)
{
/* slirpConnectOrWrite could return true even if tcp_input called tcp_drop,
* so we should be ready to such situations.
*/
else if (!fConnectOrWriteSuccess)
{
so->fUnderPolling = 0;
}
/* slirpConnectionOrWrite succeeded and socket wasn't dropped */
}
/*
* Probe a still-connecting, non-blocking socket
* to check if it's still alive
*/
#ifdef PROBE_CONN
{
if (ret < 0)
{
/* XXX */
if ( soIgnorableErrorCode(errno)
{
}
/* else failed */
/* tcp_input will take care of it */
}
else
{
if (ret < 0)
{
/* XXX */
if ( soIgnorableErrorCode(errno)
{
}
/* else failed */
}
else
}
} /* SS_ISFCONNECTING */
#endif
so->fUnderPolling = 0;
}
/*
* Now UDP sockets.
* Incoming packets are sent straight away, they're not buffered.
* Incoming UDP data isn't buffered either.
*/
/* { */
if (so->so_cloneOf)
#endif
#if 0
so->fUnderPolling = 0;
#endif
{
}
}
done:
}
struct arphdr
{
unsigned short ar_hrd; /* format of hardware address */
unsigned short ar_pro; /* format of protocol address */
unsigned char ar_hln; /* length of hardware address */
unsigned char ar_pln; /* length of protocol address */
unsigned short ar_op; /* ARP opcode (command) */
/*
* Ethernet looks like this : This bit is variable sized however...
*/
};
static void arp_output(PNATState pData, const uint8_t *pcu8EtherSource, const struct arphdr *pcARPHeaderSource, uint32_t ip4TargetAddress)
{
struct ethhdr *pEtherHeaderResponse;
struct arphdr *pARPHeaderResponse;
struct mbuf *pMbufResponse;
if (!pcu8EtherSource)
return;
if (!pMbufResponse)
return;
/* @note: if_encap will swap src and dst*/
if (!slirpMbufTagService(pData, pMbufResponse, (uint8_t)(ip4TargetAddressInHostFormat & ~pData->netmask)))
{
static bool fTagErrorReported;
if (!fTagErrorReported)
{
LogRel(("NAT: couldn't add the tag(PACKET_SERVICE:%d)\n",
fTagErrorReported = true;
}
}
}
/**
* @note This function will free m!
*/
{
struct ethhdr *pEtherHeader;
struct arphdr *pARPHeader;
int ar_op;
switch (ar_op)
{
case ARPOP_REQUEST:
/* Gratuitous ARP */
{
/* We've received an announce about address assignment,
* let's do an ARP cache update
*/
static bool fGratuitousArpReported;
if (!fGratuitousArpReported)
{
LogRel(("NAT: Gratuitous ARP [IP:%RTnaipv4, ether:%RTmac]\n",
fGratuitousArpReported = true;
}
}
break;
case ARPOP_REPLY:
break;
default:
break;
}
}
/**
* Feed a packet into the slirp engine.
*
* @param m Data buffer, m_len is not valid.
* @param cbBuf The length of the data in m.
*/
{
int proto;
static bool fWarnedIpv6;
{
return;
}
switch(proto)
{
case ETH_P_ARP:
break;
case ETH_P_IP:
/* Update time. Important if the network is very quiet, as otherwise
* the first outgoing connection gets an incorrect timestamp. */
M_ASSERTPKTHDR(m);
break;
case ETH_P_IPV6:
if (!fWarnedIpv6)
{
LogRel(("NAT: IPv6 not supported\n"));
fWarnedIpv6 = true;
}
break;
default:
break;
}
}
/**
* Output the IP packet to the ethernet device.
*
* @note This function will free m!
*/
{
LogFlowFunc(("ENTER: pData:%p, eth_proto:%RX16, m:%p, flags:%d\n",
M_ASSERTPKTHDR(m);
{
struct m_tag *t = m_tag_first(m);
{
/* don't do anything */
goto done;
}
if ( t
{
Assert(t);
}
}
/*
* we're processing the chain, that isn't not expected.
*/
if (m->m_next)
{
Log(("NAT: if_encap's recived the chain, dropping...\n"));
goto done;
}
if (flags & ETH_ENCAP_URG)
else
done:
}
/**
* Still we're using dhcp server leasing to map ether to IP
* @todo see rt_lookup_in_cache
*/
{
int rc;
return INADDR_ANY;
return INADDR_ANY;
if (RT_SUCCESS(rc))
return ip;
/* ignore return code, ip will be set to INADDR_ANY on error */
return ip;
}
/**
* We need check if we've activated port forwarding
* for specific machine ... that of course relates to
* service mode
* @todo finish this for service case
*/
{
/* check mac here */
{
struct alias_link *alias_link;
int flags;
struct sockaddr_in *psin;
int rc;
continue;
#ifdef VBOX_WITH_NAT_SERVICE
/**
* case when guest ip is INADDR_ANY shouldn't appear in NAT service
*/
#else /* VBOX_WITH_NAT_SERVICE */
#endif /* !VBOX_WITH_NAT_SERVICE */
if (guest_addr == INADDR_ANY)
{
/* the address wasn't granted */
return;
}
#if !defined(VBOX_WITH_NAT_SERVICE)
continue;
#endif
LogRel(("NAT: set redirect %s host port %d => guest port %d @ %RTnaipv4\n",
else
goto remove_port_forwarding;
goto remove_port_forwarding;
if (!alias_link)
goto remove_port_forwarding;
continue;
LogRel(("NAT: failed to redirect %s %d => %d\n",
}
}
/**
* Changes in 3.1 instead of opening new socket do the following:
* gain more information:
* 1. bind IP
* 2. host port
* 3. guest port
* 4. proto
* 5. guest MAC address
* the guest's MAC address is rather important for service, but we easily
* could get it from VM configuration in DrvNAT or Service, the idea is activating
* corresponding port-forwarding
*/
{
{
)
return 0; /* rule has been already registered */
}
return 1;
/* @todo add mac address */
/* activate port-forwarding if guest has already got assigned IP */
if ( ethaddr
return 0;
}
{
{
{
LogRel(("NAT: remove redirect %s host port %d => guest port %d @ %RTnaipv4\n",
if (is_udp)
else
break;
}
}
return 0;
}
void slirp_set_ethaddr_and_activate_port_forwarding(PNATState pData, const uint8_t *ethaddr, uint32_t GuestIP)
{
#ifndef VBOX_WITH_NAT_SERVICE
#endif
if (GuestIP != INADDR_ANY)
{
}
}
#if defined(RT_OS_WINDOWS)
{
}
{
}
#endif
{
if (link_up)
{
if (time_fasttimo)
return 2;
if (do_slowtimo)
return 500; /* see PR_SLOWHZ */
}
return 3600*1000; /* one hour */
}
#ifndef RT_OS_WINDOWS
{
}
#endif
/*
* this function called from NAT thread
*/
{
}
{
}
{
}
{
if (next_server == NULL)
else
}
{
{
return 1;
}
return 0;
}
{
if (!pData->fUseHostResolver)
{
}
else if (fDNSProxy)
LogRel(("NAT: Host Resolver conflicts with DNS proxy, the last one was forcely ignored\n"));
}
do { \
{ \
return; \
} \
else \
} while (0)
{
/* Conditions */
if (iSoMaxConn > SOMAXCONN)
{
}
if (iSoMaxConn < 1)
{
LogRel(("NAT: proposed value(%d) of somaxconn is invalid, default value is used (%d)\n", iSoMaxConn, pData->soMaxConn));
return;
}
/* Asignment */
{
LogRel(("NAT: value of somaxconn has been changed from %d to %d\n",
}
}
/* don't allow user set less 8kB and more than 1M values */
{
}
{
}
{
}
{
}
/*
* Looking for Ether by ip in ARP-cache
* Note: it´s responsible of caller to allocate buffer for result
* @returns iprt status code
*/
{
struct arp_cache_entry *ac;
return VERR_INVALID_PARAMETER;
return VERR_NOT_FOUND;
{
{
return VINF_SUCCESS;
}
}
return VERR_NOT_FOUND;
}
/*
* Looking for IP by Ether in ARP-cache
* Note: it´s responsible of caller to allocate buffer for result
* @returns 0 - if found, 1 - otherwise
*/
{
struct arp_cache_entry *ac;
*ip = INADDR_ANY;
return VERR_NOT_FOUND;
{
{
return VINF_SUCCESS;
}
}
return VERR_NOT_FOUND;
}
{
struct mbuf *m;
static bool fWarned = false;
/* ARP request WHO HAS 0.0.0.0 is one of the signals
* that something has been broken at Slirp. Investigating
* pcap dumps it's easy to miss warning ARP requests being
* focused on investigation of other protocols flow.
*/
#ifdef DEBUG_vvl
#else
if ( dst == INADDR_ANY
&& !fWarned)
{
LogRel(("NAT:ARP: \"WHO HAS INADDR_ANY\" request has been detected\n"));
fWarned = true;
}
#endif /* !DEBUG_vvl */
if (m == NULL)
{
Log(("NAT: Can't alloc mbuf for ARP request\n"));
return;
}
/* we assume that this request come from gw, but not from DNS or TFTP */
/* warn!!! should falls in mbuf minimal size */
}
void slirp_add_host_resolver_mapping(PNATState pData, const char *pszHostName, const char *pszHostNamePattern, uint32_t u32HostIP)
{
LogFlowFunc(("ENTER: pszHostName:%s, pszHostNamePattern:%s u32HostIP:%RTnaipv4\n",
u32HostIP));
if ( ( pszHostName
&& u32HostIP != INADDR_ANY
&& u32HostIP != INADDR_BROADCAST)
{
if (!pDnsMapping)
{
LogFunc(("Can't allocate DNSMAPPINGENTRY\n"));
return;
}
if (pszHostName)
else if (pszHostNamePattern)
if ( !pDnsMapping->pszCName
&& !pDnsMapping->pszPattern)
{
return;
}
LogRel(("NAT: user-defined mapping %s: %RTnaipv4 is registered\n",
}
}
#endif
/* updates the arp cache
* @note: this is helper function, slirp_arp_cache_update_or_add should be used.
* @returns 0 - if has found and updated
* 1 - if hasn't found.
*/
{
struct arp_cache_entry *ac;
{
{
return 0;
}
}
return 1;
}
/**
* add entry to the arp cache
* @note: this is helper function, slirp_arp_cache_update_or_add should be used.
*/
{
{
Log(("NAT: Can't allocate arp cache entry\n"));
return;
}
}
/* updates or adds entry to the arp cache
* @returns 0 - if has found and updated
* 1 - if hasn't found.
*/
{
{
static bool fBroadcastEtherAddReported;
{
LogRel(("NAT: Attempt to add pair [%RTmac:%RTnaipv4] in ARP cache was ignored\n",
fBroadcastEtherAddReported = true;
}
return 1;
}
return 0;
}
{
{
mtu = 1500;
}
/* MTU is maximum transition unit on */
if_mtu =
}
/**
* Info handler.
*/
{
struct arp_cache_entry *ac;
struct port_forward_rule *rule;
/* { */
}
/* { */
}
{
}
{
}
}