RASCSI/src/raspberrypi/devices/ctapdriver.h
Uwe Seimet 2beb78727f
Added support for new interfaces syntax (#684)
* Added support for new interfaces syntax

* rasctl output update

* Added operation parameters

* Fixed typo

* Manpage update

* Added deprecation warning

* Moved parser

* Updated parser

* Updated parameter override

* Removed debug code

* Made netmask handling more flexible

* Updated logging

* Logging update

* Logging update

* Comment update

* Removed unused field

* Replaced BOOL by bool

* Moved code

* Logging update

* Removed useless comments

* Added TODZ

* Logging update

* Logging update

* Logging update

* No need to report that an error is an error twice

* Removed duplicate logging

* Updated error handling

* Updated error handling

* Fixed typo

* Removed magic constant

* Fixed 32 bit platform issue

* Signature update

* Fixed message string

* Comment update

* Fixed SCSI command opcode

* Updated StopPrint

* Logging update

* Removed obsolete casts

* Renaming

* Removed duplicate logging

* Updated flushing caches

* Added FlushCache() method

* Reduced visibility

* Reduced visibility

* Reduced visibility

* Code cleanup, removed useless comments

* Removed useless comments

* Updated error handling

* Removed duplicate code

* Manpage update
2022-02-20 18:40:30 +01:00

75 lines
1.7 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI (*^..^*)
// for Raspberry Pi
//
// Powered by XM6 TypeG Technology.
// Copyright (C) 2016-2020 GIMONS
// Copyright (C) akuker
//
// Imported NetBSD support and some optimisation patch by Rin Okuyama.
//
// [ TAP Driver ]
//
//---------------------------------------------------------------------------
#pragma once
#include <pcap/pcap.h>
#include "filepath.h"
#include <map>
#include <vector>
#include <string>
#ifndef ETH_FRAME_LEN
#define ETH_FRAME_LEN 1514
#endif
using namespace std;
//===========================================================================
//
// Linux Tap Driver
//
//===========================================================================
class CTapDriver
{
private:
friend class SCSIDaynaPort;
friend class SCSIBR;
CTapDriver();
~CTapDriver() {}
bool Init(const map<string, string>&);
public:
void OpenDump(const Filepath& path);
// Capture packets
void Cleanup(); // Cleanup
void GetMacAddr(BYTE *mac); // Get Mac Address
int Rx(BYTE *buf); // Receive
int Tx(const BYTE *buf, int len); // Send
bool PendingPackets(); // Check if there are IP packets available
bool Enable(); // Enable the ras0 interface
bool Disable(); // Disable the ras0 interface
void Flush(); // Purge all of the packets that are waiting to be processed
private:
BYTE m_MacAddr[6]; // MAC Address
int m_hTAP; // File handle
BYTE m_garbage_buffer[ETH_FRAME_LEN];
pcap_t *m_pcap;
pcap_dumper_t *m_pcap_dumper;
// Prioritized comma-separated list of interfaces to create the bridge for
vector<string> interfaces;
string inet;
};