6 * Copyright 2006, 2007 Stefan Rompf <sux@loplof.de>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation
13 #include <sys/types.h>
14 #include <netinet/in.h>
18 #define MAX_OPT_LEN 512 // RFC 2131 Minimumsize: 312 FIXME: add OPTION_MAXSIZE to use additional bytes
22 #define BOOTP_OPTION_NETMASK 1
24 #define BOOTP_OPTION_GATEWAY 3
26 #define BOOTP_OPTION_DNS 6
28 #define BOOTP_OPTION_HOSTNAME 12
30 #define BOOTP_OPTION_BOOTFILE_SIZE 13
32 #define BOOTP_OPTION_DOMAIN 15
34 #define BOOTP_OPTION_BROADCAST 28
36 #define BOOTP_OPTION_NISDOMAIN 40
39 #define DHCP_OPTION_LOGSRVS 7
41 #define DHCP_OPTION_LPRSRVS 9
43 #define DHCP_OPTION_NTPSRVS 42
45 #define DHCP_OPTION_XFNTSRVS 48
47 #define DHCP_OPTION_XDMSRVS 49
49 #define DHCP_OPTION_REQADDR 50
51 #define DHCP_OPTION_LEASE 51
53 #define DHCP_OPTION_OVERLOAD 52
55 #define DHCP_OPTION_TYPE 53
57 #define DHCP_OPTION_SERVER 54
59 #define DHCP_OPTION_OPTIONREQ 55
61 #define DHCP_OPTION_PARAMREQ 56
63 #define DHCP_OPTION_MAXSIZE 57
65 #define DHCP_OPTION_T1 58
67 #define DHCP_OPTION_T2 59
69 #define DHCP_OPTION_CLASS_IDENTIFIER 60
71 #define DHCP_OPTION_CLIENT_IDENTIFIER 61
73 #define DHCP_OPTION_RAPID_COMMIT 80
75 #define BOOTP_CLIENT_PORT 68
76 #define BOOTP_SERVER_PORT 67
78 #define BOOTP_OPCODE_REQUEST 1
79 #define BOOTP_OPCODE_REPLY 2
81 #define NORESPONSE -10
82 #define DHCP_TYPE_DISCOVER 1
83 #define DHCP_TYPE_OFFER 2
84 #define DHCP_TYPE_REQUEST 3
85 #define DHCP_TYPE_DECLINE 4
86 #define DHCP_TYPE_ACK 5
87 #define DHCP_TYPE_NAK 6
88 #define DHCP_TYPE_RELEASE 7
89 #define DHCP_TYPE_INFORM 8
100 dhcp_overload_opts overload, currentblock;
102 /* embedded DHCP message */
117 u_int8_t options[MAX_OPT_LEN];
118 } __attribute__((packed)) ;
121 void dm_init(struct dhcp_message *msg);
123 void dm_finish_options(struct dhcp_message *msg);
125 void dm_add_option(struct dhcp_message *msg, u_int8_t option,
126 u_int8_t length, void *opt);
128 u_int8_t *dm_next_option(struct dhcp_message *msg);
131 int dm_parse_msg_raw(char *dframe, int plen,
132 struct in_addr *from_ip, struct dhcp_message *msg);
136 class DHCPCommunicator
139 DHCPCommunicator(const std::string& remote);
140 std::string getMac(const std::string& ip);