aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/arpping.c6
-rw-r--r--networking/udhcp/clientpacket.c4
-rw-r--r--networking/udhcp/common.h2
-rw-r--r--networking/udhcp/dhcpc.c6
-rw-r--r--networking/udhcp/dhcpd.c2
-rw-r--r--networking/udhcp/dhcpd.h22
-rw-r--r--networking/udhcp/files.c2
-rw-r--r--networking/udhcp/leases.c2
-rw-r--r--networking/udhcp/libbb_udhcp.h20
-rw-r--r--networking/udhcp/options.c4
-rw-r--r--networking/udhcp/packet.c8
-rw-r--r--networking/udhcp/script.c2
-rw-r--r--networking/udhcp/serverpacket.c4
13 files changed, 42 insertions, 42 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index 7cc2be42e..4831d4371 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -23,7 +23,7 @@
23 * ip - our ip 23 * ip - our ip
24 * mac - our arp address 24 * mac - our arp address
25 * interface - interface to use 25 * interface - interface to use
26 * retn: 1 addr free 26 * retn: 1 addr free
27 * 0 addr used 27 * 0 addr used
28 * -1 error 28 * -1 error
29 */ 29 */
@@ -33,7 +33,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
33{ 33{
34 34
35 int timeout = 2; 35 int timeout = 2;
36 int optval = 1; 36 int optval = 1;
37 int s; /* socket */ 37 int s; /* socket */
38 int rv = 1; /* return value */ 38 int rv = 1; /* return value */
39 struct sockaddr addr; /* for interface name */ 39 struct sockaddr addr; /* for interface name */
@@ -101,6 +101,6 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
101 prevTime = uptime(); 101 prevTime = uptime();
102 } 102 }
103 close(s); 103 close(s);
104 DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); 104 DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V");
105 return rv; 105 return rv;
106} 106}
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 528befde6..e377bd236 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -205,8 +205,8 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
205 packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) || 205 packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) ||
206 bytes > (int) sizeof(struct udp_dhcp_packet) || 206 bytes > (int) sizeof(struct udp_dhcp_packet) ||
207 ntohs(packet.udp.len) != (uint16_t) (bytes - sizeof(packet.ip))) { 207 ntohs(packet.udp.len) != (uint16_t) (bytes - sizeof(packet.ip))) {
208 DEBUG(LOG_INFO, "unrelated/bogus packet"); 208 DEBUG(LOG_INFO, "unrelated/bogus packet");
209 return -2; 209 return -2;
210 } 210 }
211 211
212 /* check IP checksum */ 212 /* check IP checksum */
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index efa8fd419..071a5c428 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -43,7 +43,7 @@ long uptime(void);
43void background(const char *pidfile); 43void background(const char *pidfile);
44void start_log_and_pid(const char *client_server, const char *pidfile); 44void start_log_and_pid(const char *client_server, const char *pidfile);
45void udhcp_logging(int level, const char *fmt, ...); 45void udhcp_logging(int level, const char *fmt, ...);
46 46
47#define LOG(level, str, args...) udhcp_logging(level, str, ## args) 47#define LOG(level, str, args...) udhcp_logging(level, str, ## args)
48 48
49#ifdef UDHCP_DEBUG 49#ifdef UDHCP_DEBUG
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index c4277e3f1..a4afb0c46 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
196 {"hostname", required_argument, 0, 'h'}, 196 {"hostname", required_argument, 0, 'h'},
197 {"fqdn", required_argument, 0, 'F'}, 197 {"fqdn", required_argument, 0, 'F'},
198 {"interface", required_argument, 0, 'i'}, 198 {"interface", required_argument, 0, 'i'},
199 {"now", no_argument, 0, 'n'}, 199 {"now", no_argument, 0, 'n'},
200 {"pidfile", required_argument, 0, 'p'}, 200 {"pidfile", required_argument, 0, 'p'},
201 {"quit", no_argument, 0, 'q'}, 201 {"quit", no_argument, 0, 'q'},
202 {"request", required_argument, 0, 'r'}, 202 {"request", required_argument, 0, 'r'},
@@ -314,7 +314,7 @@ int main(int argc, char *argv[])
314 client_config.vendorclass[OPT_CODE] = DHCP_VENDOR; 314 client_config.vendorclass[OPT_CODE] = DHCP_VENDOR;
315 client_config.vendorclass[OPT_LEN] = sizeof("udhcp "VERSION) - 1; 315 client_config.vendorclass[OPT_LEN] = sizeof("udhcp "VERSION) - 1;
316 client_config.vendorclass[OPT_DATA] = 1; 316 client_config.vendorclass[OPT_DATA] = 1;
317 memcpy(&client_config.vendorclass[OPT_DATA], 317 memcpy(&client_config.vendorclass[OPT_DATA],
318 "udhcp "VERSION, sizeof("udhcp "VERSION) - 1); 318 "udhcp "VERSION, sizeof("udhcp "VERSION) - 1);
319 } 319 }
320 320
@@ -370,7 +370,7 @@ int main(int argc, char *argv[])
370 } else if (client_config.abort_if_no_lease) { 370 } else if (client_config.abort_if_no_lease) {
371 LOG(LOG_INFO, "No lease, failing."); 371 LOG(LOG_INFO, "No lease, failing.");
372 return 1; 372 return 1;
373 } 373 }
374 /* wait to try again */ 374 /* wait to try again */
375 packet_num = 0; 375 packet_num = 0;
376 timeout = now + 60; 376 timeout = now + 60;
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 2812e6e8c..0dfc0b559 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -193,7 +193,7 @@ int main(int argc, char *argv[])
193 LOG(LOG_ERR, "send OFFER failed"); 193 LOG(LOG_ERR, "send OFFER failed");
194 } 194 }
195 break; 195 break;
196 case DHCPREQUEST: 196 case DHCPREQUEST:
197 DEBUG(LOG_INFO, "received REQUEST"); 197 DEBUG(LOG_INFO, "received REQUEST");
198 198
199 requested = get_option(&packet, DHCP_REQUESTED_IP); 199 requested = get_option(&packet, DHCP_REQUESTED_IP);
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h
index 65c8348bf..a060002cd 100644
--- a/networking/udhcp/dhcpd.h
+++ b/networking/udhcp/dhcpd.h
@@ -108,23 +108,23 @@ struct static_lease {
108 108
109struct server_config_t { 109struct server_config_t {
110 uint32_t server; /* Our IP, in network order */ 110 uint32_t server; /* Our IP, in network order */
111 uint32_t start; /* Start address of leases, network order */ 111 uint32_t start; /* Start address of leases, network order */
112 uint32_t end; /* End of leases, network order */ 112 uint32_t end; /* End of leases, network order */
113 struct option_set *options; /* List of DHCP options loaded from the config file */ 113 struct option_set *options; /* List of DHCP options loaded from the config file */
114 char *interface; /* The name of the interface to use */ 114 char *interface; /* The name of the interface to use */
115 int ifindex; /* Index number of the interface to use */ 115 int ifindex; /* Index number of the interface to use */
116 uint8_t arp[6]; /* Our arp address */ 116 uint8_t arp[6]; /* Our arp address */
117 unsigned long lease; /* lease time in seconds (host order) */ 117 unsigned long lease; /* lease time in seconds (host order) */
118 unsigned long max_leases; /* maximum number of leases (including reserved address) */ 118 unsigned long max_leases; /* maximum number of leases (including reserved address) */
119 char remaining; /* should the lease file be interpreted as lease time remaining, or 119 char remaining; /* should the lease file be interpreted as lease time remaining, or
120 * as the time the lease expires */ 120 * as the time the lease expires */
121 unsigned long auto_time; /* how long should udhcpd wait before writing a config file. 121 unsigned long auto_time; /* how long should udhcpd wait before writing a config file.
122 * if this is zero, it will only write one on SIGUSR1 */ 122 * if this is zero, it will only write one on SIGUSR1 */
123 unsigned long decline_time; /* how long an address is reserved if a client returns a 123 unsigned long decline_time; /* how long an address is reserved if a client returns a
124 * decline message */ 124 * decline message */
125 unsigned long conflict_time; /* how long an arp conflict offender is leased for */ 125 unsigned long conflict_time; /* how long an arp conflict offender is leased for */
126 unsigned long offer_time; /* how long an offered address is reserved */ 126 unsigned long offer_time; /* how long an offered address is reserved */
127 unsigned long min_lease; /* minimum lease a client can request*/ 127 unsigned long min_lease; /* minimum lease a client can request*/
128 char *lease_file; 128 char *lease_file;
129 char *pidfile; 129 char *pidfile;
130 char *notify_file; /* What to run whenever leases are written */ 130 char *notify_file; /* What to run whenever leases are written */
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 40e68a0a8..01534f2bb 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -271,7 +271,7 @@ static const struct config_keyword keywords[] = {
271 {"boot_file", read_str, &(server_config.boot_file), ""}, 271 {"boot_file", read_str, &(server_config.boot_file), ""},
272 {"static_lease",read_staticlease, &(server_config.static_leases), ""}, 272 {"static_lease",read_staticlease, &(server_config.static_leases), ""},
273 /*ADDME: static lease */ 273 /*ADDME: static lease */
274 {"", NULL, NULL, ""} 274 {"", NULL, NULL, ""}
275}; 275};
276 276
277 277
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
index 4da21a23b..bb08c3adb 100644
--- a/networking/udhcp/leases.c
+++ b/networking/udhcp/leases.c
@@ -148,7 +148,7 @@ uint32_t find_address(int check_expired)
148 (check_expired && lease_expired(lease))) && 148 (check_expired && lease_expired(lease))) &&
149 149
150 /* and it isn't on the network */ 150 /* and it isn't on the network */
151 !check_ip(ret)) { 151 !check_ip(ret)) {
152 return ret; 152 return ret;
153 break; 153 break;
154 } 154 }
diff --git a/networking/udhcp/libbb_udhcp.h b/networking/udhcp/libbb_udhcp.h
index 0dae40172..30e167f64 100644
--- a/networking/udhcp/libbb_udhcp.h
+++ b/networking/udhcp/libbb_udhcp.h
@@ -29,19 +29,19 @@
29 29
30/* make safe the exported namespace */ 30/* make safe the exported namespace */
31/* from common.h */ 31/* from common.h */
32#define background udhcp_background 32#define background udhcp_background
33#define start_log_and_pid udhcp_start_log_and_pid 33#define start_log_and_pid udhcp_start_log_and_pid
34/* from script.h */ 34/* from script.h */
35#define run_script udhcp_run_script 35#define run_script udhcp_run_script
36/* from packet.h */ 36/* from packet.h */
37#define init_header udhcp_init_header 37#define init_header udhcp_init_header
38#define get_packet udhcp_get_packet 38#define get_packet udhcp_get_packet
39#define checksum udhcp_checksum 39#define checksum udhcp_checksum
40#define raw_packet udhcp_raw_packet 40#define raw_packet udhcp_raw_packet
41#define kernel_packet udhcp_kernel_packet 41#define kernel_packet udhcp_kernel_packet
42/* from pidfile.h */ 42/* from pidfile.h */
43#define pidfile_acquire udhcp_pidfile_acquire 43#define pidfile_acquire udhcp_pidfile_acquire
44#define pidfile_write_release udhcp_pidfile_write_release 44#define pidfile_write_release udhcp_pidfile_write_release
45/* from options.h */ 45/* from options.h */
46#define get_option udhcp_get_option 46#define get_option udhcp_get_option
47#define end_option udhcp_end_option 47#define end_option udhcp_end_option
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index 144345134..eebcaaa58 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -154,11 +154,11 @@ int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
154 for (dh=dhcp_options; dh->code; dh++) { 154 for (dh=dhcp_options; dh->code; dh++) {
155 if (dh->code == code) { 155 if (dh->code == code) {
156 uint8_t option[6], len; 156 uint8_t option[6], len;
157 157
158 option[OPT_CODE] = code; 158 option[OPT_CODE] = code;
159 len = option_lengths[dh->flags & TYPE_MASK]; 159 len = option_lengths[dh->flags & TYPE_MASK];
160 option[OPT_LEN] = len; 160 option[OPT_LEN] = len;
161 if (__BYTE_ORDER == __BIG_ENDIAN) 161 if (__BYTE_ORDER == __BIG_ENDIAN)
162 data <<= 8 * (4 - len); 162 data <<= 8 * (4 - len);
163 /* This memcpy is for broken processors which can't 163 /* This memcpy is for broken processors which can't
164 * handle a simple unaligned 32-bit assignment */ 164 * handle a simple unaligned 32-bit assignment */
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 1c6bb0ca4..64a910031 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -71,13 +71,13 @@ int get_packet(struct dhcpMessage *packet, int fd)
71 for (i = 0; broken_vendors[i][0]; i++) { 71 for (i = 0; broken_vendors[i][0]; i++) {
72 if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) && 72 if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) &&
73 !strncmp(vendor, broken_vendors[i], vendor[OPT_LEN - 2])) { 73 !strncmp(vendor, broken_vendors[i], vendor[OPT_LEN - 2])) {
74 DEBUG(LOG_INFO, "broken client (%s), forcing broadcast", 74 DEBUG(LOG_INFO, "broken client (%s), forcing broadcast",
75 broken_vendors[i]); 75 broken_vendors[i]);
76 packet->flags |= htons(BROADCAST_FLAG); 76 packet->flags |= htons(BROADCAST_FLAG);
77 } 77 }
78 } 78 }
79 } 79 }
80 80
81 81
82 return bytes; 82 return bytes;
83} 83}
diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c
index c04c69f7e..b6b0e0d59 100644
--- a/networking/udhcp/script.c
+++ b/networking/udhcp/script.c
@@ -97,7 +97,7 @@ static void fill_options(char *dest, uint8_t *option, struct dhcp_option *type_p
97 optlen = 4; 97 optlen = 4;
98 case OPTION_IP: /* Works regardless of host byte order. */ 98 case OPTION_IP: /* Works regardless of host byte order. */
99 dest += sprintip(dest, "", option); 99 dest += sprintip(dest, "", option);
100 break; 100 break;
101 case OPTION_BOOLEAN: 101 case OPTION_BOOLEAN:
102 dest += sprintf(dest, *option ? "yes" : "no"); 102 dest += sprintf(dest, *option ? "yes" : "no");
103 break; 103 break;
diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c
index c6a820909..1b89862b2 100644
--- a/networking/udhcp/serverpacket.c
+++ b/networking/udhcp/serverpacket.c
@@ -138,11 +138,11 @@ int sendOffer(struct dhcpMessage *oldpacket)
138 /* and the ip is in the lease range */ 138 /* and the ip is in the lease range */
139 ntohl(req_align) >= ntohl(server_config.start) && 139 ntohl(req_align) >= ntohl(server_config.start) &&
140 ntohl(req_align) <= ntohl(server_config.end) && 140 ntohl(req_align) <= ntohl(server_config.end) &&
141 141
142 !static_lease_ip && /* Check that its not a static lease */ 142 !static_lease_ip && /* Check that its not a static lease */
143 /* and is not already taken/offered */ 143 /* and is not already taken/offered */
144 ((!(lease = find_lease_by_yiaddr(req_align)) || 144 ((!(lease = find_lease_by_yiaddr(req_align)) ||
145 145
146 /* or its taken, but expired */ /* ADDME: or maybe in here */ 146 /* or its taken, but expired */ /* ADDME: or maybe in here */
147 lease_expired(lease)))) { 147 lease_expired(lease)))) {
148 packet.yiaddr = req_align; /* FIXME: oh my, is there a host using this IP? */ 148 packet.yiaddr = req_align; /* FIXME: oh my, is there a host using this IP? */