33# define send_packet trace_packet_send
44 struct sockaddr_in to;
54 int peer_has_leases = 0;
63 snprintf (msgbuf,
sizeof msgbuf,
"BOOTREQUEST from %s via %s",
69 :
packet -> interface -> name);
72 log_info (
"%s: network unknown", msgbuf);
97 host_reference(&host, h,
MDL);
103 host_dereference(&hp,
MDL);
106 host_reference(&hp, host,
MDL);
107 host_dereference(&host,
MDL);
117 log_info(
"%s: BOOTP from dynamic client and no "
118 "dynamic leases", msgbuf);
122#if defined(FAILOVER_PROTOCOL)
125 dhcp_failover_state_t *peer;
141 log_info(
"%s: load balance to peer %s",
163 for (i =
packet -> class_count; i > 0; i--) {
186 log_info (
"%s: bootp disallowed", msgbuf);
197 log_info (
"%s: booting disallowed", msgbuf);
202 memset (&outgoing, 0,
sizeof outgoing);
203 memset (&raw, 0,
sizeof raw);
214 options, i),
MDL))) {
237 option_code_hash_lookup(&oc->
option,
259 packet -> options, options,
287 packet -> options, options,
292 memset (&d1, 0,
sizeof d1);
297 packet -> options, options,
319 packet -> options, options,
325 0, (
sizeof raw.
file) - d1.
len);
335 packet -> options, options,
353#if defined(DHCPv6) && defined(DHCP4o6)
357 log_info(
"DHCP4o6 BOOTREPLY for %s to %s (%s) via %s",
359 ((hp != NULL) && (hp->
name != NULL)) ?
360 hp -> name :
"unknown",
371 log_fatal(
"No memory to store DHCP4o6 reply.");
389 log_error(
"%s: Interface %s appears to have no IPv4 "
390 "addresses, and so dhcpd cannot select a source "
397 log_info(
"BOOTREPLY for %s to %s (%s) via %s",
399 ((hp != NULL) && (hp->
name != NULL)) ? hp -> name :
"unknown",
408 to.sin_family = AF_INET;
410 to.sin_len =
sizeof to;
412 memset (to.sin_zero, 0,
sizeof to.sin_zero);
424 log_error (
"%s:%d: Failed to send %d byte long "
425 "packet over %s interface.",
MDL,
432 }
else if (norelay == 2) {
461 log_error (
"%s:%d: Failed to send %d byte long packet over %s"
473 host_dereference (&hp,
MDL);
475 host_dereference (&host,
MDL);
void bootp(struct packet *packet)
int buffer_allocate(struct buffer **ptr, unsigned len, const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
int option_state_allocate(struct option_state **ptr, const char *file, int line)
int option_state_dereference(struct option_state **ptr, const char *file, int line)
int option_cache_allocate(struct option_cache **cptr, const char *file, int line)
void save_option(struct universe *universe, struct option_state *options, struct option_cache *oc)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
struct option_cache * lookup_option(struct universe *universe, struct option_state *options, unsigned code)
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)
char * print_hw_addr(int htype, const int hlen, const unsigned char *data) const
#define DHCP_FIXED_NON_UDP
#define SV_ALWAYS_REPLY_RFC1048
void use_host_decl_name(struct packet *, struct lease *, struct option_state *)
Adds hostname option when use-host-decl-names is enabled.
int find_hosts_by_haddr(struct host_decl **, int, const unsigned char *, unsigned, const char *, int)
struct ipv6_pool ** pools
ssize_t send_packet(struct interface_info *, struct packet *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *)
int allocate_lease(struct lease **, struct packet *, struct pool *, int *)
struct universe server_universe
struct universe dhcp_universe
void ack_lease(struct packet *, struct lease *, unsigned int, TIME, char *, int, struct host_decl *)
int can_unicast_without_arp(struct interface_info *)
int locate_network(struct packet *)
int find_lease(struct lease **, struct packet *, struct shared_network *, int *, int *, struct lease *, const char *, int)
int load_balance_mine(struct packet *, dhcp_failover_state_t *)
#define SV_ALWAYS_BROADCAST
struct interface_info * fallback_interface
struct in_addr limited_broadcast
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)
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)
const char * piaddr(const struct iaddr addr)
int log_error(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__
const unsigned char * data
unsigned char options[DHCP_MAX_OPTION_LEN]
char sname[DHCP_SNAME_LEN]
u_int8_t hbuf[HARDWARE_ADDR_LEN+1]
struct option_cache * fixed_addr
struct host_decl * n_ipaddr
struct in_addr * addresses
struct binding_scope * scope
struct executable_statement * on_commit
struct interface_info * interface
struct option_state * options
struct data_string * dhcp4o6_response
struct class * classes[PACKET_MAX_CLASSES]
dhcp_failover_state_t * failover_peer
struct interface_info * interface
struct shared_network * shared_network
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)
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)