aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-16 10:25:35 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-16 10:25:35 +0200
commit56f2d06c6496e49d7e752d1ee5ac5ea420b4ed11 (patch)
tree2f972e9026ee995e1ebe146b05e608af3b2785ee /networking
parent990a617edfd9040594c0889d2dd23eb7ef91c695 (diff)
downloadbusybox-w32-56f2d06c6496e49d7e752d1ee5ac5ea420b4ed11.tar.gz
busybox-w32-56f2d06c6496e49d7e752d1ee5ac5ea420b4ed11.tar.bz2
busybox-w32-56f2d06c6496e49d7e752d1ee5ac5ea420b4ed11.zip
udhcp: rename sprintip to sprint_nip, siaddr to siaddr_nip
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/udhcp/common.h12
-rw-r--r--networking/udhcp/dhcpd.h13
-rw-r--r--networking/udhcp/files.c17
-rw-r--r--networking/udhcp/script.c15
-rw-r--r--networking/udhcp/serverpacket.c2
5 files changed, 26 insertions, 33 deletions
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index fef0b66a8..de784adf5 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -34,13 +34,13 @@ struct dhcpMessage {
34#define BROADCAST_FLAG 0x8000 /* "I need broadcast replies" */ 34#define BROADCAST_FLAG 0x8000 /* "I need broadcast replies" */
35 uint32_t ciaddr; /* client IP (if client is in BOUND, RENEW or REBINDING state) */ 35 uint32_t ciaddr; /* client IP (if client is in BOUND, RENEW or REBINDING state) */
36 uint32_t yiaddr; /* 'your' (client) IP address */ 36 uint32_t yiaddr; /* 'your' (client) IP address */
37 uint32_t siaddr; /* IP address of next server to use in bootstrap, 37 /* IP address of next server to use in bootstrap, returned in DHCPOFFER, DHCPACK by server */
38 * returned in DHCPOFFER, DHCPACK by server */ 38 uint32_t siaddr_nip;
39 uint32_t gateway_nip; /* relay agent IP address */ 39 uint32_t gateway_nip; /* relay agent IP address */
40 uint8_t chaddr[16];/* link-layer client hardware address (MAC) */ 40 uint8_t chaddr[16]; /* link-layer client hardware address (MAC) */
41 uint8_t sname[64]; /* server host name (ASCIZ) */ 41 uint8_t sname[64]; /* server host name (ASCIZ) */
42 uint8_t file[128]; /* boot file name (ASCIZ) */ 42 uint8_t file[128]; /* boot file name (ASCIZ) */
43 uint32_t cookie; /* fixed first four option bytes (99,130,83,99 dec) */ 43 uint32_t cookie; /* fixed first four option bytes (99,130,83,99 dec) */
44 uint8_t options[DHCP_OPTIONS_BUFSIZE + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS]; 44 uint8_t options[DHCP_OPTIONS_BUFSIZE + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS];
45} PACKED; 45} PACKED;
46 46
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h
index bb281c51b..61cd8c7be 100644
--- a/networking/udhcp/dhcpd.h
+++ b/networking/udhcp/dhcpd.h
@@ -39,11 +39,6 @@ struct server_config_t {
39 char *interface; /* The name of the interface to use */ 39 char *interface; /* The name of the interface to use */
40 int ifindex; /* Index number of the interface to use */ 40 int ifindex; /* Index number of the interface to use */
41 uint8_t arp[6]; /* Our arp address */ 41 uint8_t arp[6]; /* Our arp address */
42// disabled: dumpleases has no way of knowing this value,
43// and will break if it's off. Now it's on always.
44// char remaining; /* Should the lease time in lease file
45// * be written as lease time remaining, or
46// * as the absolute time the lease expires */
47 uint32_t lease; /* lease time in seconds (host order) */ 42 uint32_t lease; /* lease time in seconds (host order) */
48 uint32_t max_leases; /* maximum number of leases (including reserved address) */ 43 uint32_t max_leases; /* maximum number of leases (including reserved address) */
49 uint32_t auto_time; /* how long should udhcpd wait before writing a config file. 44 uint32_t auto_time; /* how long should udhcpd wait before writing a config file.
@@ -53,7 +48,7 @@ struct server_config_t {
53 uint32_t conflict_time; /* how long an arp conflict offender is leased for */ 48 uint32_t conflict_time; /* how long an arp conflict offender is leased for */
54 uint32_t offer_time; /* how long an offered address is reserved */ 49 uint32_t offer_time; /* how long an offered address is reserved */
55 uint32_t min_lease; /* minimum lease time a client can request */ 50 uint32_t min_lease; /* minimum lease time a client can request */
56 uint32_t siaddr; /* next server bootp option */ 51 uint32_t siaddr_nip; /* next server bootp option */
57 char *lease_file; 52 char *lease_file;
58 char *pidfile; 53 char *pidfile;
59 char *notify_file; /* What to run whenever leases are written */ 54 char *notify_file; /* What to run whenever leases are written */
@@ -81,11 +76,9 @@ struct dhcpOfferedAddr {
81 uint8_t lease_mac16[16]; 76 uint8_t lease_mac16[16];
82 /* "nip": IP in network order */ 77 /* "nip": IP in network order */
83 uint32_t lease_nip; 78 uint32_t lease_nip;
84 /* Unix time when lease expires, regardless of value of 79 /* Unix time when lease expires. Kept in memory in host order.
85 * server_config.remaining. Kept in memory in host order.
86 * When written to file, converted to network order 80 * When written to file, converted to network order
87 * and optionally adjusted (current time subtracted) 81 * and adjusted (current time subtracted) */
88 * if server_config.remaining = 1 */
89 leasetime_t expires; 82 leasetime_t expires;
90 uint8_t hostname[20]; /* (size is a multiply of 4) */ 83 uint8_t hostname[20]; /* (size is a multiply of 4) */
91}; 84};
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 671ea94c9..a69a7531b 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -24,7 +24,7 @@ static inline uint64_t hton64(uint64_t v)
24 24
25 25
26/* on these functions, make sure your datatype matches */ 26/* on these functions, make sure your datatype matches */
27static int FAST_FUNC read_ip(const char *line, void *arg) 27static int FAST_FUNC read_nip(const char *line, void *arg)
28{ 28{
29 len_and_sockaddr *lsa; 29 len_and_sockaddr *lsa;
30 30
@@ -187,15 +187,15 @@ static int FAST_FUNC read_opt(const char *const_line, void *arg)
187 opt = buffer; /* new meaning for variable opt */ 187 opt = buffer; /* new meaning for variable opt */
188 switch (option->flags & TYPE_MASK) { 188 switch (option->flags & TYPE_MASK) {
189 case OPTION_IP: 189 case OPTION_IP:
190 retval = read_ip(val, buffer); 190 retval = read_nip(val, buffer);
191 break; 191 break;
192 case OPTION_IP_PAIR: 192 case OPTION_IP_PAIR:
193 retval = read_ip(val, buffer); 193 retval = read_nip(val, buffer);
194 val = strtok(NULL, ", \t/-"); 194 val = strtok(NULL, ", \t/-");
195 if (!val) 195 if (!val)
196 retval = 0; 196 retval = 0;
197 if (retval) 197 if (retval)
198 retval = read_ip(val, buffer + 4); 198 retval = read_nip(val, buffer + 4);
199 break; 199 break;
200 case OPTION_STRING: 200 case OPTION_STRING:
201#if ENABLE_FEATURE_UDHCP_RFC3397 201#if ENABLE_FEATURE_UDHCP_RFC3397
@@ -266,7 +266,7 @@ static int FAST_FUNC read_staticlease(const char *const_line, void *arg)
266 266
267 /* Read ip */ 267 /* Read ip */
268 ip_string = strtok_r(NULL, " \t", &line); 268 ip_string = strtok_r(NULL, " \t", &line);
269 read_ip(ip_string, &ip); 269 read_nip(ip_string, &ip);
270 270
271 addStaticLease(arg, (uint8_t*) &mac_bytes, ip); 271 addStaticLease(arg, (uint8_t*) &mac_bytes, ip);
272 272
@@ -285,13 +285,12 @@ struct config_keyword {
285 285
286static const struct config_keyword keywords[] = { 286static const struct config_keyword keywords[] = {
287 /* keyword handler variable address default */ 287 /* keyword handler variable address default */
288 {"start", read_ip, &(server_config.start_ip), "192.168.0.20"}, 288 {"start", read_nip, &(server_config.start_ip), "192.168.0.20"},
289 {"end", read_ip, &(server_config.end_ip), "192.168.0.254"}, 289 {"end", read_nip, &(server_config.end_ip), "192.168.0.254"},
290 {"interface", read_str, &(server_config.interface), "eth0"}, 290 {"interface", read_str, &(server_config.interface), "eth0"},
291 /* Avoid "max_leases value not sane" warning by setting default 291 /* Avoid "max_leases value not sane" warning by setting default
292 * to default_end_ip - default_start_ip + 1: */ 292 * to default_end_ip - default_start_ip + 1: */
293 {"max_leases", read_u32, &(server_config.max_leases), "235"}, 293 {"max_leases", read_u32, &(server_config.max_leases), "235"},
294// {"remaining", read_yn, &(server_config.remaining), "yes"},
295 {"auto_time", read_u32, &(server_config.auto_time), "7200"}, 294 {"auto_time", read_u32, &(server_config.auto_time), "7200"},
296 {"decline_time", read_u32, &(server_config.decline_time), "3600"}, 295 {"decline_time", read_u32, &(server_config.decline_time), "3600"},
297 {"conflict_time",read_u32, &(server_config.conflict_time),"3600"}, 296 {"conflict_time",read_u32, &(server_config.conflict_time),"3600"},
@@ -299,7 +298,7 @@ static const struct config_keyword keywords[] = {
299 {"min_lease", read_u32, &(server_config.min_lease), "60"}, 298 {"min_lease", read_u32, &(server_config.min_lease), "60"},
300 {"lease_file", read_str, &(server_config.lease_file), LEASES_FILE}, 299 {"lease_file", read_str, &(server_config.lease_file), LEASES_FILE},
301 {"pidfile", read_str, &(server_config.pidfile), "/var/run/udhcpd.pid"}, 300 {"pidfile", read_str, &(server_config.pidfile), "/var/run/udhcpd.pid"},
302 {"siaddr", read_ip, &(server_config.siaddr), "0.0.0.0"}, 301 {"siaddr", read_nip, &(server_config.siaddr_nip), "0.0.0.0"},
303 /* keywords with no defaults must be last! */ 302 /* keywords with no defaults must be last! */
304 {"option", read_opt, &(server_config.options), ""}, 303 {"option", read_opt, &(server_config.options), ""},
305 {"opt", read_opt, &(server_config.options), ""}, 304 {"opt", read_opt, &(server_config.options), ""},
diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c
index 3029b1367..97c1d30c3 100644
--- a/networking/udhcp/script.c
+++ b/networking/udhcp/script.c
@@ -37,7 +37,8 @@ static inline int upper_length(int length, int opt_index)
37} 37}
38 38
39 39
40static int sprintip(char *dest, const char *pre, const uint8_t *ip) 40/* note: ip is a pointer to an IP in network order, possibly misaliged */
41static int sprint_nip(char *dest, const char *pre, const uint8_t *ip)
41{ 42{
42 return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]); 43 return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]);
43} 44}
@@ -76,12 +77,12 @@ static char *alloc_fill_opts(uint8_t *option, const struct dhcp_option *type_p,
76 for (;;) { 77 for (;;) {
77 switch (type) { 78 switch (type) {
78 case OPTION_IP_PAIR: 79 case OPTION_IP_PAIR:
79 dest += sprintip(dest, "", option); 80 dest += sprint_nip(dest, "", option);
80 *dest++ = '/'; 81 *dest++ = '/';
81 option += 4; 82 option += 4;
82 optlen = 4; 83 optlen = 4;
83 case OPTION_IP: /* Works regardless of host byte order. */ 84 case OPTION_IP: /* Works regardless of host byte order. */
84 dest += sprintip(dest, "", option); 85 dest += sprint_nip(dest, "", option);
85 break; 86 break;
86 case OPTION_BOOLEAN: 87 case OPTION_BOOLEAN:
87 dest += sprintf(dest, *option ? "yes" : "no"); 88 dest += sprintf(dest, *option ? "yes" : "no");
@@ -145,7 +146,7 @@ static char **fill_envp(struct dhcpMessage *packet)
145 num_options++; /* for mton */ 146 num_options++; /* for mton */
146 } 147 }
147 } 148 }
148 if (packet->siaddr) 149 if (packet->siaddr_nip)
149 num_options++; 150 num_options++;
150 temp = get_option(packet, DHCP_OPTION_OVERLOAD); 151 temp = get_option(packet, DHCP_OPTION_OVERLOAD);
151 if (temp) 152 if (temp)
@@ -164,7 +165,7 @@ static char **fill_envp(struct dhcpMessage *packet)
164 return envp; 165 return envp;
165 166
166 *curr = xmalloc(sizeof("ip=255.255.255.255")); 167 *curr = xmalloc(sizeof("ip=255.255.255.255"));
167 sprintip(*curr, "ip=", (uint8_t *) &packet->yiaddr); 168 sprint_nip(*curr, "ip=", (uint8_t *) &packet->yiaddr);
168 putenv(*curr++); 169 putenv(*curr++);
169 170
170 opt_name = dhcp_option_strings; 171 opt_name = dhcp_option_strings;
@@ -187,9 +188,9 @@ static char **fill_envp(struct dhcpMessage *packet)
187 opt_name += strlen(opt_name) + 1; 188 opt_name += strlen(opt_name) + 1;
188 i++; 189 i++;
189 } 190 }
190 if (packet->siaddr) { 191 if (packet->siaddr_nip) {
191 *curr = xmalloc(sizeof("siaddr=255.255.255.255")); 192 *curr = xmalloc(sizeof("siaddr=255.255.255.255"));
192 sprintip(*curr, "siaddr=", (uint8_t *) &packet->siaddr); 193 sprint_nip(*curr, "siaddr=", (uint8_t *) &packet->siaddr_nip);
193 putenv(*curr++); 194 putenv(*curr++);
194 } 195 }
195 if (!(over & FILE_FIELD) && packet->file[0]) { 196 if (!(over & FILE_FIELD) && packet->file[0]) {
diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c
index 55ed4a833..294a6a666 100644
--- a/networking/udhcp/serverpacket.c
+++ b/networking/udhcp/serverpacket.c
@@ -99,7 +99,7 @@ static void init_packet(struct dhcpMessage *packet, struct dhcpMessage *oldpacke
99/* add in the bootp options */ 99/* add in the bootp options */
100static void add_bootp_options(struct dhcpMessage *packet) 100static void add_bootp_options(struct dhcpMessage *packet)
101{ 101{
102 packet->siaddr = server_config.siaddr; 102 packet->siaddr_nip = server_config.siaddr_nip;
103 if (server_config.sname) 103 if (server_config.sname)
104 strncpy((char*)packet->sname, server_config.sname, sizeof(packet->sname) - 1); 104 strncpy((char*)packet->sname, server_config.sname, sizeof(packet->sname) - 1);
105 if (server_config.boot_file) 105 if (server_config.boot_file)