2020-08-28 14:18:02 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SCSI Target Emulator RaSCSI (*^..^*)
|
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Powered by XM6 TypeG Technology.
|
|
|
|
// Copyright (C) 2016-2020 GIMONS
|
2021-02-07 19:00:48 +00:00
|
|
|
// Copyright (C) akuker
|
2020-08-28 14:18:02 +00:00
|
|
|
//
|
|
|
|
// Imported NetBSD support and some optimisation patch by Rin Okuyama.
|
|
|
|
//
|
|
|
|
// [ TAP Driver ]
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if !defined(ctapdriver_h)
|
|
|
|
#define ctapdriver_h
|
|
|
|
|
2021-04-03 19:02:20 +00:00
|
|
|
#include <pcap/pcap.h>
|
|
|
|
#include "filepath.h"
|
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
#ifndef ETH_FRAME_LEN
|
|
|
|
#define ETH_FRAME_LEN 1514
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
2020-12-28 02:13:21 +00:00
|
|
|
// Linux Tap Driver
|
2020-08-28 14:18:02 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
class CTapDriver
|
|
|
|
{
|
|
|
|
public:
|
2020-12-28 02:13:21 +00:00
|
|
|
// Basic Functionality
|
2021-03-08 01:29:30 +00:00
|
|
|
CTapDriver(); // Constructor
|
|
|
|
BOOL FASTCALL Init(); // Initilization
|
2021-04-03 19:02:20 +00:00
|
|
|
BOOL FASTCALL OpenDump(const Filepath& path);
|
|
|
|
// Capture packets
|
2021-03-08 01:29:30 +00:00
|
|
|
void FASTCALL Cleanup(); // Cleanup
|
|
|
|
void FASTCALL GetMacAddr(BYTE *mac); // Get Mac Address
|
|
|
|
int FASTCALL Rx(BYTE *buf); // Receive
|
2021-04-05 21:11:54 +00:00
|
|
|
int FASTCALL Tx(const BYTE *buf, int len); // Send
|
|
|
|
BOOL FASTCALL PendingPackets(); // Check if there are IP packets available
|
|
|
|
BOOL FASTCALL Enable(); // Enable the ras0 interface
|
|
|
|
BOOL FASTCALL Disable(); // Disable the ras0 interface
|
|
|
|
BOOL FASTCALL Flush(); // Purge all of the packets that are waiting to be processed
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
private:
|
2021-03-08 01:29:30 +00:00
|
|
|
BYTE m_MacAddr[6]; // MAC Address
|
|
|
|
BOOL m_bTxValid; // Send Valid Flag
|
|
|
|
int m_hTAP; // File handle
|
2021-04-05 21:11:54 +00:00
|
|
|
|
2021-02-07 19:00:48 +00:00
|
|
|
BYTE m_garbage_buffer[ETH_FRAME_LEN];
|
2021-04-03 19:02:20 +00:00
|
|
|
|
|
|
|
pcap_t *m_pcap;
|
|
|
|
pcap_dumper_t *m_pcap_dumper;
|
2021-04-05 21:11:54 +00:00
|
|
|
|
2020-08-28 14:18:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ctapdriver_h
|