Deleted Added
sdiff udiff text old ( 189592 ) new ( 191672 )
full compact
1/* $KAME: ifmcstat.c,v 1.48 2006/11/15 05:13:59 itojun Exp $ */
2
3/*
4 * Copyright (c) 2007-2009 Bruce Simpson.
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 17 unchanged lines hidden (view full) ---

26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/usr.sbin/ifmcstat/ifmcstat.c 189592 2009-03-09 17:53:05Z bms $");
35
36#include <sys/types.h>
37#include <sys/param.h>
38#include <sys/sysctl.h>
39#include <sys/socket.h>
40#include <sys/queue.h>
41#include <sys/tree.h>
42

--- 119 unchanged lines hidden (view full) ---

162#endif /* WITH_KVM */
163
164static int ifmcstat_getifmaddrs(void);
165#ifdef INET
166static void in_ifinfo(struct igmp_ifinfo *);
167static const char * inm_mode(u_int mode);
168#endif
169#ifdef INET6
170static const char * inet6_n2a(struct in6_addr *);
171#endif
172int main(int, char **);
173
174static void
175usage()
176{
177

--- 258 unchanged lines hidden (view full) ---

436 ifmp = TAILQ_NEXT(&ifm, ifma_link);
437 }
438 }
439}
440
441#ifdef INET6
442
443static void
444if6_addrlist(struct ifaddr *ifap)
445{
446 struct ifaddr ifa;
447 struct sockaddr sa;
448 struct in6_ifaddr if6a;
449 struct ifaddr *ifap0;
450
451 if (af && af != AF_INET6)
452 return;
453 ifap0 = ifap;
454 while (ifap) {
455 KREAD(ifap, &ifa, struct ifaddr);
456 if (ifa.ifa_addr == NULL)
457 goto nextifap;
458 KREAD(ifa.ifa_addr, &sa, struct sockaddr);
459 if (sa.sa_family != PF_INET6)
460 goto nextifap;
461 KREAD(ifap, &if6a, struct in6_ifaddr);
462 printf("\tinet6 %s\n", inet6_n2a(&if6a.ia_addr.sin6_addr));
463 nextifap:
464 ifap = ifa.ifa_link.tqe_next;
465 }
466 if (ifap0) {
467 struct ifnet ifnet;
468 struct ifmultiaddr ifm, *ifmp = 0;
469 struct sockaddr_dl sdl;
470

--- 366 unchanged lines hidden (view full) ---

837
838out_free:
839 free(buf);
840#undef MAX_SYSCTL_TRY
841}
842
843#endif /* INET */
844
845static int
846ifmcstat_getifmaddrs(void)
847{
848 char thisifname[IFNAMSIZ];
849 char addrbuf[NI_MAXHOST];
850 struct ifaddrs *ifap, *ifa;
851 struct ifmaddrs *ifmap, *ifma;
852 sockunion_t lastifasa;

--- 157 unchanged lines hidden (view full) ---

1010 len = sizeof(struct igmp_ifinfo);
1011 if (sysctl(mib, mibsize + 1, &igi, &len, NULL,
1012 0) == -1) {
1013 perror("sysctl net.inet.igmp.ifinfo");
1014 goto next_ifnet;
1015 }
1016 in_ifinfo(&igi);
1017 }
1018next_ifnet:
1019#endif
1020 lastifasa = *pifasa;
1021 }
1022
1023 /* Print this group address. */
1024#ifdef INET6
1025 if (pgsa->sa.sa_family == AF_INET6) {

--- 10 unchanged lines hidden (view full) ---

1036
1037 fprintf(stdout, "\t\tgroup %s", addrbuf);
1038#ifdef INET
1039 if (pgsa->sa.sa_family == AF_INET) {
1040 inm_print_sources_sysctl(thisifindex,
1041 pgsa->sin.sin_addr);
1042 }
1043#endif
1044 fprintf(stdout, "\n");
1045
1046 /* Link-layer mapping, if present. */
1047 pllsa = (sockunion_t *)ifma->ifma_lladdr;
1048 if (pllsa != NULL) {
1049 error = getnameinfo(&pllsa->sa, pllsa->sa.sa_len,
1050 addrbuf, sizeof(addrbuf), NULL, 0, NI_NUMERICHOST);
1051 fprintf(stdout, "\t\t\tmcast-macaddr %s\n", addrbuf);
1052 }
1053 }
1054out:
1055 if (ifmap != NULL)
1056 freeifmaddrs(ifmap);
1057 if (ifap != NULL)
1058 freeifaddrs(ifap);
1059
1060 return (error);
1061}