misc.c revision 97f2e9335308f0b29281f21d1e3166effb194c09
/* $Id$ */
/** @file
* NAT - helpers.
*/
/*
* 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:
*
* Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/
#define WANT_SYS_IOCTL_H
#include <slirp.h>
#include "zone.h"
#ifndef HAVE_INET_ATON
int
{
if (addr == 0xffffffff)
return 0;
return 1;
}
#endif
/*
* Get our IP address and put it in our_addr
*/
void
{
}
struct quehead
{
};
void
{
}
void
{
/* element->qh_link = NULL; TCP FIN1 crashes if you do this. Why ? */
}
/*
* Set fd blocking and non-blocking
*/
void
fd_nonblock(int fd)
{
#ifdef FIONBIO
int opt = 1;
#else
int opt;
opt |= O_NONBLOCK;
#endif
}
#if !defined(VBOX_NAT_MEM_DEBUG) && defined(LOG_ENABLED)
# define LogFlowFunc(x)
# define LogFlowFuncEnter()
# define LogFlowFuncLeave()
# define Log2(x)
#else
# define NAT_MEM_LOG_ENABLED
#endif
/**
* Called when memory becomes available, works pfnXmitPending.
*
* @note This will LEAVE the critical section of the zone and RE-ENTER it
* again. Changes to the zone data should be expected across calls to
* this function!
*
* @param zone The zone.
*/
{
if ( zone->fDoXmitPending
{
int rc2;
zone->fDoXmitPending = false;
}
}
{
int rc;
#ifndef NAT_MEM_LOG_ENABLED
#endif
for (;;)
{
{
rc = 0;
if (rc == 0)
{
}
else
{
}
break;
}
if (!zone->master_zone)
{
/* We're on the master zone and we can't allocate more. */
/* AssertMsgFailed(("NAT: OOM!")); */
zone->fDoXmitPending = true;
break;
}
/* we're on a sub-zone, we need get a chunk from the master zone and split
* it into sub-zone conforming chunks.
*/
if (!sub_area)
{
/* No room on master */
break;
}
/* It's the chunk descriptor of the master zone, we should remove it
* from the master list first.
*/
/** @todo should we alter count of master counters? */
/** @todo '+ zone->size' should be depend on flag */
}
return ret;
}
{
#ifndef NAT_MEM_LOG_ENABLED
#endif
/* check border magic */
{
}
{
}
}
{
#ifndef NAT_MEM_LOG_ENABLED
#endif
LogFlowFunc(("ENTER: name:%s size:%d, ctor:%p, dtor:%p, init:%p, fini:%p, flags1:%RX32, flags2:%RX32\n",
return zone;
}
{
LogFlowFunc(("ENTER: name:%s ctor:%p, dtor:%p, init:%p, fini:%p, master:%R[mzone]\n",
{
return NULL;
}
return zone;
}
{
int i = 0;
for (; i < max; ++i)
{
it = (struct item *)(((uint8_t *)zone->area) + i*(sizeof(struct item) + zone->size + sizeof(uint32_t)));
}
}
{
}
{
}
{
/** @todo (vvl) this function supposed to work with special zone storing
reference counters */
#ifndef NAT_MEM_LOG_ENABLED
#endif
/* for returning pointer to counter we need get 0 elemnt */
}
{
void *mem;
#ifndef NAT_MEM_LOG_ENABLED
#endif
{
LogFlowFunc(("LEAVE: NULL\n"));
return NULL;
}
{
}
return mem;
}
{
}
{
#ifndef NAT_MEM_LOG_ENABLED
#endif
}
{
int fExhausted;
return fExhausted;
}
{
/* vvl: Huh? What to do with zone which hasn't got backstore ? */
{
master_zone->cur_items--;
}
}
{
/** @todo (vvl) make it wiser */
#ifndef NAT_MEM_LOG_ENABLED
#endif
}
{
#ifndef NAT_MEM_LOG_ENABLED
#endif
LogFlowFunc(("LEAVE: NULL"));
return NULL;
}
{
struct mbuf *m;
else if (cbMin < MJUM9BYTES)
size = MJUM9BYTES;
else if (cbMin < MJUM16BYTES)
size = MJUM16BYTES;
else
AssertMsgFailed(("Unsupported size"));
if (m == NULL)
{
*pcbBuf = 0;
LogFlowFunc(("LEAVE: NULL\n"));
return NULL;
}
LogFlowFunc(("LEAVE: %p\n", m));
return m;
}
{
if ( !pu8Buf
}
{
if (zone->master_zone)
}
{
/** @todo do finalize here.*/
}
void
{
/* 14 for ethernet */
if_maxlinkhdr = 14;
if_mtu = 1500;
if_mru = 1500;
}