rtadvctl.c (225519) | rtadvctl.c (253970) |
---|---|
1/*- 2 * Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 21 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 21 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/rtadvctl/rtadvctl.c 225519 2011-09-12 23:52:55Z hrs $ | 26 * $FreeBSD: head/usr.sbin/rtadvctl/rtadvctl.c 253970 2013-08-05 20:13:02Z hrs $ |
27 * 28 */ 29 30#include <sys/queue.h> 31#include <sys/types.h> 32#include <sys/socket.h> 33#include <sys/stat.h> 34#include <sys/un.h> --- 15 unchanged lines hidden (view full) --- 50#include <netdb.h> 51#include <unistd.h> 52#include <string.h> 53#include <stdarg.h> 54#include <stdio.h> 55#include <stdlib.h> 56#include <stdarg.h> 57#include <syslog.h> | 27 * 28 */ 29 30#include <sys/queue.h> 31#include <sys/types.h> 32#include <sys/socket.h> 33#include <sys/stat.h> 34#include <sys/un.h> --- 15 unchanged lines hidden (view full) --- 50#include <netdb.h> 51#include <unistd.h> 52#include <string.h> 53#include <stdarg.h> 54#include <stdio.h> 55#include <stdlib.h> 56#include <stdarg.h> 57#include <syslog.h> |
58#include <time.h> |
|
58#include <err.h> 59 60#include "pathnames.h" 61#include "rtadvd.h" 62#include "if.h" 63#include "timer_subr.h" 64#include "timer.h" 65#include "control.h" --- 345 unchanged lines hidden (view full) --- 411 char argv_rai[IFNAMSIZ + sizeof(":rai=")]; 412 char argv_rti[IFNAMSIZ + sizeof(":rti=")]; 413 char argv_pfx[IFNAMSIZ + sizeof(":pfx=")]; 414 char argv_ifi_ra_timer[IFNAMSIZ + sizeof(":ifi_ra_timer=")]; 415 char argv_rdnss[IFNAMSIZ + sizeof(":rdnss=")]; 416 char argv_dnssl[IFNAMSIZ + sizeof(":dnssl=")]; 417 char ssbuf[SSBUFLEN]; 418 | 59#include <err.h> 60 61#include "pathnames.h" 62#include "rtadvd.h" 63#include "if.h" 64#include "timer_subr.h" 65#include "timer.h" 66#include "control.h" --- 345 unchanged lines hidden (view full) --- 412 char argv_rai[IFNAMSIZ + sizeof(":rai=")]; 413 char argv_rti[IFNAMSIZ + sizeof(":rti=")]; 414 char argv_pfx[IFNAMSIZ + sizeof(":pfx=")]; 415 char argv_ifi_ra_timer[IFNAMSIZ + sizeof(":ifi_ra_timer=")]; 416 char argv_rdnss[IFNAMSIZ + sizeof(":rdnss=")]; 417 char argv_dnssl[IFNAMSIZ + sizeof(":dnssl=")]; 418 char ssbuf[SSBUFLEN]; 419 |
420 struct timespec now, ts0, ts; |
|
419 struct ctrl_msg_pl cp; 420 struct ifinfo *ifi; 421 TAILQ_HEAD(, ifinfo) ifl = TAILQ_HEAD_INITIALIZER(ifl); 422 char *endp; 423 char *p; 424 int error; 425 int i; 426 int len; --- 32 unchanged lines hidden (view full) --- 459 errmsg = errmsgbuf; 460 return (1); 461 } 462 463 TAILQ_INSERT_TAIL(&ifl, ifi, ifi_next); 464 } 465 } 466 | 421 struct ctrl_msg_pl cp; 422 struct ifinfo *ifi; 423 TAILQ_HEAD(, ifinfo) ifl = TAILQ_HEAD_INITIALIZER(ifl); 424 char *endp; 425 char *p; 426 int error; 427 int i; 428 int len; --- 32 unchanged lines hidden (view full) --- 461 errmsg = errmsgbuf; 462 return (1); 463 } 464 465 TAILQ_INSERT_TAIL(&ifl, ifi, ifi_next); 466 } 467 } 468 |
469 clock_gettime(CLOCK_REALTIME_FAST, &now); 470 clock_gettime(CLOCK_MONOTONIC_FAST, &ts); 471 TS_SUB(&now, &ts, &ts0); 472 |
|
467 TAILQ_FOREACH(ifi, &ifl, ifi_next) { 468 struct ifinfo *ifi_s; 469 struct rtadvd_timer *rat; 470 struct rainfo *rai; 471 struct rtinfo *rti; 472 struct prefix *pfx; 473 int c; 474 int ra_ifstatus; --- 135 unchanged lines hidden (view full) --- 610 action_argv = argv_ifi_ra_timer; 611 612 error = action_propget(action_argv, &cp); 613 if (error) 614 return (error); 615 616 rat = (struct rtadvd_timer *)cp.cp_val; 617 } | 473 TAILQ_FOREACH(ifi, &ifl, ifi_next) { 474 struct ifinfo *ifi_s; 475 struct rtadvd_timer *rat; 476 struct rainfo *rai; 477 struct rtinfo *rti; 478 struct prefix *pfx; 479 int c; 480 int ra_ifstatus; --- 135 unchanged lines hidden (view full) --- 616 action_argv = argv_ifi_ra_timer; 617 618 error = action_propget(action_argv, &cp); 619 if (error) 620 return (error); 621 622 rat = (struct rtadvd_timer *)cp.cp_val; 623 } |
618 printf("\tNext RA send: %s", 619 (rat == NULL) ? "never\n" : 620 ctime((time_t *)&rat->rat_tm.tv_sec)); 621 printf("\tLast RA sent: %s", 622 (ifi_s->ifi_ra_lastsent.tv_sec == 0) ? "never\n" : 623 ctime((time_t *)&ifi_s->ifi_ra_lastsent.tv_sec)); | 624 printf("\tNext RA send: "); 625 if (rat == NULL) 626 printf("never\n"); 627 else { 628 ts.tv_sec = rat->rat_tm.tv_sec + ts0.tv_sec; 629 printf("%s", ctime(&ts.tv_sec)); 630 } 631 printf("\tLast RA send: "); 632 if (ifi_s->ifi_ra_lastsent.tv_sec == 0) 633 printf("never\n"); 634 else { 635 ts.tv_sec = ifi_s->ifi_ra_lastsent.tv_sec + ts0.tv_sec; 636 printf("%s", ctime(&ts.tv_sec)); 637 } |
624 if (rai->rai_clockskew) 625 printf("\tClock skew: %" PRIu16 "sec\n", 626 rai->rai_clockskew); 627 628 if (vflag < LOG_WARNING) 629 continue; 630 631 /* route information */ --- 110 unchanged lines hidden (view full) --- 742 return (0); 743} 744 745static int 746action_show_prefix(struct prefix *pfx) 747{ 748 char ntopbuf[INET6_ADDRSTRLEN]; 749 char ssbuf[SSBUFLEN]; | 638 if (rai->rai_clockskew) 639 printf("\tClock skew: %" PRIu16 "sec\n", 640 rai->rai_clockskew); 641 642 if (vflag < LOG_WARNING) 643 continue; 644 645 /* route information */ --- 110 unchanged lines hidden (view full) --- 756 return (0); 757} 758 759static int 760action_show_prefix(struct prefix *pfx) 761{ 762 char ntopbuf[INET6_ADDRSTRLEN]; 763 char ssbuf[SSBUFLEN]; |
750 struct timeval now; | 764 struct timespec now; |
751 | 765 |
752 gettimeofday(&now, NULL); | 766 clock_gettime(CLOCK_MONOTONIC_FAST, &now); |
753 printf("\t %s/%d", inet_ntop(AF_INET6, &pfx->pfx_prefix, 754 ntopbuf, sizeof(ntopbuf)), pfx->pfx_prefixlen); 755 756 printf(" ("); 757 switch (pfx->pfx_origin) { 758 case PREFIX_FROM_KERNEL: 759 printf("KERNEL"); 760 break; --- 34 unchanged lines hidden (view full) --- 795 printf(" flags="); 796 if (pfx->pfx_onlinkflg || pfx->pfx_autoconfflg) { 797 printf("%s", pfx->pfx_onlinkflg ? "L" : ""); 798 printf("%s", pfx->pfx_autoconfflg ? "A" : ""); 799 } else 800 printf("<none>"); 801 802 if (pfx->pfx_timer) { | 767 printf("\t %s/%d", inet_ntop(AF_INET6, &pfx->pfx_prefix, 768 ntopbuf, sizeof(ntopbuf)), pfx->pfx_prefixlen); 769 770 printf(" ("); 771 switch (pfx->pfx_origin) { 772 case PREFIX_FROM_KERNEL: 773 printf("KERNEL"); 774 break; --- 34 unchanged lines hidden (view full) --- 809 printf(" flags="); 810 if (pfx->pfx_onlinkflg || pfx->pfx_autoconfflg) { 811 printf("%s", pfx->pfx_onlinkflg ? "L" : ""); 812 printf("%s", pfx->pfx_autoconfflg ? "A" : ""); 813 } else 814 printf("<none>"); 815 816 if (pfx->pfx_timer) { |
803 struct timeval *rest; | 817 struct timespec *rest; |
804 805 rest = rtadvd_timer_rest(pfx->pfx_timer); 806 if (rest) { /* XXX: what if not? */ 807 printf(" expire=%s", sec2str(rest->tv_sec, ssbuf)); 808 } 809 } 810 811 printf(")\n"); --- 114 unchanged lines hidden --- | 818 819 rest = rtadvd_timer_rest(pfx->pfx_timer); 820 if (rest) { /* XXX: what if not? */ 821 printf(" expire=%s", sec2str(rest->tv_sec, ssbuf)); 822 } 823 } 824 825 printf(")\n"); --- 114 unchanged lines hidden --- |