Pcap.cpp revision c416e508765da1c58ecc3b9228fa7451efae91a6
/* $Id$ */
/** @file
* Helpers for writing libpcap files.
*/
/*
* Copyright (C) 2006-2008 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 "Pcap.h"
#include <VBox/pdmnetinline.h>
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/* "libpcap" magic */
#define PCAP_MAGIC 0xa1b2c3d4
/* "libpcap" file header (minus magic number). */
struct pcap_hdr
{
};
/* "libpcap" record header. */
struct pcaprec_hdr
{
};
struct pcaprec_hdr_init
{
struct pcaprec_hdr rec0;
};
/*******************************************************************************
* Global Variables *
*******************************************************************************/
static pcaprec_hdr_init const s_Hdr =
{
{ 2, 4, 0, 0, 0xffff, 1 },
/* force ethereal to start at 0.000000. */
{ 0, 1, 0, 60 }
};
/**
* Internal helper.
*/
static void pcapCalcHeader(struct pcaprec_hdr *pHdr, uint64_t StartNanoTS, size_t cbFrame, size_t cbMax)
{
}
/**
* Internal helper.
*/
{
}
/**
* Writes the stream header.
*
* @returns IPRT status code, @see RTStrmWrite.
*
* @param pStream The stream handle.
* @param StartNanoTS What to subtract from the RTTimeNanoTS output.
*/
{
}
/**
* Writes a frame to a stream.
*
* @returns IPRT status code, @see RTStrmWrite.
*
* @param pStream The stream handle.
* @param StartNanoTS What to subtract from the RTTimeNanoTS output.
* @param pvFrame The start of the frame.
* @param cbFrame The size of the frame.
* @param cbMax The max number of bytes to include in the file.
*/
int PcapStreamFrame(PRTSTREAM pStream, uint64_t StartNanoTS, const void *pvFrame, size_t cbFrame, size_t cbMax)
{
struct pcaprec_hdr Hdr;
}
/**
* Writes a GSO frame to a stream.
*
* @returns IPRT status code, @see RTStrmWrite.
*
* @param pStream The stream handle.
* @param StartNanoTS What to subtract from the RTTimeNanoTS output.
* @param pGso Pointer to the GSO context.
* @param pvFrame The start of the GSO frame.
* @param cbFrame The size of the GSO frame.
* @param cbSegMax The max number of bytes to include in the file for
* each segment.
*/
{
struct pcaprec_hdr Hdr;
{
uint32_t offSegPayload = PDMNetGsoCarveSegment(pGso, pbFrame, cbFrame, iSeg, cSegs, abHdrs, &cbSegPayload);
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
}
return VINF_SUCCESS;
}
/**
* Writes the file header.
*
* @returns IPRT status code, @see RTFileWrite.
*
* @param File The file handle.
* @param StartNanoTS What to subtract from the RTTimeNanoTS output.
*/
{
}
/**
* Writes a frame to a file.
*
* @returns IPRT status code, @see RTFileWrite.
*
* @param File The file handle.
* @param StartNanoTS What to subtract from the RTTimeNanoTS output.
* @param pvFrame The start of the frame.
* @param cbFrame The size of the frame.
* @param cbMax The max number of bytes to include in the file.
*/
int PcapFileFrame(RTFILE File, uint64_t StartNanoTS, const void *pvFrame, size_t cbFrame, size_t cbMax)
{
struct pcaprec_hdr Hdr;
}
/**
* Writes a GSO frame to a file.
*
* @returns IPRT status code, @see RTFileWrite.
*
* @param File The file handle.
* @param StartNanoTS What to subtract from the RTTimeNanoTS output.
* @param pGso Pointer to the GSO context.
* @param pvFrame The start of the GSO frame.
* @param cbFrame The size of the GSO frame.
* @param cbSegMax The max number of bytes to include in the file for
* each segment.
*/
{
struct pcaprec_hdr Hdr;
{
uint32_t offSegPayload = PDMNetGsoCarveSegment(pGso, pbFrame, cbFrame, iSeg, cSegs, abHdrs, &cbSegPayload);
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
}
return VINF_SUCCESS;
}