version 1.1, 2012/02/21 22:30:18
|
version 1.1.1.1, 2012/10/09 09:06:54
|
Line 3
|
Line 3
|
DHCP Client. */ |
DHCP Client. */ |
|
|
/* |
/* |
* Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC") | * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC") |
* Copyright (c) 1995-2003 by Internet Software Consortium |
* Copyright (c) 1995-2003 by Internet Software Consortium |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 66 struct data_string default_duid;
|
Line 66 struct data_string default_duid;
|
#define ASSERT_STATE(state_is, state_shouldbe) {} |
#define ASSERT_STATE(state_is, state_shouldbe) {} |
|
|
static const char copyright[] = |
static const char copyright[] = |
"Copyright 2004-2011 Internet Systems Consortium."; | "Copyright 2004-2012 Internet Systems Consortium."; |
static const char arr [] = "All rights reserved."; |
static const char arr [] = "All rights reserved."; |
static const char message [] = "Internet Systems Consortium DHCP Client"; |
static const char message [] = "Internet Systems Consortium DHCP Client"; |
static const char url [] = |
static const char url [] = |
Line 1885 void send_discover (cpp)
|
Line 1885 void send_discover (cpp)
|
ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval)); |
ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval)); |
|
|
/* Send out a packet. */ |
/* Send out a packet. */ |
result = send_packet (client -> interface, (struct packet *)0, | result = send_packet(client->interface, NULL, &client->packet, |
&client -> packet, | client->packet_length, inaddr_any, |
client -> packet_length, | &sockaddr_broadcast, NULL); |
inaddr_any, &sockaddr_broadcast, | if (result < 0) { |
(struct hardware *)0); | log_error("%s:%d: Failed to send %d byte long packet over %s " |
| "interface.", MDL, client->packet_length, |
| client->interface->name); |
| } |
|
|
/* |
/* |
* If we used 0 microseconds here, and there were other clients on the |
* If we used 0 microseconds here, and there were other clients on the |
Line 2152 void send_request (cpp)
|
Line 2155 void send_request (cpp)
|
ntohs (destination.sin_port)); |
ntohs (destination.sin_port)); |
|
|
if (destination.sin_addr.s_addr != INADDR_BROADCAST && |
if (destination.sin_addr.s_addr != INADDR_BROADCAST && |
fallback_interface) | fallback_interface) { |
result = send_packet (fallback_interface, | result = send_packet(fallback_interface, NULL, &client->packet, |
(struct packet *)0, | client->packet_length, from, &destination, |
&client -> packet, | NULL); |
client -> packet_length, | if (result < 0) { |
from, &destination, | log_error("%s:%d: Failed to send %d byte long packet " |
(struct hardware *)0); | "over %s interface.", MDL, |
else | client->packet_length, |
| fallback_interface->name); |
| } |
| } |
| else { |
/* Send out a packet. */ |
/* Send out a packet. */ |
result = send_packet (client -> interface, (struct packet *)0, | result = send_packet(client->interface, NULL, &client->packet, |
&client -> packet, | client->packet_length, from, &destination, |
client -> packet_length, | NULL); |
from, &destination, | if (result < 0) { |
(struct hardware *)0); | log_error("%s:%d: Failed to send %d byte long packet" |
| " over %s interface.", MDL, |
| client->packet_length, |
| client->interface->name); |
| } |
| } |
|
|
tv.tv_sec = cur_tv.tv_sec + client->interval; |
tv.tv_sec = cur_tv.tv_sec + client->interval; |
tv.tv_usec = ((tv.tv_sec - cur_tv.tv_sec) > 1) ? |
tv.tv_usec = ((tv.tv_sec - cur_tv.tv_sec) > 1) ? |
Line 2181 void send_decline (cpp)
|
Line 2193 void send_decline (cpp)
|
int result; |
int result; |
|
|
log_info ("DHCPDECLINE on %s to %s port %d", |
log_info ("DHCPDECLINE on %s to %s port %d", |
client -> name ? client -> name : client -> interface -> name, | client->name ? client->name : client->interface->name, |
inet_ntoa (sockaddr_broadcast.sin_addr), | inet_ntoa(sockaddr_broadcast.sin_addr), |
ntohs (sockaddr_broadcast.sin_port)); | ntohs(sockaddr_broadcast.sin_port)); |
|
|
/* Send out a packet. */ |
/* Send out a packet. */ |
result = send_packet (client -> interface, (struct packet *)0, | result = send_packet(client->interface, NULL, &client->packet, |
&client -> packet, | client->packet_length, inaddr_any, |
client -> packet_length, | &sockaddr_broadcast, NULL); |
inaddr_any, &sockaddr_broadcast, | if (result < 0) { |
(struct hardware *)0); | log_error("%s:%d: Failed to send %d byte long packet over %s" |
| " interface.", MDL, client->packet_length, |
| client->interface->name); |
| } |
} |
} |
|
|
void send_release (cpp) |
void send_release (cpp) |
Line 2228 void send_release (cpp)
|
Line 2243 void send_release (cpp)
|
inet_ntoa (destination.sin_addr), |
inet_ntoa (destination.sin_addr), |
ntohs (destination.sin_port)); |
ntohs (destination.sin_port)); |
|
|
if (fallback_interface) | if (fallback_interface) { |
result = send_packet (fallback_interface, | result = send_packet(fallback_interface, NULL, &client->packet, |
(struct packet *)0, | client->packet_length, from, &destination, |
&client -> packet, | NULL); |
client -> packet_length, | if (result < 0) { |
from, &destination, | log_error("%s:%d: Failed to send %d byte long packet" |
(struct hardware *)0); | " over %s interface.", MDL, |
else | client->packet_length, |
| fallback_interface->name); |
| } |
| } else { |
/* Send out a packet. */ |
/* Send out a packet. */ |
result = send_packet (client -> interface, (struct packet *)0, | result = send_packet(client->interface, NULL, &client->packet, |
&client -> packet, | client->packet_length, from, &destination, |
client -> packet_length, | NULL); |
from, &destination, | if (result < 0) { |
(struct hardware *)0); | log_error ("%s:%d: Failed to send %d byte long packet" |
| " over %s interface.", MDL, |
| client->packet_length, |
| client->interface->name); |
| } |
| |
| } |
} |
} |
|
|
void |
void |
Line 2704 void write_lease_option (struct option_cache *oc,
|
Line 2728 void write_lease_option (struct option_cache *oc,
|
} |
} |
if (evaluate_option_cache (&ds, packet, lease, client_state, |
if (evaluate_option_cache (&ds, packet, lease, client_state, |
in_options, cfg_options, scope, oc, MDL)) { |
in_options, cfg_options, scope, oc, MDL)) { |
fprintf(leaseFile, "%soption %s%s%s %s;\n", preamble, | /* The option name */ |
name, dot, oc->option->name, | fprintf(leaseFile, "%soption %s%s%s", preamble, |
pretty_print_option(oc->option, ds.data, ds.len, | name, dot, oc->option->name); |
1, 1)); | |
| /* The option value if there is one */ |
| if ((oc->option->format == NULL) || |
| (oc->option->format[0] != 'Z')) { |
| fprintf(leaseFile, " %s", |
| pretty_print_option(oc->option, ds.data, |
| ds.len, 1, 1)); |
| } |
| |
| /* The closing semi-colon and newline */ |
| fprintf(leaseFile, ";\n"); |
| |
data_string_forget (&ds, MDL); |
data_string_forget (&ds, MDL); |
} |
} |
} |
} |
Line 3204 void script_write_params (client, prefix, lease)
|
Line 3239 void script_write_params (client, prefix, lease)
|
lease->server_name); |
lease->server_name); |
} |
} |
} |
} |
|
|
|
|
for (i = 0; i < lease -> options -> universe_count; i++) { |
for (i = 0; i < lease -> options -> universe_count; i++) { |
option_space_foreach ((struct packet *)0, (struct lease *)0, |
option_space_foreach ((struct packet *)0, (struct lease *)0, |