RASCSI/src/raspberrypi/devices/ctapdriver.h

61 lines
1.6 KiB
C
Raw Normal View History

//---------------------------------------------------------------------------
//
// 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 ]
//
//---------------------------------------------------------------------------
#if !defined(ctapdriver_h)
#define ctapdriver_h
#include <pcap/pcap.h>
#include "filepath.h"
#ifndef ETH_FRAME_LEN
#define ETH_FRAME_LEN 1514
#endif
//===========================================================================
//
// Linux Tap Driver
//
//===========================================================================
class CTapDriver
{
public:
// Basic Functionality
CTapDriver(); // Constructor
BOOL Init(); // Initilization
Feature extended server information (#169) * PbDevice returns information on whether a device is removable * Fixed log message * Added additional status data (ejectable, protctable, removable) * Assume ejectable == removable * Removed obsolete fields * Added locked/lockable to interface * Code review * Logging update * The user should be allowed to also write protect hard disk drives * Updated error handling * Testing * INSERT also has to search in the default file folder * Added TODO * Manpage update * Message updates * Moved some sanity checks to the server, so that they are run for any client * Updated error handling * Moved CR/LF handling to the client, the server should not format too much * rascsi should not mention "rasctl" in its messages, there may be other clients * Improved error messages * Improved error handling by returning an error string * Added TODO * Moved check for duplicate ID to ProcessCmd() * Removed debug output * Moved include * Removed obsolete includes, updated includes * Reverted ready check * Fixed error messages * Added convenience method * Simplified error handling * Socket/error handling review * "NO MEDIA" is added by the client, not by the server * Added missing include * Only check for duplicate ID when attaching a device * Added type/string converters for PbDeviceType * PbDevice indicates whether image files are supported * Write-protecing a read-only devices is not treated as an error anymore * Updated read-only check * Made difference between read-only and protected more explicit * Added comment * Comment update * Made hard disk drives write-protectable by the user * Resolved https://github.com/akuker/RASCSI/issues/166 * Addressing compiler error - type needs to be initialized Co-authored-by: akuker <akuker@gmail.com>
2021-08-08 15:08:58 +00:00
const char *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
BOOL Flush(); // Purge all of the packets that are waiting to be processed
private:
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
BYTE m_garbage_buffer[ETH_FRAME_LEN];
pcap_t *m_pcap;
pcap_dumper_t *m_pcap_dumper;
2021-04-05 21:11:54 +00:00
};
#endif // ctapdriver_h