Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/networking/route.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/networking/route.c
r1765 r2725 11 11 * (derived from FvK's 'route.c 1.70 01/04/94') 12 12 * 13 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.13 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 14 14 * 15 15 * … … 26 26 */ 27 27 28 #include <getopt.h>29 28 #include <net/route.h> 30 29 #include <net/if.h> … … 153 152 /* Add or delete a route, depending on action. */ 154 153 155 static void INET_setroute(int action, char **args)154 static NOINLINE void INET_setroute(int action, char **args) 156 155 { 157 156 struct rtentry rt; … … 180 179 181 180 prefix_len = xatoul_range(prefix+1, 0, 32); 182 mask_in_addr(rt) = htonl( ~ 181 mask_in_addr(rt) = htonl( ~(0xffffffffUL >> prefix_len)); 183 182 *prefix = '\0'; 184 183 #if HAVE_NEW_ADDRT … … 187 186 } else { 188 187 /* Default netmask. */ 189 netmask = bb_str_default;188 netmask = "default"; 190 189 } 191 190 /* Prefer hostname lookup is -host flag (xflag==1) was given. */ … … 304 303 /* sanity checks.. */ 305 304 if (mask_in_addr(rt)) { 306 u nsigned longmask = mask_in_addr(rt);305 uint32_t mask = mask_in_addr(rt); 307 306 308 307 mask = ~ntohl(mask); … … 315 314 } 316 315 mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr; 317 if (mask & ~ mask_in_addr(rt)) {316 if (mask & ~(uint32_t)mask_in_addr(rt)) { 318 317 bb_error_msg_and_die("netmask and route address conflict"); 319 318 } … … 338 337 #if ENABLE_FEATURE_IPV6 339 338 340 static void INET6_setroute(int action, char **args)339 static NOINLINE void INET6_setroute(int action, char **args) 341 340 { 342 341 struct sockaddr_in6 sa6; … … 348 347 const char *target = *args++; 349 348 350 if (strcmp(target, bb_str_default) == 0) {349 if (strcmp(target, "default") == 0) { 351 350 prefix_len = 0; 352 351 memset(&sa6, 0, sizeof(sa6)); 353 352 } else { 354 353 char *cp; 355 if ((cp = strchr(target, '/'))) { /* Yes... const to non is ok. */ 356 *cp = 0; 357 prefix_len = xatoul_range(cp+1, 0, 128); 354 cp = strchr(target, '/'); /* Yes... const to non is ok. */ 355 if (cp) { 356 *cp = '\0'; 357 prefix_len = xatoul_range(cp + 1, 0, 128); 358 358 } else { 359 359 prefix_len = 128; … … 424 424 struct ifreq ifr; 425 425 memset(&ifr, 0, sizeof(ifr)); 426 strncpy (ifr.ifr_name, devname, sizeof(ifr.ifr_name));426 strncpy_IFNAMSIZ(ifr.ifr_name, devname); 427 427 xioctl(skfd, SIOGIFINDEX, &ifr); 428 428 rt.rtmsg_ifindex = ifr.ifr_ifindex; … … 477 477 478 478 /* also used in netstat */ 479 void bb_displayroutes(int noresolve, int netstatfmt)479 void FAST_FUNC bb_displayroutes(int noresolve, int netstatfmt) 480 480 { 481 481 char devname[64], flags[16], *sdest, *sgw; … … 485 485 struct in_addr mask; 486 486 487 FILE *fp = xfopen ("/proc/net/route", "r");487 FILE *fp = xfopen_for_read("/proc/net/route"); 488 488 489 489 printf("Kernel IP routing table\n" … … 539 539 #if ENABLE_FEATURE_IPV6 540 540 541 static void INET6_displayroutes( int noresolve)541 static void INET6_displayroutes(void) 542 542 { 543 543 char addr6[128], *naddr6; … … 553 553 struct sockaddr_in6 snaddr6; 554 554 555 FILE *fp = xfopen ("/proc/net/ipv6_route", "r");555 FILE *fp = xfopen_for_read("/proc/net/ipv6_route"); 556 556 557 557 printf("Kernel IPv6 routing table\n%-44s%-40s" … … 562 562 int r; 563 563 r = fscanf(fp, "%32s%x%*s%x%32s%x%x%x%x%s\n", 564 565 564 addr6x+14, &prefix_len, &slen, addr6x+40+7, 565 &metric, &use, &refcnt, &iflags, iface); 566 566 if (r != 9) { 567 567 if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */ … … 641 641 ; 642 642 643 int route_main(int argc, char **argv) ;644 int route_main(int argc , char **argv)643 int route_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 644 int route_main(int argc UNUSED_PARAM, char **argv) 645 645 { 646 646 unsigned opt; … … 675 675 #if ENABLE_FEATURE_IPV6 676 676 if (opt & ROUTE_OPT_INET6) 677 INET6_displayroutes( noresolve);677 INET6_displayroutes(); 678 678 else 679 679 #endif
Note:
See TracChangeset
for help on using the changeset viewer.