Deleted Added
full compact
route.c (78078) route.c (78238)
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 78078 2001-06-11 17:32:53Z ume $";
39 "$FreeBSD: head/usr.bin/netstat/route.c 78238 2001-06-15 00:25:44Z assar $";
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>

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

230
231/* column widths; each followed by one space */
232#ifndef INET6
233#define WID_DST(af) 18 /* width of destination column */
234#define WID_GW(af) 18 /* width of gateway column */
235#define WID_IF(af) 6 /* width of netif column */
236#else
237#define WID_DST(af) \
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>

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

230
231/* column widths; each followed by one space */
232#ifndef INET6
233#define WID_DST(af) 18 /* width of destination column */
234#define WID_GW(af) 18 /* width of gateway column */
235#define WID_IF(af) 6 /* width of netif column */
236#else
237#define WID_DST(af) \
238 ((af) == AF_INET6 ? (lflag ? 39 : (nflag ? 33: 18)) : 18)
238 ((af) == AF_INET6 ? (lflag ? 39 : (numeric_addr ? 33: 18)) : 18)
239#define WID_GW(af) \
239#define WID_GW(af) \
240 ((af) == AF_INET6 ? (lflag ? 31 : (nflag ? 29 : 18)) : 18)
240 ((af) == AF_INET6 ? (lflag ? 31 : (numeric_addr ? 29 : 18)) : 18)
241#define WID_IF(af) ((af) == AF_INET6 ? 8 : 6)
242#endif /*INET6*/
243
244/*
245 * Print header for routing table columns.
246 */
247void
248pr_rthdr(af)

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

559 cp += sprintf(cp, "%02x", *s++);
560 }
561 cp = workbuf;
562 }
563 }
564 if (width < 0 )
565 printf("%s ", cp);
566 else {
241#define WID_IF(af) ((af) == AF_INET6 ? 8 : 6)
242#endif /*INET6*/
243
244/*
245 * Print header for routing table columns.
246 */
247void
248pr_rthdr(af)

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

559 cp += sprintf(cp, "%02x", *s++);
560 }
561 cp = workbuf;
562 }
563 }
564 if (width < 0 )
565 printf("%s ", cp);
566 else {
567 if (nflag)
567 if (numeric_addr)
568 printf("%-*s ", width, cp);
569 else
570 printf("%-*.*s ", width, width, cp);
571 }
572}
573
574static void
575p_flags(f, format)

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

657routename(in)
658 u_long in;
659{
660 register char *cp;
661 static char line[MAXHOSTNAMELEN];
662 struct hostent *hp;
663
664 cp = 0;
568 printf("%-*s ", width, cp);
569 else
570 printf("%-*.*s ", width, width, cp);
571 }
572}
573
574static void
575p_flags(f, format)

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

657routename(in)
658 u_long in;
659{
660 register char *cp;
661 static char line[MAXHOSTNAMELEN];
662 struct hostent *hp;
663
664 cp = 0;
665 if (!nflag) {
665 if (!numeric_addr) {
666 hp = gethostbyaddr((char *)&in, sizeof (struct in_addr),
667 AF_INET);
668 if (hp) {
669 cp = hp->h_name;
670 trimdomain(cp, strlen(cp));
671 }
672 }
673 if (cp) {

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

739 static char line[MAXHOSTNAMELEN];
740 struct netent *np = 0;
741 u_long net, omask, dmask;
742 register u_long i;
743
744 i = ntohl(in);
745 dmask = forgemask(i);
746 omask = mask;
666 hp = gethostbyaddr((char *)&in, sizeof (struct in_addr),
667 AF_INET);
668 if (hp) {
669 cp = hp->h_name;
670 trimdomain(cp, strlen(cp));
671 }
672 }
673 if (cp) {

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

739 static char line[MAXHOSTNAMELEN];
740 struct netent *np = 0;
741 u_long net, omask, dmask;
742 register u_long i;
743
744 i = ntohl(in);
745 dmask = forgemask(i);
746 omask = mask;
747 if (!nflag && i) {
747 if (!numeric_addr && i) {
748 net = i & dmask;
749 if (!(np = getnetbyaddr(i, AF_INET)) && net != i)
750 np = getnetbyaddr(net, AF_INET);
751 if (np) {
752 cp = np->n_name;
753 trimdomain(cp, strlen(cp));
754 }
755 }

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

836 fprintf(stderr, "illegal prefixlen\n");
837 }
838 else
839 masklen = 128;
840
841 if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr))
842 return("default");
843
748 net = i & dmask;
749 if (!(np = getnetbyaddr(i, AF_INET)) && net != i)
750 np = getnetbyaddr(net, AF_INET);
751 if (np) {
752 cp = np->n_name;
753 trimdomain(cp, strlen(cp));
754 }
755 }

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

836 fprintf(stderr, "illegal prefixlen\n");
837 }
838 else
839 masklen = 128;
840
841 if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr))
842 return("default");
843
844 if (nflag)
844 if (numeric_addr)
845 flag |= NI_NUMERICHOST;
846 getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line),
847 NULL, 0, flag);
848
845 flag |= NI_NUMERICHOST;
846 getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line),
847 NULL, 0, flag);
848
849 if (nflag)
849 if (numeric_addr)
850 sprintf(&line[strlen(line)], "/%d", masklen);
851
852 return line;
853}
854
855char *
856routename6(sa6)
857 struct sockaddr_in6 *sa6;
858{
859 static char line[MAXHOSTNAMELEN];
860 int flag = NI_WITHSCOPEID;
861 /* use local variable for safety */
862 struct sockaddr_in6 sa6_local = {AF_INET6, sizeof(sa6_local),};
863
864 sa6_local.sin6_addr = sa6->sin6_addr;
865 sa6_local.sin6_scope_id = sa6->sin6_scope_id;
866
850 sprintf(&line[strlen(line)], "/%d", masklen);
851
852 return line;
853}
854
855char *
856routename6(sa6)
857 struct sockaddr_in6 *sa6;
858{
859 static char line[MAXHOSTNAMELEN];
860 int flag = NI_WITHSCOPEID;
861 /* use local variable for safety */
862 struct sockaddr_in6 sa6_local = {AF_INET6, sizeof(sa6_local),};
863
864 sa6_local.sin6_addr = sa6->sin6_addr;
865 sa6_local.sin6_scope_id = sa6->sin6_scope_id;
866
867 if (nflag)
867 if (numeric_addr)
868 flag |= NI_NUMERICHOST;
869
870 getnameinfo((struct sockaddr *)&sa6_local, sa6_local.sin6_len,
871 line, sizeof(line), NULL, 0, flag);
872
873 return line;
874}
875#endif /*INET6*/

--- 209 unchanged lines hidden ---
868 flag |= NI_NUMERICHOST;
869
870 getnameinfo((struct sockaddr *)&sa6_local, sa6_local.sin6_len,
871 line, sizeof(line), NULL, 0, flag);
872
873 return line;
874}
875#endif /*INET6*/

--- 209 unchanged lines hidden ---