instance.c revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/*
* TAP-Win32 -- A kernel driver to provide virtual tap device
* functionality on Windows. Originally derived
* from the CIPE-Win32 project by Damion K. Wilson,
* with extensive modifications by James Yonan.
*
* All source code which derives from the CIPE-Win32 project is
* Copyright (C) Damion K. Wilson, 2003, and is released under the
* GPL version 2 (see below).
*
* All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC,
* and is released under the GPL version 2 (see below).
*
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see the file COPYING included with this
* distribution); if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define N_INSTANCE_BUCKETS 256
typedef struct _INSTANCE {
} INSTANCE;
typedef struct {
typedef struct {
// must return a hash >= 0 and < N_INSTANCE_BUCKETS
int
{
if (sizeof (addr) == 4)
return p[0] ^ p[1] ^ p[2] ^ p[3];
else if (sizeof (addr) == 8)
return p[0] ^ p[1] ^ p[2] ^ p[3] ^ p[4] ^ p[5] ^ p[6] ^ p[7];
else
{
MYASSERT (0);
}
}
{
if (g_InstanceHash)
{
int i;
for (i = 0; i < N_INSTANCE_BUCKETS; ++i)
return TRUE;
}
else
return FALSE;
}
int
{
int i, n = 0;
if (g_InstanceHash)
{
for (i = 0; i < N_INSTANCE_BUCKETS; ++i)
{
if (got_lock)
{
++n;
}
else
return -1;
}
}
return n;
}
int
{
int i, n = 0;
if (g_InstanceHash)
{
for (i = 0; i < N_INSTANCE_BUCKETS; ++i)
{
int bucket_size = 0;
if (got_lock)
{
++bucket_size;
if (bucket_size > n)
n = bucket_size;
}
else
return -1;
}
}
return n;
}
{
if (g_InstanceHash)
{
MYASSERT (NInstances() == 0);
}
}
{
if (got_lock)
{
if (i)
{
}
}
return ret;
}
{
if (got_lock)
{
{
{
if (prev)
else
break;
}
}
}
return ret;
}
{
if (got_lock)
{
{
{
// move it to head of list
if (prev)
{
}
break;
}
}
}
return ret;
}