VBoxNetUDP.cpp revision 111c5fc39f11d448ea7c37f036c7f65449f6d9a0
/* $Id$ */
/** @file
* VBoxNetUDP - UDP Library for IntNet.
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBoxNetUDP.h"
/**
* Checks if the head of the receive ring is a UDP packet matching the given
* criteria.
*
* @returns Pointer to the data if it matches.
* @param pBuf The IntNet buffers.
* @param uDstPort The destination port to match.
* @param pDstMac The destination address to match if
* VBOXNETUDP_MATCH_UNICAST is specied.
* @param fFlags Flags indicating what to match and some debug stuff.
* See VBOXNETUDP_MATCH_*.
* @param pHdrs Where to return the pointers to the headers.
* Optional.
* @param pcb Where to return the size of the data on success.
*/
void *VBoxNetUDPMatch(PCINTNETBUF pBuf, unsigned uDstPort, PCRTMAC pDstMac, uint32_t fFlags, PVBOXNETUDPHDRS pHdrs, size_t *pcb)
{
/*
* Clear return values so we can return easier on mismatch.
*/
*pcb = 0;
if (pHdrs)
{
}
/*
* Valid IntNet Ethernet frame?
*/
return NULL;
if (pHdrs)
#ifdef IN_RING3
{
}
#endif
/*
* Ethernet matching.
*/
/* Ethernet min frame size. */
if (cbFrame < 64)
return NULL;
/* Match Ethertype: IPV4? */
/** @todo VLAN tagging? */
return NULL;
/* Match destination address (ethernet) */
if ( ( !(fFlags & VBOXNETUDP_MATCH_UNICAST)
&& ( !(fFlags & VBOXNETUDP_MATCH_BROADCAST)
return NULL;
/*
* IP validation and matching.
*/
if (pHdrs)
/* Protocol: UDP */
return NULL;
/* Valid IPv4 header? */
return NULL;
/*
* UDP matching and validation.
*/
if (pHdrs)
/* Destination port */
return NULL;
/* Validate the UDP header according to flags. */
{
return NULL;
if ( (fFlags & VBOXNETUDP_MATCH_REQUIRE_CHECKSUM)
return NULL;
}
else
{
return NULL;
}
/*
* We've got a match!
*/
return (void *)(pUdpHdr + 1);
}