程序目的:
程序可用来封装特定的arp回应包。
使用此程序主要用于网络调试目的和实验项目, 请勿非法使用。
代码摘选了:原始套接字(网络编程再进阶)中的代码实现,为了更加灵活的使用,做了一些更改
#include <netpacket/packet.h>
#include <sys/socket.h>
#include <stdio.h>
#include <string.h>
#include <netinet/ether.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <unistd.h>
int main(int argc, char** argv)
{
struct _ipv4_arp_response {
unsigned char target_mac[6];
unsigned char source_mac[6];
unsigned char protocal[2];
unsigned char hardclass[2];
unsigned char protocalclass[2];
unsigned char hardlong;
unsigned char protocallong;
unsigned char opcode[2];
unsigned char sendermac[6];
unsigned char se