Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/route.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/networking/route.c
r3232 r3621 56 56 #define RTF_IRTT 0x0100 /* Initial round trip time */ 57 57 #define RTF_REJECT 0x0200 /* Reject route */ 58 #define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */ 58 59 #endif 59 60 … … 129 130 ; 130 131 131 static const int flags_ipvx[] = { /* MUST match tbl_ipvx[] values above. */132 static const uint16_t flags_ipvx[] = { /* MUST match tbl_ipvx[] values above. */ 132 133 #ifdef RTF_REJECT 133 134 RTF_REJECT, … … 284 285 rt->rt_flags |= RTF_IRTT; 285 286 rt->rt_irtt = xatoul(args_m1); 286 rt->rt_irtt *= ( sysconf(_SC_CLK_TCK) / 100); /* FIXME */287 rt->rt_irtt *= (bb_clk_tck() / 100); /* FIXME */ 287 288 #if 0 /* FIXME: do we need to check anything of this? */ 288 289 if (rt->rt_irtt < 1 || rt->rt_irtt > (120 * HZ)) { … … 450 451 #endif 451 452 452 static const unsigned flagvals[] = { /* Must agree with flagchars[]. */ 453 static const 454 IF_NOT_FEATURE_IPV6(uint16_t) 455 IF_FEATURE_IPV6(unsigned) 456 flagvals[] = { /* Must agree with flagchars[]. */ 457 RTF_UP, 453 458 RTF_GATEWAY, 454 459 RTF_HOST, … … 459 464 RTF_DEFAULT, 460 465 RTF_ADDRCONF, 461 RTF_CACHE 466 RTF_CACHE, 467 RTF_REJECT, 468 RTF_NONEXTHOP, /* this one doesn't fit into 16 bits */ 462 469 #endif 463 470 }; 464 465 #define IPV4_MASK (RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)466 #define IPV6_MASK (RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE)467 468 471 /* Must agree with flagvals[]. */ 469 472 static const char flagchars[] ALIGN1 = 470 " GHRDM"473 "UGHRDM" 471 474 #if ENABLE_FEATURE_IPV6 472 "DAC "475 "DAC!n" 473 476 #endif 474 477 ; 478 #define IPV4_MASK (RTF_UP|RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED) 479 #define IPV6_MASK (RTF_UP|RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE|RTF_REJECT|RTF_NONEXTHOP) 475 480 476 481 static void set_flags(char *flagstr, int flags) 477 482 { 478 483 int i; 479 480 *flagstr++ = 'U';481 484 482 485 for (i = 0; (*flagstr = flagchars[i]) != 0; i++) { … … 492 495 char devname[64], flags[16], *sdest, *sgw; 493 496 unsigned long d, g, m; 497 int r; 494 498 int flgs, ref, use, metric, mtu, win, ir; 495 499 struct sockaddr_in s_addr; … … 502 506 netstatfmt ? " MSS Window irtt" : "Metric Ref Use"); 503 507 504 if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */ 505 goto ERROR; /* Empty or missing line, or read error. */ 508 /* Skip the first line. */ 509 r = fscanf(fp, "%*[^\n]\n"); 510 if (r < 0) { 511 /* Empty line, read error, or EOF. Yes, if routing table 512 * is completely empty, /proc/net/route has no header. 513 */ 514 goto ERROR; 506 515 } 507 516 while (1) { 508 int r;509 517 r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n", 510 518 devname, &d, &g, &flgs, &ref, &use, &metric, &m, 511 519 &mtu, &win, &ir); 512 520 if (r != 11) { 521 ERROR: 513 522 if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */ 514 523 break; 515 524 } 516 ERROR: 517 bb_error_msg_and_die("fscanf"); 525 bb_perror_msg_and_die(bb_msg_read_error); 518 526 } 519 527 … … 575 583 r = fscanf(fp, "%32s%x%*s%x%32s%x%x%x%x%s\n", 576 584 addr6x+14, &prefix_len, &slen, addr6x+40+7, 577 &metric, & use, &refcnt, &iflags, iface);585 &metric, &refcnt, &use, &iflags, iface); 578 586 if (r != 9) { 579 587 if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */ … … 581 589 } 582 590 ERROR: 583 bb_ error_msg_and_die("fscanf");591 bb_perror_msg_and_die(bb_msg_read_error); 584 592 } 585 593 … … 607 615 } 608 616 609 if (!(iflags & RTF_UP)) { /* Skip interfaces that are down. */610 continue;611 }612 613 617 set_flags(flags, (iflags & IPV6_MASK)); 614 618
Note:
See TracChangeset
for help on using the changeset viewer.