diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /networking | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'networking')
31 files changed, 444 insertions, 434 deletions
diff --git a/networking/arping.c b/networking/arping.c index bf0a77cf4..2e1adf0a2 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -302,9 +302,9 @@ int arping_main(int argc, char **argv) | |||
302 | break; | 302 | break; |
303 | case 'I': | 303 | case 'I': |
304 | if (optarg == NULL) | 304 | if (optarg == NULL) |
305 | show_usage(); | 305 | bb_show_usage(); |
306 | if (xstrlen(optarg) > IF_NAMESIZE) { | 306 | if (bb_strlen(optarg) > IF_NAMESIZE) { |
307 | error_msg("Interface name `%s' must be less than %d", optarg, | 307 | bb_error_msg("Interface name `%s' must be less than %d", optarg, |
308 | IF_NAMESIZE); | 308 | IF_NAMESIZE); |
309 | exit(2); | 309 | exit(2); |
310 | } | 310 | } |
@@ -319,20 +319,20 @@ int arping_main(int argc, char **argv) | |||
319 | case 'h': | 319 | case 'h': |
320 | case '?': | 320 | case '?': |
321 | default: | 321 | default: |
322 | show_usage(); | 322 | bb_show_usage(); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | argc -= optind; | 325 | argc -= optind; |
326 | argv += optind; | 326 | argv += optind; |
327 | 327 | ||
328 | if (argc != 1) | 328 | if (argc != 1) |
329 | show_usage(); | 329 | bb_show_usage(); |
330 | 330 | ||
331 | target = *argv; | 331 | target = *argv; |
332 | 332 | ||
333 | 333 | ||
334 | if (s < 0) { | 334 | if (s < 0) { |
335 | error_msg("socket"); | 335 | bb_error_msg("socket"); |
336 | exit(socket_errno); | 336 | exit(socket_errno); |
337 | } | 337 | } |
338 | 338 | ||
@@ -342,21 +342,21 @@ int arping_main(int argc, char **argv) | |||
342 | memset(&ifr, 0, sizeof(ifr)); | 342 | memset(&ifr, 0, sizeof(ifr)); |
343 | strncpy(ifr.ifr_name, device, IFNAMSIZ - 1); | 343 | strncpy(ifr.ifr_name, device, IFNAMSIZ - 1); |
344 | if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { | 344 | if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { |
345 | error_msg("Interface %s not found", device); | 345 | bb_error_msg("Interface %s not found", device); |
346 | exit(2); | 346 | exit(2); |
347 | } | 347 | } |
348 | ifindex = ifr.ifr_ifindex; | 348 | ifindex = ifr.ifr_ifindex; |
349 | 349 | ||
350 | if (ioctl(s, SIOCGIFFLAGS, (char *) &ifr)) { | 350 | if (ioctl(s, SIOCGIFFLAGS, (char *) &ifr)) { |
351 | error_msg("SIOCGIFFLAGS"); | 351 | bb_error_msg("SIOCGIFFLAGS"); |
352 | exit(2); | 352 | exit(2); |
353 | } | 353 | } |
354 | if (!(ifr.ifr_flags & IFF_UP)) { | 354 | if (!(ifr.ifr_flags & IFF_UP)) { |
355 | error_msg("Interface %s is down", device); | 355 | bb_error_msg("Interface %s is down", device); |
356 | exit(2); | 356 | exit(2); |
357 | } | 357 | } |
358 | if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { | 358 | if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { |
359 | error_msg("Interface %s is not ARPable", device); | 359 | bb_error_msg("Interface %s is not ARPable", device); |
360 | exit(dad ? 0 : 2); | 360 | exit(dad ? 0 : 2); |
361 | } | 361 | } |
362 | } | 362 | } |
@@ -366,14 +366,14 @@ int arping_main(int argc, char **argv) | |||
366 | 366 | ||
367 | hp = gethostbyname2(target, AF_INET); | 367 | hp = gethostbyname2(target, AF_INET); |
368 | if (!hp) { | 368 | if (!hp) { |
369 | error_msg("invalid or unknown target %s", target); | 369 | bb_error_msg("invalid or unknown target %s", target); |
370 | exit(2); | 370 | exit(2); |
371 | } | 371 | } |
372 | memcpy(&dst, hp->h_addr, 4); | 372 | memcpy(&dst, hp->h_addr, 4); |
373 | } | 373 | } |
374 | 374 | ||
375 | if (source && !inet_aton(source, &src)) { | 375 | if (source && !inet_aton(source, &src)) { |
376 | error_msg("invalid source address %s", source); | 376 | bb_error_msg("invalid source address %s", source); |
377 | exit(2); | 377 | exit(2); |
378 | } | 378 | } |
379 | 379 | ||
@@ -385,21 +385,21 @@ int arping_main(int argc, char **argv) | |||
385 | int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); | 385 | int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); |
386 | 386 | ||
387 | if (probe_fd < 0) { | 387 | if (probe_fd < 0) { |
388 | error_msg("socket"); | 388 | bb_error_msg("socket"); |
389 | exit(2); | 389 | exit(2); |
390 | } | 390 | } |
391 | if (device) { | 391 | if (device) { |
392 | if (setsockopt | 392 | if (setsockopt |
393 | (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, | 393 | (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, |
394 | strlen(device) + 1) == -1) | 394 | strlen(device) + 1) == -1) |
395 | error_msg("WARNING: interface %s is ignored", device); | 395 | bb_error_msg("WARNING: interface %s is ignored", device); |
396 | } | 396 | } |
397 | memset(&saddr, 0, sizeof(saddr)); | 397 | memset(&saddr, 0, sizeof(saddr)); |
398 | saddr.sin_family = AF_INET; | 398 | saddr.sin_family = AF_INET; |
399 | if (src.s_addr) { | 399 | if (src.s_addr) { |
400 | saddr.sin_addr = src; | 400 | saddr.sin_addr = src; |
401 | if (bind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { | 401 | if (bind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { |
402 | error_msg("bind"); | 402 | bb_error_msg("bind"); |
403 | exit(2); | 403 | exit(2); |
404 | } | 404 | } |
405 | } else if (!dad) { | 405 | } else if (!dad) { |
@@ -415,12 +415,12 @@ int arping_main(int argc, char **argv) | |||
415 | perror("WARNING: setsockopt(SO_DONTROUTE)"); | 415 | perror("WARNING: setsockopt(SO_DONTROUTE)"); |
416 | if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) | 416 | if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) |
417 | == -1) { | 417 | == -1) { |
418 | error_msg("connect"); | 418 | bb_error_msg("connect"); |
419 | exit(2); | 419 | exit(2); |
420 | } | 420 | } |
421 | if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == | 421 | if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == |
422 | -1) { | 422 | -1) { |
423 | error_msg("getsockname"); | 423 | bb_error_msg("getsockname"); |
424 | exit(2); | 424 | exit(2); |
425 | } | 425 | } |
426 | src = saddr.sin_addr; | 426 | src = saddr.sin_addr; |
@@ -432,7 +432,7 @@ int arping_main(int argc, char **argv) | |||
432 | me.sll_ifindex = ifindex; | 432 | me.sll_ifindex = ifindex; |
433 | me.sll_protocol = htons(ETH_P_ARP); | 433 | me.sll_protocol = htons(ETH_P_ARP); |
434 | if (bind(s, (struct sockaddr *) &me, sizeof(me)) == -1) { | 434 | if (bind(s, (struct sockaddr *) &me, sizeof(me)) == -1) { |
435 | error_msg("bind"); | 435 | bb_error_msg("bind"); |
436 | exit(2); | 436 | exit(2); |
437 | } | 437 | } |
438 | 438 | ||
@@ -440,12 +440,12 @@ int arping_main(int argc, char **argv) | |||
440 | int alen = sizeof(me); | 440 | int alen = sizeof(me); |
441 | 441 | ||
442 | if (getsockname(s, (struct sockaddr *) &me, &alen) == -1) { | 442 | if (getsockname(s, (struct sockaddr *) &me, &alen) == -1) { |
443 | error_msg("getsockname"); | 443 | bb_error_msg("getsockname"); |
444 | exit(2); | 444 | exit(2); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | if (me.sll_halen == 0) { | 447 | if (me.sll_halen == 0) { |
448 | error_msg("Interface \"%s\" is not ARPable (no ll address)", device); | 448 | bb_error_msg("Interface \"%s\" is not ARPable (no ll address)", device); |
449 | exit(dad ? 0 : 2); | 449 | exit(dad ? 0 : 2); |
450 | } | 450 | } |
451 | he = me; | 451 | he = me; |
@@ -458,7 +458,7 @@ int arping_main(int argc, char **argv) | |||
458 | } | 458 | } |
459 | 459 | ||
460 | if (!src.s_addr && !dad) { | 460 | if (!src.s_addr && !dad) { |
461 | error_msg("no src address in the non-DAD mode"); | 461 | bb_error_msg("no src address in the non-DAD mode"); |
462 | exit(2); | 462 | exit(2); |
463 | } | 463 | } |
464 | 464 | ||
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 44e91c37a..394389043 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -77,7 +77,7 @@ static ftp_host_info_t *ftp_init(void) | |||
77 | static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) | 77 | static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) |
78 | { | 78 | { |
79 | if (verbose_flag) { | 79 | if (verbose_flag) { |
80 | error_msg("cmd %s%s", s1, s2); | 80 | bb_error_msg("cmd %s%s", s1, s2); |
81 | } | 81 | } |
82 | 82 | ||
83 | if (s1) { | 83 | if (s1) { |
@@ -90,7 +90,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) | |||
90 | 90 | ||
91 | do { | 91 | do { |
92 | if (fgets(buf, 510, stream) == NULL) { | 92 | if (fgets(buf, 510, stream) == NULL) { |
93 | perror_msg_and_die("fgets()"); | 93 | bb_perror_msg_and_die("fgets()"); |
94 | } | 94 | } |
95 | } while (! isdigit(buf[0]) || buf[3] != ' '); | 95 | } while (! isdigit(buf[0]) || buf[3] != ' '); |
96 | 96 | ||
@@ -125,11 +125,11 @@ static FILE *ftp_login(ftp_host_info_t *server) | |||
125 | control_fd = xconnect(server->host, server->port); | 125 | control_fd = xconnect(server->host, server->port); |
126 | control_stream = fdopen(control_fd, "r+"); | 126 | control_stream = fdopen(control_fd, "r+"); |
127 | if (control_stream == NULL) { | 127 | if (control_stream == NULL) { |
128 | perror_msg_and_die("Couldnt open control stream"); | 128 | bb_perror_msg_and_die("Couldnt open control stream"); |
129 | } | 129 | } |
130 | 130 | ||
131 | if (ftpcmd(NULL, NULL, control_stream, buf) != 220) { | 131 | if (ftpcmd(NULL, NULL, control_stream, buf) != 220) { |
132 | error_msg_and_die("%s", buf + 4); | 132 | bb_error_msg_and_die("%s", buf + 4); |
133 | } | 133 | } |
134 | 134 | ||
135 | /* Login to the server */ | 135 | /* Login to the server */ |
@@ -138,11 +138,11 @@ static FILE *ftp_login(ftp_host_info_t *server) | |||
138 | break; | 138 | break; |
139 | case 331: | 139 | case 331: |
140 | if (ftpcmd("PASS ", server->password, control_stream, buf) != 230) { | 140 | if (ftpcmd("PASS ", server->password, control_stream, buf) != 230) { |
141 | error_msg_and_die("PASS error: %s", buf + 4); | 141 | bb_error_msg_and_die("PASS error: %s", buf + 4); |
142 | } | 142 | } |
143 | break; | 143 | break; |
144 | default: | 144 | default: |
145 | error_msg_and_die("USER error: %s", buf + 4); | 145 | bb_error_msg_and_die("USER error: %s", buf + 4); |
146 | } | 146 | } |
147 | 147 | ||
148 | ftpcmd("TYPE I", NULL, control_stream, buf); | 148 | ftpcmd("TYPE I", NULL, control_stream, buf); |
@@ -161,12 +161,12 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
161 | int fd_local; | 161 | int fd_local; |
162 | off_t beg_range = 0; | 162 | off_t beg_range = 0; |
163 | 163 | ||
164 | filename = get_last_path_component(server_path); | 164 | filename = bb_get_last_path_component(server_path); |
165 | local_file = concat_path_file(local_path, filename); | 165 | local_file = concat_path_file(local_path, filename); |
166 | 166 | ||
167 | /* Connect to the data socket */ | 167 | /* Connect to the data socket */ |
168 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { | 168 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { |
169 | error_msg_and_die("PASV error: %s", buf + 4); | 169 | bb_error_msg_and_die("PASV error: %s", buf + 4); |
170 | } | 170 | } |
171 | fd_data = xconnect_ftpdata(host, buf); | 171 | fd_data = xconnect_ftpdata(host, buf); |
172 | 172 | ||
@@ -177,7 +177,7 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
177 | if (do_continue) { | 177 | if (do_continue) { |
178 | struct stat sbuf; | 178 | struct stat sbuf; |
179 | if (lstat(local_file, &sbuf) < 0) { | 179 | if (lstat(local_file, &sbuf) < 0) { |
180 | perror_msg_and_die("fstat()"); | 180 | bb_perror_msg_and_die("fstat()"); |
181 | } | 181 | } |
182 | if (sbuf.st_size > 0) { | 182 | if (sbuf.st_size > 0) { |
183 | beg_range = sbuf.st_size; | 183 | beg_range = sbuf.st_size; |
@@ -196,25 +196,25 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
196 | } | 196 | } |
197 | 197 | ||
198 | if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) { | 198 | if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) { |
199 | error_msg_and_die("RETR error: %s", buf + 4); | 199 | bb_error_msg_and_die("RETR error: %s", buf + 4); |
200 | } | 200 | } |
201 | 201 | ||
202 | /* only make a local file if we know that one exists on the remote server */ | 202 | /* only make a local file if we know that one exists on the remote server */ |
203 | if (do_continue) { | 203 | if (do_continue) { |
204 | fd_local = xopen(local_file, O_APPEND | O_WRONLY); | 204 | fd_local = bb_xopen(local_file, O_APPEND | O_WRONLY); |
205 | } else { | 205 | } else { |
206 | fd_local = xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); | 206 | fd_local = bb_xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); |
207 | } | 207 | } |
208 | 208 | ||
209 | /* Copy the file */ | 209 | /* Copy the file */ |
210 | if (copyfd(fd_data, fd_local, filesize) == -1) { | 210 | if (bb_copyfd(fd_data, fd_local, filesize) == -1) { |
211 | exit(EXIT_FAILURE); | 211 | exit(EXIT_FAILURE); |
212 | } | 212 | } |
213 | 213 | ||
214 | /* close it all down */ | 214 | /* close it all down */ |
215 | close(fd_data); | 215 | close(fd_data); |
216 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { | 216 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { |
217 | error_msg_and_die("ftp error: %s", buf + 4); | 217 | bb_error_msg_and_die("ftp error: %s", buf + 4); |
218 | } | 218 | } |
219 | ftpcmd("QUIT", NULL, control_stream, buf); | 219 | ftpcmd("QUIT", NULL, control_stream, buf); |
220 | 220 | ||
@@ -233,16 +233,16 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p | |||
233 | 233 | ||
234 | /* Connect to the data socket */ | 234 | /* Connect to the data socket */ |
235 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { | 235 | if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { |
236 | error_msg_and_die("PASV error: %s", buf + 4); | 236 | bb_error_msg_and_die("PASV error: %s", buf + 4); |
237 | } | 237 | } |
238 | fd_data = xconnect_ftpdata(host, buf); | 238 | fd_data = xconnect_ftpdata(host, buf); |
239 | 239 | ||
240 | if (ftpcmd("CWD ", server_path, control_stream, buf) != 250) { | 240 | if (ftpcmd("CWD ", server_path, control_stream, buf) != 250) { |
241 | error_msg_and_die("CWD error: %s", buf + 4); | 241 | bb_error_msg_and_die("CWD error: %s", buf + 4); |
242 | } | 242 | } |
243 | 243 | ||
244 | /* get the local file */ | 244 | /* get the local file */ |
245 | fd_local = xopen(local_path, O_RDONLY); | 245 | fd_local = bb_xopen(local_path, O_RDONLY); |
246 | fstat(fd_local, &sbuf); | 246 | fstat(fd_local, &sbuf); |
247 | 247 | ||
248 | sprintf(buf, "ALLO %lu", sbuf.st_size); | 248 | sprintf(buf, "ALLO %lu", sbuf.st_size); |
@@ -253,7 +253,7 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p | |||
253 | break; | 253 | break; |
254 | default: | 254 | default: |
255 | close(fd_local); | 255 | close(fd_local); |
256 | error_msg_and_die("ALLO error: %s", buf + 4); | 256 | bb_error_msg_and_die("ALLO error: %s", buf + 4); |
257 | break; | 257 | break; |
258 | } | 258 | } |
259 | 259 | ||
@@ -264,18 +264,18 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p | |||
264 | break; | 264 | break; |
265 | default: | 265 | default: |
266 | close(fd_local); | 266 | close(fd_local); |
267 | error_msg_and_die("STOR error: %s", buf + 4); | 267 | bb_error_msg_and_die("STOR error: %s", buf + 4); |
268 | } | 268 | } |
269 | 269 | ||
270 | /* transfer the file */ | 270 | /* transfer the file */ |
271 | if (copyfd(fd_local, fd_data, 0) == -1) { | 271 | if (bb_copyfd(fd_local, fd_data, 0) == -1) { |
272 | exit(EXIT_FAILURE); | 272 | exit(EXIT_FAILURE); |
273 | } | 273 | } |
274 | 274 | ||
275 | /* close it all down */ | 275 | /* close it all down */ |
276 | close(fd_data); | 276 | close(fd_data); |
277 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { | 277 | if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { |
278 | error_msg_and_die("error: %s", buf + 4); | 278 | bb_error_msg_and_die("error: %s", buf + 4); |
279 | } | 279 | } |
280 | ftpcmd("QUIT", NULL, control_stream, buf); | 280 | ftpcmd("QUIT", NULL, control_stream, buf); |
281 | 281 | ||
@@ -307,12 +307,12 @@ int ftpgetput_main(int argc, char **argv) | |||
307 | }; | 307 | }; |
308 | 308 | ||
309 | #ifdef CONFIG_FTPPUT | 309 | #ifdef CONFIG_FTPPUT |
310 | if (applet_name[3] == 'p') { | 310 | if (bb_applet_name[3] == 'p') { |
311 | ftp_action = ftp_send; | 311 | ftp_action = ftp_send; |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | #ifdef CONFIG_FTPGET | 314 | #ifdef CONFIG_FTPGET |
315 | if (applet_name[3] == 'g') { | 315 | if (bb_applet_name[3] == 'g') { |
316 | ftp_action = ftp_recieve; | 316 | ftp_action = ftp_recieve; |
317 | } | 317 | } |
318 | #endif | 318 | #endif |
@@ -342,7 +342,7 @@ int ftpgetput_main(int argc, char **argv) | |||
342 | verbose_flag = 1; | 342 | verbose_flag = 1; |
343 | break; | 343 | break; |
344 | default: | 344 | default: |
345 | show_usage(); | 345 | bb_show_usage(); |
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
@@ -350,7 +350,7 @@ int ftpgetput_main(int argc, char **argv) | |||
350 | * Process the non-option command line arguments | 350 | * Process the non-option command line arguments |
351 | */ | 351 | */ |
352 | if (argc - optind != 3) { | 352 | if (argc - optind != 3) { |
353 | show_usage(); | 353 | bb_show_usage(); |
354 | } | 354 | } |
355 | 355 | ||
356 | /* Connect/Setup/Configure the FTP session */ | 356 | /* Connect/Setup/Configure the FTP session */ |
diff --git a/networking/hostname.c b/networking/hostname.c index f7c9fc426..6522bb21b 100644 --- a/networking/hostname.c +++ b/networking/hostname.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: hostname.c,v 1.34 2002/11/10 22:07:48 bug1 Exp $ | 3 | * $Id: hostname.c,v 1.35 2003/03/19 09:12:37 mjn3 Exp $ |
4 | * Mini hostname implementation for busybox | 4 | * Mini hostname implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -46,12 +46,12 @@ static void do_sethostname(char *s, int isfile) | |||
46 | if (!isfile) { | 46 | if (!isfile) { |
47 | if (sethostname(s, strlen(s)) < 0) { | 47 | if (sethostname(s, strlen(s)) < 0) { |
48 | if (errno == EPERM) | 48 | if (errno == EPERM) |
49 | error_msg_and_die("you must be root to change the hostname"); | 49 | bb_error_msg_and_die("you must be root to change the hostname"); |
50 | else | 50 | else |
51 | perror_msg_and_die("sethostname"); | 51 | bb_perror_msg_and_die("sethostname"); |
52 | } | 52 | } |
53 | } else { | 53 | } else { |
54 | f = xfopen(s, "r"); | 54 | f = bb_xfopen(s, "r"); |
55 | while (fgets(buf, 255, f) != NULL) { | 55 | while (fgets(buf, 255, f) != NULL) { |
56 | if (buf[0] =='#') { | 56 | if (buf[0] =='#') { |
57 | continue; | 57 | continue; |
@@ -75,7 +75,7 @@ int hostname_main(int argc, char **argv) | |||
75 | char *p = NULL; | 75 | char *p = NULL; |
76 | 76 | ||
77 | if (argc < 1) | 77 | if (argc < 1) |
78 | show_usage(); | 78 | bb_show_usage(); |
79 | 79 | ||
80 | while ((opt = getopt(argc, argv, "dfisF:")) > 0) { | 80 | while ((opt = getopt(argc, argv, "dfisF:")) > 0) { |
81 | switch (opt) { | 81 | switch (opt) { |
@@ -89,7 +89,7 @@ int hostname_main(int argc, char **argv) | |||
89 | filename = optarg; | 89 | filename = optarg; |
90 | break; | 90 | break; |
91 | default: | 91 | default: |
92 | show_usage(); | 92 | bb_show_usage(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
diff --git a/networking/httpd.c b/networking/httpd.c index fb37224cf..e62168d38 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -178,12 +178,12 @@ static const char home[] = "/www"; | |||
178 | #define CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | 178 | #define CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP |
179 | 179 | ||
180 | /* require from libbb.a for linking */ | 180 | /* require from libbb.a for linking */ |
181 | const char *applet_name = "httpd"; | 181 | const char *bb_applet_name = "httpd"; |
182 | 182 | ||
183 | void show_usage(void) | 183 | void bb_show_usage(void) |
184 | { | 184 | { |
185 | fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] " | 185 | fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] " |
186 | "[-r realm] [-u user]\n", applet_name); | 186 | "[-r realm] [-u user]\n", bb_applet_name); |
187 | exit(1); | 187 | exit(1); |
188 | } | 188 | } |
189 | #endif | 189 | #endif |
@@ -395,7 +395,7 @@ static int conf_sort(const void *p1, const void *p2) | |||
395 | } | 395 | } |
396 | #ifdef DEBUG | 396 | #ifdef DEBUG |
397 | if(!test) | 397 | if(!test) |
398 | error_msg_and_die("sort: can`t found compares!"); | 398 | bb_error_msg_and_die("sort: can`t found compares!"); |
399 | #endif | 399 | #endif |
400 | return test; | 400 | return test; |
401 | } | 401 | } |
@@ -423,7 +423,7 @@ static void parse_conf(const char *path, int flag) | |||
423 | cf = p0 = alloca(strlen(path) + sizeof(httpd_conf) + 2); | 423 | cf = p0 = alloca(strlen(path) + sizeof(httpd_conf) + 2); |
424 | if(p0 == NULL) { | 424 | if(p0 == NULL) { |
425 | if(flag == FIRST_PARSE) | 425 | if(flag == FIRST_PARSE) |
426 | error_msg_and_die(memory_exhausted); | 426 | bb_error_msg_and_die(bb_msg_memory_exhausted); |
427 | return; | 427 | return; |
428 | } | 428 | } |
429 | sprintf(p0, "%s/%s", path, httpd_conf); | 429 | sprintf(p0, "%s/%s", path, httpd_conf); |
@@ -433,7 +433,7 @@ static void parse_conf(const char *path, int flag) | |||
433 | if(flag != FIRST_PARSE) | 433 | if(flag != FIRST_PARSE) |
434 | return; /* subdir config not found */ | 434 | return; /* subdir config not found */ |
435 | if(p0 == NULL) /* if -c option gived */ | 435 | if(p0 == NULL) /* if -c option gived */ |
436 | perror_msg_and_die("%s", cf); | 436 | bb_perror_msg_and_die("%s", cf); |
437 | p0 = NULL; | 437 | p0 = NULL; |
438 | cf = httpd_conf; /* set -c ./httpd_conf */ | 438 | cf = httpd_conf; /* set -c ./httpd_conf */ |
439 | } | 439 | } |
@@ -543,7 +543,7 @@ static void parse_conf(const char *path, int flag) | |||
543 | pcur = alloca((n + 1) * sizeof(Htaccess *)); | 543 | pcur = alloca((n + 1) * sizeof(Htaccess *)); |
544 | if(pcur == NULL) { | 544 | if(pcur == NULL) { |
545 | if(flag == FIRST_PARSE) | 545 | if(flag == FIRST_PARSE) |
546 | error_msg_and_die(memory_exhausted); | 546 | bb_error_msg_and_die(bb_msg_memory_exhausted); |
547 | return; | 547 | return; |
548 | } | 548 | } |
549 | n = 0; | 549 | n = 0; |
@@ -557,7 +557,7 @@ static void parse_conf(const char *path, int flag) | |||
557 | config->Httpd_conf_parsed = *pcur; | 557 | config->Httpd_conf_parsed = *pcur; |
558 | for(cur = *pcur; cur; cur = cur->next) { | 558 | for(cur = *pcur; cur; cur = cur->next) { |
559 | #ifdef DEBUG | 559 | #ifdef DEBUG |
560 | error_msg("%s: %s:%s", cf, cur->before_colon, cur->after_colon); | 560 | bb_error_msg("%s: %s:%s", cf, cur->before_colon, cur->after_colon); |
561 | #endif | 561 | #endif |
562 | cur->next = *++pcur; | 562 | cur->next = *++pcur; |
563 | } | 563 | } |
@@ -829,10 +829,10 @@ static int openServer(void) | |||
829 | listen(fd, 9); | 829 | listen(fd, 9); |
830 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ | 830 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ |
831 | } else { | 831 | } else { |
832 | perror_msg_and_die("bind"); | 832 | bb_perror_msg_and_die("bind"); |
833 | } | 833 | } |
834 | } else { | 834 | } else { |
835 | perror_msg_and_die("create socket"); | 835 | bb_perror_msg_and_die("create socket"); |
836 | } | 836 | } |
837 | return fd; | 837 | return fd; |
838 | } | 838 | } |
@@ -905,7 +905,7 @@ static int sendHeaders(HttpResponseNum responseNum) | |||
905 | #ifdef DEBUG | 905 | #ifdef DEBUG |
906 | if (config->debugHttpd) fprintf(stderr, "Headers: '%s'", buf); | 906 | if (config->debugHttpd) fprintf(stderr, "Headers: '%s'", buf); |
907 | #endif | 907 | #endif |
908 | return full_write(a_c_w, buf, len); | 908 | return bb_full_write(a_c_w, buf, len); |
909 | } | 909 | } |
910 | 910 | ||
911 | /**************************************************************************** | 911 | /**************************************************************************** |
@@ -1105,7 +1105,7 @@ static int sendCgi(const char *url, | |||
1105 | outFd = toCgi[1]; | 1105 | outFd = toCgi[1]; |
1106 | close(fromCgi[1]); | 1106 | close(fromCgi[1]); |
1107 | close(toCgi[0]); | 1107 | close(toCgi[0]); |
1108 | if (body) full_write(outFd, body, bodyLen); | 1108 | if (body) bb_full_write(outFd, body, bodyLen); |
1109 | close(outFd); | 1109 | close(outFd); |
1110 | 1110 | ||
1111 | while (1) { | 1111 | while (1) { |
@@ -1129,9 +1129,9 @@ static int sendCgi(const char *url, | |||
1129 | #ifdef DEBUG | 1129 | #ifdef DEBUG |
1130 | if (config->debugHttpd) { | 1130 | if (config->debugHttpd) { |
1131 | if (WIFEXITED(status)) | 1131 | if (WIFEXITED(status)) |
1132 | error_msg("piped has exited with status=%d", WEXITSTATUS(status)); | 1132 | bb_error_msg("piped has exited with status=%d", WEXITSTATUS(status)); |
1133 | if (WIFSIGNALED(status)) | 1133 | if (WIFSIGNALED(status)) |
1134 | error_msg("piped has exited with signal=%d", WTERMSIG(status)); | 1134 | bb_error_msg("piped has exited with signal=%d", WTERMSIG(status)); |
1135 | } | 1135 | } |
1136 | #endif | 1136 | #endif |
1137 | pid = -1; | 1137 | pid = -1; |
@@ -1141,7 +1141,7 @@ static int sendCgi(const char *url, | |||
1141 | int s = a_c_w; | 1141 | int s = a_c_w; |
1142 | 1142 | ||
1143 | // There is something to read | 1143 | // There is something to read |
1144 | count = full_read(inFd, buf, sizeof(buf)-1); | 1144 | count = bb_full_read(inFd, buf, sizeof(buf)-1); |
1145 | // If a read returns 0 at this point then some type of error has | 1145 | // If a read returns 0 at this point then some type of error has |
1146 | // occurred. Bail now. | 1146 | // occurred. Bail now. |
1147 | if (count == 0) break; | 1147 | if (count == 0) break; |
@@ -1149,14 +1149,14 @@ static int sendCgi(const char *url, | |||
1149 | if (firstLine) { | 1149 | if (firstLine) { |
1150 | /* check to see if the user script added headers */ | 1150 | /* check to see if the user script added headers */ |
1151 | if (strncmp(buf, "HTTP/1.0 200 OK\n", 4) != 0) { | 1151 | if (strncmp(buf, "HTTP/1.0 200 OK\n", 4) != 0) { |
1152 | full_write(s, "HTTP/1.0 200 OK\n", 16); | 1152 | bb_full_write(s, "HTTP/1.0 200 OK\n", 16); |
1153 | } | 1153 | } |
1154 | if (strstr(buf, "ontent-") == 0) { | 1154 | if (strstr(buf, "ontent-") == 0) { |
1155 | full_write(s, "Content-type: text/plain\n\n", 26); | 1155 | bb_full_write(s, "Content-type: text/plain\n\n", 26); |
1156 | } | 1156 | } |
1157 | firstLine=0; | 1157 | firstLine=0; |
1158 | } | 1158 | } |
1159 | full_write(s, buf, count); | 1159 | bb_full_write(s, buf, count); |
1160 | #ifdef DEBUG | 1160 | #ifdef DEBUG |
1161 | if (config->debugHttpd) | 1161 | if (config->debugHttpd) |
1162 | fprintf(stderr, "cgi read %d bytes\n", count); | 1162 | fprintf(stderr, "cgi read %d bytes\n", count); |
@@ -1223,14 +1223,14 @@ static int sendFile(const char *url, char *buf) | |||
1223 | int count; | 1223 | int count; |
1224 | 1224 | ||
1225 | sendHeaders(HTTP_OK); | 1225 | sendHeaders(HTTP_OK); |
1226 | while ((count = full_read(f, buf, MAX_MEMORY_BUFF)) > 0) { | 1226 | while ((count = bb_full_read(f, buf, MAX_MEMORY_BUFF)) > 0) { |
1227 | full_write(a_c_w, buf, count); | 1227 | bb_full_write(a_c_w, buf, count); |
1228 | } | 1228 | } |
1229 | close(f); | 1229 | close(f); |
1230 | } else { | 1230 | } else { |
1231 | #ifdef DEBUG | 1231 | #ifdef DEBUG |
1232 | if (config->debugHttpd) | 1232 | if (config->debugHttpd) |
1233 | perror_msg("Unable to open '%s'", url); | 1233 | bb_perror_msg("Unable to open '%s'", url); |
1234 | #endif | 1234 | #endif |
1235 | sendHeaders(HTTP_NOT_FOUND); | 1235 | sendHeaders(HTTP_NOT_FOUND); |
1236 | } | 1236 | } |
@@ -1399,7 +1399,7 @@ BAD_REQUEST: | |||
1399 | but CGI script can`t be a directory */ | 1399 | but CGI script can`t be a directory */ |
1400 | } | 1400 | } |
1401 | 1401 | ||
1402 | /* algorithm stolen from libbb simplify_path(), | 1402 | /* algorithm stolen from libbb bb_simplify_path(), |
1403 | but don`t strdup and reducing trailing slash */ | 1403 | but don`t strdup and reducing trailing slash */ |
1404 | purl = test = url; | 1404 | purl = test = url; |
1405 | 1405 | ||
@@ -1517,7 +1517,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1517 | if (length > 0) { | 1517 | if (length > 0) { |
1518 | body = malloc(length + 1); | 1518 | body = malloc(length + 1); |
1519 | if (body) { | 1519 | if (body) { |
1520 | length = full_read(a_c_r, body, length); | 1520 | length = bb_full_read(a_c_r, body, length); |
1521 | if(length < 0) // closed | 1521 | if(length < 0) // closed |
1522 | length = 0; | 1522 | length = 0; |
1523 | body[length] = 0; // always null terminate for safety | 1523 | body[length] = 0; // always null terminate for safety |
@@ -1629,7 +1629,7 @@ static int miniHttpd(int server) | |||
1629 | config->port = ntohs(fromAddr.sin_port); | 1629 | config->port = ntohs(fromAddr.sin_port); |
1630 | #ifdef DEBUG | 1630 | #ifdef DEBUG |
1631 | if (config->debugHttpd) { | 1631 | if (config->debugHttpd) { |
1632 | error_msg("connection from IP=%s, port %u\n", | 1632 | bb_error_msg("connection from IP=%s, port %u\n", |
1633 | config->rmt_ip, config->port); | 1633 | config->rmt_ip, config->port); |
1634 | } | 1634 | } |
1635 | #endif | 1635 | #endif |
@@ -1748,7 +1748,7 @@ int httpd_main(int argc, char *argv[]) | |||
1748 | case 'p': | 1748 | case 'p': |
1749 | config->port = atoi(optarg); | 1749 | config->port = atoi(optarg); |
1750 | if(config->port <= 0 || config->port > 0xffff) | 1750 | if(config->port <= 0 || config->port > 0xffff) |
1751 | error_msg_and_die("invalid %s for -p", optarg); | 1751 | bb_error_msg_and_die("invalid %s for -p", optarg); |
1752 | break; | 1752 | break; |
1753 | #endif | 1753 | #endif |
1754 | #ifdef CONFIG_FEATURE_HTTPD_DECODE_URL_STR | 1754 | #ifdef CONFIG_FEATURE_HTTPD_DECODE_URL_STR |
@@ -1780,13 +1780,13 @@ int httpd_main(int argc, char *argv[]) | |||
1780 | break; | 1780 | break; |
1781 | #endif | 1781 | #endif |
1782 | default: | 1782 | default: |
1783 | error_msg("%s", httpdVersion); | 1783 | bb_error_msg("%s", httpdVersion); |
1784 | show_usage(); | 1784 | bb_show_usage(); |
1785 | } | 1785 | } |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | if(chdir(home_httpd)) { | 1788 | if(chdir(home_httpd)) { |
1789 | perror_msg_and_die("can`t chdir to %s", home_httpd); | 1789 | bb_perror_msg_and_die("can`t chdir to %s", home_httpd); |
1790 | } | 1790 | } |
1791 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1791 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY |
1792 | server = openServer(); | 1792 | server = openServer(); |
@@ -1809,7 +1809,7 @@ int httpd_main(int argc, char *argv[]) | |||
1809 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1809 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY |
1810 | if (!config->debugHttpd) { | 1810 | if (!config->debugHttpd) { |
1811 | if (daemon(1, 0) < 0) /* don`t change curent directory */ | 1811 | if (daemon(1, 0) < 0) /* don`t change curent directory */ |
1812 | perror_msg_and_die("daemon"); | 1812 | bb_perror_msg_and_die("daemon"); |
1813 | } | 1813 | } |
1814 | return miniHttpd(server); | 1814 | return miniHttpd(server); |
1815 | #else | 1815 | #else |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 95cc07ab0..c09c48c58 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * Foundation; either version 2 of the License, or (at | 15 | * Foundation; either version 2 of the License, or (at |
16 | * your option) any later version. | 16 | * your option) any later version. |
17 | * | 17 | * |
18 | * $Id: ifconfig.c,v 1.22 2003/01/14 08:54:07 andersen Exp $ | 18 | * $Id: ifconfig.c,v 1.23 2003/03/19 09:12:38 mjn3 Exp $ |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
@@ -323,14 +323,14 @@ int ifconfig_main(int argc, char **argv) | |||
323 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS | 323 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
324 | return display_interfaces(argc ? *argv : NULL); | 324 | return display_interfaces(argc ? *argv : NULL); |
325 | #else | 325 | #else |
326 | error_msg_and_die | 326 | bb_error_msg_and_die |
327 | ("ifconfig was not compiled with interface status display support."); | 327 | ("ifconfig was not compiled with interface status display support."); |
328 | #endif | 328 | #endif |
329 | } | 329 | } |
330 | 330 | ||
331 | /* Create a channel to the NET kernel. */ | 331 | /* Create a channel to the NET kernel. */ |
332 | if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { | 332 | if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { |
333 | perror_msg_and_die("socket"); | 333 | bb_perror_msg_and_die("socket"); |
334 | } | 334 | } |
335 | 335 | ||
336 | /* get interface name */ | 336 | /* get interface name */ |
@@ -366,11 +366,11 @@ int ifconfig_main(int argc, char **argv) | |||
366 | mask = op->arg_flags; | 366 | mask = op->arg_flags; |
367 | a1op = Arg1Opt + (op - OptArray); | 367 | a1op = Arg1Opt + (op - OptArray); |
368 | if (mask & A_NETMASK & did_flags) { | 368 | if (mask & A_NETMASK & did_flags) { |
369 | show_usage(); | 369 | bb_show_usage(); |
370 | } | 370 | } |
371 | if (*++argv == NULL) { | 371 | if (*++argv == NULL) { |
372 | if (mask & A_ARG_REQ) { | 372 | if (mask & A_ARG_REQ) { |
373 | show_usage(); | 373 | bb_show_usage(); |
374 | } else { | 374 | } else { |
375 | --argv; | 375 | --argv; |
376 | mask &= A_SET_AFTER; /* just for broadcast */ | 376 | mask &= A_SET_AFTER; /* just for broadcast */ |
@@ -421,7 +421,7 @@ int ifconfig_main(int argc, char **argv) | |||
421 | 421 | ||
422 | /* Create a channel to the NET kernel. */ | 422 | /* Create a channel to the NET kernel. */ |
423 | if ((sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | 423 | if ((sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { |
424 | perror_msg_and_die("socket6"); | 424 | bb_perror_msg_and_die("socket6"); |
425 | } | 425 | } |
426 | if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { | 426 | if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { |
427 | perror("SIOGIFINDEX"); | 427 | perror("SIOGIFINDEX"); |
@@ -454,11 +454,11 @@ int ifconfig_main(int argc, char **argv) | |||
454 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ | 454 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ |
455 | /* This is the "hw" arg case. */ | 455 | /* This is the "hw" arg case. */ |
456 | if (strcmp("ether", *argv) || (*++argv == NULL)) { | 456 | if (strcmp("ether", *argv) || (*++argv == NULL)) { |
457 | show_usage(); | 457 | bb_show_usage(); |
458 | } | 458 | } |
459 | safe_strncpy(host, *argv, (sizeof host)); | 459 | safe_strncpy(host, *argv, (sizeof host)); |
460 | if (in_ether(host, &sa)) { | 460 | if (in_ether(host, &sa)) { |
461 | error_msg("invalid hw-addr %s", host); | 461 | bb_error_msg("invalid hw-addr %s", host); |
462 | ++goterr; | 462 | ++goterr; |
463 | continue; | 463 | continue; |
464 | } | 464 | } |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 0511a5b95..9bbb90496 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -244,7 +244,7 @@ static char *parse(char *command, interface_defn_t *ifd) | |||
244 | varvalue = get_var(command, nextpercent - command, ifd); | 244 | varvalue = get_var(command, nextpercent - command, ifd); |
245 | 245 | ||
246 | if (varvalue) { | 246 | if (varvalue) { |
247 | addstr(&result, &len, &pos, varvalue, xstrlen(varvalue)); | 247 | addstr(&result, &len, &pos, varvalue, bb_strlen(varvalue)); |
248 | } else { | 248 | } else { |
249 | #ifdef CONFIG_FEATURE_IFUPDOWN_IP | 249 | #ifdef CONFIG_FEATURE_IFUPDOWN_IP |
250 | /* Sigh... Add a special case for 'ip' to convert from | 250 | /* Sigh... Add a special case for 'ip' to convert from |
@@ -255,7 +255,7 @@ static char *parse(char *command, interface_defn_t *ifd) | |||
255 | if (varvalue && (res=count_netmask_bits(varvalue)) > 0) { | 255 | if (varvalue && (res=count_netmask_bits(varvalue)) > 0) { |
256 | char argument[255]; | 256 | char argument[255]; |
257 | sprintf(argument, "%d", res); | 257 | sprintf(argument, "%d", res); |
258 | addstr(&result, &len, &pos, argument, xstrlen(argument)); | 258 | addstr(&result, &len, &pos, argument, bb_strlen(argument)); |
259 | command = nextpercent + 1; | 259 | command = nextpercent + 1; |
260 | break; | 260 | break; |
261 | } | 261 | } |
@@ -734,9 +734,9 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
734 | defn->mappings = NULL; | 734 | defn->mappings = NULL; |
735 | defn->ifaces = NULL; | 735 | defn->ifaces = NULL; |
736 | 736 | ||
737 | f = xfopen(filename, "r"); | 737 | f = bb_xfopen(filename, "r"); |
738 | 738 | ||
739 | while ((buf = get_line_from_file(f)) != NULL) { | 739 | while ((buf = bb_get_line_from_file(f)) != NULL) { |
740 | char *buf_ptr = buf; | 740 | char *buf_ptr = buf; |
741 | 741 | ||
742 | /* Ignore comments */ | 742 | /* Ignore comments */ |
@@ -762,7 +762,7 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
762 | currmap->match = xrealloc(currmap->match, sizeof(currmap->match) * currmap->max_matches); | 762 | currmap->match = xrealloc(currmap->match, sizeof(currmap->match) * currmap->max_matches); |
763 | } | 763 | } |
764 | 764 | ||
765 | currmap->match[currmap->n_matches++] = xstrdup(firstword); | 765 | currmap->match[currmap->n_matches++] = bb_xstrdup(firstword); |
766 | } | 766 | } |
767 | currmap->max_mappings = 0; | 767 | currmap->max_mappings = 0; |
768 | currmap->n_mappings = 0; | 768 | currmap->n_mappings = 0; |
@@ -802,26 +802,26 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
802 | method_name = next_word(&buf_ptr); | 802 | method_name = next_word(&buf_ptr); |
803 | 803 | ||
804 | if (buf_ptr == NULL) { | 804 | if (buf_ptr == NULL) { |
805 | error_msg("too few parameters for line \"%s\"", buf); | 805 | bb_error_msg("too few parameters for line \"%s\"", buf); |
806 | return NULL; | 806 | return NULL; |
807 | } | 807 | } |
808 | 808 | ||
809 | if (buf_ptr[0] != '\0') { | 809 | if (buf_ptr[0] != '\0') { |
810 | error_msg("too many parameters \"%s\"", buf); | 810 | bb_error_msg("too many parameters \"%s\"", buf); |
811 | return NULL; | 811 | return NULL; |
812 | } | 812 | } |
813 | 813 | ||
814 | currif->iface = xstrdup(iface_name); | 814 | currif->iface = bb_xstrdup(iface_name); |
815 | 815 | ||
816 | currif->address_family = get_address_family(addr_fams, address_family_name); | 816 | currif->address_family = get_address_family(addr_fams, address_family_name); |
817 | if (!currif->address_family) { | 817 | if (!currif->address_family) { |
818 | error_msg("unknown address type \"%s\"", buf); | 818 | bb_error_msg("unknown address type \"%s\"", buf); |
819 | return NULL; | 819 | return NULL; |
820 | } | 820 | } |
821 | 821 | ||
822 | currif->method = get_method(currif->address_family, method_name); | 822 | currif->method = get_method(currif->address_family, method_name); |
823 | if (!currif->method) { | 823 | if (!currif->method) { |
824 | error_msg("unknown method \"%s\"", buf); | 824 | bb_error_msg("unknown method \"%s\"", buf); |
825 | return NULL; | 825 | return NULL; |
826 | } | 826 | } |
827 | 827 | ||
@@ -836,7 +836,7 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
836 | 836 | ||
837 | while (*where != NULL) { | 837 | while (*where != NULL) { |
838 | if (duplicate_if(*where, currif)) { | 838 | if (duplicate_if(*where, currif)) { |
839 | error_msg("duplicate interface \"%s\"", buf); | 839 | bb_error_msg("duplicate interface \"%s\"", buf); |
840 | return NULL; | 840 | return NULL; |
841 | } | 841 | } |
842 | where = &(*where)->next; | 842 | where = &(*where)->next; |
@@ -852,7 +852,7 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
852 | 852 | ||
853 | /* Check the interface isnt already listed */ | 853 | /* Check the interface isnt already listed */ |
854 | if (find_list_string(defn->autointerfaces, firstword)) { | 854 | if (find_list_string(defn->autointerfaces, firstword)) { |
855 | perror_msg_and_die("interface declared auto twice \"%s\"", buf); | 855 | bb_perror_msg_and_die("interface declared auto twice \"%s\"", buf); |
856 | } | 856 | } |
857 | 857 | ||
858 | /* Add the interface to the list */ | 858 | /* Add the interface to the list */ |
@@ -865,8 +865,8 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
865 | { | 865 | { |
866 | int i; | 866 | int i; |
867 | 867 | ||
868 | if (xstrlen(buf_ptr) == 0) { | 868 | if (bb_strlen(buf_ptr) == 0) { |
869 | error_msg("option with empty value \"%s\"", buf); | 869 | bb_error_msg("option with empty value \"%s\"", buf); |
870 | return NULL; | 870 | return NULL; |
871 | } | 871 | } |
872 | 872 | ||
@@ -876,7 +876,7 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
876 | && strcmp(firstword, "post-down") != 0) { | 876 | && strcmp(firstword, "post-down") != 0) { |
877 | for (i = 0; i < currif->n_options; i++) { | 877 | for (i = 0; i < currif->n_options; i++) { |
878 | if (strcmp(currif->option[i].name, firstword) == 0) { | 878 | if (strcmp(currif->option[i].name, firstword) == 0) { |
879 | error_msg("duplicate option \"%s\"", buf); | 879 | bb_error_msg("duplicate option \"%s\"", buf); |
880 | return NULL; | 880 | return NULL; |
881 | } | 881 | } |
882 | } | 882 | } |
@@ -889,8 +889,8 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
889 | opt = xrealloc(currif->option, sizeof(*opt) * currif->max_options); | 889 | opt = xrealloc(currif->option, sizeof(*opt) * currif->max_options); |
890 | currif->option = opt; | 890 | currif->option = opt; |
891 | } | 891 | } |
892 | currif->option[currif->n_options].name = xstrdup(firstword); | 892 | currif->option[currif->n_options].name = bb_xstrdup(firstword); |
893 | currif->option[currif->n_options].value = xstrdup(next_word(&buf_ptr)); | 893 | currif->option[currif->n_options].value = bb_xstrdup(next_word(&buf_ptr)); |
894 | if (!currif->option[currif->n_options].name) { | 894 | if (!currif->option[currif->n_options].name) { |
895 | perror(filename); | 895 | perror(filename); |
896 | return NULL; | 896 | return NULL; |
@@ -905,34 +905,34 @@ static interfaces_file_t *read_interfaces(char *filename) | |||
905 | #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING | 905 | #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING |
906 | if (strcmp(firstword, "script") == 0) { | 906 | if (strcmp(firstword, "script") == 0) { |
907 | if (currmap->script != NULL) { | 907 | if (currmap->script != NULL) { |
908 | error_msg("duplicate script in mapping \"%s\"", buf); | 908 | bb_error_msg("duplicate script in mapping \"%s\"", buf); |
909 | return NULL; | 909 | return NULL; |
910 | } else { | 910 | } else { |
911 | currmap->script = xstrdup(next_word(&buf_ptr)); | 911 | currmap->script = bb_xstrdup(next_word(&buf_ptr)); |
912 | } | 912 | } |
913 | } else if (strcmp(firstword, "map") == 0) { | 913 | } else if (strcmp(firstword, "map") == 0) { |
914 | if (currmap->max_mappings == currmap->n_mappings) { | 914 | if (currmap->max_mappings == currmap->n_mappings) { |
915 | currmap->max_mappings = currmap->max_mappings * 2 + 1; | 915 | currmap->max_mappings = currmap->max_mappings * 2 + 1; |
916 | currmap->mapping = xrealloc(currmap->mapping, sizeof(char *) * currmap->max_mappings); | 916 | currmap->mapping = xrealloc(currmap->mapping, sizeof(char *) * currmap->max_mappings); |
917 | } | 917 | } |
918 | currmap->mapping[currmap->n_mappings] = xstrdup(next_word(&buf_ptr)); | 918 | currmap->mapping[currmap->n_mappings] = bb_xstrdup(next_word(&buf_ptr)); |
919 | currmap->n_mappings++; | 919 | currmap->n_mappings++; |
920 | } else { | 920 | } else { |
921 | error_msg("misplaced option \"%s\"", buf); | 921 | bb_error_msg("misplaced option \"%s\"", buf); |
922 | return NULL; | 922 | return NULL; |
923 | } | 923 | } |
924 | #endif | 924 | #endif |
925 | break; | 925 | break; |
926 | case NONE: | 926 | case NONE: |
927 | default: | 927 | default: |
928 | error_msg("misplaced option \"%s\"", buf); | 928 | bb_error_msg("misplaced option \"%s\"", buf); |
929 | return NULL; | 929 | return NULL; |
930 | } | 930 | } |
931 | } | 931 | } |
932 | free(buf); | 932 | free(buf); |
933 | } | 933 | } |
934 | if (ferror(f) != 0) { | 934 | if (ferror(f) != 0) { |
935 | perror_msg_and_die("%s", filename); | 935 | bb_perror_msg_and_die("%s", filename); |
936 | } | 936 | } |
937 | fclose(f); | 937 | fclose(f); |
938 | 938 | ||
@@ -945,7 +945,7 @@ static char *setlocalenv(char *format, char *name, char *value) | |||
945 | char *here; | 945 | char *here; |
946 | char *there; | 946 | char *there; |
947 | 947 | ||
948 | result = xmalloc(xstrlen(format) + xstrlen(name) + xstrlen(value) + 1); | 948 | result = xmalloc(bb_strlen(format) + bb_strlen(name) + bb_strlen(value) + 1); |
949 | 949 | ||
950 | sprintf(result, format, name, value); | 950 | sprintf(result, format, name, value); |
951 | 951 | ||
@@ -960,7 +960,7 @@ static char *setlocalenv(char *format, char *name, char *value) | |||
960 | here++; | 960 | here++; |
961 | } | 961 | } |
962 | } | 962 | } |
963 | memmove(here, there, xstrlen(there) + 1); | 963 | memmove(here, there, bb_strlen(there) + 1); |
964 | 964 | ||
965 | return result; | 965 | return result; |
966 | } | 966 | } |
@@ -1010,7 +1010,7 @@ static void set_environ(interface_defn_t *iface, char *mode) | |||
1010 | static int doit(char *str) | 1010 | static int doit(char *str) |
1011 | { | 1011 | { |
1012 | if (verbose || no_act) { | 1012 | if (verbose || no_act) { |
1013 | error_msg("%s", str); | 1013 | bb_error_msg("%s", str); |
1014 | } | 1014 | } |
1015 | if (!no_act) { | 1015 | if (!no_act) { |
1016 | pid_t child; | 1016 | pid_t child; |
@@ -1045,7 +1045,7 @@ static int execute_all(interface_defn_t *ifd, execfn *exec, const char *opt) | |||
1045 | } | 1045 | } |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | buf = xmalloc(xstrlen(opt) + 19); | 1048 | buf = xmalloc(bb_strlen(opt) + 19); |
1049 | sprintf(buf, "/etc/network/if-%s.d", opt); | 1049 | sprintf(buf, "/etc/network/if-%s.d", opt); |
1050 | run_parts(&buf, 2); | 1050 | run_parts(&buf, 2); |
1051 | free(buf); | 1051 | free(buf); |
@@ -1155,7 +1155,7 @@ static int run_mapping(char *physical, char *logical, int len, mapping_defn_t * | |||
1155 | waitpid(pid, &status, 0); | 1155 | waitpid(pid, &status, 0); |
1156 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { | 1156 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { |
1157 | if (fgets(logical, len, out)) { | 1157 | if (fgets(logical, len, out)) { |
1158 | char *pch = logical + xstrlen(logical) - 1; | 1158 | char *pch = logical + bb_strlen(logical) - 1; |
1159 | 1159 | ||
1160 | while (pch >= logical && isspace(*pch)) | 1160 | while (pch >= logical && isspace(*pch)) |
1161 | *(pch--) = '\0'; | 1161 | *(pch--) = '\0'; |
@@ -1169,7 +1169,7 @@ static int run_mapping(char *physical, char *logical, int len, mapping_defn_t * | |||
1169 | 1169 | ||
1170 | static llist_t *find_iface_state(llist_t *state_list, const char *iface) | 1170 | static llist_t *find_iface_state(llist_t *state_list, const char *iface) |
1171 | { | 1171 | { |
1172 | unsigned short iface_len = xstrlen(iface); | 1172 | unsigned short iface_len = bb_strlen(iface); |
1173 | llist_t *search = state_list; | 1173 | llist_t *search = state_list; |
1174 | 1174 | ||
1175 | while (search) { | 1175 | while (search) { |
@@ -1199,7 +1199,7 @@ extern int ifupdown_main(int argc, char **argv) | |||
1199 | int force = 0; | 1199 | int force = 0; |
1200 | int i; | 1200 | int i; |
1201 | 1201 | ||
1202 | if (applet_name[2] == 'u') { | 1202 | if (bb_applet_name[2] == 'u') { |
1203 | /* ifup command */ | 1203 | /* ifup command */ |
1204 | cmds = iface_up; | 1204 | cmds = iface_up; |
1205 | } else { | 1205 | } else { |
@@ -1214,7 +1214,7 @@ extern int ifupdown_main(int argc, char **argv) | |||
1214 | #endif | 1214 | #endif |
1215 | switch (i) { | 1215 | switch (i) { |
1216 | case 'i': /* interfaces */ | 1216 | case 'i': /* interfaces */ |
1217 | interfaces = xstrdup(optarg); | 1217 | interfaces = bb_xstrdup(optarg); |
1218 | break; | 1218 | break; |
1219 | case 'v': /* verbose */ | 1219 | case 'v': /* verbose */ |
1220 | verbose = 1; | 1220 | verbose = 1; |
@@ -1234,18 +1234,18 @@ extern int ifupdown_main(int argc, char **argv) | |||
1234 | force = 1; | 1234 | force = 1; |
1235 | break; | 1235 | break; |
1236 | default: | 1236 | default: |
1237 | show_usage(); | 1237 | bb_show_usage(); |
1238 | break; | 1238 | break; |
1239 | } | 1239 | } |
1240 | } | 1240 | } |
1241 | 1241 | ||
1242 | if (argc - optind > 0) { | 1242 | if (argc - optind > 0) { |
1243 | if (do_all) { | 1243 | if (do_all) { |
1244 | show_usage(); | 1244 | bb_show_usage(); |
1245 | } | 1245 | } |
1246 | } else { | 1246 | } else { |
1247 | if (!do_all) { | 1247 | if (!do_all) { |
1248 | show_usage(); | 1248 | bb_show_usage(); |
1249 | } | 1249 | } |
1250 | } | 1250 | } |
1251 | 1251 | ||
@@ -1297,13 +1297,13 @@ extern int ifupdown_main(int argc, char **argv) | |||
1297 | if (cmds == iface_up) { | 1297 | if (cmds == iface_up) { |
1298 | /* ifup */ | 1298 | /* ifup */ |
1299 | if (iface_state) { | 1299 | if (iface_state) { |
1300 | error_msg("interface %s already configured", iface); | 1300 | bb_error_msg("interface %s already configured", iface); |
1301 | continue; | 1301 | continue; |
1302 | } | 1302 | } |
1303 | } else { | 1303 | } else { |
1304 | /* ifdown */ | 1304 | /* ifdown */ |
1305 | if (iface_state) { | 1305 | if (iface_state) { |
1306 | error_msg("interface %s not configured", iface); | 1306 | bb_error_msg("interface %s not configured", iface); |
1307 | continue; | 1307 | continue; |
1308 | } | 1308 | } |
1309 | } | 1309 | } |
@@ -1319,7 +1319,7 @@ extern int ifupdown_main(int argc, char **argv) | |||
1319 | if (fnmatch(currmap->match[i], liface, 0) != 0) | 1319 | if (fnmatch(currmap->match[i], liface, 0) != 0) |
1320 | continue; | 1320 | continue; |
1321 | if (verbose) { | 1321 | if (verbose) { |
1322 | error_msg("Running mapping script %s on %s", currmap->script, liface); | 1322 | bb_error_msg("Running mapping script %s on %s", currmap->script, liface); |
1323 | } | 1323 | } |
1324 | run_mapping(iface, liface, sizeof(liface), currmap); | 1324 | run_mapping(iface, liface, sizeof(liface), currmap); |
1325 | break; | 1325 | break; |
@@ -1336,7 +1336,7 @@ extern int ifupdown_main(int argc, char **argv) | |||
1336 | currif->iface = iface; | 1336 | currif->iface = iface; |
1337 | 1337 | ||
1338 | if (verbose) { | 1338 | if (verbose) { |
1339 | error_msg("Configuring interface %s=%s (%s)", iface, liface, currif->address_family->name); | 1339 | bb_error_msg("Configuring interface %s=%s (%s)", iface, liface, currif->address_family->name); |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | /* Call the cmds function pointer, does either iface_up() or iface_down() */ | 1342 | /* Call the cmds function pointer, does either iface_up() or iface_down() */ |
@@ -1351,12 +1351,12 @@ extern int ifupdown_main(int argc, char **argv) | |||
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | if (!okay && !force) { | 1353 | if (!okay && !force) { |
1354 | error_msg("Ignoring unknown interface %s=%s.", iface, liface); | 1354 | bb_error_msg("Ignoring unknown interface %s=%s.", iface, liface); |
1355 | } else { | 1355 | } else { |
1356 | llist_t *iface_state = find_iface_state(state_list, iface); | 1356 | llist_t *iface_state = find_iface_state(state_list, iface); |
1357 | 1357 | ||
1358 | if (cmds == iface_up) { | 1358 | if (cmds == iface_up) { |
1359 | char *newiface = xmalloc(xstrlen(iface) + 1 + xstrlen(liface) + 1); | 1359 | char *newiface = xmalloc(bb_strlen(iface) + 1 + bb_strlen(liface) + 1); |
1360 | sprintf(newiface, "%s=%s", iface, liface); | 1360 | sprintf(newiface, "%s=%s", iface, liface); |
1361 | if (iface_state == NULL) { | 1361 | if (iface_state == NULL) { |
1362 | state_list = llist_add_to(state_list, newiface); | 1362 | state_list = llist_add_to(state_list, newiface); |
@@ -1387,10 +1387,10 @@ extern int ifupdown_main(int argc, char **argv) | |||
1387 | 1387 | ||
1388 | if (state_fp) | 1388 | if (state_fp) |
1389 | fclose(state_fp); | 1389 | fclose(state_fp); |
1390 | state_fp = xfopen(statefile, "a+"); | 1390 | state_fp = bb_xfopen(statefile, "a+"); |
1391 | 1391 | ||
1392 | if (ftruncate(fileno(state_fp), 0) < 0) { | 1392 | if (ftruncate(fileno(state_fp), 0) < 0) { |
1393 | error_msg_and_die("failed to truncate statefile %s: %s", statefile, strerror(errno)); | 1393 | bb_error_msg_and_die("failed to truncate statefile %s: %s", statefile, strerror(errno)); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | rewind(state_fp); | 1396 | rewind(state_fp); |
diff --git a/networking/inetd.c b/networking/inetd.c index 2769c01b7..33b97ba94 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -519,7 +519,7 @@ enter(struct servtab *cp) | |||
519 | 519 | ||
520 | sep = (struct servtab *)malloc(sizeof (*sep)); | 520 | sep = (struct servtab *)malloc(sizeof (*sep)); |
521 | if (sep == NULL) { | 521 | if (sep == NULL) { |
522 | syslog_err_and_discard_dg(SOCK_STREAM, memory_exhausted); | 522 | syslog_err_and_discard_dg(SOCK_STREAM, bb_msg_memory_exhausted); |
523 | } | 523 | } |
524 | *sep = *cp; | 524 | *sep = *cp; |
525 | sep->se_fd = -1; | 525 | sep->se_fd = -1; |
@@ -835,7 +835,7 @@ inetd_main(int argc, char *argv[]) | |||
835 | if (global_queuelen < 8) global_queuelen=8; | 835 | if (global_queuelen < 8) global_queuelen=8; |
836 | break; | 836 | break; |
837 | default: | 837 | default: |
838 | show_usage(); // "[-q len] [conf]" | 838 | bb_show_usage(); // "[-q len] [conf]" |
839 | } | 839 | } |
840 | argc -= optind; | 840 | argc -= optind; |
841 | argv += optind; | 841 | argv += optind; |
@@ -844,7 +844,7 @@ inetd_main(int argc, char *argv[]) | |||
844 | CONFIG = argv[0]; | 844 | CONFIG = argv[0]; |
845 | 845 | ||
846 | daemon(0, 0); | 846 | daemon(0, 0); |
847 | openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); | 847 | openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); |
848 | { | 848 | { |
849 | FILE *fp; | 849 | FILE *fp; |
850 | 850 | ||
diff --git a/networking/ip.c b/networking/ip.c index e7cab74c9..a0781bdba 100644 --- a/networking/ip.c +++ b/networking/ip.c | |||
@@ -72,7 +72,7 @@ void ip_parse_common_args(int *argcp, char ***argvp) | |||
72 | } else if (matches(opt, "-oneline") == 0) { | 72 | } else if (matches(opt, "-oneline") == 0) { |
73 | ++oneline; | 73 | ++oneline; |
74 | } else { | 74 | } else { |
75 | show_usage(); | 75 | bb_show_usage(); |
76 | } | 76 | } |
77 | argc--; argv++; | 77 | argc--; argv++; |
78 | } | 78 | } |
@@ -109,7 +109,7 @@ int ip_main(int argc, char **argv) | |||
109 | #endif | 109 | #endif |
110 | } | 110 | } |
111 | if (ret) { | 111 | if (ret) { |
112 | show_usage(); | 112 | bb_show_usage(); |
113 | } | 113 | } |
114 | return(EXIT_SUCCESS); | 114 | return(EXIT_SUCCESS); |
115 | } | 115 | } |
diff --git a/networking/ipcalc.c b/networking/ipcalc.c index f130f3b7c..2c23d17f6 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c | |||
@@ -82,24 +82,24 @@ int ipcalc_main(int argc, char **argv) | |||
82 | mode |= SILENT; | 82 | mode |= SILENT; |
83 | #endif | 83 | #endif |
84 | else { | 84 | else { |
85 | show_usage(); | 85 | bb_show_usage(); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | if (mode & (BROADCAST | NETWORK)) { | 89 | if (mode & (BROADCAST | NETWORK)) { |
90 | if (argc - optind > 2) { | 90 | if (argc - optind > 2) { |
91 | show_usage(); | 91 | bb_show_usage(); |
92 | } | 92 | } |
93 | } else { | 93 | } else { |
94 | if (argc - optind != 1) { | 94 | if (argc - optind != 1) { |
95 | show_usage(); | 95 | bb_show_usage(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | ipaddr = inet_addr(argv[optind]); | 99 | ipaddr = inet_addr(argv[optind]); |
100 | 100 | ||
101 | if (ipaddr == INADDR_NONE) { | 101 | if (ipaddr == INADDR_NONE) { |
102 | IPCALC_MSG(error_msg_and_die("bad IP address: %s\n", argv[optind]), | 102 | IPCALC_MSG(bb_error_msg_and_die("bad IP address: %s\n", argv[optind]), |
103 | exit(EXIT_FAILURE)); | 103 | exit(EXIT_FAILURE)); |
104 | } | 104 | } |
105 | 105 | ||
@@ -109,7 +109,7 @@ int ipcalc_main(int argc, char **argv) | |||
109 | } | 109 | } |
110 | 110 | ||
111 | if (ipaddr == INADDR_NONE) { | 111 | if (ipaddr == INADDR_NONE) { |
112 | IPCALC_MSG(error_msg_and_die("bad netmask: %s\n", argv[optind + 1]), | 112 | IPCALC_MSG(bb_error_msg_and_die("bad netmask: %s\n", argv[optind + 1]), |
113 | exit(EXIT_FAILURE)); | 113 | exit(EXIT_FAILURE)); |
114 | } | 114 | } |
115 | 115 | ||
@@ -138,7 +138,7 @@ int ipcalc_main(int argc, char **argv) | |||
138 | 138 | ||
139 | hostinfo = gethostbyaddr((char *) &ipaddr, sizeof(ipaddr), AF_INET); | 139 | hostinfo = gethostbyaddr((char *) &ipaddr, sizeof(ipaddr), AF_INET); |
140 | if (!hostinfo) { | 140 | if (!hostinfo) { |
141 | IPCALC_MSG(error_msg("cannot find hostname for %s", argv[optind]); | 141 | IPCALC_MSG(bb_error_msg("cannot find hostname for %s", argv[optind]); |
142 | herror(NULL); | 142 | herror(NULL); |
143 | putc('\n', stderr);,); | 143 | putc('\n', stderr);,); |
144 | exit(EXIT_FAILURE); | 144 | exit(EXIT_FAILURE); |
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index 4b4355ac1..21e9f74ba 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c | |||
@@ -48,7 +48,7 @@ void ip_parse_common_args(int *argcp, char ***argvp) | |||
48 | argc--; | 48 | argc--; |
49 | argv++; | 49 | argv++; |
50 | if (! argv[1]) | 50 | if (! argv[1]) |
51 | show_usage(); | 51 | bb_show_usage(); |
52 | if (strcmp(argv[1], "inet") == 0) | 52 | if (strcmp(argv[1], "inet") == 0) |
53 | preferred_family = AF_INET; | 53 | preferred_family = AF_INET; |
54 | else if (strcmp(argv[1], "inet6") == 0) | 54 | else if (strcmp(argv[1], "inet6") == 0) |
@@ -66,7 +66,7 @@ void ip_parse_common_args(int *argcp, char ***argvp) | |||
66 | } else if (matches(opt, "-oneline") == 0) { | 66 | } else if (matches(opt, "-oneline") == 0) { |
67 | ++oneline; | 67 | ++oneline; |
68 | } else { | 68 | } else { |
69 | show_usage(); | 69 | bb_show_usage(); |
70 | } | 70 | } |
71 | argc--; argv++; | 71 | argc--; argv++; |
72 | } | 72 | } |
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 8eba90c77..44e871ee5 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -125,7 +125,7 @@ static int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg | |||
125 | memset(tb, 0, sizeof(tb)); | 125 | memset(tb, 0, sizeof(tb)); |
126 | parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); | 126 | parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); |
127 | if (tb[IFLA_IFNAME] == NULL) { | 127 | if (tb[IFLA_IFNAME] == NULL) { |
128 | error_msg("nil ifname"); | 128 | bb_error_msg("nil ifname"); |
129 | return -1; | 129 | return -1; |
130 | } | 130 | } |
131 | if (filter.label && | 131 | if (filter.label && |
@@ -217,7 +217,7 @@ static int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg | |||
217 | return 0; | 217 | return 0; |
218 | len -= NLMSG_LENGTH(sizeof(*ifa)); | 218 | len -= NLMSG_LENGTH(sizeof(*ifa)); |
219 | if (len < 0) { | 219 | if (len < 0) { |
220 | error_msg("wrong nlmsg len %d", len); | 220 | bb_error_msg("wrong nlmsg len %d", len); |
221 | return -1; | 221 | return -1; |
222 | } | 222 | } |
223 | 223 | ||
@@ -489,17 +489,17 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush) | |||
489 | exit(1); | 489 | exit(1); |
490 | 490 | ||
491 | if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) { | 491 | if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) { |
492 | perror_msg_and_die("Cannot send dump request"); | 492 | bb_perror_msg_and_die("Cannot send dump request"); |
493 | } | 493 | } |
494 | 494 | ||
495 | if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) { | 495 | if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) { |
496 | error_msg_and_die("Dump terminated"); | 496 | bb_error_msg_and_die("Dump terminated"); |
497 | } | 497 | } |
498 | 498 | ||
499 | if (filter_dev) { | 499 | if (filter_dev) { |
500 | filter.ifindex = ll_name_to_index(filter_dev); | 500 | filter.ifindex = ll_name_to_index(filter_dev); |
501 | if (filter.ifindex <= 0) { | 501 | if (filter.ifindex <= 0) { |
502 | error_msg("Device \"%s\" does not exist.", filter_dev); | 502 | bb_error_msg("Device \"%s\" does not exist.", filter_dev); |
503 | return -1; | 503 | return -1; |
504 | } | 504 | } |
505 | } | 505 | } |
@@ -539,11 +539,11 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush) | |||
539 | 539 | ||
540 | if (filter.family != AF_PACKET) { | 540 | if (filter.family != AF_PACKET) { |
541 | if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { | 541 | if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { |
542 | perror_msg_and_die("Cannot send dump request"); | 542 | bb_perror_msg_and_die("Cannot send dump request"); |
543 | } | 543 | } |
544 | 544 | ||
545 | if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) { | 545 | if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) { |
546 | error_msg_and_die("Dump terminated"); | 546 | bb_error_msg_and_die("Dump terminated"); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
@@ -749,11 +749,11 @@ static int ipaddr_modify(int cmd, int argc, char **argv) | |||
749 | } | 749 | } |
750 | 750 | ||
751 | if (d == NULL) { | 751 | if (d == NULL) { |
752 | error_msg("Not enough information: \"dev\" argument is required."); | 752 | bb_error_msg("Not enough information: \"dev\" argument is required."); |
753 | return -1; | 753 | return -1; |
754 | } | 754 | } |
755 | if (l && matches(d, l) != 0) { | 755 | if (l && matches(d, l) != 0) { |
756 | error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l); | 756 | bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l); |
757 | } | 757 | } |
758 | 758 | ||
759 | if (peer_len == 0 && local_len && cmd != RTM_DELADDR) { | 759 | if (peer_len == 0 && local_len && cmd != RTM_DELADDR) { |
@@ -767,7 +767,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) | |||
767 | inet_prefix brd; | 767 | inet_prefix brd; |
768 | int i; | 768 | int i; |
769 | if (req.ifa.ifa_family != AF_INET) { | 769 | if (req.ifa.ifa_family != AF_INET) { |
770 | error_msg("Broadcast can be set only for IPv4 addresses"); | 770 | bb_error_msg("Broadcast can be set only for IPv4 addresses"); |
771 | return -1; | 771 | return -1; |
772 | } | 772 | } |
773 | brd = peer; | 773 | brd = peer; |
@@ -791,7 +791,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) | |||
791 | ll_init_map(&rth); | 791 | ll_init_map(&rth); |
792 | 792 | ||
793 | if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) { | 793 | if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) { |
794 | error_msg("Cannot find device \"%s\"", d); | 794 | bb_error_msg("Cannot find device \"%s\"", d); |
795 | return -1; | 795 | return -1; |
796 | } | 796 | } |
797 | 797 | ||
@@ -821,5 +821,5 @@ extern int do_ipaddr(int argc, char **argv) | |||
821 | case 5: /* flush */ | 821 | case 5: /* flush */ |
822 | return ipaddr_list_or_flush(argc-1, argv+1, 1); | 822 | return ipaddr_list_or_flush(argc-1, argv+1, 1); |
823 | } | 823 | } |
824 | error_msg_and_die("Unknown command %s", *argv); | 824 | bb_error_msg_and_die("Unknown command %s", *argv); |
825 | } | 825 | } |
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index 1cfaf6d6a..f826ba081 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c | |||
@@ -42,7 +42,7 @@ static int do_link; | |||
42 | 42 | ||
43 | static int on_off(char *msg) | 43 | static int on_off(char *msg) |
44 | { | 44 | { |
45 | error_msg("Error: argument of \"%s\" must be \"on\" or \"off\"", msg); | 45 | bb_error_msg("Error: argument of \"%s\" must be \"on\" or \"off\"", msg); |
46 | return -1; | 46 | return -1; |
47 | } | 47 | } |
48 | 48 | ||
@@ -211,7 +211,7 @@ static int parse_address(char *dev, int hatype, int halen, char *lla, struct ifr | |||
211 | if (alen < 0) | 211 | if (alen < 0) |
212 | return -1; | 212 | return -1; |
213 | if (alen != halen) { | 213 | if (alen != halen) { |
214 | error_msg("Wrong address (%s) length: expected %d bytes", lla, halen); | 214 | bb_error_msg("Wrong address (%s) length: expected %d bytes", lla, halen); |
215 | return -1; | 215 | return -1; |
216 | } | 216 | } |
217 | return 0; | 217 | return 0; |
@@ -293,7 +293,7 @@ static int do_set(int argc, char **argv) | |||
293 | } | 293 | } |
294 | 294 | ||
295 | if (!dev) { | 295 | if (!dev) { |
296 | error_msg("Not enough of information: \"dev\" argument is required."); | 296 | bb_error_msg("Not enough of information: \"dev\" argument is required."); |
297 | exit(-1); | 297 | exit(-1); |
298 | } | 298 | } |
299 | 299 | ||
@@ -358,6 +358,6 @@ int do_iplink(int argc, char **argv) | |||
358 | } else | 358 | } else |
359 | return ipaddr_list_link(0, NULL); | 359 | return ipaddr_list_link(0, NULL); |
360 | 360 | ||
361 | error_msg("Command \"%s\" is unknown, try \"ip link help\".", *argv); | 361 | bb_error_msg("Command \"%s\" is unknown, try \"ip link help\".", *argv); |
362 | exit(-1); | 362 | exit(-1); |
363 | } | 363 | } |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index be4435f66..3dcafdb6f 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -85,7 +85,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) | |||
85 | return 0; | 85 | return 0; |
86 | len -= NLMSG_LENGTH(sizeof(*r)); | 86 | len -= NLMSG_LENGTH(sizeof(*r)); |
87 | if (len < 0) { | 87 | if (len < 0) { |
88 | error_msg("wrong nlmsg len %d", len); | 88 | bb_error_msg("wrong nlmsg len %d", len); |
89 | return -1; | 89 | return -1; |
90 | } | 90 | } |
91 | 91 | ||
@@ -385,7 +385,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv) | |||
385 | 385 | ||
386 | if (d) { | 386 | if (d) { |
387 | if ((idx = ll_name_to_index(d)) == 0) { | 387 | if ((idx = ll_name_to_index(d)) == 0) { |
388 | error_msg("Cannot find device \"%s\"", d); | 388 | bb_error_msg("Cannot find device \"%s\"", d); |
389 | return -1; | 389 | return -1; |
390 | } | 390 | } |
391 | addattr32(&req.n, sizeof(req), RTA_OIF, idx); | 391 | addattr32(&req.n, sizeof(req), RTA_OIF, idx); |
@@ -549,7 +549,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) | |||
549 | 549 | ||
550 | if (id) { | 550 | if (id) { |
551 | if ((idx = ll_name_to_index(id)) == 0) { | 551 | if ((idx = ll_name_to_index(id)) == 0) { |
552 | error_msg("Cannot find device \"%s\"", id); | 552 | bb_error_msg("Cannot find device \"%s\"", id); |
553 | return -1; | 553 | return -1; |
554 | } | 554 | } |
555 | filter.iif = idx; | 555 | filter.iif = idx; |
@@ -557,7 +557,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) | |||
557 | } | 557 | } |
558 | if (od) { | 558 | if (od) { |
559 | if ((idx = ll_name_to_index(od)) == 0) { | 559 | if ((idx = ll_name_to_index(od)) == 0) { |
560 | error_msg("Cannot find device \"%s\"", od); | 560 | bb_error_msg("Cannot find device \"%s\"", od); |
561 | } | 561 | } |
562 | filter.oif = idx; | 562 | filter.oif = idx; |
563 | filter.oifmask = -1; | 563 | filter.oifmask = -1; |
@@ -587,7 +587,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) | |||
587 | } | 587 | } |
588 | filter.flushed = 0; | 588 | filter.flushed = 0; |
589 | if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) { | 589 | if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) { |
590 | error_msg("Flush terminated\n"); | 590 | bb_error_msg("Flush terminated\n"); |
591 | return -1; | 591 | return -1; |
592 | } | 592 | } |
593 | if (filter.flushed == 0) { | 593 | if (filter.flushed == 0) { |
@@ -606,16 +606,16 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) | |||
606 | 606 | ||
607 | if (filter.tb != -1) { | 607 | if (filter.tb != -1) { |
608 | if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) { | 608 | if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) { |
609 | perror_msg_and_die("Cannot send dump request"); | 609 | bb_perror_msg_and_die("Cannot send dump request"); |
610 | } | 610 | } |
611 | } else { | 611 | } else { |
612 | if (rtnl_rtcache_request(&rth, do_ipv6) < 0) { | 612 | if (rtnl_rtcache_request(&rth, do_ipv6) < 0) { |
613 | perror_msg_and_die("Cannot send dump request"); | 613 | bb_perror_msg_and_die("Cannot send dump request"); |
614 | } | 614 | } |
615 | } | 615 | } |
616 | 616 | ||
617 | if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) { | 617 | if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) { |
618 | error_msg_and_die("Dump terminated"); | 618 | bb_error_msg_and_die("Dump terminated"); |
619 | } | 619 | } |
620 | 620 | ||
621 | exit(0); | 621 | exit(0); |
@@ -703,7 +703,7 @@ static int iproute_get(int argc, char **argv) | |||
703 | } | 703 | } |
704 | 704 | ||
705 | if (req.r.rtm_dst_len == 0) { | 705 | if (req.r.rtm_dst_len == 0) { |
706 | error_msg_and_die("need at least destination address"); | 706 | bb_error_msg_and_die("need at least destination address"); |
707 | } | 707 | } |
708 | 708 | ||
709 | if (rtnl_open(&rth, 0) < 0) | 709 | if (rtnl_open(&rth, 0) < 0) |
@@ -716,14 +716,14 @@ static int iproute_get(int argc, char **argv) | |||
716 | 716 | ||
717 | if (idev) { | 717 | if (idev) { |
718 | if ((idx = ll_name_to_index(idev)) == 0) { | 718 | if ((idx = ll_name_to_index(idev)) == 0) { |
719 | error_msg("Cannot find device \"%s\"", idev); | 719 | bb_error_msg("Cannot find device \"%s\"", idev); |
720 | return -1; | 720 | return -1; |
721 | } | 721 | } |
722 | addattr32(&req.n, sizeof(req), RTA_IIF, idx); | 722 | addattr32(&req.n, sizeof(req), RTA_IIF, idx); |
723 | } | 723 | } |
724 | if (odev) { | 724 | if (odev) { |
725 | if ((idx = ll_name_to_index(odev)) == 0) { | 725 | if ((idx = ll_name_to_index(odev)) == 0) { |
726 | error_msg("Cannot find device \"%s\"", odev); | 726 | bb_error_msg("Cannot find device \"%s\"", odev); |
727 | return -1; | 727 | return -1; |
728 | } | 728 | } |
729 | addattr32(&req.n, sizeof(req), RTA_OIF, idx); | 729 | addattr32(&req.n, sizeof(req), RTA_OIF, idx); |
@@ -744,16 +744,16 @@ static int iproute_get(int argc, char **argv) | |||
744 | struct rtattr * tb[RTA_MAX+1]; | 744 | struct rtattr * tb[RTA_MAX+1]; |
745 | 745 | ||
746 | if (print_route(NULL, &req.n, (void*)stdout) < 0) { | 746 | if (print_route(NULL, &req.n, (void*)stdout) < 0) { |
747 | error_msg_and_die("An error :-)"); | 747 | bb_error_msg_and_die("An error :-)"); |
748 | } | 748 | } |
749 | 749 | ||
750 | if (req.n.nlmsg_type != RTM_NEWROUTE) { | 750 | if (req.n.nlmsg_type != RTM_NEWROUTE) { |
751 | error_msg("Not a route?"); | 751 | bb_error_msg("Not a route?"); |
752 | return -1; | 752 | return -1; |
753 | } | 753 | } |
754 | len -= NLMSG_LENGTH(sizeof(*r)); | 754 | len -= NLMSG_LENGTH(sizeof(*r)); |
755 | if (len < 0) { | 755 | if (len < 0) { |
756 | error_msg("Wrong len %d", len); | 756 | bb_error_msg("Wrong len %d", len); |
757 | return -1; | 757 | return -1; |
758 | } | 758 | } |
759 | 759 | ||
@@ -764,7 +764,7 @@ static int iproute_get(int argc, char **argv) | |||
764 | tb[RTA_PREFSRC]->rta_type = RTA_SRC; | 764 | tb[RTA_PREFSRC]->rta_type = RTA_SRC; |
765 | r->rtm_src_len = 8*RTA_PAYLOAD(tb[RTA_PREFSRC]); | 765 | r->rtm_src_len = 8*RTA_PAYLOAD(tb[RTA_PREFSRC]); |
766 | } else if (!tb[RTA_SRC]) { | 766 | } else if (!tb[RTA_SRC]) { |
767 | error_msg("Failed to connect the route"); | 767 | bb_error_msg("Failed to connect the route"); |
768 | return -1; | 768 | return -1; |
769 | } | 769 | } |
770 | if (!odev && tb[RTA_OIF]) { | 770 | if (!odev && tb[RTA_OIF]) { |
@@ -785,7 +785,7 @@ static int iproute_get(int argc, char **argv) | |||
785 | } | 785 | } |
786 | 786 | ||
787 | if (print_route(NULL, &req.n, (void*)stdout) < 0) { | 787 | if (print_route(NULL, &req.n, (void*)stdout) < 0) { |
788 | error_msg_and_die("An error :-)"); | 788 | bb_error_msg_and_die("An error :-)"); |
789 | } | 789 | } |
790 | 790 | ||
791 | exit(0); | 791 | exit(0); |
@@ -830,7 +830,7 @@ int do_iproute(int argc, char **argv) | |||
830 | case 11: /* flush */ | 830 | case 11: /* flush */ |
831 | return iproute_list_or_flush(argc-1, argv+1, 1); | 831 | return iproute_list_or_flush(argc-1, argv+1, 1); |
832 | default: | 832 | default: |
833 | error_msg_and_die("Unknown command %s", *argv); | 833 | bb_error_msg_and_die("Unknown command %s", *argv); |
834 | } | 834 | } |
835 | 835 | ||
836 | return iproute_modify(cmd, flags, argc-1, argv+1); | 836 | return iproute_modify(cmd, flags, argc-1, argv+1); |
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index 1eb17799c..eae5bb091 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c | |||
@@ -47,7 +47,7 @@ static int do_ioctl_get_ifindex(char *dev) | |||
47 | strcpy(ifr.ifr_name, dev); | 47 | strcpy(ifr.ifr_name, dev); |
48 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 48 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
49 | if (ioctl(fd, SIOCGIFINDEX, &ifr)) { | 49 | if (ioctl(fd, SIOCGIFINDEX, &ifr)) { |
50 | perror_msg("ioctl"); | 50 | bb_perror_msg("ioctl"); |
51 | return 0; | 51 | return 0; |
52 | } | 52 | } |
53 | close(fd); | 53 | close(fd); |
@@ -62,7 +62,7 @@ static int do_ioctl_get_iftype(char *dev) | |||
62 | strcpy(ifr.ifr_name, dev); | 62 | strcpy(ifr.ifr_name, dev); |
63 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 63 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
64 | if (ioctl(fd, SIOCGIFHWADDR, &ifr)) { | 64 | if (ioctl(fd, SIOCGIFHWADDR, &ifr)) { |
65 | perror_msg("ioctl"); | 65 | bb_perror_msg("ioctl"); |
66 | return -1; | 66 | return -1; |
67 | } | 67 | } |
68 | close(fd); | 68 | close(fd); |
@@ -78,7 +78,7 @@ static char *do_ioctl_get_ifname(int idx) | |||
78 | ifr.ifr_ifindex = idx; | 78 | ifr.ifr_ifindex = idx; |
79 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 79 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
80 | if (ioctl(fd, SIOCGIFNAME, &ifr)) { | 80 | if (ioctl(fd, SIOCGIFNAME, &ifr)) { |
81 | perror_msg("ioctl"); | 81 | bb_perror_msg("ioctl"); |
82 | return NULL; | 82 | return NULL; |
83 | } | 83 | } |
84 | close(fd); | 84 | close(fd); |
@@ -98,7 +98,7 @@ static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p) | |||
98 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 98 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
99 | err = ioctl(fd, SIOCGETTUNNEL, &ifr); | 99 | err = ioctl(fd, SIOCGETTUNNEL, &ifr); |
100 | if (err) { | 100 | if (err) { |
101 | perror_msg("ioctl"); | 101 | bb_perror_msg("ioctl"); |
102 | } | 102 | } |
103 | close(fd); | 103 | close(fd); |
104 | return err; | 104 | return err; |
@@ -119,7 +119,7 @@ static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p) | |||
119 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 119 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
120 | err = ioctl(fd, cmd, &ifr); | 120 | err = ioctl(fd, cmd, &ifr); |
121 | if (err) { | 121 | if (err) { |
122 | perror_msg("ioctl"); | 122 | bb_perror_msg("ioctl"); |
123 | } | 123 | } |
124 | close(fd); | 124 | close(fd); |
125 | return err; | 125 | return err; |
@@ -140,7 +140,7 @@ static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p) | |||
140 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 140 | fd = socket(AF_INET, SOCK_DGRAM, 0); |
141 | err = ioctl(fd, SIOCDELTUNNEL, &ifr); | 141 | err = ioctl(fd, SIOCDELTUNNEL, &ifr); |
142 | if (err) { | 142 | if (err) { |
143 | perror_msg("ioctl"); | 143 | bb_perror_msg("ioctl"); |
144 | } | 144 | } |
145 | close(fd); | 145 | close(fd); |
146 | return err; | 146 | return err; |
@@ -166,26 +166,26 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) | |||
166 | if (strcmp(*argv, "ipip") == 0 || | 166 | if (strcmp(*argv, "ipip") == 0 || |
167 | strcmp(*argv, "ip/ip") == 0) { | 167 | strcmp(*argv, "ip/ip") == 0) { |
168 | if (p->iph.protocol && p->iph.protocol != IPPROTO_IPIP) { | 168 | if (p->iph.protocol && p->iph.protocol != IPPROTO_IPIP) { |
169 | error_msg("You managed to ask for more than one tunnel mode."); | 169 | bb_error_msg("You managed to ask for more than one tunnel mode."); |
170 | exit(-1); | 170 | exit(-1); |
171 | } | 171 | } |
172 | p->iph.protocol = IPPROTO_IPIP; | 172 | p->iph.protocol = IPPROTO_IPIP; |
173 | } else if (strcmp(*argv, "gre") == 0 || | 173 | } else if (strcmp(*argv, "gre") == 0 || |
174 | strcmp(*argv, "gre/ip") == 0) { | 174 | strcmp(*argv, "gre/ip") == 0) { |
175 | if (p->iph.protocol && p->iph.protocol != IPPROTO_GRE) { | 175 | if (p->iph.protocol && p->iph.protocol != IPPROTO_GRE) { |
176 | error_msg("You managed to ask for more than one tunnel mode."); | 176 | bb_error_msg("You managed to ask for more than one tunnel mode."); |
177 | exit(-1); | 177 | exit(-1); |
178 | } | 178 | } |
179 | p->iph.protocol = IPPROTO_GRE; | 179 | p->iph.protocol = IPPROTO_GRE; |
180 | } else if (strcmp(*argv, "sit") == 0 || | 180 | } else if (strcmp(*argv, "sit") == 0 || |
181 | strcmp(*argv, "ipv6/ip") == 0) { | 181 | strcmp(*argv, "ipv6/ip") == 0) { |
182 | if (p->iph.protocol && p->iph.protocol != IPPROTO_IPV6) { | 182 | if (p->iph.protocol && p->iph.protocol != IPPROTO_IPV6) { |
183 | error_msg("You managed to ask for more than one tunnel mode."); | 183 | bb_error_msg("You managed to ask for more than one tunnel mode."); |
184 | exit(-1); | 184 | exit(-1); |
185 | } | 185 | } |
186 | p->iph.protocol = IPPROTO_IPV6; | 186 | p->iph.protocol = IPPROTO_IPV6; |
187 | } else { | 187 | } else { |
188 | error_msg("Cannot guess tunnel mode."); | 188 | bb_error_msg("Cannot guess tunnel mode."); |
189 | exit(-1); | 189 | exit(-1); |
190 | } | 190 | } |
191 | } else if (strcmp(*argv, "key") == 0) { | 191 | } else if (strcmp(*argv, "key") == 0) { |
@@ -197,7 +197,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) | |||
197 | p->i_key = p->o_key = get_addr32(*argv); | 197 | p->i_key = p->o_key = get_addr32(*argv); |
198 | else { | 198 | else { |
199 | if (get_unsigned(&uval, *argv, 0)<0) { | 199 | if (get_unsigned(&uval, *argv, 0)<0) { |
200 | error_msg("invalid value of \"key\""); | 200 | bb_error_msg("invalid value of \"key\""); |
201 | exit(-1); | 201 | exit(-1); |
202 | } | 202 | } |
203 | p->i_key = p->o_key = htonl(uval); | 203 | p->i_key = p->o_key = htonl(uval); |
@@ -210,7 +210,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) | |||
210 | p->o_key = get_addr32(*argv); | 210 | p->o_key = get_addr32(*argv); |
211 | else { | 211 | else { |
212 | if (get_unsigned(&uval, *argv, 0)<0) { | 212 | if (get_unsigned(&uval, *argv, 0)<0) { |
213 | error_msg("invalid value of \"ikey\""); | 213 | bb_error_msg("invalid value of \"ikey\""); |
214 | exit(-1); | 214 | exit(-1); |
215 | } | 215 | } |
216 | p->i_key = htonl(uval); | 216 | p->i_key = htonl(uval); |
@@ -223,7 +223,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) | |||
223 | p->o_key = get_addr32(*argv); | 223 | p->o_key = get_addr32(*argv); |
224 | else { | 224 | else { |
225 | if (get_unsigned(&uval, *argv, 0)<0) { | 225 | if (get_unsigned(&uval, *argv, 0)<0) { |
226 | error_msg("invalid value of \"okey\""); | 226 | bb_error_msg("invalid value of \"okey\""); |
227 | exit(-1); | 227 | exit(-1); |
228 | } | 228 | } |
229 | p->o_key = htonl(uval); | 229 | p->o_key = htonl(uval); |
@@ -308,7 +308,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) | |||
308 | 308 | ||
309 | if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) { | 309 | if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) { |
310 | if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) { | 310 | if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) { |
311 | error_msg("Keys are not allowed with ipip and sit."); | 311 | bb_error_msg("Keys are not allowed with ipip and sit."); |
312 | return -1; | 312 | return -1; |
313 | } | 313 | } |
314 | } | 314 | } |
@@ -328,7 +328,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) | |||
328 | p->o_flags |= GRE_KEY; | 328 | p->o_flags |= GRE_KEY; |
329 | } | 329 | } |
330 | if (IN_MULTICAST(ntohl(p->iph.daddr)) && !p->iph.saddr) { | 330 | if (IN_MULTICAST(ntohl(p->iph.daddr)) && !p->iph.saddr) { |
331 | error_msg("Broadcast tunnel requires a source address."); | 331 | bb_error_msg("Broadcast tunnel requires a source address."); |
332 | return -1; | 332 | return -1; |
333 | } | 333 | } |
334 | return 0; | 334 | return 0; |
@@ -343,7 +343,7 @@ static int do_add(int cmd, int argc, char **argv) | |||
343 | return -1; | 343 | return -1; |
344 | 344 | ||
345 | if (p.iph.ttl && p.iph.frag_off == 0) { | 345 | if (p.iph.ttl && p.iph.frag_off == 0) { |
346 | error_msg("ttl != 0 and noptmudisc are incompatible"); | 346 | bb_error_msg("ttl != 0 and noptmudisc are incompatible"); |
347 | return -1; | 347 | return -1; |
348 | } | 348 | } |
349 | 349 | ||
@@ -355,7 +355,7 @@ static int do_add(int cmd, int argc, char **argv) | |||
355 | case IPPROTO_IPV6: | 355 | case IPPROTO_IPV6: |
356 | return do_add_ioctl(cmd, "sit0", &p); | 356 | return do_add_ioctl(cmd, "sit0", &p); |
357 | default: | 357 | default: |
358 | error_msg("cannot determine tunnel mode (ipip, gre or sit)"); | 358 | bb_error_msg("cannot determine tunnel mode (ipip, gre or sit)"); |
359 | return -1; | 359 | return -1; |
360 | } | 360 | } |
361 | return -1; | 361 | return -1; |
@@ -464,7 +464,7 @@ static int do_tunnels_list(struct ip_tunnel_parm *p) | |||
464 | buf[sizeof(buf) - 1] = 0; | 464 | buf[sizeof(buf) - 1] = 0; |
465 | if ((ptr = strchr(buf, ':')) == NULL || | 465 | if ((ptr = strchr(buf, ':')) == NULL || |
466 | (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) { | 466 | (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) { |
467 | error_msg("Wrong format of /proc/net/dev. Sorry."); | 467 | bb_error_msg("Wrong format of /proc/net/dev. Sorry."); |
468 | return -1; | 468 | return -1; |
469 | } | 469 | } |
470 | if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld", | 470 | if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld", |
@@ -477,7 +477,7 @@ static int do_tunnels_list(struct ip_tunnel_parm *p) | |||
477 | continue; | 477 | continue; |
478 | type = do_ioctl_get_iftype(name); | 478 | type = do_ioctl_get_iftype(name); |
479 | if (type == -1) { | 479 | if (type == -1) { |
480 | error_msg("Failed to get type of [%s]", name); | 480 | bb_error_msg("Failed to get type of [%s]", name); |
481 | continue; | 481 | continue; |
482 | } | 482 | } |
483 | if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT) | 483 | if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT) |
@@ -543,6 +543,6 @@ int do_iptunnel(int argc, char **argv) | |||
543 | } else | 543 | } else |
544 | return do_show(0, NULL); | 544 | return do_show(0, NULL); |
545 | 545 | ||
546 | error_msg("Command \"%s\" is unknown, try \"ip tunnel help\".", *argv); | 546 | bb_error_msg("Command \"%s\" is unknown, try \"ip tunnel help\".", *argv); |
547 | exit(-1); | 547 | exit(-1); |
548 | } | 548 | } |
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index fbc555dfe..04411931d 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c | |||
@@ -34,7 +34,7 @@ int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) | |||
34 | 34 | ||
35 | rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); | 35 | rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); |
36 | if (rth->fd < 0) { | 36 | if (rth->fd < 0) { |
37 | perror_msg("Cannot open netlink socket"); | 37 | bb_perror_msg("Cannot open netlink socket"); |
38 | return -1; | 38 | return -1; |
39 | } | 39 | } |
40 | 40 | ||
@@ -43,20 +43,20 @@ int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) | |||
43 | rth->local.nl_groups = subscriptions; | 43 | rth->local.nl_groups = subscriptions; |
44 | 44 | ||
45 | if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) { | 45 | if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) { |
46 | perror_msg("Cannot bind netlink socket"); | 46 | bb_perror_msg("Cannot bind netlink socket"); |
47 | return -1; | 47 | return -1; |
48 | } | 48 | } |
49 | addr_len = sizeof(rth->local); | 49 | addr_len = sizeof(rth->local); |
50 | if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { | 50 | if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { |
51 | perror_msg("Cannot getsockname"); | 51 | bb_perror_msg("Cannot getsockname"); |
52 | return -1; | 52 | return -1; |
53 | } | 53 | } |
54 | if (addr_len != sizeof(rth->local)) { | 54 | if (addr_len != sizeof(rth->local)) { |
55 | error_msg("Wrong address length %d", addr_len); | 55 | bb_error_msg("Wrong address length %d", addr_len); |
56 | return -1; | 56 | return -1; |
57 | } | 57 | } |
58 | if (rth->local.nl_family != AF_NETLINK) { | 58 | if (rth->local.nl_family != AF_NETLINK) { |
59 | error_msg("Wrong address family %d", rth->local.nl_family); | 59 | bb_error_msg("Wrong address family %d", rth->local.nl_family); |
60 | return -1; | 60 | return -1; |
61 | } | 61 | } |
62 | rth->seq = time(NULL); | 62 | rth->seq = time(NULL); |
@@ -144,15 +144,15 @@ int rtnl_dump_filter(struct rtnl_handle *rth, | |||
144 | if (status < 0) { | 144 | if (status < 0) { |
145 | if (errno == EINTR) | 145 | if (errno == EINTR) |
146 | continue; | 146 | continue; |
147 | perror_msg("OVERRUN"); | 147 | bb_perror_msg("OVERRUN"); |
148 | continue; | 148 | continue; |
149 | } | 149 | } |
150 | if (status == 0) { | 150 | if (status == 0) { |
151 | error_msg("EOF on netlink"); | 151 | bb_error_msg("EOF on netlink"); |
152 | return -1; | 152 | return -1; |
153 | } | 153 | } |
154 | if (msg.msg_namelen != sizeof(nladdr)) { | 154 | if (msg.msg_namelen != sizeof(nladdr)) { |
155 | error_msg_and_die("sender address length == %d", msg.msg_namelen); | 155 | bb_error_msg_and_die("sender address length == %d", msg.msg_namelen); |
156 | } | 156 | } |
157 | 157 | ||
158 | h = (struct nlmsghdr*)buf; | 158 | h = (struct nlmsghdr*)buf; |
@@ -176,10 +176,10 @@ int rtnl_dump_filter(struct rtnl_handle *rth, | |||
176 | if (h->nlmsg_type == NLMSG_ERROR) { | 176 | if (h->nlmsg_type == NLMSG_ERROR) { |
177 | struct nlmsgerr *l_err = (struct nlmsgerr*)NLMSG_DATA(h); | 177 | struct nlmsgerr *l_err = (struct nlmsgerr*)NLMSG_DATA(h); |
178 | if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { | 178 | if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { |
179 | error_msg("ERROR truncated"); | 179 | bb_error_msg("ERROR truncated"); |
180 | } else { | 180 | } else { |
181 | errno = -l_err->error; | 181 | errno = -l_err->error; |
182 | perror_msg("RTNETLINK answers"); | 182 | bb_perror_msg("RTNETLINK answers"); |
183 | } | 183 | } |
184 | return -1; | 184 | return -1; |
185 | } | 185 | } |
@@ -192,11 +192,11 @@ skip_it: | |||
192 | h = NLMSG_NEXT(h, status); | 192 | h = NLMSG_NEXT(h, status); |
193 | } | 193 | } |
194 | if (msg.msg_flags & MSG_TRUNC) { | 194 | if (msg.msg_flags & MSG_TRUNC) { |
195 | error_msg("Message truncated"); | 195 | bb_error_msg("Message truncated"); |
196 | continue; | 196 | continue; |
197 | } | 197 | } |
198 | if (status) { | 198 | if (status) { |
199 | error_msg_and_die("!!!Remnant of size %d", status); | 199 | bb_error_msg_and_die("!!!Remnant of size %d", status); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
@@ -231,7 +231,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, | |||
231 | status = sendmsg(rtnl->fd, &msg, 0); | 231 | status = sendmsg(rtnl->fd, &msg, 0); |
232 | 232 | ||
233 | if (status < 0) { | 233 | if (status < 0) { |
234 | perror_msg("Cannot talk to rtnetlink"); | 234 | bb_perror_msg("Cannot talk to rtnetlink"); |
235 | return -1; | 235 | return -1; |
236 | } | 236 | } |
237 | 237 | ||
@@ -245,15 +245,15 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, | |||
245 | if (errno == EINTR) { | 245 | if (errno == EINTR) { |
246 | continue; | 246 | continue; |
247 | } | 247 | } |
248 | perror_msg("OVERRUN"); | 248 | bb_perror_msg("OVERRUN"); |
249 | continue; | 249 | continue; |
250 | } | 250 | } |
251 | if (status == 0) { | 251 | if (status == 0) { |
252 | error_msg("EOF on netlink"); | 252 | bb_error_msg("EOF on netlink"); |
253 | return -1; | 253 | return -1; |
254 | } | 254 | } |
255 | if (msg.msg_namelen != sizeof(nladdr)) { | 255 | if (msg.msg_namelen != sizeof(nladdr)) { |
256 | error_msg_and_die("sender address length == %d", msg.msg_namelen); | 256 | bb_error_msg_and_die("sender address length == %d", msg.msg_namelen); |
257 | } | 257 | } |
258 | for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { | 258 | for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { |
259 | int l_err; | 259 | int l_err; |
@@ -262,10 +262,10 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, | |||
262 | 262 | ||
263 | if (l<0 || len>status) { | 263 | if (l<0 || len>status) { |
264 | if (msg.msg_flags & MSG_TRUNC) { | 264 | if (msg.msg_flags & MSG_TRUNC) { |
265 | error_msg("Truncated message"); | 265 | bb_error_msg("Truncated message"); |
266 | return -1; | 266 | return -1; |
267 | } | 267 | } |
268 | error_msg_and_die("!!!malformed message: len=%d", len); | 268 | bb_error_msg_and_die("!!!malformed message: len=%d", len); |
269 | } | 269 | } |
270 | 270 | ||
271 | if (h->nlmsg_pid != rtnl->local.nl_pid || | 271 | if (h->nlmsg_pid != rtnl->local.nl_pid || |
@@ -282,7 +282,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, | |||
282 | if (h->nlmsg_type == NLMSG_ERROR) { | 282 | if (h->nlmsg_type == NLMSG_ERROR) { |
283 | struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); | 283 | struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); |
284 | if (l < sizeof(struct nlmsgerr)) { | 284 | if (l < sizeof(struct nlmsgerr)) { |
285 | error_msg("ERROR truncated"); | 285 | bb_error_msg("ERROR truncated"); |
286 | } else { | 286 | } else { |
287 | errno = -err->error; | 287 | errno = -err->error; |
288 | if (errno == 0) { | 288 | if (errno == 0) { |
@@ -291,7 +291,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, | |||
291 | } | 291 | } |
292 | return 0; | 292 | return 0; |
293 | } | 293 | } |
294 | perror_msg("RTNETLINK answers"); | 294 | bb_perror_msg("RTNETLINK answers"); |
295 | } | 295 | } |
296 | return -1; | 296 | return -1; |
297 | } | 297 | } |
@@ -300,17 +300,17 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, | |||
300 | return 0; | 300 | return 0; |
301 | } | 301 | } |
302 | 302 | ||
303 | error_msg("Unexpected reply!!!"); | 303 | bb_error_msg("Unexpected reply!!!"); |
304 | 304 | ||
305 | status -= NLMSG_ALIGN(len); | 305 | status -= NLMSG_ALIGN(len); |
306 | h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); | 306 | h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); |
307 | } | 307 | } |
308 | if (msg.msg_flags & MSG_TRUNC) { | 308 | if (msg.msg_flags & MSG_TRUNC) { |
309 | error_msg("Message truncated"); | 309 | bb_error_msg("Message truncated"); |
310 | continue; | 310 | continue; |
311 | } | 311 | } |
312 | if (status) { | 312 | if (status) { |
313 | error_msg_and_die("!!!Remnant of size %d", status); | 313 | bb_error_msg_and_die("!!!Remnant of size %d", status); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | } | 316 | } |
@@ -346,15 +346,15 @@ int rtnl_listen(struct rtnl_handle *rtnl, | |||
346 | if (status < 0) { | 346 | if (status < 0) { |
347 | if (errno == EINTR) | 347 | if (errno == EINTR) |
348 | continue; | 348 | continue; |
349 | perror_msg("OVERRUN"); | 349 | bb_perror_msg("OVERRUN"); |
350 | continue; | 350 | continue; |
351 | } | 351 | } |
352 | if (status == 0) { | 352 | if (status == 0) { |
353 | error_msg("EOF on netlink"); | 353 | bb_error_msg("EOF on netlink"); |
354 | return -1; | 354 | return -1; |
355 | } | 355 | } |
356 | if (msg.msg_namelen != sizeof(nladdr)) { | 356 | if (msg.msg_namelen != sizeof(nladdr)) { |
357 | error_msg_and_die("Sender address length == %d", msg.msg_namelen); | 357 | bb_error_msg_and_die("Sender address length == %d", msg.msg_namelen); |
358 | } | 358 | } |
359 | for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { | 359 | for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { |
360 | int err; | 360 | int err; |
@@ -363,10 +363,10 @@ int rtnl_listen(struct rtnl_handle *rtnl, | |||
363 | 363 | ||
364 | if (l<0 || len>status) { | 364 | if (l<0 || len>status) { |
365 | if (msg.msg_flags & MSG_TRUNC) { | 365 | if (msg.msg_flags & MSG_TRUNC) { |
366 | error_msg("Truncated message"); | 366 | bb_error_msg("Truncated message"); |
367 | return -1; | 367 | return -1; |
368 | } | 368 | } |
369 | error_msg_and_die("!!!malformed message: len=%d", len); | 369 | bb_error_msg_and_die("!!!malformed message: len=%d", len); |
370 | } | 370 | } |
371 | 371 | ||
372 | err = handler(&nladdr, h, jarg); | 372 | err = handler(&nladdr, h, jarg); |
@@ -378,11 +378,11 @@ int rtnl_listen(struct rtnl_handle *rtnl, | |||
378 | h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); | 378 | h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); |
379 | } | 379 | } |
380 | if (msg.msg_flags & MSG_TRUNC) { | 380 | if (msg.msg_flags & MSG_TRUNC) { |
381 | error_msg("Message truncated"); | 381 | bb_error_msg("Message truncated"); |
382 | continue; | 382 | continue; |
383 | } | 383 | } |
384 | if (status) { | 384 | if (status) { |
385 | error_msg_and_die("!!!Remnant of size %d", status); | 385 | bb_error_msg_and_die("!!!Remnant of size %d", status); |
386 | } | 386 | } |
387 | } | 387 | } |
388 | } | 388 | } |
@@ -410,7 +410,7 @@ int rtnl_from_file(FILE *rtnl, | |||
410 | if (status < 0) { | 410 | if (status < 0) { |
411 | if (errno == EINTR) | 411 | if (errno == EINTR) |
412 | continue; | 412 | continue; |
413 | perror_msg("rtnl_from_file: fread"); | 413 | bb_perror_msg("rtnl_from_file: fread"); |
414 | return -1; | 414 | return -1; |
415 | } | 415 | } |
416 | if (status == 0) | 416 | if (status == 0) |
@@ -421,7 +421,7 @@ int rtnl_from_file(FILE *rtnl, | |||
421 | l = len - sizeof(*h); | 421 | l = len - sizeof(*h); |
422 | 422 | ||
423 | if (l<0 || len>sizeof(buf)) { | 423 | if (l<0 || len>sizeof(buf)) { |
424 | error_msg("!!!malformed message: len=%d @%lu", | 424 | bb_error_msg("!!!malformed message: len=%d @%lu", |
425 | len, ftell(rtnl)); | 425 | len, ftell(rtnl)); |
426 | return -1; | 426 | return -1; |
427 | } | 427 | } |
@@ -429,11 +429,11 @@ int rtnl_from_file(FILE *rtnl, | |||
429 | status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl); | 429 | status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl); |
430 | 430 | ||
431 | if (status < 0) { | 431 | if (status < 0) { |
432 | perror_msg("rtnl_from_file: fread"); | 432 | bb_perror_msg("rtnl_from_file: fread"); |
433 | return -1; | 433 | return -1; |
434 | } | 434 | } |
435 | if (status < l) { | 435 | if (status < l) { |
436 | error_msg("rtnl-from_file: truncated message"); | 436 | bb_error_msg("rtnl-from_file: truncated message"); |
437 | return -1; | 437 | return -1; |
438 | } | 438 | } |
439 | 439 | ||
@@ -514,7 +514,7 @@ int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) | |||
514 | rta = RTA_NEXT(rta,len); | 514 | rta = RTA_NEXT(rta,len); |
515 | } | 515 | } |
516 | if (len) { | 516 | if (len) { |
517 | error_msg("!!!Deficit %d, rta_len=%d", len, rta->rta_len); | 517 | bb_error_msg("!!!Deficit %d, rta_len=%d", len, rta->rta_len); |
518 | } | 518 | } |
519 | return 0; | 519 | return 0; |
520 | } | 520 | } |
diff --git a/networking/libiproute/ll_addr.c b/networking/libiproute/ll_addr.c index 39e561fe5..ada685f4e 100644 --- a/networking/libiproute/ll_addr.c +++ b/networking/libiproute/ll_addr.c | |||
@@ -44,7 +44,7 @@ int ll_addr_a2n(unsigned char *lladdr, int len, char *arg) | |||
44 | if (strchr(arg, '.')) { | 44 | if (strchr(arg, '.')) { |
45 | inet_prefix pfx; | 45 | inet_prefix pfx; |
46 | if (get_addr_1(&pfx, arg, AF_INET)) { | 46 | if (get_addr_1(&pfx, arg, AF_INET)) { |
47 | error_msg("\"%s\" is invalid lladdr.", arg); | 47 | bb_error_msg("\"%s\" is invalid lladdr.", arg); |
48 | return -1; | 48 | return -1; |
49 | } | 49 | } |
50 | if (len < 4) { | 50 | if (len < 4) { |
@@ -63,11 +63,11 @@ int ll_addr_a2n(unsigned char *lladdr, int len, char *arg) | |||
63 | cp++; | 63 | cp++; |
64 | } | 64 | } |
65 | if (sscanf(arg, "%x", &temp) != 1) { | 65 | if (sscanf(arg, "%x", &temp) != 1) { |
66 | error_msg("\"%s\" is invalid lladdr.", arg); | 66 | bb_error_msg("\"%s\" is invalid lladdr.", arg); |
67 | return -1; | 67 | return -1; |
68 | } | 68 | } |
69 | if (temp < 0 || temp > 255) { | 69 | if (temp < 0 || temp > 255) { |
70 | error_msg("\"%s\" is invalid lladdr.", arg); | 70 | bb_error_msg("\"%s\" is invalid lladdr.", arg); |
71 | return -1; | 71 | return -1; |
72 | } | 72 | } |
73 | lladdr[i] = temp; | 73 | lladdr[i] = temp; |
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 2c23cd294..fa1548609 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c | |||
@@ -209,10 +209,10 @@ int get_prefix_1(inet_prefix * dst, char *arg, int family) | |||
209 | int get_addr(inet_prefix * dst, char *arg, int family) | 209 | int get_addr(inet_prefix * dst, char *arg, int family) |
210 | { | 210 | { |
211 | if (family == AF_PACKET) { | 211 | if (family == AF_PACKET) { |
212 | error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); | 212 | bb_error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); |
213 | } | 213 | } |
214 | if (get_addr_1(dst, arg, family)) { | 214 | if (get_addr_1(dst, arg, family)) { |
215 | error_msg_and_die("an inet address is expected rather than \"%s\".", arg); | 215 | bb_error_msg_and_die("an inet address is expected rather than \"%s\".", arg); |
216 | } | 216 | } |
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
@@ -220,10 +220,10 @@ int get_addr(inet_prefix * dst, char *arg, int family) | |||
220 | int get_prefix(inet_prefix * dst, char *arg, int family) | 220 | int get_prefix(inet_prefix * dst, char *arg, int family) |
221 | { | 221 | { |
222 | if (family == AF_PACKET) { | 222 | if (family == AF_PACKET) { |
223 | error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); | 223 | bb_error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); |
224 | } | 224 | } |
225 | if (get_prefix_1(dst, arg, family)) { | 225 | if (get_prefix_1(dst, arg, family)) { |
226 | error_msg_and_die("an inet address is expected rather than \"%s\".", arg); | 226 | bb_error_msg_and_die("an inet address is expected rather than \"%s\".", arg); |
227 | } | 227 | } |
228 | return 0; | 228 | return 0; |
229 | } | 229 | } |
@@ -233,32 +233,32 @@ __u32 get_addr32(char *name) | |||
233 | inet_prefix addr; | 233 | inet_prefix addr; |
234 | 234 | ||
235 | if (get_addr_1(&addr, name, AF_INET)) { | 235 | if (get_addr_1(&addr, name, AF_INET)) { |
236 | error_msg_and_die("an IP address is expected rather than \"%s\"", name); | 236 | bb_error_msg_and_die("an IP address is expected rather than \"%s\"", name); |
237 | } | 237 | } |
238 | return addr.data[0]; | 238 | return addr.data[0]; |
239 | } | 239 | } |
240 | 240 | ||
241 | void incomplete_command() | 241 | void incomplete_command() |
242 | { | 242 | { |
243 | error_msg("Command line is not complete. Try option \"help\""); | 243 | bb_error_msg("Command line is not complete. Try option \"help\""); |
244 | exit(-1); | 244 | exit(-1); |
245 | } | 245 | } |
246 | 246 | ||
247 | void invarg(char *msg, char *arg) | 247 | void invarg(char *msg, char *arg) |
248 | { | 248 | { |
249 | error_msg("argument \"%s\" is wrong: %s", arg, msg); | 249 | bb_error_msg("argument \"%s\" is wrong: %s", arg, msg); |
250 | exit(-1); | 250 | exit(-1); |
251 | } | 251 | } |
252 | 252 | ||
253 | void duparg(char *key, char *arg) | 253 | void duparg(char *key, char *arg) |
254 | { | 254 | { |
255 | error_msg("duplicate \"%s\": \"%s\" is the second value.", key, arg); | 255 | bb_error_msg("duplicate \"%s\": \"%s\" is the second value.", key, arg); |
256 | exit(-1); | 256 | exit(-1); |
257 | } | 257 | } |
258 | 258 | ||
259 | void duparg2(char *key, char *arg) | 259 | void duparg2(char *key, char *arg) |
260 | { | 260 | { |
261 | error_msg("either \"%s\" is duplicate, or \"%s\" is a garbage.", key, arg); | 261 | bb_error_msg("either \"%s\" is duplicate, or \"%s\" is a garbage.", key, arg); |
262 | exit(-1); | 262 | exit(-1); |
263 | } | 263 | } |
264 | 264 | ||
diff --git a/networking/nameif.c b/networking/nameif.c index f3b927158..e74a04213 100644 --- a/networking/nameif.c +++ b/networking/nameif.c | |||
@@ -63,11 +63,11 @@ static void serror(const char *s, ...) | |||
63 | va_start(ap, s); | 63 | va_start(ap, s); |
64 | 64 | ||
65 | if (use_syslog) { | 65 | if (use_syslog) { |
66 | openlog(applet_name, 0, LOG_LOCAL0); | 66 | openlog(bb_applet_name, 0, LOG_LOCAL0); |
67 | vsyslog(LOG_ERR, s, ap); | 67 | vsyslog(LOG_ERR, s, ap); |
68 | closelog(); | 68 | closelog(); |
69 | } else { | 69 | } else { |
70 | verror_msg(s, ap); | 70 | bb_verror_msg(s, ap); |
71 | putc('\n', stderr); | 71 | putc('\n', stderr); |
72 | } | 72 | } |
73 | 73 | ||
@@ -111,12 +111,12 @@ int nameif_main(int argc, char **argv) | |||
111 | use_syslog = 1; | 111 | use_syslog = 1; |
112 | break; | 112 | break; |
113 | default: | 113 | default: |
114 | show_usage(); | 114 | bb_show_usage(); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | if ((argc - optind) & 1) | 118 | if ((argc - optind) & 1) |
119 | show_usage(); | 119 | bb_show_usage(); |
120 | 120 | ||
121 | if (optind < argc) { | 121 | if (optind < argc) { |
122 | char **a = argv + optind; | 122 | char **a = argv + optind; |
@@ -126,7 +126,7 @@ int nameif_main(int argc, char **argv) | |||
126 | if (strlen(*a) > IF_NAMESIZE) | 126 | if (strlen(*a) > IF_NAMESIZE) |
127 | serror("interface name `%s' too long", *a); | 127 | serror("interface name `%s' too long", *a); |
128 | ch = xcalloc(1, sizeof(mactable_t)); | 128 | ch = xcalloc(1, sizeof(mactable_t)); |
129 | ch->ifname = xstrdup(*a++); | 129 | ch->ifname = bb_xstrdup(*a++); |
130 | ch->mac = cc_macaddr(*a++); | 130 | ch->mac = cc_macaddr(*a++); |
131 | if (clist) | 131 | if (clist) |
132 | clist->prev = ch; | 132 | clist->prev = ch; |
@@ -134,9 +134,9 @@ int nameif_main(int argc, char **argv) | |||
134 | clist = ch; | 134 | clist = ch; |
135 | } | 135 | } |
136 | } else { | 136 | } else { |
137 | ifh = xfopen(fname, "r"); | 137 | ifh = bb_xfopen(fname, "r"); |
138 | 138 | ||
139 | while ((line = get_line_from_file(ifh)) != NULL) { | 139 | while ((line = bb_get_line_from_file(ifh)) != NULL) { |
140 | char *line_ptr; | 140 | char *line_ptr; |
141 | size_t name_length; | 141 | size_t name_length; |
142 | 142 | ||
@@ -145,7 +145,7 @@ int nameif_main(int argc, char **argv) | |||
145 | continue; | 145 | continue; |
146 | name_length = strcspn(line_ptr, " \t"); | 146 | name_length = strcspn(line_ptr, " \t"); |
147 | ch = xcalloc(1, sizeof(mactable_t)); | 147 | ch = xcalloc(1, sizeof(mactable_t)); |
148 | ch->ifname = xstrndup(line_ptr, name_length); | 148 | ch->ifname = bb_xstrndup(line_ptr, name_length); |
149 | if (name_length > IF_NAMESIZE) | 149 | if (name_length > IF_NAMESIZE) |
150 | serror("interface name `%s' too long", ch->ifname); | 150 | serror("interface name `%s' too long", ch->ifname); |
151 | line_ptr += name_length; | 151 | line_ptr += name_length; |
diff --git a/networking/nc.c b/networking/nc.c index 63d8c5b19..4888ccceb 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -72,7 +72,7 @@ int nc_main(int argc, char **argv) | |||
72 | break; | 72 | break; |
73 | #endif | 73 | #endif |
74 | default: | 74 | default: |
75 | show_usage(); | 75 | bb_show_usage(); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
@@ -85,13 +85,13 @@ int nc_main(int argc, char **argv) | |||
85 | 85 | ||
86 | 86 | ||
87 | if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) | 87 | if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) |
88 | show_usage(); | 88 | bb_show_usage(); |
89 | 89 | ||
90 | if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) | 90 | if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) |
91 | perror_msg_and_die("socket"); | 91 | bb_perror_msg_and_die("socket"); |
92 | x = 1; | 92 | x = 1; |
93 | if (setsockopt (sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) | 93 | if (setsockopt (sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) |
94 | perror_msg_and_die ("reuseaddr failed"); | 94 | bb_perror_msg_and_die ("reuseaddr failed"); |
95 | address.sin_family = AF_INET; | 95 | address.sin_family = AF_INET; |
96 | 96 | ||
97 | if (lport != 0) { | 97 | if (lport != 0) { |
@@ -99,17 +99,17 @@ int nc_main(int argc, char **argv) | |||
99 | address.sin_port = htons(lport); | 99 | address.sin_port = htons(lport); |
100 | 100 | ||
101 | if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) | 101 | if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) |
102 | perror_msg_and_die("bind"); | 102 | bb_perror_msg_and_die("bind"); |
103 | } | 103 | } |
104 | 104 | ||
105 | if (do_listen) { | 105 | if (do_listen) { |
106 | socklen_t addrlen = sizeof(address); | 106 | socklen_t addrlen = sizeof(address); |
107 | 107 | ||
108 | if (listen(sfd, 1) < 0) | 108 | if (listen(sfd, 1) < 0) |
109 | perror_msg_and_die("listen"); | 109 | bb_perror_msg_and_die("listen"); |
110 | 110 | ||
111 | if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0) | 111 | if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0) |
112 | perror_msg_and_die("accept"); | 112 | bb_perror_msg_and_die("accept"); |
113 | 113 | ||
114 | close(sfd); | 114 | close(sfd); |
115 | sfd = tmpfd; | 115 | sfd = tmpfd; |
@@ -120,7 +120,7 @@ int nc_main(int argc, char **argv) | |||
120 | address.sin_port = htons(atoi(argv[optind+1])); | 120 | address.sin_port = htons(atoi(argv[optind+1])); |
121 | 121 | ||
122 | if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) | 122 | if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) |
123 | perror_msg_and_die("connect"); | 123 | bb_perror_msg_and_die("connect"); |
124 | } | 124 | } |
125 | 125 | ||
126 | #ifdef GAPING_SECURITY_HOLE | 126 | #ifdef GAPING_SECURITY_HOLE |
@@ -149,12 +149,12 @@ int nc_main(int argc, char **argv) | |||
149 | testfds = readfds; | 149 | testfds = readfds; |
150 | 150 | ||
151 | if (select(FD_SETSIZE, &testfds, NULL, NULL, NULL) < 0) | 151 | if (select(FD_SETSIZE, &testfds, NULL, NULL, NULL) < 0) |
152 | perror_msg_and_die("select"); | 152 | bb_perror_msg_and_die("select"); |
153 | 153 | ||
154 | for (fd = 0; fd < FD_SETSIZE; fd++) { | 154 | for (fd = 0; fd < FD_SETSIZE; fd++) { |
155 | if (FD_ISSET(fd, &testfds)) { | 155 | if (FD_ISSET(fd, &testfds)) { |
156 | if ((nread = safe_read(fd, buf, sizeof(buf))) < 0) | 156 | if ((nread = safe_read(fd, buf, sizeof(buf))) < 0) |
157 | perror_msg_and_die("read"); | 157 | bb_perror_msg_and_die("read"); |
158 | 158 | ||
159 | if (fd == sfd) { | 159 | if (fd == sfd) { |
160 | if (nread == 0) | 160 | if (nread == 0) |
@@ -166,8 +166,8 @@ int nc_main(int argc, char **argv) | |||
166 | ofd = sfd; | 166 | ofd = sfd; |
167 | } | 167 | } |
168 | 168 | ||
169 | if (full_write(ofd, buf, nread) < 0) | 169 | if (bb_full_write(ofd, buf, nread) < 0) |
170 | perror_msg_and_die("write"); | 170 | bb_perror_msg_and_die("write"); |
171 | if (delay > 0) { | 171 | if (delay > 0) { |
172 | sleep(delay); | 172 | sleep(delay); |
173 | } | 173 | } |
diff --git a/networking/netstat.c b/networking/netstat.c index d2b2d5ede..17a58876c 100644 --- a/networking/netstat.c +++ b/networking/netstat.c | |||
@@ -200,7 +200,7 @@ static void tcp_do_one(int lnr, const char *line) | |||
200 | } | 200 | } |
201 | 201 | ||
202 | if (num < 10) { | 202 | if (num < 10) { |
203 | error_msg("warning, got bogus tcp line."); | 203 | bb_error_msg("warning, got bogus tcp line."); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | state_str = tcp_state[state]; | 206 | state_str = tcp_state[state]; |
@@ -271,7 +271,7 @@ static void udp_do_one(int lnr, const char *line) | |||
271 | } | 271 | } |
272 | 272 | ||
273 | if (num < 10) { | 273 | if (num < 10) { |
274 | error_msg("warning, got bogus udp line."); | 274 | bb_error_msg("warning, got bogus udp line."); |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | switch (state) { | 277 | switch (state) { |
@@ -365,7 +365,7 @@ static void raw_do_one(int lnr, const char *line) | |||
365 | } | 365 | } |
366 | 366 | ||
367 | if (num < 10) { | 367 | if (num < 10) { |
368 | error_msg("warning, got bogus raw line."); | 368 | bb_error_msg("warning, got bogus raw line."); |
369 | return; | 369 | return; |
370 | } | 370 | } |
371 | state_str=itoa(state); | 371 | state_str=itoa(state); |
@@ -418,7 +418,7 @@ static void unix_do_one(int nr, const char *line) | |||
418 | num = sscanf(line, "%p: %lX %lX %lX %X %X %d %s", | 418 | num = sscanf(line, "%p: %lX %lX %lX %X %X %d %s", |
419 | &d, &refcnt, &proto, &unix_flags, &type, &state, &inode, path); | 419 | &d, &refcnt, &proto, &unix_flags, &type, &state, &inode, path); |
420 | if (num < 6) { | 420 | if (num < 6) { |
421 | error_msg("warning, got bogus unix line."); | 421 | bb_error_msg("warning, got bogus unix line."); |
422 | return; | 422 | return; |
423 | } | 423 | } |
424 | if (!(has & HAS_INODE)) | 424 | if (!(has & HAS_INODE)) |
@@ -539,7 +539,7 @@ static void do_info(const char *file, const char *name, void (*proc)(int, const | |||
539 | if (errno != ENOENT) { | 539 | if (errno != ENOENT) { |
540 | perror(file); | 540 | perror(file); |
541 | } else { | 541 | } else { |
542 | error_msg("no support for `%s' on this system.", name); | 542 | bb_error_msg("no support for `%s' on this system.", name); |
543 | } | 543 | } |
544 | } else { | 544 | } else { |
545 | do { | 545 | do { |
@@ -597,14 +597,14 @@ int netstat_main(int argc, char **argv) | |||
597 | new_flags |= NETSTAT_UNIX; | 597 | new_flags |= NETSTAT_UNIX; |
598 | break; | 598 | break; |
599 | default: | 599 | default: |
600 | show_usage(); | 600 | bb_show_usage(); |
601 | } | 601 | } |
602 | if ( showroute ) { | 602 | if ( showroute ) { |
603 | #ifdef CONFIG_ROUTE | 603 | #ifdef CONFIG_ROUTE |
604 | displayroutes ( flags & NETSTAT_NUMERIC, !extended ); | 604 | displayroutes ( flags & NETSTAT_NUMERIC, !extended ); |
605 | return 0; | 605 | return 0; |
606 | #else | 606 | #else |
607 | error_msg_and_die( "-r (display routing table) is not compiled in." ); | 607 | bb_error_msg_and_die( "-r (display routing table) is not compiled in." ); |
608 | #endif | 608 | #endif |
609 | } | 609 | } |
610 | 610 | ||
diff --git a/networking/nslookup.c b/networking/nslookup.c index edbc65650..0f3102e30 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
@@ -185,7 +185,7 @@ int nslookup_main(int argc, char **argv) | |||
185 | */ | 185 | */ |
186 | 186 | ||
187 | if (argc < 2 || *argv[1]=='-' || argc > 3) | 187 | if (argc < 2 || *argv[1]=='-' || argc > 3) |
188 | show_usage(); | 188 | bb_show_usage(); |
189 | else if(argc == 3) | 189 | else if(argc == 3) |
190 | set_default_dns(argv[2]); | 190 | set_default_dns(argv[2]); |
191 | 191 | ||
@@ -199,4 +199,4 @@ int nslookup_main(int argc, char **argv) | |||
199 | return EXIT_SUCCESS; | 199 | return EXIT_SUCCESS; |
200 | } | 200 | } |
201 | 201 | ||
202 | /* $Id: nslookup.c,v 1.29 2002/07/24 00:56:56 sandman Exp $ */ | 202 | /* $Id: nslookup.c,v 1.30 2003/03/19 09:12:38 mjn3 Exp $ */ |
diff --git a/networking/ping.c b/networking/ping.c index 044b547ac..28b38db14 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: ping.c,v 1.53 2003/01/12 06:08:33 andersen Exp $ | 3 | * $Id: ping.c,v 1.54 2003/03/19 09:12:38 mjn3 Exp $ |
4 | * Mini ping implementation for busybox | 4 | * Mini ping implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -208,7 +208,7 @@ static void ping(const char *host) | |||
208 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); | 208 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); |
209 | 209 | ||
210 | if (c < 0 || c != sizeof(packet)) | 210 | if (c < 0 || c != sizeof(packet)) |
211 | perror_msg_and_die("sendto"); | 211 | bb_perror_msg_and_die("sendto"); |
212 | 212 | ||
213 | signal(SIGALRM, noresp); | 213 | signal(SIGALRM, noresp); |
214 | alarm(5); /* give the host 5000ms to respond */ | 214 | alarm(5); /* give the host 5000ms to respond */ |
@@ -221,7 +221,7 @@ static void ping(const char *host) | |||
221 | (struct sockaddr *) &from, &fromlen)) < 0) { | 221 | (struct sockaddr *) &from, &fromlen)) < 0) { |
222 | if (errno == EINTR) | 222 | if (errno == EINTR) |
223 | continue; | 223 | continue; |
224 | perror_msg("recvfrom"); | 224 | bb_perror_msg("recvfrom"); |
225 | continue; | 225 | continue; |
226 | } | 226 | } |
227 | if (c >= 76) { /* ip + icmp */ | 227 | if (c >= 76) { /* ip + icmp */ |
@@ -241,7 +241,7 @@ extern int ping_main(int argc, char **argv) | |||
241 | argc--; | 241 | argc--; |
242 | argv++; | 242 | argv++; |
243 | if (argc < 1) | 243 | if (argc < 1) |
244 | show_usage(); | 244 | bb_show_usage(); |
245 | ping(*argv); | 245 | ping(*argv); |
246 | return EXIT_SUCCESS; | 246 | return EXIT_SUCCESS; |
247 | } | 247 | } |
@@ -313,9 +313,9 @@ static void sendping(int junk) | |||
313 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); | 313 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); |
314 | 314 | ||
315 | if (i < 0) | 315 | if (i < 0) |
316 | perror_msg_and_die("sendto"); | 316 | bb_perror_msg_and_die("sendto"); |
317 | else if ((size_t)i != sizeof(packet)) | 317 | else if ((size_t)i != sizeof(packet)) |
318 | error_msg_and_die("ping wrote %d chars; %d expected", i, | 318 | bb_error_msg_and_die("ping wrote %d chars; %d expected", i, |
319 | (int)sizeof(packet)); | 319 | (int)sizeof(packet)); |
320 | 320 | ||
321 | signal(SIGALRM, sendping); | 321 | signal(SIGALRM, sendping); |
@@ -410,7 +410,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) | |||
410 | printf("\n"); | 410 | printf("\n"); |
411 | } else | 411 | } else |
412 | if (icmppkt->icmp_type != ICMP_ECHO) | 412 | if (icmppkt->icmp_type != ICMP_ECHO) |
413 | error_msg("Warning: Got ICMP %d (%s)", | 413 | bb_error_msg("Warning: Got ICMP %d (%s)", |
414 | icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); | 414 | icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); |
415 | } | 415 | } |
416 | 416 | ||
@@ -426,7 +426,7 @@ static void ping(const char *host) | |||
426 | pingaddr.sin_family = AF_INET; | 426 | pingaddr.sin_family = AF_INET; |
427 | hostent = xgethostbyname(host); | 427 | hostent = xgethostbyname(host); |
428 | if (hostent->h_addrtype != AF_INET) | 428 | if (hostent->h_addrtype != AF_INET) |
429 | error_msg_and_die("unknown address type; only AF_INET is currently supported."); | 429 | bb_error_msg_and_die("unknown address type; only AF_INET is currently supported."); |
430 | 430 | ||
431 | memcpy(&pingaddr.sin_addr, hostent->h_addr, sizeof(pingaddr.sin_addr)); | 431 | memcpy(&pingaddr.sin_addr, hostent->h_addr, sizeof(pingaddr.sin_addr)); |
432 | 432 | ||
@@ -460,7 +460,7 @@ static void ping(const char *host) | |||
460 | (struct sockaddr *) &from, &fromlen)) < 0) { | 460 | (struct sockaddr *) &from, &fromlen)) < 0) { |
461 | if (errno == EINTR) | 461 | if (errno == EINTR) |
462 | continue; | 462 | continue; |
463 | perror_msg("recvfrom"); | 463 | bb_perror_msg("recvfrom"); |
464 | continue; | 464 | continue; |
465 | } | 465 | } |
466 | unpack(packet, c, &from); | 466 | unpack(packet, c, &from); |
@@ -489,24 +489,24 @@ extern int ping_main(int argc, char **argv) | |||
489 | break; | 489 | break; |
490 | case 'c': | 490 | case 'c': |
491 | if (--argc <= 0) | 491 | if (--argc <= 0) |
492 | show_usage(); | 492 | bb_show_usage(); |
493 | argv++; | 493 | argv++; |
494 | pingcount = atoi(*argv); | 494 | pingcount = atoi(*argv); |
495 | break; | 495 | break; |
496 | case 's': | 496 | case 's': |
497 | if (--argc <= 0) | 497 | if (--argc <= 0) |
498 | show_usage(); | 498 | bb_show_usage(); |
499 | argv++; | 499 | argv++; |
500 | datalen = atoi(*argv); | 500 | datalen = atoi(*argv); |
501 | break; | 501 | break; |
502 | default: | 502 | default: |
503 | show_usage(); | 503 | bb_show_usage(); |
504 | } | 504 | } |
505 | argc--; | 505 | argc--; |
506 | argv++; | 506 | argv++; |
507 | } | 507 | } |
508 | if (argc < 1) | 508 | if (argc < 1) |
509 | show_usage(); | 509 | bb_show_usage(); |
510 | 510 | ||
511 | myid = getpid() & 0xFFFF; | 511 | myid = getpid() & 0xFFFF; |
512 | ping(*argv); | 512 | ping(*argv); |
diff --git a/networking/ping6.c b/networking/ping6.c index f1ccff483..c40624219 100644 --- a/networking/ping6.c +++ b/networking/ping6.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: ping6.c,v 1.3 2003/01/12 06:08:33 andersen Exp $ | 3 | * $Id: ping6.c,v 1.4 2003/03/19 09:12:38 mjn3 Exp $ |
4 | * Mini ping implementation for busybox | 4 | * Mini ping implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -112,7 +112,7 @@ static void ping(const char *host) | |||
112 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); | 112 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); |
113 | 113 | ||
114 | if (c < 0 || c != sizeof(packet)) | 114 | if (c < 0 || c != sizeof(packet)) |
115 | perror_msg_and_die("sendto"); | 115 | bb_perror_msg_and_die("sendto"); |
116 | 116 | ||
117 | signal(SIGALRM, noresp); | 117 | signal(SIGALRM, noresp); |
118 | alarm(5); /* give the host 5000ms to respond */ | 118 | alarm(5); /* give the host 5000ms to respond */ |
@@ -125,7 +125,7 @@ static void ping(const char *host) | |||
125 | (struct sockaddr *) &from, &fromlen)) < 0) { | 125 | (struct sockaddr *) &from, &fromlen)) < 0) { |
126 | if (errno == EINTR) | 126 | if (errno == EINTR) |
127 | continue; | 127 | continue; |
128 | perror_msg("recvfrom"); | 128 | bb_perror_msg("recvfrom"); |
129 | continue; | 129 | continue; |
130 | } | 130 | } |
131 | if (c >= 8) { /* icmp6_hdr */ | 131 | if (c >= 8) { /* icmp6_hdr */ |
@@ -143,7 +143,7 @@ extern int ping6_main(int argc, char **argv) | |||
143 | argc--; | 143 | argc--; |
144 | argv++; | 144 | argv++; |
145 | if (argc < 1) | 145 | if (argc < 1) |
146 | show_usage(); | 146 | bb_show_usage(); |
147 | ping(*argv); | 147 | ping(*argv); |
148 | return EXIT_SUCCESS; | 148 | return EXIT_SUCCESS; |
149 | } | 149 | } |
@@ -218,9 +218,9 @@ static void sendping(int junk) | |||
218 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); | 218 | (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); |
219 | 219 | ||
220 | if (i < 0) | 220 | if (i < 0) |
221 | perror_msg_and_die("sendto"); | 221 | bb_perror_msg_and_die("sendto"); |
222 | else if ((size_t)i != sizeof(packet)) | 222 | else if ((size_t)i != sizeof(packet)) |
223 | error_msg_and_die("ping wrote %d chars; %d expected", i, | 223 | bb_error_msg_and_die("ping wrote %d chars; %d expected", i, |
224 | (int)sizeof(packet)); | 224 | (int)sizeof(packet)); |
225 | 225 | ||
226 | signal(SIGALRM, sendping); | 226 | signal(SIGALRM, sendping); |
@@ -308,7 +308,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit | |||
308 | printf("\n"); | 308 | printf("\n"); |
309 | } else | 309 | } else |
310 | if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) | 310 | if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) |
311 | error_msg("Warning: Got ICMP %d (%s)", | 311 | bb_error_msg("Warning: Got ICMP %d (%s)", |
312 | icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type)); | 312 | icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type)); |
313 | } | 313 | } |
314 | 314 | ||
@@ -329,7 +329,7 @@ static void ping(const char *host) | |||
329 | pingaddr.sin6_family = AF_INET6; | 329 | pingaddr.sin6_family = AF_INET6; |
330 | hostent = xgethostbyname2(host, AF_INET6); | 330 | hostent = xgethostbyname2(host, AF_INET6); |
331 | if (hostent->h_addrtype != AF_INET6) | 331 | if (hostent->h_addrtype != AF_INET6) |
332 | error_msg_and_die("unknown address type; only AF_INET6 is currently supported."); | 332 | bb_error_msg_and_die("unknown address type; only AF_INET6 is currently supported."); |
333 | 333 | ||
334 | memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr)); | 334 | memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr)); |
335 | 335 | ||
@@ -350,7 +350,7 @@ static void ping(const char *host) | |||
350 | } | 350 | } |
351 | if (setsockopt(pingsock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt, | 351 | if (setsockopt(pingsock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt, |
352 | sizeof(filt)) < 0) | 352 | sizeof(filt)) < 0) |
353 | error_msg_and_die("setsockopt(ICMP6_FILTER)"); | 353 | bb_error_msg_and_die("setsockopt(ICMP6_FILTER)"); |
354 | } | 354 | } |
355 | #endif /*ICMP6_FILTER*/ | 355 | #endif /*ICMP6_FILTER*/ |
356 | 356 | ||
@@ -374,7 +374,7 @@ static void ping(const char *host) | |||
374 | 374 | ||
375 | if (ifname) { | 375 | if (ifname) { |
376 | if ((pingaddr.sin6_scope_id = if_nametoindex(ifname)) == 0) | 376 | if ((pingaddr.sin6_scope_id = if_nametoindex(ifname)) == 0) |
377 | error_msg_and_die("%s: invalid interface name", ifname); | 377 | bb_error_msg_and_die("%s: invalid interface name", ifname); |
378 | } | 378 | } |
379 | 379 | ||
380 | printf("PING %s (%s): %d data bytes\n", | 380 | printf("PING %s (%s): %d data bytes\n", |
@@ -405,7 +405,7 @@ static void ping(const char *host) | |||
405 | if ((c = recvmsg(pingsock, &msg, 0)) < 0) { | 405 | if ((c = recvmsg(pingsock, &msg, 0)) < 0) { |
406 | if (errno == EINTR) | 406 | if (errno == EINTR) |
407 | continue; | 407 | continue; |
408 | perror_msg("recvfrom"); | 408 | bb_perror_msg("recvfrom"); |
409 | continue; | 409 | continue; |
410 | } | 410 | } |
411 | for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; | 411 | for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; |
@@ -446,30 +446,30 @@ extern int ping6_main(int argc, char **argv) | |||
446 | break; | 446 | break; |
447 | case 'c': | 447 | case 'c': |
448 | if (--argc <= 0) | 448 | if (--argc <= 0) |
449 | show_usage(); | 449 | bb_show_usage(); |
450 | argv++; | 450 | argv++; |
451 | pingcount = atoi(*argv); | 451 | pingcount = atoi(*argv); |
452 | break; | 452 | break; |
453 | case 's': | 453 | case 's': |
454 | if (--argc <= 0) | 454 | if (--argc <= 0) |
455 | show_usage(); | 455 | bb_show_usage(); |
456 | argv++; | 456 | argv++; |
457 | datalen = atoi(*argv); | 457 | datalen = atoi(*argv); |
458 | break; | 458 | break; |
459 | case 'I': | 459 | case 'I': |
460 | if (--argc <= 0) | 460 | if (--argc <= 0) |
461 | show_usage(); | 461 | bb_show_usage(); |
462 | argv++; | 462 | argv++; |
463 | ifname = *argv; | 463 | ifname = *argv; |
464 | break; | 464 | break; |
465 | default: | 465 | default: |
466 | show_usage(); | 466 | bb_show_usage(); |
467 | } | 467 | } |
468 | argc--; | 468 | argc--; |
469 | argv++; | 469 | argv++; |
470 | } | 470 | } |
471 | if (argc < 1) | 471 | if (argc < 1) |
472 | show_usage(); | 472 | bb_show_usage(); |
473 | 473 | ||
474 | myid = getpid() & 0xFFFF; | 474 | myid = getpid() & 0xFFFF; |
475 | ping(*argv); | 475 | ping(*argv); |
diff --git a/networking/route.c b/networking/route.c index b564c6dcd..083149a3d 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * Foundation; either version 2 of the License, or (at | 15 | * Foundation; either version 2 of the License, or (at |
16 | * your option) any later version. | 16 | * your option) any later version. |
17 | * | 17 | * |
18 | * $Id: route.c,v 1.21 2002/12/16 22:04:18 sandman Exp $ | 18 | * $Id: route.c,v 1.22 2003/03/19 09:12:39 mjn3 Exp $ |
19 | * | 19 | * |
20 | * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> | 20 | * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> |
21 | * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> | 21 | * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> |
@@ -88,7 +88,7 @@ static int INET_setroute(int action, int options, char **args) | |||
88 | xflag = 0; | 88 | xflag = 0; |
89 | 89 | ||
90 | if (*args == NULL) | 90 | if (*args == NULL) |
91 | show_usage(); | 91 | bb_show_usage(); |
92 | if (strcmp(*args, "-net") == 0) { | 92 | if (strcmp(*args, "-net") == 0) { |
93 | xflag = 1; | 93 | xflag = 1; |
94 | args++; | 94 | args++; |
@@ -97,7 +97,7 @@ static int INET_setroute(int action, int options, char **args) | |||
97 | args++; | 97 | args++; |
98 | } | 98 | } |
99 | if (*args == NULL) | 99 | if (*args == NULL) |
100 | show_usage(); | 100 | bb_show_usage(); |
101 | safe_strncpy(target, *args++, (sizeof target)); | 101 | safe_strncpy(target, *args++, (sizeof target)); |
102 | 102 | ||
103 | /* Clean out the RTREQ structure. */ | 103 | /* Clean out the RTREQ structure. */ |
@@ -107,7 +107,7 @@ static int INET_setroute(int action, int options, char **args) | |||
107 | if ((isnet = | 107 | if ((isnet = |
108 | INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, | 108 | INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, |
109 | xflag != 1)) < 0) { | 109 | xflag != 1)) < 0) { |
110 | error_msg(_("can't resolve %s"), target); | 110 | bb_error_msg(_("can't resolve %s"), target); |
111 | return EXIT_FAILURE; /* XXX change to E_something */ | 111 | return EXIT_FAILURE; /* XXX change to E_something */ |
112 | } | 112 | } |
113 | 113 | ||
@@ -135,7 +135,7 @@ static int INET_setroute(int action, int options, char **args) | |||
135 | 135 | ||
136 | args++; | 136 | args++; |
137 | if (!*args || !isdigit(**args)) | 137 | if (!*args || !isdigit(**args)) |
138 | show_usage(); | 138 | bb_show_usage(); |
139 | metric = atoi(*args); | 139 | metric = atoi(*args); |
140 | #if HAVE_NEW_ADDRT | 140 | #if HAVE_NEW_ADDRT |
141 | rt.rt_metric = metric + 1; | 141 | rt.rt_metric = metric + 1; |
@@ -151,12 +151,12 @@ static int INET_setroute(int action, int options, char **args) | |||
151 | 151 | ||
152 | args++; | 152 | args++; |
153 | if (!*args || mask_in_addr(rt)) | 153 | if (!*args || mask_in_addr(rt)) |
154 | show_usage(); | 154 | bb_show_usage(); |
155 | netmask = *args; | 155 | netmask = *args; |
156 | if ((isnet = | 156 | if ((isnet = |
157 | INET_resolve(netmask, (struct sockaddr_in *) &mask, | 157 | INET_resolve(netmask, (struct sockaddr_in *) &mask, |
158 | 0)) < 0) { | 158 | 0)) < 0) { |
159 | error_msg(_("can't resolve netmask %s"), netmask); | 159 | bb_error_msg(_("can't resolve netmask %s"), netmask); |
160 | return E_LOOKUP; | 160 | return E_LOOKUP; |
161 | } | 161 | } |
162 | rt.rt_genmask = full_mask(mask); | 162 | rt.rt_genmask = full_mask(mask); |
@@ -167,18 +167,18 @@ static int INET_setroute(int action, int options, char **args) | |||
167 | if (strcmp(*args, "gw") == 0 || strcmp(*args, "gateway") == 0) { | 167 | if (strcmp(*args, "gw") == 0 || strcmp(*args, "gateway") == 0) { |
168 | args++; | 168 | args++; |
169 | if (!*args) | 169 | if (!*args) |
170 | show_usage(); | 170 | bb_show_usage(); |
171 | if (rt.rt_flags & RTF_GATEWAY) | 171 | if (rt.rt_flags & RTF_GATEWAY) |
172 | show_usage(); | 172 | bb_show_usage(); |
173 | safe_strncpy(gateway, *args, (sizeof gateway)); | 173 | safe_strncpy(gateway, *args, (sizeof gateway)); |
174 | if ((isnet = | 174 | if ((isnet = |
175 | INET_resolve(gateway, (struct sockaddr_in *) &rt.rt_gateway, | 175 | INET_resolve(gateway, (struct sockaddr_in *) &rt.rt_gateway, |
176 | 1)) < 0) { | 176 | 1)) < 0) { |
177 | error_msg(_("can't resolve gw %s"), gateway); | 177 | bb_error_msg(_("can't resolve gw %s"), gateway); |
178 | return E_LOOKUP; | 178 | return E_LOOKUP; |
179 | } | 179 | } |
180 | if (isnet) { | 180 | if (isnet) { |
181 | error_msg(_("%s: cannot use a NETWORK as gateway!"), gateway); | 181 | bb_error_msg(_("%s: cannot use a NETWORK as gateway!"), gateway); |
182 | return E_OPTERR; | 182 | return E_OPTERR; |
183 | } | 183 | } |
184 | rt.rt_flags |= RTF_GATEWAY; | 184 | rt.rt_flags |= RTF_GATEWAY; |
@@ -190,11 +190,11 @@ static int INET_setroute(int action, int options, char **args) | |||
190 | args++; | 190 | args++; |
191 | rt.rt_flags |= RTF_MSS; | 191 | rt.rt_flags |= RTF_MSS; |
192 | if (!*args) | 192 | if (!*args) |
193 | show_usage(); | 193 | bb_show_usage(); |
194 | rt.rt_mss = atoi(*args); | 194 | rt.rt_mss = atoi(*args); |
195 | args++; | 195 | args++; |
196 | if (rt.rt_mss < 64 || rt.rt_mss > 32768) { | 196 | if (rt.rt_mss < 64 || rt.rt_mss > 32768) { |
197 | error_msg(_("Invalid MSS.")); | 197 | bb_error_msg(_("Invalid MSS.")); |
198 | return E_OPTERR; | 198 | return E_OPTERR; |
199 | } | 199 | } |
200 | continue; | 200 | continue; |
@@ -203,12 +203,12 @@ static int INET_setroute(int action, int options, char **args) | |||
203 | if (strcmp(*args, "window") == 0) { | 203 | if (strcmp(*args, "window") == 0) { |
204 | args++; | 204 | args++; |
205 | if (!*args) | 205 | if (!*args) |
206 | show_usage(); | 206 | bb_show_usage(); |
207 | rt.rt_flags |= RTF_WINDOW; | 207 | rt.rt_flags |= RTF_WINDOW; |
208 | rt.rt_window = atoi(*args); | 208 | rt.rt_window = atoi(*args); |
209 | args++; | 209 | args++; |
210 | if (rt.rt_window < 128) { | 210 | if (rt.rt_window < 128) { |
211 | error_msg(_("Invalid window.")); | 211 | bb_error_msg(_("Invalid window.")); |
212 | return E_OPTERR; | 212 | return E_OPTERR; |
213 | } | 213 | } |
214 | continue; | 214 | continue; |
@@ -217,7 +217,7 @@ static int INET_setroute(int action, int options, char **args) | |||
217 | if (strcmp(*args, "irtt") == 0) { | 217 | if (strcmp(*args, "irtt") == 0) { |
218 | args++; | 218 | args++; |
219 | if (!*args) | 219 | if (!*args) |
220 | show_usage(); | 220 | bb_show_usage(); |
221 | args++; | 221 | args++; |
222 | #if HAVE_RTF_IRTT | 222 | #if HAVE_RTF_IRTT |
223 | rt.rt_flags |= RTF_IRTT; | 223 | rt.rt_flags |= RTF_IRTT; |
@@ -225,7 +225,7 @@ static int INET_setroute(int action, int options, char **args) | |||
225 | rt.rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ | 225 | rt.rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ |
226 | #if 0 /* FIXME: do we need to check anything of this? */ | 226 | #if 0 /* FIXME: do we need to check anything of this? */ |
227 | if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { | 227 | if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { |
228 | error_msg(_("Invalid initial rtt.")); | 228 | bb_error_msg(_("Invalid initial rtt.")); |
229 | return E_OPTERR; | 229 | return E_OPTERR; |
230 | } | 230 | } |
231 | #endif | 231 | #endif |
@@ -262,7 +262,7 @@ static int INET_setroute(int action, int options, char **args) | |||
262 | if (strcmp(*args, "device") == 0 || strcmp(*args, "dev") == 0) { | 262 | if (strcmp(*args, "device") == 0 || strcmp(*args, "dev") == 0) { |
263 | args++; | 263 | args++; |
264 | if (rt.rt_dev || *args == NULL) | 264 | if (rt.rt_dev || *args == NULL) |
265 | show_usage(); | 265 | bb_show_usage(); |
266 | rt.rt_dev = *args++; | 266 | rt.rt_dev = *args++; |
267 | continue; | 267 | continue; |
268 | } | 268 | } |
@@ -270,9 +270,9 @@ static int INET_setroute(int action, int options, char **args) | |||
270 | if (!rt.rt_dev) { | 270 | if (!rt.rt_dev) { |
271 | rt.rt_dev = *args++; | 271 | rt.rt_dev = *args++; |
272 | if (*args) | 272 | if (*args) |
273 | show_usage(); /* must be last to catch typos */ | 273 | bb_show_usage(); /* must be last to catch typos */ |
274 | } else { | 274 | } else { |
275 | show_usage(); | 275 | bb_show_usage(); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
@@ -287,17 +287,17 @@ static int INET_setroute(int action, int options, char **args) | |||
287 | 287 | ||
288 | mask = ~ntohl(mask); | 288 | mask = ~ntohl(mask); |
289 | if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) { | 289 | if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) { |
290 | error_msg(_("netmask %.8x doesn't make sense with host route"), | 290 | bb_error_msg(_("netmask %.8x doesn't make sense with host route"), |
291 | (unsigned int) mask); | 291 | (unsigned int) mask); |
292 | return E_OPTERR; | 292 | return E_OPTERR; |
293 | } | 293 | } |
294 | if (mask & (mask + 1)) { | 294 | if (mask & (mask + 1)) { |
295 | error_msg(_("bogus netmask %s"), netmask); | 295 | bb_error_msg(_("bogus netmask %s"), netmask); |
296 | return E_OPTERR; | 296 | return E_OPTERR; |
297 | } | 297 | } |
298 | mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr; | 298 | mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr; |
299 | if (mask & ~mask_in_addr(rt)) { | 299 | if (mask & ~mask_in_addr(rt)) { |
300 | error_msg(_("netmask doesn't match route address")); | 300 | bb_error_msg(_("netmask doesn't match route address")); |
301 | return E_OPTERR; | 301 | return E_OPTERR; |
302 | } | 302 | } |
303 | } | 303 | } |
@@ -343,7 +343,7 @@ static int INET6_setroute(int action, int options, char **args) | |||
343 | int skfd; | 343 | int skfd; |
344 | 344 | ||
345 | if (*args == NULL) | 345 | if (*args == NULL) |
346 | show_usage(); | 346 | bb_show_usage(); |
347 | 347 | ||
348 | strcpy(target, *args++); | 348 | strcpy(target, *args++); |
349 | if (!strcmp(target, "default")) { | 349 | if (!strcmp(target, "default")) { |
@@ -353,13 +353,13 @@ static int INET6_setroute(int action, int options, char **args) | |||
353 | if ((cp = strchr(target, '/'))) { | 353 | if ((cp = strchr(target, '/'))) { |
354 | prefix_len = atol(cp + 1); | 354 | prefix_len = atol(cp + 1); |
355 | if ((prefix_len < 0) || (prefix_len > 128)) | 355 | if ((prefix_len < 0) || (prefix_len > 128)) |
356 | show_usage(); | 356 | bb_show_usage(); |
357 | *cp = 0; | 357 | *cp = 0; |
358 | } else { | 358 | } else { |
359 | prefix_len = 128; | 359 | prefix_len = 128; |
360 | } | 360 | } |
361 | if (INET6_resolve(target, (struct sockaddr_in6 *) &sa6) < 0) { | 361 | if (INET6_resolve(target, (struct sockaddr_in6 *) &sa6) < 0) { |
362 | error_msg(_("can't resolve %s"), target); | 362 | bb_error_msg(_("can't resolve %s"), target); |
363 | return EXIT_FAILURE; /* XXX change to E_something */ | 363 | return EXIT_FAILURE; /* XXX change to E_something */ |
364 | } | 364 | } |
365 | } | 365 | } |
@@ -381,7 +381,7 @@ static int INET6_setroute(int action, int options, char **args) | |||
381 | 381 | ||
382 | args++; | 382 | args++; |
383 | if (!*args || !isdigit(**args)) | 383 | if (!*args || !isdigit(**args)) |
384 | show_usage(); | 384 | bb_show_usage(); |
385 | metric = atoi(*args); | 385 | metric = atoi(*args); |
386 | rt.rtmsg_metric = metric; | 386 | rt.rtmsg_metric = metric; |
387 | args++; | 387 | args++; |
@@ -390,12 +390,12 @@ static int INET6_setroute(int action, int options, char **args) | |||
390 | if (!strcmp(*args, "gw") || !strcmp(*args, "gateway")) { | 390 | if (!strcmp(*args, "gw") || !strcmp(*args, "gateway")) { |
391 | args++; | 391 | args++; |
392 | if (!*args) | 392 | if (!*args) |
393 | show_usage(); | 393 | bb_show_usage(); |
394 | if (rt.rtmsg_flags & RTF_GATEWAY) | 394 | if (rt.rtmsg_flags & RTF_GATEWAY) |
395 | show_usage(); | 395 | bb_show_usage(); |
396 | strcpy(gateway, *args); | 396 | strcpy(gateway, *args); |
397 | if (INET6_resolve(gateway, (struct sockaddr_in6 *) &sa6) < 0) { | 397 | if (INET6_resolve(gateway, (struct sockaddr_in6 *) &sa6) < 0) { |
398 | error_msg(_("can't resolve gw %s"), gateway); | 398 | bb_error_msg(_("can't resolve gw %s"), gateway); |
399 | return (E_LOOKUP); | 399 | return (E_LOOKUP); |
400 | } | 400 | } |
401 | memcpy(&rt.rtmsg_gateway, sa6.sin6_addr.s6_addr, | 401 | memcpy(&rt.rtmsg_gateway, sa6.sin6_addr.s6_addr, |
@@ -417,9 +417,9 @@ static int INET6_setroute(int action, int options, char **args) | |||
417 | if (!strcmp(*args, "device") || !strcmp(*args, "dev")) { | 417 | if (!strcmp(*args, "device") || !strcmp(*args, "dev")) { |
418 | args++; | 418 | args++; |
419 | if (!*args) | 419 | if (!*args) |
420 | show_usage(); | 420 | bb_show_usage(); |
421 | } else if (args[1]) | 421 | } else if (args[1]) |
422 | show_usage(); | 422 | bb_show_usage(); |
423 | 423 | ||
424 | devname = *args; | 424 | devname = *args; |
425 | args++; | 425 | args++; |
@@ -493,7 +493,7 @@ void displayroutes(int noresolve, int netstatfmt) | |||
493 | 493 | ||
494 | char sdest[16], sgw[16]; | 494 | char sdest[16], sgw[16]; |
495 | 495 | ||
496 | FILE *fp = xfopen("/proc/net/route", "r"); | 496 | FILE *fp = bb_xfopen("/proc/net/route", "r"); |
497 | 497 | ||
498 | if (noresolve) | 498 | if (noresolve) |
499 | noresolve = 0x0fff; | 499 | noresolve = 0x0fff; |
@@ -515,7 +515,7 @@ void displayroutes(int noresolve, int netstatfmt) | |||
515 | if (sscanf(buff + ifl + 1, "%lx%lx%X%d%d%d%lx%d%d%d", | 515 | if (sscanf(buff + ifl + 1, "%lx%lx%X%d%d%d%lx%d%d%d", |
516 | &d, &g, &flgs, &ref, &use, &metric, &m, &mtu, &win, | 516 | &d, &g, &flgs, &ref, &use, &metric, &m, &mtu, &win, |
517 | &ir) != 10) { | 517 | &ir) != 10) { |
518 | error_msg_and_die("Unsuported kernel route format\n"); | 518 | bb_error_msg_and_die("Unsuported kernel route format\n"); |
519 | } | 519 | } |
520 | ifl = 0; /* parse flags */ | 520 | ifl = 0; /* parse flags */ |
521 | if (flgs & RTF_UP) { | 521 | if (flgs & RTF_UP) { |
@@ -570,7 +570,7 @@ static void INET6_displayroutes(int noresolve) | |||
570 | 570 | ||
571 | char addr6p[8][5], saddr6p[8][5], naddr6p[8][5]; | 571 | char addr6p[8][5], saddr6p[8][5], naddr6p[8][5]; |
572 | 572 | ||
573 | FILE *fp = xfopen("/proc/net/ipv6_route", "r"); | 573 | FILE *fp = bb_xfopen("/proc/net/ipv6_route", "r"); |
574 | 574 | ||
575 | flags[0] = 'U'; | 575 | flags[0] = 'U'; |
576 | 576 | ||
@@ -598,7 +598,7 @@ static void INET6_displayroutes(int noresolve) | |||
598 | naddr6p[0], naddr6p[1], naddr6p[2], naddr6p[3], | 598 | naddr6p[0], naddr6p[1], naddr6p[2], naddr6p[3], |
599 | naddr6p[4], naddr6p[5], naddr6p[6], naddr6p[7], | 599 | naddr6p[4], naddr6p[5], naddr6p[6], naddr6p[7], |
600 | &metric, &use, &refcnt, &iflags, iface) != 31) { | 600 | &metric, &use, &refcnt, &iflags, iface) != 31) { |
601 | error_msg_and_die("Unsuported kernel route format\n"); | 601 | bb_error_msg_and_die("Unsuported kernel route format\n"); |
602 | } | 602 | } |
603 | 603 | ||
604 | ifl = 1; /* parse flags */ | 604 | ifl = 1; /* parse flags */ |
@@ -673,7 +673,7 @@ int route_main(int argc, char **argv) | |||
673 | break; | 673 | break; |
674 | #endif | 674 | #endif |
675 | default: | 675 | default: |
676 | show_usage(); | 676 | bb_show_usage(); |
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
@@ -694,7 +694,7 @@ int route_main(int argc, char **argv) | |||
694 | else if (strcmp(argv[1], "flush") == 0) | 694 | else if (strcmp(argv[1], "flush") == 0) |
695 | what = RTACTION_FLUSH; | 695 | what = RTACTION_FLUSH; |
696 | else | 696 | else |
697 | show_usage(); | 697 | bb_show_usage(); |
698 | } | 698 | } |
699 | 699 | ||
700 | #ifdef CONFIG_FEATURE_IPV6 | 700 | #ifdef CONFIG_FEATURE_IPV6 |
diff --git a/networking/telnet.c b/networking/telnet.c index 0c794b62f..8f2573c27 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -604,7 +604,7 @@ extern int telnet_main(int argc, char** argv) | |||
604 | G.termios_raw = G.termios_def; | 604 | G.termios_raw = G.termios_def; |
605 | cfmakeraw(&G.termios_raw); | 605 | cfmakeraw(&G.termios_raw); |
606 | 606 | ||
607 | if (argc < 2) show_usage(); | 607 | if (argc < 2) bb_show_usage(); |
608 | port = (argc > 2)? argv[2] : "23"; | 608 | port = (argc > 2)? argv[2] : "23"; |
609 | 609 | ||
610 | host = argv[1]; | 610 | host = argv[1]; |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 8634a4233..077194cfd 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: telnetd.c,v 1.4 2003/01/22 21:09:48 bug1 Exp $ | 1 | /* $Id: telnetd.c,v 1.5 2003/03/19 09:12:39 mjn3 Exp $ |
2 | * | 2 | * |
3 | * Simple telnet server | 3 | * Simple telnet server |
4 | * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) | 4 | * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) |
@@ -380,12 +380,12 @@ telnetd_main(int argc, char **argv) | |||
380 | break; | 380 | break; |
381 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ | 381 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ |
382 | default: | 382 | default: |
383 | show_usage(); | 383 | bb_show_usage(); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | if (access(loginpath, X_OK) < 0) { | 387 | if (access(loginpath, X_OK) < 0) { |
388 | error_msg_and_die ("'%s' unavailable.", loginpath); | 388 | bb_error_msg_and_die ("'%s' unavailable.", loginpath); |
389 | } | 389 | } |
390 | 390 | ||
391 | argv_init[0] = loginpath; | 391 | argv_init[0] = loginpath; |
@@ -400,7 +400,7 @@ telnetd_main(int argc, char **argv) | |||
400 | 400 | ||
401 | master_fd = socket(AF_INET, SOCK_STREAM, 0); | 401 | master_fd = socket(AF_INET, SOCK_STREAM, 0); |
402 | if (master_fd < 0) { | 402 | if (master_fd < 0) { |
403 | perror_msg_and_die("socket"); | 403 | bb_perror_msg_and_die("socket"); |
404 | } | 404 | } |
405 | (void)setsockopt(master_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); | 405 | (void)setsockopt(master_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
406 | 406 | ||
@@ -411,15 +411,15 @@ telnetd_main(int argc, char **argv) | |||
411 | sa.sin_port = htons(portnbr); | 411 | sa.sin_port = htons(portnbr); |
412 | 412 | ||
413 | if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { | 413 | if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { |
414 | perror_msg_and_die("bind"); | 414 | bb_perror_msg_and_die("bind"); |
415 | } | 415 | } |
416 | 416 | ||
417 | if (listen(master_fd, 1) < 0) { | 417 | if (listen(master_fd, 1) < 0) { |
418 | perror_msg_and_die("listen"); | 418 | bb_perror_msg_and_die("listen"); |
419 | } | 419 | } |
420 | 420 | ||
421 | if (daemon(0, 0) < 0) | 421 | if (daemon(0, 0) < 0) |
422 | perror_msg_and_die("daemon"); | 422 | bb_perror_msg_and_die("daemon"); |
423 | 423 | ||
424 | 424 | ||
425 | maxfd = master_fd; | 425 | maxfd = master_fd; |
diff --git a/networking/tftp.c b/networking/tftp.c index 378ba2fef..a33b5c21e 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -60,7 +60,7 @@ | |||
60 | #define TFTP_ERROR 5 | 60 | #define TFTP_ERROR 5 |
61 | #define TFTP_OACK 6 | 61 | #define TFTP_OACK 6 |
62 | 62 | ||
63 | static const char *tftp_error_msg[] = { | 63 | static const char *tftp_bb_error_msg[] = { |
64 | "Undefined error", | 64 | "Undefined error", |
65 | "File not found", | 65 | "File not found", |
66 | "Access violation", | 66 | "Access violation", |
@@ -86,7 +86,7 @@ static int tftp_blocksize_check(int blocksize, int bufsize) | |||
86 | 86 | ||
87 | if ((bufsize && (blocksize > bufsize)) || | 87 | if ((bufsize && (blocksize > bufsize)) || |
88 | (blocksize < 8) || (blocksize > 65464)) { | 88 | (blocksize < 8) || (blocksize > 65464)) { |
89 | error_msg("bad blocksize"); | 89 | bb_error_msg("bad blocksize"); |
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
@@ -169,7 +169,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
169 | tftp_bufsize += 4; | 169 | tftp_bufsize += 4; |
170 | 170 | ||
171 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { | 171 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { |
172 | perror_msg("socket"); | 172 | bb_perror_msg("socket"); |
173 | return EXIT_FAILURE; | 173 | return EXIT_FAILURE; |
174 | } | 174 | } |
175 | 175 | ||
@@ -223,7 +223,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
223 | } | 223 | } |
224 | 224 | ||
225 | if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) { | 225 | if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) { |
226 | error_msg("too long remote-filename"); | 226 | bb_error_msg("too long remote-filename"); |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | 229 | ||
@@ -239,7 +239,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
239 | if (len != TFTP_BLOCKSIZE_DEFAULT) { | 239 | if (len != TFTP_BLOCKSIZE_DEFAULT) { |
240 | 240 | ||
241 | if ((&buf[tftp_bufsize - 1] - cp) < 15) { | 241 | if ((&buf[tftp_bufsize - 1] - cp) < 15) { |
242 | error_msg("too long remote-filename"); | 242 | bb_error_msg("too long remote-filename"); |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | 245 | ||
@@ -270,7 +270,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
270 | len = read(localfd, cp, tftp_bufsize - 4); | 270 | len = read(localfd, cp, tftp_bufsize - 4); |
271 | 271 | ||
272 | if (len < 0) { | 272 | if (len < 0) { |
273 | perror_msg("read"); | 273 | bb_perror_msg("read"); |
274 | break; | 274 | break; |
275 | } | 275 | } |
276 | 276 | ||
@@ -298,7 +298,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
298 | #endif | 298 | #endif |
299 | if (sendto(socketfd, buf, len, 0, | 299 | if (sendto(socketfd, buf, len, 0, |
300 | (struct sockaddr *) &sa, sizeof(sa)) < 0) { | 300 | (struct sockaddr *) &sa, sizeof(sa)) < 0) { |
301 | perror_msg("send"); | 301 | bb_perror_msg("send"); |
302 | len = -1; | 302 | len = -1; |
303 | break; | 303 | break; |
304 | } | 304 | } |
@@ -325,7 +325,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
325 | (struct sockaddr *) &from, &fromlen); | 325 | (struct sockaddr *) &from, &fromlen); |
326 | 326 | ||
327 | if (len < 0) { | 327 | if (len < 0) { |
328 | perror_msg("recvfrom"); | 328 | bb_perror_msg("recvfrom"); |
329 | break; | 329 | break; |
330 | } | 330 | } |
331 | 331 | ||
@@ -343,18 +343,18 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
343 | timeout = bb_tftp_num_retries; | 343 | timeout = bb_tftp_num_retries; |
344 | 344 | ||
345 | case 0: | 345 | case 0: |
346 | error_msg("timeout"); | 346 | bb_error_msg("timeout"); |
347 | 347 | ||
348 | if (timeout == 0) { | 348 | if (timeout == 0) { |
349 | len = -1; | 349 | len = -1; |
350 | error_msg("last timeout"); | 350 | bb_error_msg("last timeout"); |
351 | } else { | 351 | } else { |
352 | timeout--; | 352 | timeout--; |
353 | } | 353 | } |
354 | break; | 354 | break; |
355 | 355 | ||
356 | default: | 356 | default: |
357 | perror_msg("select"); | 357 | bb_perror_msg("select"); |
358 | len = -1; | 358 | len = -1; |
359 | } | 359 | } |
360 | 360 | ||
@@ -380,14 +380,14 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
380 | if (buf[4] != '\0') { | 380 | if (buf[4] != '\0') { |
381 | msg = &buf[4]; | 381 | msg = &buf[4]; |
382 | buf[tftp_bufsize - 1] = '\0'; | 382 | buf[tftp_bufsize - 1] = '\0'; |
383 | } else if (tmp < (sizeof(tftp_error_msg) | 383 | } else if (tmp < (sizeof(tftp_bb_error_msg) |
384 | / sizeof(char *))) { | 384 | / sizeof(char *))) { |
385 | 385 | ||
386 | msg = (char *) tftp_error_msg[tmp]; | 386 | msg = (char *) tftp_bb_error_msg[tmp]; |
387 | } | 387 | } |
388 | 388 | ||
389 | if (msg) { | 389 | if (msg) { |
390 | error_msg("server says: %s", msg); | 390 | bb_error_msg("server says: %s", msg); |
391 | } | 391 | } |
392 | 392 | ||
393 | break; | 393 | break; |
@@ -429,11 +429,11 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
429 | } | 429 | } |
430 | /* FIXME: | 430 | /* FIXME: |
431 | * we should send ERROR 8 */ | 431 | * we should send ERROR 8 */ |
432 | error_msg("bad server option"); | 432 | bb_error_msg("bad server option"); |
433 | break; | 433 | break; |
434 | } | 434 | } |
435 | 435 | ||
436 | error_msg("warning: blksize not supported by server" | 436 | bb_error_msg("warning: blksize not supported by server" |
437 | " - reverting to 512"); | 437 | " - reverting to 512"); |
438 | 438 | ||
439 | tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4; | 439 | tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4; |
@@ -447,7 +447,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
447 | len = write(localfd, &buf[4], len - 4); | 447 | len = write(localfd, &buf[4], len - 4); |
448 | 448 | ||
449 | if (len < 0) { | 449 | if (len < 0) { |
450 | perror_msg("write"); | 450 | bb_perror_msg("write"); |
451 | break; | 451 | break; |
452 | } | 452 | } |
453 | 453 | ||
@@ -538,16 +538,16 @@ int tftp_main(int argc, char **argv) | |||
538 | break; | 538 | break; |
539 | #endif | 539 | #endif |
540 | case 'l': | 540 | case 'l': |
541 | localfile = xstrdup(optarg); | 541 | localfile = bb_xstrdup(optarg); |
542 | break; | 542 | break; |
543 | case 'r': | 543 | case 'r': |
544 | remotefile = xstrdup(optarg); | 544 | remotefile = bb_xstrdup(optarg); |
545 | break; | 545 | break; |
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | if ((cmd == 0) || (optind == argc)) { | 549 | if ((cmd == 0) || (optind == argc)) { |
550 | show_usage(); | 550 | bb_show_usage(); |
551 | } | 551 | } |
552 | if(localfile && strcmp(localfile, "-") == 0) { | 552 | if(localfile && strcmp(localfile, "-") == 0) { |
553 | fd = fileno((cmd==tftp_cmd_get)? stdout : stdin); | 553 | fd = fileno((cmd==tftp_cmd_get)? stdout : stdin); |
@@ -560,7 +560,7 @@ int tftp_main(int argc, char **argv) | |||
560 | fd = open(localfile, flags, 0644); | 560 | fd = open(localfile, flags, 0644); |
561 | } | 561 | } |
562 | if (fd < 0) { | 562 | if (fd < 0) { |
563 | perror_msg_and_die("local file"); | 563 | bb_perror_msg_and_die("local file"); |
564 | } | 564 | } |
565 | 565 | ||
566 | host = xgethostbyname(argv[optind]); | 566 | host = xgethostbyname(argv[optind]); |
diff --git a/networking/traceroute.c b/networking/traceroute.c index a9cad4baf..be9ea1d95 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -448,7 +448,7 @@ traceroute_main(int argc, char *argv[]) | |||
448 | case 'm': | 448 | case 'm': |
449 | max_ttl = atoi(optarg); | 449 | max_ttl = atoi(optarg); |
450 | if (max_ttl <= 1) | 450 | if (max_ttl <= 1) |
451 | error_msg_and_die("max ttl must be >1."); | 451 | bb_error_msg_and_die("max ttl must be >1."); |
452 | break; | 452 | break; |
453 | case 'n': | 453 | case 'n': |
454 | nflag++; | 454 | nflag++; |
@@ -456,12 +456,12 @@ traceroute_main(int argc, char *argv[]) | |||
456 | case 'p': | 456 | case 'p': |
457 | port = atoi(optarg); | 457 | port = atoi(optarg); |
458 | if (port < 1) | 458 | if (port < 1) |
459 | error_msg_and_die("port must be >0."); | 459 | bb_error_msg_and_die("port must be >0."); |
460 | break; | 460 | break; |
461 | case 'q': | 461 | case 'q': |
462 | nprobes = atoi(optarg); | 462 | nprobes = atoi(optarg); |
463 | if (nprobes < 1) | 463 | if (nprobes < 1) |
464 | error_msg_and_die("nprobes must be >0."); | 464 | bb_error_msg_and_die("nprobes must be >0."); |
465 | break; | 465 | break; |
466 | case 'r': | 466 | case 'r': |
467 | options |= SO_DONTROUTE; | 467 | options |= SO_DONTROUTE; |
@@ -476,7 +476,7 @@ traceroute_main(int argc, char *argv[]) | |||
476 | case 't': | 476 | case 't': |
477 | tos = atoi(optarg); | 477 | tos = atoi(optarg); |
478 | if (tos < 0 || tos > 255) | 478 | if (tos < 0 || tos > 255) |
479 | error_msg_and_die("tos must be 0 to 255."); | 479 | bb_error_msg_and_die("tos must be 0 to 255."); |
480 | break; | 480 | break; |
481 | case 'v': | 481 | case 'v': |
482 | #ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE | 482 | #ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE |
@@ -486,16 +486,16 @@ traceroute_main(int argc, char *argv[]) | |||
486 | case 'w': | 486 | case 'w': |
487 | waittime = atoi(optarg); | 487 | waittime = atoi(optarg); |
488 | if (waittime <= 1) | 488 | if (waittime <= 1) |
489 | error_msg_and_die("wait must be >1 sec."); | 489 | bb_error_msg_and_die("wait must be >1 sec."); |
490 | break; | 490 | break; |
491 | default: | 491 | default: |
492 | show_usage(); | 492 | bb_show_usage(); |
493 | } | 493 | } |
494 | argc -= optind; | 494 | argc -= optind; |
495 | argv += optind; | 495 | argv += optind; |
496 | 496 | ||
497 | if (argc < 1) | 497 | if (argc < 1) |
498 | show_usage(); | 498 | bb_show_usage(); |
499 | 499 | ||
500 | setlinebuf (stdout); | 500 | setlinebuf (stdout); |
501 | 501 | ||
@@ -507,7 +507,7 @@ traceroute_main(int argc, char *argv[]) | |||
507 | if (*++argv) | 507 | if (*++argv) |
508 | datalen = atoi(*argv); | 508 | datalen = atoi(*argv); |
509 | if (datalen < 0 || datalen >= MAXPACKET - sizeof(struct opacket)) | 509 | if (datalen < 0 || datalen >= MAXPACKET - sizeof(struct opacket)) |
510 | error_msg_and_die("packet size must be 0 <= s < %d.", | 510 | bb_error_msg_and_die("packet size must be 0 <= s < %d.", |
511 | MAXPACKET - sizeof(struct opacket)); | 511 | MAXPACKET - sizeof(struct opacket)); |
512 | datalen += sizeof(struct opacket); | 512 | datalen += sizeof(struct opacket); |
513 | outpacket = (struct opacket *)xmalloc((unsigned)datalen); | 513 | outpacket = (struct opacket *)xmalloc((unsigned)datalen); |
@@ -520,7 +520,7 @@ traceroute_main(int argc, char *argv[]) | |||
520 | ident = (getpid() & 0xffff) | 0x8000; | 520 | ident = (getpid() & 0xffff) | 0x8000; |
521 | 521 | ||
522 | if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) | 522 | if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) |
523 | perror_msg_and_die(can_not_create_raw_socket); | 523 | bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket); |
524 | 524 | ||
525 | s = create_icmp_socket(); | 525 | s = create_icmp_socket(); |
526 | 526 | ||
@@ -535,12 +535,12 @@ traceroute_main(int argc, char *argv[]) | |||
535 | #ifdef SO_SNDBUF | 535 | #ifdef SO_SNDBUF |
536 | if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen, | 536 | if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen, |
537 | sizeof(datalen)) < 0) | 537 | sizeof(datalen)) < 0) |
538 | perror_msg_and_die("SO_SNDBUF"); | 538 | bb_perror_msg_and_die("SO_SNDBUF"); |
539 | #endif | 539 | #endif |
540 | #ifdef IP_HDRINCL | 540 | #ifdef IP_HDRINCL |
541 | if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on, | 541 | if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on, |
542 | sizeof(on)) < 0) | 542 | sizeof(on)) < 0) |
543 | perror_msg_and_die("IP_HDRINCL"); | 543 | bb_perror_msg_and_die("IP_HDRINCL"); |
544 | #endif | 544 | #endif |
545 | #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG | 545 | #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG |
546 | if (options & SO_DEBUG) | 546 | if (options & SO_DEBUG) |
@@ -556,11 +556,11 @@ traceroute_main(int argc, char *argv[]) | |||
556 | from.sin_family = AF_INET; | 556 | from.sin_family = AF_INET; |
557 | from.sin_addr.s_addr = inet_addr(source); | 557 | from.sin_addr.s_addr = inet_addr(source); |
558 | if (from.sin_addr.s_addr == -1) | 558 | if (from.sin_addr.s_addr == -1) |
559 | error_msg_and_die("unknown host %s", source); | 559 | bb_error_msg_and_die("unknown host %s", source); |
560 | outpacket->ip.ip_src = from.sin_addr; | 560 | outpacket->ip.ip_src = from.sin_addr; |
561 | #ifndef IP_HDRINCL | 561 | #ifndef IP_HDRINCL |
562 | if (bind(sndsock, (struct sockaddr *)&from, sizeof(from)) < 0) | 562 | if (bind(sndsock, (struct sockaddr *)&from, sizeof(from)) < 0) |
563 | perror_msg_and_die("bind"); | 563 | bb_perror_msg_and_die("bind"); |
564 | #endif | 564 | #endif |
565 | } | 565 | } |
566 | 566 | ||
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index fdcd17f79..c97e422e2 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -81,7 +81,7 @@ struct client_config_t client_config = { | |||
81 | }; | 81 | }; |
82 | 82 | ||
83 | #ifndef IN_BUSYBOX | 83 | #ifndef IN_BUSYBOX |
84 | static void __attribute__ ((noreturn)) show_usage(void) | 84 | static void __attribute__ ((noreturn)) bb_show_usage(void) |
85 | { | 85 | { |
86 | printf( | 86 | printf( |
87 | "Usage: udhcpc [OPTIONS]\n\n" | 87 | "Usage: udhcpc [OPTIONS]\n\n" |
@@ -104,7 +104,7 @@ static void __attribute__ ((noreturn)) show_usage(void) | |||
104 | exit(0); | 104 | exit(0); |
105 | } | 105 | } |
106 | #else | 106 | #else |
107 | extern void show_usage(void) __attribute__ ((noreturn)); | 107 | extern void bb_show_usage(void) __attribute__ ((noreturn)); |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | 110 | ||
@@ -298,7 +298,7 @@ int main(int argc, char *argv[]) | |||
298 | exit_client(0); | 298 | exit_client(0); |
299 | break; | 299 | break; |
300 | default: | 300 | default: |
301 | show_usage(); | 301 | bb_show_usage(); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
diff --git a/networking/vconfig.c b/networking/vconfig.c index 3bd9c3040..d58c375f7 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c | |||
@@ -1,3 +1,27 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * vconfig implementation for busybox | ||
4 | * | ||
5 | * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | /* BB_AUDIT SUSv3 N/A */ | ||
24 | |||
1 | #include <stdlib.h> | 25 | #include <stdlib.h> |
2 | #include <unistd.h> | 26 | #include <unistd.h> |
3 | #include <fcntl.h> | 27 | #include <fcntl.h> |
@@ -11,29 +35,14 @@ | |||
11 | #define VLAN_GROUP_ARRAY_LEN 4096 | 35 | #define VLAN_GROUP_ARRAY_LEN 4096 |
12 | #define SIOCSIFVLAN 0x8983 /* Set 802.1Q VLAN options */ | 36 | #define SIOCSIFVLAN 0x8983 /* Set 802.1Q VLAN options */ |
13 | 37 | ||
14 | /* This is rather specialized in that we're passing a 'char **' in | ||
15 | * order to avoid the pointer dereference multiple times in the | ||
16 | * actual calls below. */ | ||
17 | static unsigned long xstrtoul10(char **str, unsigned long max_val) | ||
18 | { | ||
19 | char *endptr; | ||
20 | unsigned long r; | ||
21 | |||
22 | r = strtoul(str[2], &endptr, 10); | ||
23 | if ((r > max_val) || (*endptr != 0)) { | ||
24 | show_usage(); | ||
25 | } | ||
26 | return r; | ||
27 | } | ||
28 | |||
29 | /* On entry, table points to the length of the current string plus | 38 | /* On entry, table points to the length of the current string plus |
30 | * nul terminator plus data lenght for the subsequent entry. The | 39 | * nul terminator plus data length for the subsequent entry. The |
31 | * return value is the last data entry for the matching string. */ | 40 | * return value is the last data entry for the matching string. */ |
32 | static const char *xfind_str(const char *table, const char *str) | 41 | static const char *xfind_str(const char *table, const char *str) |
33 | { | 42 | { |
34 | while (strcasecmp(str, table+1) != 0) { | 43 | while (strcasecmp(str, table+1) != 0) { |
35 | if (!*(table += table[0])) { | 44 | if (!*(table += table[0])) { |
36 | show_usage(); | 45 | bb_show_usage(); |
37 | } | 46 | } |
38 | } | 47 | } |
39 | return table - 1; | 48 | return table - 1; |
@@ -89,12 +98,12 @@ int vconfig_main(int argc, char **argv) | |||
89 | int fd; | 98 | int fd; |
90 | 99 | ||
91 | if (argc < 3) { | 100 | if (argc < 3) { |
92 | show_usage(); | 101 | bb_show_usage(); |
93 | } | 102 | } |
94 | 103 | ||
95 | /* Don't bother closing the filedes. It will be closed on cleanup. */ | 104 | /* Don't bother closing the filedes. It will be closed on cleanup. */ |
96 | if (open(conf_file_name, O_RDONLY) < 0) { /* Is 802.1q is present? */ | 105 | if (open(conf_file_name, O_RDONLY) < 0) { /* Is 802.1q is present? */ |
97 | perror_msg_and_die("open %s", conf_file_name); | 106 | bb_perror_msg_and_die("open %s", conf_file_name); |
98 | } | 107 | } |
99 | 108 | ||
100 | memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); | 109 | memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); |
@@ -103,16 +112,17 @@ int vconfig_main(int argc, char **argv) | |||
103 | p = xfind_str(cmds+2, *argv); | 112 | p = xfind_str(cmds+2, *argv); |
104 | ifr.cmd = *p; | 113 | ifr.cmd = *p; |
105 | if (argc != p[-1]) { | 114 | if (argc != p[-1]) { |
106 | show_usage(); | 115 | bb_show_usage(); |
107 | } | 116 | } |
108 | 117 | ||
109 | if (ifr.cmd == SET_VLAN_NAME_TYPE_CMD) { /* set_name_type */ | 118 | if (ifr.cmd == SET_VLAN_NAME_TYPE_CMD) { /* set_name_type */ |
110 | ifr.u.name_type = *xfind_str(name_types+1, argv[1]); | 119 | ifr.u.name_type = *xfind_str(name_types+1, argv[1]); |
111 | } else { | 120 | } else { |
112 | if (strlen(argv[1]) >= IF_NAMESIZE) { | 121 | if (strlen(argv[1]) >= IF_NAMESIZE) { |
113 | error_msg_and_die("if_name >= %d chars\n", IF_NAMESIZE); | 122 | bb_error_msg_and_die("if_name >= %d chars\n", IF_NAMESIZE); |
114 | } | 123 | } |
115 | strcpy(ifr.device1, argv[1]); | 124 | strcpy(ifr.device1, argv[1]); |
125 | p = argv[2]; | ||
116 | 126 | ||
117 | /* I suppose one could try to combine some of the function calls below, | 127 | /* I suppose one could try to combine some of the function calls below, |
118 | * since ifr.u.flag, ifr.u.VID, and ifr.u.skb_priority are all same-sized | 128 | * since ifr.u.flag, ifr.u.VID, and ifr.u.skb_priority are all same-sized |
@@ -120,19 +130,19 @@ int vconfig_main(int argc, char **argv) | |||
120 | * doing so wouldn't save that much space and would also make maintainence | 130 | * doing so wouldn't save that much space and would also make maintainence |
121 | * more of a pain. */ | 131 | * more of a pain. */ |
122 | if (ifr.cmd == SET_VLAN_FLAG_CMD) { /* set_flag */ | 132 | if (ifr.cmd == SET_VLAN_FLAG_CMD) { /* set_flag */ |
123 | ifr.u.flag = xstrtoul10(argv, 1); | 133 | ifr.u.flag = bb_xgetularg10_bnd(p, 0, 1); |
124 | } else if (ifr.cmd == ADD_VLAN_CMD) { /* add */ | 134 | } else if (ifr.cmd == ADD_VLAN_CMD) { /* add */ |
125 | ifr.u.VID = xstrtoul10(argv, VLAN_GROUP_ARRAY_LEN-1); | 135 | ifr.u.VID = bb_xgetularg10_bnd(p, 0, VLAN_GROUP_ARRAY_LEN-1); |
126 | } else if (ifr.cmd != DEL_VLAN_CMD) { /* set_{egress|ingress}_map */ | 136 | } else if (ifr.cmd != DEL_VLAN_CMD) { /* set_{egress|ingress}_map */ |
127 | ifr.u.skb_priority = xstrtoul10(argv, ULONG_MAX); | 137 | ifr.u.skb_priority = bb_xgetularg10_bnd(p, 0, ULONG_MAX); |
128 | ifr.vlan_qos = xstrtoul10(argv+1, 7); | 138 | ifr.vlan_qos = bb_xgetularg10_bnd(argv[3], 0, 7); |
129 | } | 139 | } |
130 | } | 140 | } |
131 | 141 | ||
132 | if (((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) | 142 | if (((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) |
133 | || (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) | 143 | || (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) |
134 | ) { | 144 | ) { |
135 | perror_msg_and_die("socket or ioctl error for %s", *argv); | 145 | bb_perror_msg_and_die("socket or ioctl error for %s", *argv); |
136 | } | 146 | } |
137 | 147 | ||
138 | return 0; | 148 | return 0; |
diff --git a/networking/wget.c b/networking/wget.c index 7154faa11..d68b16524 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -123,7 +123,7 @@ static char *safe_fgets(char *s, int size, FILE *stream) | |||
123 | 123 | ||
124 | #define close_delete_and_die(s...) { \ | 124 | #define close_delete_and_die(s...) { \ |
125 | close_and_delete_outfile(output, fname_out, do_continue); \ | 125 | close_and_delete_outfile(output, fname_out, do_continue); \ |
126 | error_msg_and_die(s); } | 126 | bb_error_msg_and_die(s); } |
127 | 127 | ||
128 | 128 | ||
129 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION | 129 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION |
@@ -140,7 +140,7 @@ char *base64enc(char *p, char *buf, int len) { | |||
140 | 140 | ||
141 | while(*p) { | 141 | while(*p) { |
142 | if (s >= buf+len-4) | 142 | if (s >= buf+len-4) |
143 | error_msg_and_die("buffer overflow"); | 143 | bb_error_msg_and_die("buffer overflow"); |
144 | *(s++) = al[(*p >> 2) & 0x3F]; | 144 | *(s++) = al[(*p >> 2) & 0x3F]; |
145 | *(s++) = al[((*p << 4) & 0x30) | ((*(p+1) >> 4) & 0x0F)]; | 145 | *(s++) = al[((*p << 4) & 0x30) | ((*(p+1) >> 4) & 0x0F)]; |
146 | *s = *(s+1) = '='; | 146 | *s = *(s+1) = '='; |
@@ -221,7 +221,7 @@ int wget_main(int argc, char **argv) | |||
221 | case LONG_HEADER: { | 221 | case LONG_HEADER: { |
222 | int arglen = strlen(optarg); | 222 | int arglen = strlen(optarg); |
223 | if(extra_headers_left - arglen - 2 <= 0) | 223 | if(extra_headers_left - arglen - 2 <= 0) |
224 | error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen); | 224 | bb_error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen); |
225 | strcpy(extra_headers_ptr, optarg); | 225 | strcpy(extra_headers_ptr, optarg); |
226 | extra_headers_ptr += arglen; | 226 | extra_headers_ptr += arglen; |
227 | extra_headers_left -= ( arglen + 2 ); | 227 | extra_headers_left -= ( arglen + 2 ); |
@@ -236,12 +236,12 @@ int wget_main(int argc, char **argv) | |||
236 | } | 236 | } |
237 | break; | 237 | break; |
238 | default: | 238 | default: |
239 | show_usage(); | 239 | bb_show_usage(); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | if (argc - optind != 1) | 243 | if (argc - optind != 1) |
244 | show_usage(); | 244 | bb_show_usage(); |
245 | 245 | ||
246 | parse_url(argv[optind], &target); | 246 | parse_url(argv[optind], &target); |
247 | server.host = target.host; | 247 | server.host = target.host; |
@@ -253,7 +253,7 @@ int wget_main(int argc, char **argv) | |||
253 | if (!noproxy) { | 253 | if (!noproxy) { |
254 | proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); | 254 | proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); |
255 | if (proxy) | 255 | if (proxy) |
256 | parse_url(xstrdup(proxy), &server); | 256 | parse_url(bb_xstrdup(proxy), &server); |
257 | } | 257 | } |
258 | 258 | ||
259 | /* Guess an output filename */ | 259 | /* Guess an output filename */ |
@@ -262,7 +262,7 @@ int wget_main(int argc, char **argv) | |||
262 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 262 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
263 | curfile = | 263 | curfile = |
264 | #endif | 264 | #endif |
265 | get_last_path_component(target.path); | 265 | bb_get_last_path_component(target.path); |
266 | if (fname_out==NULL || strlen(fname_out)<1) { | 266 | if (fname_out==NULL || strlen(fname_out)<1) { |
267 | fname_out = | 267 | fname_out = |
268 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 268 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
@@ -274,11 +274,11 @@ int wget_main(int argc, char **argv) | |||
274 | fname_out = concat_path_file(dir_prefix, fname_out); | 274 | fname_out = concat_path_file(dir_prefix, fname_out); |
275 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 275 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
276 | } else { | 276 | } else { |
277 | curfile = get_last_path_component(fname_out); | 277 | curfile = bb_get_last_path_component(fname_out); |
278 | #endif | 278 | #endif |
279 | } | 279 | } |
280 | if (do_continue && !fname_out) | 280 | if (do_continue && !fname_out) |
281 | error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); | 281 | bb_error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); |
282 | 282 | ||
283 | 283 | ||
284 | /* | 284 | /* |
@@ -288,7 +288,7 @@ int wget_main(int argc, char **argv) | |||
288 | output = stdout; | 288 | output = stdout; |
289 | quiet_flag = TRUE; | 289 | quiet_flag = TRUE; |
290 | } else { | 290 | } else { |
291 | output = xfopen(fname_out, (do_continue ? "a" : "w")); | 291 | output = bb_xfopen(fname_out, (do_continue ? "a" : "w")); |
292 | } | 292 | } |
293 | 293 | ||
294 | /* | 294 | /* |
@@ -296,7 +296,7 @@ int wget_main(int argc, char **argv) | |||
296 | */ | 296 | */ |
297 | if (do_continue) { | 297 | if (do_continue) { |
298 | if (fstat(fileno(output), &sbuf) < 0) | 298 | if (fstat(fileno(output), &sbuf) < 0) |
299 | perror_msg_and_die("fstat()"); | 299 | bb_perror_msg_and_die("fstat()"); |
300 | if (sbuf.st_size > 0) | 300 | if (sbuf.st_size > 0) |
301 | beg_range = sbuf.st_size; | 301 | beg_range = sbuf.st_size; |
302 | else | 302 | else |
@@ -399,9 +399,9 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
399 | } | 399 | } |
400 | if (strcasecmp(buf, "location") == 0) { | 400 | if (strcasecmp(buf, "location") == 0) { |
401 | if (s[0] == '/') | 401 | if (s[0] == '/') |
402 | target.path = xstrdup(s+1); | 402 | target.path = bb_xstrdup(s+1); |
403 | else { | 403 | else { |
404 | parse_url(xstrdup(s), &target); | 404 | parse_url(bb_xstrdup(s), &target); |
405 | if (!proxy) { | 405 | if (!proxy) { |
406 | server.host = target.host; | 406 | server.host = target.host; |
407 | server.port = target.port; | 407 | server.port = target.port; |
@@ -419,7 +419,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
419 | * FTP session | 419 | * FTP session |
420 | */ | 420 | */ |
421 | if (! target.user) | 421 | if (! target.user) |
422 | target.user = xstrdup("anonymous:busybox@"); | 422 | target.user = bb_xstrdup("anonymous:busybox@"); |
423 | 423 | ||
424 | sfp = open_socket(server.host, server.port); | 424 | sfp = open_socket(server.host, server.port); |
425 | if (ftpcmd(NULL, NULL, sfp, buf) != 220) | 425 | if (ftpcmd(NULL, NULL, sfp, buf) != 220) |
@@ -496,7 +496,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
496 | do { | 496 | do { |
497 | while ((filesize > 0 || !got_clen) && (n = safe_fread(buf, 1, chunked ? (filesize > sizeof(buf) ? sizeof(buf) : filesize) : sizeof(buf), dfp)) > 0) { | 497 | while ((filesize > 0 || !got_clen) && (n = safe_fread(buf, 1, chunked ? (filesize > sizeof(buf) ? sizeof(buf) : filesize) : sizeof(buf), dfp)) > 0) { |
498 | if (safe_fwrite(buf, 1, n, output) != n) | 498 | if (safe_fwrite(buf, 1, n, output) != n) |
499 | perror_msg_and_die("write error"); | 499 | bb_perror_msg_and_die("write error"); |
500 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 500 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
501 | statbytes+=n; | 501 | statbytes+=n; |
502 | #endif | 502 | #endif |
@@ -512,7 +512,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
512 | } | 512 | } |
513 | 513 | ||
514 | if (n == 0 && ferror(dfp)) | 514 | if (n == 0 && ferror(dfp)) |
515 | perror_msg_and_die("network read error"); | 515 | bb_perror_msg_and_die("network read error"); |
516 | } while (chunked); | 516 | } while (chunked); |
517 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR | 517 | #ifdef CONFIG_FEATURE_WGET_STATUSBAR |
518 | if (quiet_flag==FALSE) | 518 | if (quiet_flag==FALSE) |
@@ -521,7 +521,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) | |||
521 | if (!proxy && target.is_ftp) { | 521 | if (!proxy && target.is_ftp) { |
522 | fclose(dfp); | 522 | fclose(dfp); |
523 | if (ftpcmd(NULL, NULL, sfp, buf) != 226) | 523 | if (ftpcmd(NULL, NULL, sfp, buf) != 226) |
524 | error_msg_and_die("ftp error: %s", buf+4); | 524 | bb_error_msg_and_die("ftp error: %s", buf+4); |
525 | ftpcmd("QUIT", NULL, sfp, buf); | 525 | ftpcmd("QUIT", NULL, sfp, buf); |
526 | } | 526 | } |
527 | exit(EXIT_SUCCESS); | 527 | exit(EXIT_SUCCESS); |
@@ -541,14 +541,14 @@ void parse_url(char *url, struct host_info *h) | |||
541 | h->host = url + 6; | 541 | h->host = url + 6; |
542 | h->is_ftp = 1; | 542 | h->is_ftp = 1; |
543 | } else | 543 | } else |
544 | error_msg_and_die("not an http or ftp url: %s", url); | 544 | bb_error_msg_and_die("not an http or ftp url: %s", url); |
545 | 545 | ||
546 | sp = strchr(h->host, '/'); | 546 | sp = strchr(h->host, '/'); |
547 | if (sp != NULL) { | 547 | if (sp != NULL) { |
548 | *sp++ = '\0'; | 548 | *sp++ = '\0'; |
549 | h->path = sp; | 549 | h->path = sp; |
550 | } else | 550 | } else |
551 | h->path = xstrdup(""); | 551 | h->path = bb_xstrdup(""); |
552 | 552 | ||
553 | up = strrchr(h->host, '@'); | 553 | up = strrchr(h->host, '@'); |
554 | if (up != NULL) { | 554 | if (up != NULL) { |
@@ -580,7 +580,7 @@ FILE *open_socket(char *host, int port) | |||
580 | * Get the server onto a stdio stream. | 580 | * Get the server onto a stdio stream. |
581 | */ | 581 | */ |
582 | if ((fp = fdopen(fd, "r+")) == NULL) | 582 | if ((fp = fdopen(fd, "r+")) == NULL) |
583 | perror_msg_and_die("fdopen()"); | 583 | bb_perror_msg_and_die("fdopen()"); |
584 | 584 | ||
585 | return fp; | 585 | return fp; |
586 | } | 586 | } |
@@ -609,7 +609,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc) | |||
609 | 609 | ||
610 | /* verify we are at the end of the header name */ | 610 | /* verify we are at the end of the header name */ |
611 | if (*s != ':') | 611 | if (*s != ':') |
612 | error_msg_and_die("bad header line: %s", buf); | 612 | bb_error_msg_and_die("bad header line: %s", buf); |
613 | 613 | ||
614 | /* locate the start of the header value */ | 614 | /* locate the start of the header value */ |
615 | for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) | 615 | for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) |
@@ -646,7 +646,7 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) | |||
646 | do { | 646 | do { |
647 | p = fgets(buf, 510, fp); | 647 | p = fgets(buf, 510, fp); |
648 | if (!p) | 648 | if (!p) |
649 | perror_msg_and_die("fgets()"); | 649 | bb_perror_msg_and_die("fgets()"); |
650 | } while (! isdigit(buf[0]) || buf[3] != ' '); | 650 | } while (! isdigit(buf[0]) || buf[3] != ' '); |
651 | 651 | ||
652 | return atoi(buf); | 652 | return atoi(buf); |
@@ -824,7 +824,7 @@ progressmeter(int flag) | |||
824 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 824 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
825 | * SUCH DAMAGE. | 825 | * SUCH DAMAGE. |
826 | * | 826 | * |
827 | * $Id: wget.c,v 1.52 2003/03/11 18:03:39 andersen Exp $ | 827 | * $Id: wget.c,v 1.53 2003/03/19 09:12:39 mjn3 Exp $ |
828 | */ | 828 | */ |
829 | 829 | ||
830 | 830 | ||