34 # define send_packet trace_packet_send 43 struct packet outgoing;
45 struct sockaddr_in to;
55 int peer_has_leases = 0;
64 snprintf (msgbuf,
sizeof msgbuf,
"BOOTREQUEST from %s via %s",
66 packet -> raw -> hlen,
67 packet -> raw -> chaddr),
68 packet -> raw ->
giaddr.s_addr
69 ? inet_ntoa (packet -> raw ->
giaddr)
70 : packet -> interface -> name);
73 log_info (
"%s: network unknown", msgbuf);
78 0, 0, (
struct lease *)0,
MDL);
80 if (lease && lease->
host)
81 host_reference(&hp, lease->
host,
MDL);
98 host_reference(&host, h,
MDL);
104 host_dereference(&hp,
MDL);
107 host_reference(&hp, host,
MDL);
108 host_dereference(&host,
MDL);
118 log_info(
"%s: BOOTP from dynamic client and no " 119 "dynamic leases", msgbuf);
123 #if defined(FAILOVER_PROTOCOL) 124 if ((lease->
pool != NULL) &&
126 dhcp_failover_state_t *peer;
142 log_info(
"%s: load balance to peer %s",
149 ack_lease (packet, lease, 0, 0, msgbuf, 0, hp);
164 for (i = packet -> class_count; i > 0; i--) {
184 packet -> options, options,
185 &lease -> scope, oc,
MDL)) {
187 log_info (
"%s: bootp disallowed", msgbuf);
195 packet -> options, options,
196 &lease -> scope, oc,
MDL)) {
198 log_info (
"%s: booting disallowed", msgbuf);
203 memset (&outgoing, 0,
sizeof outgoing);
204 memset (&raw, 0,
sizeof raw);
209 if (!packet -> options_valid &&
212 packet -> options, options, &lease -> scope,
215 memcpy (outgoing.
raw -> options,
229 lease ->
subnet -> netmask.iabuf,
230 lease ->
subnet -> netmask.len,
232 option_code_hash_lookup(&oc->
option,
249 packet -> options, options,
259 raw.
htype = packet -> raw -> htype;
260 raw.
hlen = packet -> raw -> hlen;
261 memcpy (raw.
chaddr, packet -> raw -> chaddr,
sizeof raw.
chaddr);
262 raw.
hops = packet -> raw -> hops;
263 raw.
xid = packet -> raw -> xid;
264 raw.
secs = packet -> raw -> secs;
266 raw.
ciaddr = packet -> raw -> ciaddr;
277 packet -> options, options,
278 &lease -> scope, oc,
MDL))
282 memset (&d1, 0,
sizeof d1);
287 packet -> options, options,
288 &lease -> scope, oc,
MDL)) {
309 packet -> options, options,
310 &lease -> scope, oc,
MDL)) {
315 0, (
sizeof raw.
file) - d1.
len);
318 memcpy (raw.
file, packet -> raw ->
file,
sizeof raw.
file);
325 packet -> options, options,
326 &lease -> scope, oc,
MDL)) {
344 hto.
hbuf [0] = packet -> raw -> htype;
345 hto.
hlen = packet -> raw -> hlen + 1;
346 memcpy (&hto.
hbuf [1], packet -> raw -> chaddr, packet -> raw -> hlen);
351 log_error(
"%s: Interface %s appears to have no IPv4 " 352 "addresses, and so dhcpd cannot select a source " 359 log_info(
"BOOTREPLY for %s to %s (%s) via %s",
361 ((hp != NULL) && (hp->
name != NULL)) ? hp -> name :
"unknown",
370 to.sin_family = AF_INET;
372 to.sin_len =
sizeof to;
374 memset (to.sin_zero, 0,
sizeof to.sin_zero);
386 log_error (
"%s:%d: Failed to send %d byte long " 387 "packet over %s interface.",
MDL,
394 }
else if (norelay == 2) {
423 log_error (
"%s:%d: Failed to send %d byte long packet over %s" 433 lease_dereference (&lease,
MDL);
435 host_dereference (&hp,
MDL);
437 host_dereference (&host,
MDL);
int find_lease(struct lease **, struct packet *, struct shared_network *, int *, int *, struct lease *, const char *, int)
char sname[DHCP_SNAME_LEN]
void save_option(struct universe *universe, struct option_state *options, struct option_cache *oc)
const char * piaddr(const struct iaddr addr)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
struct universe server_universe
int execute_statements(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct executable_statement *statements, struct on_star *on_star)
char * print_hw_addr(int htype, const int hlen, const unsigned char *data) const
struct in_addr * addresses
struct universe dhcp_universe
void data_string_forget(struct data_string *data, const char *file, int line)
struct option_cache * fixed_addr
int log_error(const char *,...) __attribute__((__format__(__printf__
int allocate_lease(struct lease **, struct packet *, struct pool *, int *)
dhcp_failover_state_t * failover_peer
int find_hosts_by_haddr(struct host_decl **, int, const unsigned char *, unsigned, const char *, int)
struct option_state * options
int locate_network(struct packet *)
int option_cache_allocate(struct option_cache **cptr, const char *file, int line)
void execute_statements_in_scope(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct group *group, struct group *limiting_group, struct on_star *on_star)
struct interface_info * fallback_interface
int option_state_allocate(struct option_state **ptr, const char *file, int line)
int evaluate_option_cache(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
#define DHCP_MAX_OPTION_LEN
#define SV_ALWAYS_BROADCAST
struct class * classes[PACKET_MAX_CLASSES]
struct interface_info * interface
#define SV_ALWAYS_REPLY_RFC1048
ssize_t send_packet(struct interface_info *, struct packet *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *)
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, struct lease *lease, struct client_state *client_state, int mms, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, int overload_avail, int terminate, int bootpp, struct data_string *prl, const char *vuname)
struct host_decl * n_ipaddr
int load_balance_mine(struct packet *, dhcp_failover_state_t *)
struct option_cache * lookup_option(struct universe *universe, struct option_state *options, unsigned code)
struct in_addr limited_broadcast
int int log_info(const char *,...) __attribute__((__format__(__printf__
struct shared_network * shared_network
void bootp(struct packet *packet)
int option_state_dereference(struct option_state **ptr, const char *file, int line)
int evaluate_boolean_option_cache(int *ignorep, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
int make_const_data(struct expression **expr, const unsigned char *data, unsigned len, int terminated, int allocate, const char *file, int line)
void ack_lease(struct packet *, struct lease *, unsigned int, TIME, char *, int, struct host_decl *)
struct interface_info * interface
u_int8_t hbuf[HARDWARE_ADDR_LEN+1]
struct ipv6_pool ** pools
option_code_hash_t * code_hash
int can_unicast_without_arp(struct interface_info *)
struct executable_statement * on_commit
const unsigned char * data
struct binding_scope * scope