Added attachment of a bpf to raw Ethernet socket, removed all
previous checks on server-side for MAC addresses and stream IDs,
now handled by bpf. Removed all usage of ProperPacket() method.
return(setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &bpf, sizeof(bpf)));
+}
+
int SockAddr_v4_Connect_BPF_Drop (int sock, uint32_t dstip, uint32_t srcip, uint16_t dstport, uint16_t srcport) {
// Use full quintuple, proto, src ip, dst ip, src port, dst port
// ip proto is already set per the PF_PACKET ETH_P_IP
--
2.17.1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Added attachment of a bpf to raw Ethernet socket, removed all
previous checks on server-side for MAC addresses and stream IDs,
now handled by bpf. Removed all usage of ProperPacket() method.
include/Server.hpp | 2 --
include/SocketAddr.h | 2 ++
src/Listener.cpp | 6 ++++
src/SocketAddr.c | 75 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/include/Server.hpp b/include/Server.hpp
index 7a9f219..31f30fa 100644
--- a/include/Server.hpp
+++ b/include/Server.hpp
@@ -104,8 +104,6 @@ private:
int myDropSocket;
#endif
ReportHeader *myJob;
void SetServerStats(int offset);
// Send acknowledgement to client that server is ready to receive
void SendInitialACK();
diff --git a/include/SocketAddr.h b/include/SocketAddr.h
index 9dca421..04047fe 100644
--- a/include/SocketAddr.h
+++ b/include/SocketAddr.h
@@ -103,6 +103,8 @@ extern "C" {
int SockAddr_Accept_BPF(int socket, uint16_t port);
int SockAddr_Drop_All_BPF(int socket);
int SockAddr_v4_Connect_BPF(int socket, uint32_t srcip, uint32_t dstip, uint16_t srcport, uint16_t dstport);
int SockAddr_v4_Connect_BPF_Drop(int socket, uint32_t srcip, uint32_t dstip, uint16_t srcport, uint16_t dstport);
# ifdef HAVE_IPV6
int SockAddr_v6_Connect_BPF (int sock, struct in6_addr src, struct in6_addr dst, uint16_t dstport, uint16_t srcport);
diff --git a/src/Listener.cpp b/src/Listener.cpp
index 8b5d307..1becbfd 100644
--- a/src/Listener.cpp
+++ b/src/Listener.cpp
@@ -829,7 +829,13 @@ int Listener::L2_setup (void) {
mSettings->mLocalhost = new char[ INET_ADDRSTRLEN + 1 ];
strcpy(mSettings->mLocalhost, src_ip);
}
+
inet_aton(mSettings->mLocalhost, localAddr);
+
}
if (rc < 0)
return -1;
diff --git a/src/SocketAddr.c b/src/SocketAddr.c
index ee7f8bc..e1036c7 100644
--- a/src/SocketAddr.c
+++ b/src/SocketAddr.c
@@ -698,6 +698,81 @@ int SockAddr_v4_Connect_BPF (int sock, uint32_t dstip, uint32_t srcip, uint16_t
return(setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &bpf, sizeof(bpf)));
}
+//
+// Simulate the Raw Ethernet connect for the AF_PACKET (or PF_PACKET)
+//
+int SockAddr_v4_Ethernet_Connect_BPF (int sock, uint8_t src_mac[6], uint8_t dest_mac[6],
+
+
+
+
+
+
+
+}
+
int SockAddr_v4_Connect_BPF_Drop (int sock, uint32_t dstip, uint32_t srcip, uint16_t dstport, uint16_t srcport) {
// Use full quintuple, proto, src ip, dst ip, src port, dst port
// ip proto is already set per the PF_PACKET ETH_P_IP
--
2.17.1