-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC_Net_Raw.hpp
86 lines (61 loc) · 1.99 KB
/
C_Net_Raw.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//////////////////////////////////////////////////////////////////////////////////
//[ RawSocket_Class_Header ]
//////////////////////////////////////////////////////////////////////////////////
//
//
// [::Raw Socket Class::]
//
// [::Last modi: 12.03.21 L.ey (µ~)::]
//
//
#ifndef _C_NET_RAW_H_
#define _C_NET_RAW_H_
#include <cstdint>
#include <iostream>
#include <thread>
using namespace std;
//#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <errno.h>
#include <linux/if_packet.h>
#include "C_Net_Interface.hpp"
#include <sigc++/sigc++.h>
//////////////////////////////////////////////////////////////////////////////////
// CONSTANT
//////////////////////////////////////////////////////////////////////////////////
const int C_NET_RAW_READY = 0x01;
const int C_NET_RAW_ERROR = 0x00;
//////////////////////////////////////////////////////////////////////////////////
// CLASS
//////////////////////////////////////////////////////////////////////////////////
class C_Net_Raw {
public:
C_Net_Raw(){};
~C_Net_Raw(){};
int open(const S_Net_Interface* pSInterface);
int close();
int send(uint8_t* pData, uint32_t cData);
// Non Blocking
int start(int id, uint8_t* pBuffer, uint32_t cBuffer);
int stop();
///////////////////////////////
// Signal
typedef sigc::signal<void, int, int> type_signal_data;
type_signal_data signal_data();
protected:
type_signal_data m_signal_data;
private:
struct sockaddr_ll socket_address;
int32_t sockfd = {0};
int32_t id = {0};
bool bOpen = {false};
bool bRun = {false};
// ((( RECIVE THREAD )))
thread m_thread;
void run();
/////////////////
uint8_t* pBuffer = {nullptr};
uint32_t cBuffer = {0};
};
#endif // _C_NET_RAW_H_