VBoxNetUDP.cpp revision 0280e4ae13799a3136778dc90efa5841a3f40cf2
/* $Id$ */
/** @file
* VBoxNetUDP - IntNet UDP Client Routines.
*/
/*
* 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 *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DEFAULT
#include "VBoxNetLib.h"
#include <VBox/pdmnetinline.h>
#include <VBox/intnetinline.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(PINTNETBUF 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?
*/
if ( !pHdr
return NULL;
{
return NULL;
/** @todo IPv6 UDP support, goes for this entire function really. Not really
* important yet since this is currently only used by the DHCP server. */
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;
/*
* If we're working on a GSO frame, we need to make sure the length fields
* are set correctly (they are usually set to 0).
*/
if (pGso)
/*
* 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;
if (!pGso)
{
/* 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);
}
/** Internal worker for VBoxNetUDPUnicast and VBoxNetUDPBroadcast. */
{
/* the Ethernet header */
/* the IP header */
/* the UDP bit */
#if 0
#else
#endif
/* the payload */
/* send it */
}
/**
* Sends an unicast UDP packet.
*
* @returns VBox status code.
* @param pSession The support driver session handle.
* @param hIf The interface handle.
* @param pBuf The interface buffer.
* @param SrcIPv4Addr The source IPv4 address.
* @param pSrcMacAddr The source MAC address.
* @param uSrcPort The source port number.
* @param DstIPv4Addr The destination IPv4 address. Can be broadcast.
* @param pDstMacAddr The destination MAC address.
* @param uDstPort The destination port number.
* @param pvData The data payload.
* @param cbData The size of the data payload.
*/
{
}
/**
* Sends a broadcast UDP packet.
*
* @returns VBox status code.
* @param pSession The support driver session handle.
* @param hIf The interface handle.
* @param pBuf The interface buffer.
* @param SrcIPv4Addr The source IPv4 address.
* @param pSrcMacAddr The source MAC address.
* @param uSrcPort The source port number.
* @param uDstPort The destination port number.
* @param pvData The data payload.
* @param cbData The size of the data payload.
*/
unsigned uDstPort,
{
}