blob: b2be5d7f7b6cde5981eee5b2fa059aae4b0a62d6 [file] [log] [blame]
Russ Dill61fb4892002-10-14 21:41:28 +00001#ifndef _PACKET_H
2#define _PACKET_H
3
4#include <netinet/udp.h>
5#include <netinet/ip.h>
6
7struct dhcpMessage {
Eric Andersenad953732004-01-30 23:45:53 +00008 uint8_t op;
9 uint8_t htype;
10 uint8_t hlen;
11 uint8_t hops;
12 uint32_t xid;
13 uint16_t secs;
14 uint16_t flags;
15 uint32_t ciaddr;
16 uint32_t yiaddr;
17 uint32_t siaddr;
18 uint32_t giaddr;
19 uint8_t chaddr[16];
20 uint8_t sname[64];
21 uint8_t file[128];
22 uint32_t cookie;
Eric Andersenc7bda1c2004-03-15 08:29:22 +000023 uint8_t options[308]; /* 312 - cookie */
Russ Dill61fb4892002-10-14 21:41:28 +000024};
25
26struct udp_dhcp_packet {
27 struct iphdr ip;
28 struct udphdr udp;
29 struct dhcpMessage data;
30};
31
"Vladimir N. Oleynik"2f9c30a2005-09-22 15:07:33 +000032#define init_header udhcp_init_header
33#define get_packet udhcp_get_packet
34#define checksum udhcp_checksum
35#define raw_packet udhcp_raw_packet
36#define kernel_packet udhcp_kernel_packet
37
Russ Dill61fb4892002-10-14 21:41:28 +000038void init_header(struct dhcpMessage *packet, char type);
39int get_packet(struct dhcpMessage *packet, int fd);
Eric Andersenad953732004-01-30 23:45:53 +000040uint16_t checksum(void *addr, int count);
41int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
42 uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex);
43int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
44 uint32_t dest_ip, int dest_port);
Russ Dill61fb4892002-10-14 21:41:28 +000045
46
47#endif