misc.c revision 760446f710619a9daa6cedc7f0601f49e4ea3442
/* $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>
#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
}
#ifdef VBOX_WITH_SLIRP_BSD_MBUF
#define ITEM_MAGIC 0xdead0001
struct item
{
};
#define ZONE_MAGIC 0xdead0002
struct uma_zone
{
const char *name;
int max_items;
int cur_items;
void *area;
};
{
int rc;
for (;;)
{
{
rc = 0;
if (rc == 0)
{
}
else
{
}
break;
}
if (!zone->master_zone)
{
/* We're on master zone and we cant allocate more */
break;
}
/* we're on sub-zone we need get chunk of master zone and split
* it for sub-zone conforming chunks.
*/
if (!sub_area)
{
/* No room on master */
break;
}
/* it's chunk descriptor of 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;
}
{
/* check bourder magic */
{
}
{
}
}
{
return zone;
}
{
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 */
/* for returning pointer to counter we need get 0 elemnt */
}
{
void *mem;
return NULL;
{
}
return mem;
}
{
}
{
}
{
int fExhausted;
return fExhausted;
}
{
/* vvl: Huh? What to do with zone which hasn't got backstore ? */
{
master_zone->cur_items--;
}
}
{
/*@todo (r=vvl) make it wiser*/
}
{
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;
return NULL;
}
return m;
}
{
}
{
if (zone->master_zone)
}
{
/*@todo do finalize here.*/
}
#endif /* VBOX_WITH_SLIRP_BSD_MBUF */