libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
rawsocket.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
14
15PROMEKI_NAMESPACE_BEGIN
16
41class RawSocket : public AbstractSocket {
42 PROMEKI_OBJECT(RawSocket, AbstractSocket)
43 public:
48 RawSocket(ObjectBase *parent = nullptr);
49
51 ~RawSocket() override;
52
60 void setInterface(const String &interfaceName) { _interface = interfaceName; }
61
63 const String &interface() const { return _interface; }
64
77 void setProtocol(uint16_t ethertype) { _protocol = ethertype; }
78
80 uint16_t protocol() const { return _protocol; }
81
92 Error open(OpenMode mode) override;
93
98 Error close() override;
99
101 bool isOpen() const override { return _fd >= 0; }
102
109 int64_t read(void *data, int64_t maxSize) override;
110
117 int64_t write(const void *data, int64_t maxSize) override;
118
124 Error setPromiscuous(bool enable);
125
126 private:
127 String _interface;
128 uint16_t _protocol = 0;
129};
130
131PROMEKI_NAMESPACE_END
132
133#endif // PROMEKI_ENABLE_NETWORK