Consider that I’m developing a C program utilizing AFPACKET RAW Sockets:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/if_ether.h>
int main() {
int sockfd;
char buffer[ETH_FRAME_LEN];
struct sockaddr saddr;
socklen_t saddr_len = sizeof(saddr);
// Create a raw socket
sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (sockfd < 0) {
perror("socket");
exit(EXIT_FAILURE);
}
// Receive a packet
int packet_len = recvfrom(sockfd, buffer, ETH_FRAME_LEN, 0, &saddr, &saddr_len);
if (packet_len < 0) {
perror("recvfrom");
close(sockfd);
exit(EXIT_FAILURE);
}
printf("Received a packetn");
close(sockfd);
return 0;
}
And I apply different rules in ebtables to for example drop frames depending on their MAC address, will the RAW socket program be affected by those rules?
Will the socket receive the frames regardless or will they be filtered, before the RAW socket has access to the frames?