"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 2 | #ifndef _PACKET_H |
| 3 | #define _PACKET_H |
| 4 | |
| 5 | #include <netinet/udp.h> |
| 6 | #include <netinet/ip.h> |
| 7 | |
| 8 | struct dhcpMessage { |
| 9 | uint8_t op; |
| 10 | uint8_t htype; |
| 11 | uint8_t hlen; |
| 12 | uint8_t hops; |
| 13 | uint32_t xid; |
| 14 | uint16_t secs; |
| 15 | uint16_t flags; |
| 16 | uint32_t ciaddr; |
| 17 | uint32_t yiaddr; |
| 18 | uint32_t siaddr; |
| 19 | uint32_t giaddr; |
| 20 | uint8_t chaddr[16]; |
| 21 | uint8_t sname[64]; |
| 22 | uint8_t file[128]; |
| 23 | uint32_t cookie; |
| 24 | uint8_t options[308]; /* 312 - cookie */ |
| 25 | }; |
| 26 | |
| 27 | struct udp_dhcp_packet { |
| 28 | struct iphdr ip; |
| 29 | struct udphdr udp; |
| 30 | struct dhcpMessage data; |
| 31 | }; |
| 32 | |
Rob Landley | 3f78561 | 2006-05-28 01:06:36 +0000 | [diff] [blame] | 33 | void udhcp_init_header(struct dhcpMessage *packet, char type); |
| 34 | int udhcp_get_packet(struct dhcpMessage *packet, int fd); |
| 35 | uint16_t udhcp_checksum(void *addr, int count); |
| 36 | int udhcp_raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 37 | uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex); |
Rob Landley | 3f78561 | 2006-05-28 01:06:36 +0000 | [diff] [blame] | 38 | int udhcp_kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 39 | uint32_t dest_ip, int dest_port); |
| 40 | |
| 41 | |
| 42 | #endif |