Changeset 11627
- Timestamp:
- 02/17/09 19:17:17 (4 years ago)
- File:
-
- 1 edited
-
src/router/upnp/src/linux/linux_osl.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/router/upnp/src/linux/linux_osl.c
r11612 r11627 573 573 upnp_osl_wan_ip(struct in_addr *inaddr) 574 574 { 575 char tmp[32]; 575 inaddr->s_addr = 0; 576 char *wanface = get_wan_face(); 576 577 int status = 0; 577 578 inaddr->s_addr = 0; 579 580 if (strcasecmp(nvram_safe_get(igd_pri_wan_var(tmp, sizeof(tmp), "proto")), 581 "disabled") != 0) { 582 if (upnp_osl_ifaddr(nvram_safe_get(igd_pri_wan_var(tmp, 583 sizeof(tmp), "ifname")), inaddr) == 0) { 584 if (inaddr->s_addr != 0) { 585 status = 1; 586 } 578 if (upnp_osl_ifaddr(wanface, inaddr) == 0) { 579 if (inaddr->s_addr != 0) { 580 status = 1; 587 581 } 588 582 } 589 590 583 return status; 591 584 } … … 594 587 upnp_osl_wan_isup() 595 588 { 596 struct in_addr inaddr = {0};597 589 int status = 0; 598 char tmp[100]; 599 600 if (strcasecmp(nvram_safe_get(igd_pri_wan_var(tmp, sizeof(tmp), "proto")), 601 "disabled") != 0) { 602 if (upnp_osl_ifaddr(nvram_safe_get(igd_pri_wan_var(tmp, 603 sizeof(tmp), "ifname")), &inaddr) == 0) { 604 if (inaddr.s_addr != 0) { 605 status = 1; 606 } 607 } 608 } 609 590 int link = check_wan_link(0); 591 if (link) 592 status=1; 610 593 return status; 611 594 } … … 614 597 upnp_osl_wan_uptime() 615 598 { 616 FILE *fp; 617 long int second1, second2; 618 619 fp = fopen("/proc/uptime", "r"); 620 if (!fp) { 621 fprintf(stderr, "can't open \"uptime\" !\n"); 622 return -1; 623 } 624 625 fscanf(fp, "%ld.%ld", &second1, &second2); 626 fclose(fp); 627 628 return second1; 599 FILE *fp; 600 if( nvram_match( "wan_proto", "disabled" ) ) 601 return -1; 602 if( nvram_match( "wan_ipaddr", "0.0.0.0" ) ) 603 { 604 return -1; 605 } 606 if( !( fp = fopen( "/tmp/.wanuptime", "r" ) ) ) 607 { 608 return -1; 609 } 610 float uptime; 611 if( !feof( fp ) && fscanf( fp, "%f", &uptime ) == 1 ) 612 { 613 float sys_uptime; 614 FILE *fp2 = fopen( "/proc/uptime", "r" ); 615 fscanf( fp2, "%f", &sys_uptime ); 616 fclose( fp2 ); 617 uptime = sys_uptime - uptime; 618 return (int)uptime; 619 } 620 return -1; 629 621 } 630 622 … … 650 642 } 651 643 644 /* We want to match destination ip address */ 645 if(nvram_match("wan_proto","pptp")) 646 { 647 inet_aton(nvram_safe_get("pptp_get_ip"), &nat.match.dst.ipaddr); 648 } 649 else if(nvram_match("wan_proto","l2tp")) 650 { 651 inet_aton(nvram_safe_get("l2tp_get_ip"), &nat.match.dst.ipaddr); 652 } 653 else 654 { 655 inet_aton(nvram_safe_get("wan_ipaddr"), &nat.match.dst.ipaddr); 656 } 657 nat.match.dst.netmask.s_addr = htonl(0xffffffff); 652 658 /* Set up LAN side match */ 653 659 memset(&filter, 0, sizeof(filter)); … … 687 693 } 688 694 695 689 696 /* Set up LAN side match */ 690 697 memset(&filter, 0, sizeof(filter));
Note: See TracChangeset
for help on using the changeset viewer.
