socket.h revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
* NAT - socket handling (declarations/defines).
*/
/*
* 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.
*/
/* MINE */
#ifndef _SLIRP_SOCKET_H_
#define _SLIRP_SOCKET_H_
#ifdef VBOX_WITH_SLIRP_MT
#include <iprt/critsect.h>
#endif
#define SO_EXPIRE 240000
#define SO_EXPIREFAST 10000
/*
* Our socket structure
*/
struct socket
{
#if !defined(RT_OS_WINDOWS)
int s; /* The actual socket */
#else
union {
int s;
};
#endif
/* XXX union these with not-yet-used sbuf params */
* for non-blocking connect()'s, and
* PING reply's */
* so_mconn, for non-blocking connections */
int so_urgc;
int so_state; /* internal state flags SS_*, below */
int so_queued; /* Number of packets queued from this socket */
int so_nqueued; /* Number of packets queued in a row
* Used to determine when to "downgrade" a session
* from fastq to batchq */
#ifdef VBOX_WITH_SLIRP_MT
int so_deleted;
#endif
#ifndef RT_OS_WINDOWS
int so_poll_index;
#endif /* !RT_OS_WINDOWS */
/*
*/
int so_close;
void *so_timeout_arg;
#ifdef VBOX_WITH_NAT_SERVICE
/* storage of source ether address */
unsigned char so_ethaddr[6];
#endif
/* required for port-forwarding */
};
#ifdef VBOX_WITH_SLIRP_MT
# define SOCKET_LOCK(so) \
do { \
int rc; \
/* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \
} while (0)
# define SOCKET_UNLOCK(so) \
do { \
int rc; \
} while (0)
# define SOCKET_LOCK_CREATE(so) \
do { \
int rc; \
} while (0)
# define SOCKET_LOCK_DESTROY(so) \
do { \
} while (0)
#else
# define SOCKET_LOCK(so) do {} while (0)
# define SOCKET_UNLOCK(so) do {} while (0)
# define SOCKET_LOCK_CREATE(so) do {} while (0)
# define SOCKET_LOCK_DESTROY(so) do {} while (0)
#endif
/*
* Socket state bits. (peer means the host on the Internet,
* local host means the host on the other end of the modem)
*/
/* #define SS_ISFDISCONNECTED 0x020*/ /* Socket has disconnected from peer, in 2MSL state */
/* #define SS_CTL 0x080 */
#if defined(DECLARE_IOVEC) && !defined(HAVE_READV)
struct iovec
{
char *iov_base;
};
#endif
void so_init (void);
#ifdef VBOX_WITH_SLIRP_MT
#endif
void soisfconnecting (register struct socket *);
void soisfconnected (register struct socket *);
void sofcantrcvmore (struct socket *);
void sofcantsendmore (struct socket *);
void soisfdisconnected (struct socket *);
#endif /* _SOCKET_H_ */