blob: 0257a2ca915d63bea4591e337dbb5b71dc9ab22e [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Mike Frysinger7031f622006-05-08 03:20:50 +00002#ifndef _PACKET_H
3#define _PACKET_H
4
5#include <netinet/udp.h>
6#include <netinet/ip.h>
7
8struct 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
27struct udp_dhcp_packet {
28 struct iphdr ip;
29 struct udphdr udp;
30 struct dhcpMessage data;
31};
32
Rob Landley3f785612006-05-28 01:06:36 +000033void udhcp_init_header(struct dhcpMessage *packet, char type);
34int udhcp_get_packet(struct dhcpMessage *packet, int fd);
35uint16_t udhcp_checksum(void *addr, int count);
36int udhcp_raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
Mike Frysinger7031f622006-05-08 03:20:50 +000037 uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex);
Rob Landley3f785612006-05-28 01:06:36 +000038int udhcp_kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
Mike Frysinger7031f622006-05-08 03:20:50 +000039 uint32_t dest_ip, int dest_port);
40
41
42#endif