Deleted Added
full compact
route.c (54956) route.c (55163)
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. 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

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

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "From: @(#)route.c 8.6 (Berkeley) 4/28/95";
37#endif
38static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. 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

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

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "From: @(#)route.c 8.6 (Berkeley) 4/28/95";
37#endif
38static const char rcsid[] =
39 "$FreeBSD: head/usr.bin/netstat/route.c 54956 1999-12-21 11:25:30Z shin $";
39 "$FreeBSD: head/usr.bin/netstat/route.c 55163 1999-12-28 02:37:14Z shin $";
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/protosw.h>
44#include <sys/socket.h>
45#include <sys/time.h>
46
47#include <net/if.h>

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

600 bcopy(sa, &mask, sa->sa_len);
601 p_sockaddr(&addr.u_sa, &mask.u_sa, rt->rt_flags,
602#ifdef INET6
603 addr.u_sa.sa_family == AF_INET6 ? WID_DST6 :
604#endif
605 WID_DST);
606 p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST,
607#ifdef INET6
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/protosw.h>
44#include <sys/socket.h>
45#include <sys/time.h>
46
47#include <net/if.h>

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

600 bcopy(sa, &mask, sa->sa_len);
601 p_sockaddr(&addr.u_sa, &mask.u_sa, rt->rt_flags,
602#ifdef INET6
603 addr.u_sa.sa_family == AF_INET6 ? WID_DST6 :
604#endif
605 WID_DST);
606 p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST,
607#ifdef INET6
608 kgetsa(rt->rt_gateway)->sa_family == AF_INET6 ? WID_GW6 :
608 addr.u_sa.sa_family == AF_INET6 ? WID_GW6 :
609#endif
610 WID_GW);
611 p_flags(rt->rt_flags, "%-6.6s ");
612 if (lflag)
613 printf("%6ld %8ld ", rt->rt_refcnt, rt->rt_use);
614 if (rt->rt_ifp) {
615 if (rt->rt_ifp != lastif) {
616 kget(rt->rt_ifp, ifnet);

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

758netname6(sa6, mask)
759 struct sockaddr_in6 *sa6;
760 struct in6_addr *mask;
761{
762 static char line[MAXHOSTNAMELEN + 1];
763 u_char *p = (u_char *)mask;
764 u_char *lim;
765 int masklen, illegal = 0;
609#endif
610 WID_GW);
611 p_flags(rt->rt_flags, "%-6.6s ");
612 if (lflag)
613 printf("%6ld %8ld ", rt->rt_refcnt, rt->rt_use);
614 if (rt->rt_ifp) {
615 if (rt->rt_ifp != lastif) {
616 kget(rt->rt_ifp, ifnet);

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

758netname6(sa6, mask)
759 struct sockaddr_in6 *sa6;
760 struct in6_addr *mask;
761{
762 static char line[MAXHOSTNAMELEN + 1];
763 u_char *p = (u_char *)mask;
764 u_char *lim;
765 int masklen, illegal = 0;
766#ifdef notyet
767 int flag = NI_WITHSCOPEID;
766 int flag = NI_WITHSCOPEID;
768#endif
769
770 if (mask) {
771 for (masklen = 0, lim = p + 16; p < lim; p++) {
767
768 if (mask) {
769 for (masklen = 0, lim = p + 16; p < lim; p++) {
770 if (*p == 0xff)
771 masklen += 8;
772 else
773 break;
774 }
775 if (p < lim) {
772 switch (*p) {
776 switch (*p) {
773 case 0xff:
774 masklen += 8;
775 break;
776 case 0xfe:
777 masklen += 7;
778 break;
779 case 0xfc:
780 masklen += 6;
781 break;
782 case 0xf8:
783 masklen += 5;

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

805 fprintf(stderr, "illegal prefixlen\n");
806 }
807 else
808 masklen = 128;
809
810 if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr))
811 return("default");
812
777 case 0xfe:
778 masklen += 7;
779 break;
780 case 0xfc:
781 masklen += 6;
782 break;
783 case 0xf8:
784 masklen += 5;

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

806 fprintf(stderr, "illegal prefixlen\n");
807 }
808 else
809 masklen = 128;
810
811 if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr))
812 return("default");
813
813#ifdef notyet
814 if (nflag)
815 flag |= NI_NUMERICHOST;
816 getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line),
817 NULL, 0, flag);
814 if (nflag)
815 flag |= NI_NUMERICHOST;
816 getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line),
817 NULL, 0, flag);
818#else
819 inet_ntop(AF_INET6, (void *)&sa6->sin6_addr, line, sizeof(line));
820#endif
821
822 if (nflag)
823 sprintf(&line[strlen(line)], "/%d", masklen);
824
825 return line;
826}
827
828char *
829routename6(sa6)
830 struct sockaddr_in6 *sa6;
831{
818
819 if (nflag)
820 sprintf(&line[strlen(line)], "/%d", masklen);
821
822 return line;
823}
824
825char *
826routename6(sa6)
827 struct sockaddr_in6 *sa6;
828{
832#ifdef notyet
829 static char line[MAXHOSTNAMELEN + 1];
833 int flag = NI_WITHSCOPEID;
834
835 if (nflag)
836 flag |= NI_NUMERICHOST;
830 int flag = NI_WITHSCOPEID;
831
832 if (nflag)
833 flag |= NI_NUMERICHOST;
837#else
838 register char *cp;
839#endif
840 static char line[MAXHOSTNAMELEN + 1];
841 struct hostent *hp;
842
834
843#ifdef notyet
844 getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line),
845 NULL, 0, flag);
835 getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line),
836 NULL, 0, flag);
846#else
847 cp = 0;
848 if (!nflag) {
849 hp = gethostbyaddr((char *)&sa6->sin6_addr,
850 sizeof(sa6->sin6_addr), AF_INET6);
851 if (hp) {
852 cp = hp->h_name;
853 trimdomain(cp);
854 }
855 }
856 if (cp) {
857 strncpy(line, cp, sizeof(line) - 1);
858 line[sizeof(line) - 1] = '\0';
859 } else
860 inet_ntop(AF_INET6, (void *)&sa6->sin6_addr, line,
861 sizeof(line));
862#endif
863
864 return line;
865}
866#endif /*INET6*/
867
868/*
869 * Print routing statistics
870 */

--- 205 unchanged lines hidden ---
837
838 return line;
839}
840#endif /*INET6*/
841
842/*
843 * Print routing statistics
844 */

--- 205 unchanged lines hidden ---