Browse Source

pcap send packet

develop
Robin Thoni 8 years ago
parent
commit
03e541058a
2 changed files with 14 additions and 0 deletions
  1. 12
    0
      src/DataAccess/Pcap.cpp
  2. 2
    0
      src/DataAccess/Pcap.h

+ 12
- 0
src/DataAccess/Pcap.cpp View File

91
         _pcap = 0;
91
         _pcap = 0;
92
     }
92
     }
93
 }
93
 }
94
+
95
+ResultBool Pcap::send(void *data, unsigned int len)
96
+{
97
+    if (!_pcap) {
98
+        return ResultBool::error("Pcap has not been initialized");
99
+    }
100
+    int res = pcap_sendpacket(_pcap, (const u_char*)data, len);
101
+    if (res == -1) {
102
+        return ResultBool::error(getPcapLastError());
103
+    }
104
+    return ResultBool::ok(true);
105
+}

+ 2
- 0
src/DataAccess/Pcap.h View File

22
 
22
 
23
     ResultBool run(PcapCallback callback, void* data = 0, int count = -1);
23
     ResultBool run(PcapCallback callback, void* data = 0, int count = -1);
24
 
24
 
25
+    ResultBool send(void* data, unsigned int len);
26
+
25
     void stop();
27
     void stop();
26
 
28
 
27
     void close();
29
     void close();

Loading…
Cancel
Save