summaryrefslogtreecommitdiff
path: root/networking/route.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
committerRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
commitd921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch)
treee4a2769349867c441cf2983d83097bb66701a733 /networking/route.c
parent6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff)
downloadbusybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only had one user), clean up lots of #includes... General cleanup pass. What I've been doing for the last couple days. And it conflicts! I've removed httpd.c from this checkin due to somebody else touching that file. It builds for me. I have to catch a bus. (Now you know why I'm looking forward to Mercurial.)
Diffstat (limited to 'networking/route.c')
-rw-r--r--networking/route.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/networking/route.c b/networking/route.c
index d90578615..5fd888617 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -26,20 +26,12 @@
26 * remove ridiculous amounts of bloat. 26 * remove ridiculous amounts of bloat.
27 */ 27 */
28 28
29#include <stdio.h> 29#include "busybox.h"
30#include <stdlib.h> 30#include "inet_common.h"
31#include <string.h>
32#include <errno.h>
33#include <assert.h>
34#include <unistd.h>
35#include <fcntl.h>
36#include <getopt.h> 31#include <getopt.h>
37#include <sys/types.h>
38#include <sys/ioctl.h>
39#include <net/route.h> 32#include <net/route.h>
40#include <net/if.h> 33#include <net/if.h>
41#include "busybox.h" 34
42#include "inet_common.h"
43 35
44#ifndef RTF_UP 36#ifndef RTF_UP
45/* Keep this in sync with /usr/src/linux/include/linux/route.h */ 37/* Keep this in sync with /usr/src/linux/include/linux/route.h */
@@ -166,8 +158,6 @@ static void INET_setroute(int action, char **args)
166 const char *netmask = NULL; 158 const char *netmask = NULL;
167 int skfd, isnet, xflag; 159 int skfd, isnet, xflag;
168 160
169 assert((action == RTACTION_ADD) || (action == RTACTION_DEL));
170
171 /* Grab the -net or -host options. Remember they were transformed. */ 161 /* Grab the -net or -host options. Remember they were transformed. */
172 xflag = kw_lookup(tbl_hash_net_host, &args); 162 xflag = kw_lookup(tbl_hash_net_host, &args);
173 163
@@ -335,7 +325,7 @@ static void INET_setroute(int action, char **args)
335 } 325 }
336 326
337 /* Create a socket to the INET kernel. */ 327 /* Create a socket to the INET kernel. */
338 skfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0); 328 skfd = xsocket(AF_INET, SOCK_DGRAM, 0);
339 329
340 if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) { 330 if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) {
341 bb_perror_msg_and_die("SIOC[ADD|DEL]RT"); 331 bb_perror_msg_and_die("SIOC[ADD|DEL]RT");
@@ -353,9 +343,6 @@ static void INET6_setroute(int action, char **args)
353 int prefix_len, skfd; 343 int prefix_len, skfd;
354 const char *devname; 344 const char *devname;
355 345
356 assert((action == RTACTION_ADD) || (action == RTACTION_DEL));
357
358 {
359 /* We know args isn't NULL from the check in route_main. */ 346 /* We know args isn't NULL from the check in route_main. */
360 const char *target = *args++; 347 const char *target = *args++;
361 348
@@ -374,7 +361,6 @@ static void INET6_setroute(int action, char **args)
374 bb_error_msg_and_die("resolving %s", target); 361 bb_error_msg_and_die("resolving %s", target);
375 } 362 }
376 } 363 }
377 }
378 364
379 /* Clean out the RTREQ structure. */ 365 /* Clean out the RTREQ structure. */
380 memset((char *) &rt, 0, sizeof(struct in6_rtmsg)); 366 memset((char *) &rt, 0, sizeof(struct in6_rtmsg));
@@ -429,7 +415,7 @@ static void INET6_setroute(int action, char **args)
429 } 415 }
430 416
431 /* Create a socket to the INET6 kernel. */ 417 /* Create a socket to the INET6 kernel. */
432 skfd = bb_xsocket(AF_INET6, SOCK_DGRAM, 0); 418 skfd = xsocket(AF_INET6, SOCK_DGRAM, 0);
433 419
434 rt.rtmsg_ifindex = 0; 420 rt.rtmsg_ifindex = 0;
435 421
@@ -503,7 +489,7 @@ void displayroutes(int noresolve, int netstatfmt)
503 struct sockaddr_in s_addr; 489 struct sockaddr_in s_addr;
504 struct in_addr mask; 490 struct in_addr mask;
505 491
506 FILE *fp = bb_xfopen("/proc/net/route", "r"); 492 FILE *fp = xfopen("/proc/net/route", "r");
507 493
508 bb_printf("Kernel IP routing table\n" 494 bb_printf("Kernel IP routing table\n"
509 "Destination Gateway Genmask" 495 "Destination Gateway Genmask"
@@ -573,7 +559,7 @@ static void INET6_displayroutes(int noresolve)
573 int iflags, metric, refcnt, use, prefix_len, slen; 559 int iflags, metric, refcnt, use, prefix_len, slen;
574 struct sockaddr_in6 snaddr6; 560 struct sockaddr_in6 snaddr6;
575 561
576 FILE *fp = bb_xfopen("/proc/net/ipv6_route", "r"); 562 FILE *fp = xfopen("/proc/net/ipv6_route", "r");
577 563
578 bb_printf("Kernel IPv6 routing table\n%-44s%-40s" 564 bb_printf("Kernel IPv6 routing table\n%-44s%-40s"
579 "Flags Metric Ref Use Iface\n", 565 "Flags Metric Ref Use Iface\n",
@@ -699,7 +685,7 @@ int route_main(int argc, char **argv)
699#endif 685#endif
700 displayroutes(noresolve, opt & ROUTE_OPT_e); 686 displayroutes(noresolve, opt & ROUTE_OPT_e);
701 687
702 bb_xferror_stdout(); 688 xferror_stdout();
703 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 689 bb_fflush_stdout_and_exit(EXIT_SUCCESS);
704 } 690 }
705 691