⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 packet.h

📁 这个是Linux下的应用程序
💻 H
字号:
#ifndef _PACKET_H#define _PACKET_H#include <netinet/udp.h>#include <netinet/ip.h>#define DHCP_CLIENT_PORT             68#define DHCP_SERVER_PORT           67#define MAC_BCAST_ADDR          (uint8_t *) "\xff\xff\xff\xff\xff\xff"#define DEFAULT_SCRIPT  "/etc/simple.script"#define DHCP_MAGIC                0x63825363struct client_config_t {	char foreground;		/* Do not fork */	char quit_after_lease;		/* Quit after obtaining lease */	char abort_if_no_lease;		/* Abort if no lease */	char background_if_no_lease;	/* Fork to background if no lease */	char *interface;		/* The name of the interface to use */	char *pidfile;			/* Optionally store the process ID */	char *script;			/* User script to run at dhcp events */	uint8_t *clientid;		/* Optional client id to use */	uint8_t *hostname;		/* Optional hostname to use */	int ifindex;			/* Index number of the interface to use */	uint8_t arp[6];			/* Our arp address */};struct client_config_t client_config = {	/* Default options. */	abort_if_no_lease: 0,	foreground: 0,	quit_after_lease: 0,	background_if_no_lease: 0,	interface: "eth0",	pidfile: NULL,	script: DEFAULT_SCRIPT,	clientid: NULL,	hostname: NULL,	ifindex: 0,	arp: "\0\0\0\0\0\0",		/* appease gcc-3.0 */};struct dhcpMessage {	uint8_t op;	uint8_t htype;	uint8_t hlen;	uint8_t hops;	uint32_t xid;	uint16_t secs;	uint16_t flags;	uint32_t ciaddr;	uint32_t yiaddr;	uint32_t siaddr;	uint32_t giaddr;	uint8_t chaddr[16];	uint8_t sname[64];	uint8_t file[128];	uint32_t cookie;	uint8_t options[308]; /* 312 - cookie */};struct udp_dhcp_packet {	struct iphdr ip;	struct udphdr udp;	struct dhcpMessage data;};void init_header(struct dhcpMessage *packet, char type);int get_packet(struct dhcpMessage *packet, int fd);uint16_t checksum(void *addr, int count);int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,		   uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex);int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,		   uint32_t dest_ip, int dest_port);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -