PF_PACKET을 이용하여 C코드로 패킷을 보내는 예
#include <stdio.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #include <net/ethernet.h> #include <netpacket/packet.h> int main() { int sock_fd; struct sockaddr_ll dest_addr; char buffer(ETH_FRAME_LEN); unsigned char dest_mac(6) = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; // Broadcast address // Create a PF_PACKET socket sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock_fd < 0) { perror(“socket”); … Read more