ndp.c (62590) | ndp.c (66865) |
---|---|
1/* $FreeBSD: head/usr.sbin/ndp/ndp.c 62590 2000-07-04 16:43:14Z itojun $ */ 2/* $KAME: ndp.c,v 1.41 2000/07/04 12:54:11 jinmei Exp $ */ | 1/* $FreeBSD: head/usr.sbin/ndp/ndp.c 66865 2000-10-09 09:28:49Z sumikawa $ */ 2/* $KAME: ndp.c,v 1.46 2000/10/09 09:17:10 sumikawa Exp $ */ |
3 4/* 5 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 106 unchanged lines hidden (view full) --- 117#endif 118 119/* packing rule for routing socket */ 120#define ROUNDUP(a) \ 121 ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) 122#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) 123 124static int pid; | 3 4/* 5 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 106 unchanged lines hidden (view full) --- 117#endif 118 119/* packing rule for routing socket */ 120#define ROUNDUP(a) \ 121 ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) 122#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) 123 124static int pid; |
125static int fflag; | 125static int cflag; |
126static int nflag; 127static int tflag; 128static int32_t thiszone; /* time difference with gmt */ 129static int s = -1; 130static int repeat = 0; 131static int lflag = 0; 132 133char ntop_buf[INET6_ADDRSTRLEN]; /* inet_ntop() */ --- 29 unchanged lines hidden (view full) --- 163static void ts_print __P((const struct timeval *)); 164 165int 166main(argc, argv) 167 int argc; 168 char **argv; 169{ 170 int ch; | 126static int nflag; 127static int tflag; 128static int32_t thiszone; /* time difference with gmt */ 129static int s = -1; 130static int repeat = 0; 131static int lflag = 0; 132 133char ntop_buf[INET6_ADDRSTRLEN]; /* inet_ntop() */ --- 29 unchanged lines hidden (view full) --- 163static void ts_print __P((const struct timeval *)); 164 165int 166main(argc, argv) 167 int argc; 168 char **argv; 169{ 170 int ch; |
171 int aflag = 0, cflag = 0, dflag = 0, sflag = 0, Hflag = 0, | 171 int aflag = 0, dflag = 0, sflag = 0, Hflag = 0, |
172 pflag = 0, rflag = 0, Pflag = 0, Rflag = 0; 173 174 pid = getpid(); 175 thiszone = gmt2local(0); 176 while ((ch = getopt(argc, argv, "acndfIilprstA:HPR")) != EOF) 177 switch ((char)ch) { 178 case 'a': 179 aflag = 1; 180 break; 181 case 'c': | 172 pflag = 0, rflag = 0, Pflag = 0, Rflag = 0; 173 174 pid = getpid(); 175 thiszone = gmt2local(0); 176 while ((ch = getopt(argc, argv, "acndfIilprstA:HPR")) != EOF) 177 switch ((char)ch) { 178 case 'a': 179 aflag = 1; 180 break; 181 case 'c': |
182 fflag = 1; | |
183 cflag = 1; 184 break; 185 case 'd': 186 dflag = 1; 187 break; 188 case 'I': 189#ifdef SIOCSDEFIFACE_IN6 /* XXX: check SIOCGDEFIFACE_IN6 as well? */ 190 if (argc > 2) --- 366 unchanged lines hidden (view full) --- 557 struct sockaddr_dl *sdl; 558 extern int h_errno; 559 struct in6_nbrinfo *nbi; 560 struct timeval time; 561 int addrwidth; 562 char flgbuf[8]; 563 564 /* Print header */ | 182 cflag = 1; 183 break; 184 case 'd': 185 dflag = 1; 186 break; 187 case 'I': 188#ifdef SIOCSDEFIFACE_IN6 /* XXX: check SIOCGDEFIFACE_IN6 as well? */ 189 if (argc > 2) --- 366 unchanged lines hidden (view full) --- 556 struct sockaddr_dl *sdl; 557 extern int h_errno; 558 struct in6_nbrinfo *nbi; 559 struct timeval time; 560 int addrwidth; 561 char flgbuf[8]; 562 563 /* Print header */ |
565 if (!tflag) | 564 if (!tflag && !cflag) |
566 printf("%-31.31s %-17.17s %6.6s %-9.9s %2s %4s %4s\n", 567 "Neighbor", "Linklayer Address", "Netif", "Expire", 568 "St", "Flgs", "Prbs"); 569 570again:; 571 mib[0] = CTL_NET; 572 mib[1] = PF_ROUTE; 573 mib[2] = 0; --- 18 unchanged lines hidden (view full) --- 592 sin = (struct sockaddr_in6 *)(rtm + 1); 593 sdl = (struct sockaddr_dl *)((char *)sin + ROUNDUP(sin->sin6_len)); 594 if (addr) { 595 if (!IN6_ARE_ADDR_EQUAL(addr, &sin->sin6_addr)) 596 continue; 597 found_entry = 1; 598 } else if (IN6_IS_ADDR_MULTICAST(&sin->sin6_addr)) 599 continue; | 565 printf("%-31.31s %-17.17s %6.6s %-9.9s %2s %4s %4s\n", 566 "Neighbor", "Linklayer Address", "Netif", "Expire", 567 "St", "Flgs", "Prbs"); 568 569again:; 570 mib[0] = CTL_NET; 571 mib[1] = PF_ROUTE; 572 mib[2] = 0; --- 18 unchanged lines hidden (view full) --- 591 sin = (struct sockaddr_in6 *)(rtm + 1); 592 sdl = (struct sockaddr_dl *)((char *)sin + ROUNDUP(sin->sin6_len)); 593 if (addr) { 594 if (!IN6_ARE_ADDR_EQUAL(addr, &sin->sin6_addr)) 595 continue; 596 found_entry = 1; 597 } else if (IN6_IS_ADDR_MULTICAST(&sin->sin6_addr)) 598 continue; |
600 if (fflag == 1) { 601 delete((char *)inet_ntop(AF_INET6, &sin->sin6_addr, 602 ntop_buf, sizeof(ntop_buf))); 603 continue; 604 } 605 | |
606 if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr) || 607 IN6_IS_ADDR_MC_LINKLOCAL(&sin->sin6_addr)) { 608 /* XXX: should scope id be filled in the kernel? */ 609 if (sin->sin6_scope_id == 0) 610 sin->sin6_scope_id = sdl->sdl_index; | 599 if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr) || 600 IN6_IS_ADDR_MC_LINKLOCAL(&sin->sin6_addr)) { 601 /* XXX: should scope id be filled in the kernel? */ 602 if (sin->sin6_scope_id == 0) 603 sin->sin6_scope_id = sdl->sdl_index; |
611 612 /* XXX: KAME specific hack; removed the embedded id */ | 604#ifdef __KAME__ 605 /* KAME specific hack; removed the embedded id */ |
613 *(u_int16_t *)&sin->sin6_addr.s6_addr[2] = 0; | 606 *(u_int16_t *)&sin->sin6_addr.s6_addr[2] = 0; |
607#endif |
|
614 } 615 getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf, 616 sizeof(host_buf), NULL, 0, 617 NI_WITHSCOPEID | (nflag ? NI_NUMERICHOST : 0)); | 608 } 609 getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf, 610 sizeof(host_buf), NULL, 0, 611 NI_WITHSCOPEID | (nflag ? NI_NUMERICHOST : 0)); |
612 if (cflag == 1) { 613 delete(host_buf); 614 continue; 615 } |
|
618 gettimeofday(&time, 0); 619 if (tflag) 620 ts_print(&time); 621 622 if (lflag) { 623 addrwidth = strlen(host_buf); 624 if (addrwidth < 31) 625 addrwidth = 31; --- 610 unchanged lines hidden --- | 616 gettimeofday(&time, 0); 617 if (tflag) 618 ts_print(&time); 619 620 if (lflag) { 621 addrwidth = strlen(host_buf); 622 if (addrwidth < 31) 623 addrwidth = 31; --- 610 unchanged lines hidden --- |