Russ Dill | 61fb489 | 2002-10-14 21:41:28 +0000 | [diff] [blame^] | 1 | #ifndef _PACKET_H |
| 2 | #define _PACKET_H |
| 3 | |
| 4 | #include <netinet/udp.h> |
| 5 | #include <netinet/ip.h> |
| 6 | |
| 7 | struct dhcpMessage { |
| 8 | u_int8_t op; |
| 9 | u_int8_t htype; |
| 10 | u_int8_t hlen; |
| 11 | u_int8_t hops; |
| 12 | u_int32_t xid; |
| 13 | u_int16_t secs; |
| 14 | u_int16_t flags; |
| 15 | u_int32_t ciaddr; |
| 16 | u_int32_t yiaddr; |
| 17 | u_int32_t siaddr; |
| 18 | u_int32_t giaddr; |
| 19 | u_int8_t chaddr[16]; |
| 20 | u_int8_t sname[64]; |
| 21 | u_int8_t file[128]; |
| 22 | u_int32_t cookie; |
| 23 | u_int8_t options[308]; /* 312 - cookie */ |
| 24 | }; |
| 25 | |
| 26 | struct udp_dhcp_packet { |
| 27 | struct iphdr ip; |
| 28 | struct udphdr udp; |
| 29 | struct dhcpMessage data; |
| 30 | }; |
| 31 | |
| 32 | void init_header(struct dhcpMessage *packet, char type); |
| 33 | int get_packet(struct dhcpMessage *packet, int fd); |
| 34 | u_int16_t checksum(void *addr, int count); |
| 35 | int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port, |
| 36 | u_int32_t dest_ip, int dest_port, unsigned char *dest_arp, int ifindex); |
| 37 | int kernel_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port, |
| 38 | u_int32_t dest_ip, int dest_port); |
| 39 | |
| 40 | |
| 41 | #endif |