slirp.c revision 21f41483611463008ef71e88d2c2b5ece30bc290
/* $Id$ */
/** @file
* NAT - slirp glue.
*/
/*
* Copyright (C) 2006-2010 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 Unix API */
/* 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)
# define rdhup_poll (POLLHUP)
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
#else
#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
};
#ifdef RT_OS_WINDOWS
const char **ppszDomain)
{
ULONG flags = GAA_FLAG_INCLUDE_PREFIX; /*GAA_FLAG_INCLUDE_ALL_INTERFACES;*/ /* all interfaces registered in NDIS */
int wlen = 0;
char *pszSuffix;
/* @todo add SKIPing flags to get only required information */
/* determine size of buffer */
size = 0;
if (ret != ERROR_BUFFER_OVERFLOW)
{
return -1;
}
if (size == 0)
{
Log(("NAT: Win socket API returns non capacity\n"));
return -1;
}
if (!pAdapterAddr)
{
Log(("NAT: No memory available\n"));
return -1;
}
if (ret != ERROR_SUCCESS)
{
return -1;
}
{
int found;
continue;
{
continue;
/* add dns server to list */
if (!pDns)
{
Log(("NAT: Can't allocate buffer for DNS entry\n"));
return VERR_NO_MEMORY;
}
else
continue;
/* uniq */
{
continue;
}
found = 0;
{
{
found = 1;
break;
}
}
if (!found)
{
if (!pDomain)
{
Log(("NAT: not enough memory\n"));
return VERR_NO_MEMORY;
}
}
}
}
return 0;
}
#else /* !RT_OS_WINDOWS */
{
char bTest;
int rc = VERR_NO_MEMORY;
*pcbRead = 0;
{
if (cbRead == 0)
return VERR_EOF;
{
*pu8Buf = 0;
return VINF_SUCCESS;
}
pu8Buf++;
(*pcbRead)++;
}
return rc;
}
const char **ppszDomain)
{
char buff[512];
char buff2[256];
RTFILE f;
int cNameserversFound = 0;
bool fWarnTooManyDnsServers = false;
int rc;
# ifdef RT_OS_OS2
/* Try various locations. */
if (etc)
{
}
if (RT_FAILURE(rc))
{
}
if (RT_FAILURE(rc))
{
}
# else /* !RT_OS_OS2 */
# ifndef DEBUG_vvl
# else
if (RT_SUCCESS(rc))
{
}
else
{
}
# endif
# endif /* !RT_OS_OS2 */
if (RT_FAILURE(rc))
return -1;
if (ppszDomain)
*ppszDomain = NULL;
Log(("NAT: DNS Servers:\n"));
{
if ( cNameserversFound == 4
{
fWarnTooManyDnsServers = true;
LogRel(("NAT: too many nameservers registered.\n"));
}
{
continue;
/* localhost mask */
if (!pDns)
{
Log(("can't alloc memory for DNS entry\n"));
return -1;
}
/* check */
if ((pDns->de_addr.s_addr & RT_H2N_U32_C(IN_CLASSA_NET)) == RT_N2H_U32_C(INADDR_LOOPBACK & IN_CLASSA_NET))
{
}
}
{
char *tok;
char *saveptr;
int fFoundDomain = 0;
{
{
fFoundDomain = 1;
break;
}
}
{
if (!pDomain)
{
Log(("NAT: not enought memory to add domain list\n"));
return VERR_NO_MEMORY;
}
}
}
}
RTFileClose(f);
if (!cNameserversFound)
return -1;
return 0;
}
#endif /* !RT_OS_WINDOWS */
{
}
{
{
}
{
}
}
{
}
int iIcmpCacheLimit, void *pvUser)
{
int fNATfailed = 0;
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 */
#ifdef RT_OS_WINDOWS
{
}
#endif
#ifdef VBOX_WITH_SLIRP_MT
#endif
link_up = 1;
if (RT_FAILURE(rc))
{
Log(("NAT: DHCP server initialization failed\n"));
return rc;
}
debug_init();
/* Initialise mbufs *after* setting the MTU */
/* @todo: add ability to configure this staff */
/* set default addresses */
if (!pData->fUseHostResolver)
{
if (slirp_init_dns_list(pData) < 0)
fNATfailed = 1;
}
{
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)
}
}
/**
* 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); */
#endif /* VBOX_WITH_STATISTICS */
}
/**
* Deregister statistics.
*/
{
return;
#ifdef VBOX_WITH_STATISTICS
# include "counters.h"
#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;
{
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)
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
/*
* 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
*/
{
{
{
}
#ifdef VBOX_WITH_SLIRP_MT
/* we need so_next for continue our cycle*/
#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 */
}
{
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 */
|| errno == EWOULDBLOCK
|| errno == EINPROGRESS
{
LogFlowFunc(("LEAVE: true"));
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"));
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
*/
/* { */
#ifdef VBOX_WITH_SLIRP_MT
{
{
}
{
}
NSOCK_DEC();
}
#endif
/*
* FD_ISSET is meaningless on these sockets
* (and they can crash the program)
*/
/*
* 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
*/
{
}
/* 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
*/
for (;;)
{
if (ret > 0)
else
{
break;
}
}
/* 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
}
/*
* Check sockets for writing
*/
#ifdef RT_OS_WINDOWS
#endif
)
{
}
/*
* Probe a still-connecting, non-blocking socket
* to check if it's still alive
*/
#ifdef PROBE_CONN
{
if (ret < 0)
{
/* XXX */
|| errno == EWOULDBLOCK
|| errno == EINPROGRESS
{
}
/* else failed */
/* tcp_input will take care of it */
}
else
{
if (ret < 0)
{
/* XXX */
|| errno == EWOULDBLOCK
|| errno == EINPROGRESS
{
}
/* else failed */
}
else
}
} /* SS_ISFCONNECTING */
#endif
}
/*
* Now UDP sockets.
* Incoming packets are sent straight away, they're not buffered.
* Incoming UDP data isn't buffered either.
*/
/* { */
#ifdef VBOX_WITH_SLIRP_MT
{
{
}
{
}
NSOCK_DEC();
}
#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...
*/
};
/**
* @note This function will free m!
*/
{
int ar_op;
switch (ar_op)
{
case ARPOP_REQUEST:
if (!mr)
break;
if ( 0
#ifdef VBOX_WITH_NAT_SERVICE
#endif
)
)
{
{
case CTL_DNS:
case CTL_ALIAS:
case CTL_TFTP:
{
static bool fTagErrorReported;
if (!fTagErrorReported)
{
LogRel(("NAT: couldn't add the tag(PACKET_SERVICE:%d) to mbuf:%p\n",
fTagErrorReported = true;
}
}
break;
default:;
}
}
else
/* 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
continue; /*not right mac, @todo: it'd be better do the list port forwarding per mac */
#else
#if 0
continue;
#endif
#endif
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 */
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
*/
{
}
#ifdef VBOX_WITH_SLIRP_MT
{
}
{
}
#endif
{
}
{
}
{
if (next_server == NULL)
else
}
{
{
return 1;
}
return 0;
}
{
if (!pData->fUseHostResolver)
{
}
else
LogRel(("NAT: Host Resolver conflicts with DNS proxy, the last one was forcely ignored\n"));
}
do { \
{ \
return; \
} \
else \
} while (0)
{
if (iSoMaxConn > SOMAXCONN)
{
}
}
/* 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;
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 */
}
/* 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;
/* { */
}
/* { */
}
{
}
{
}
}