Deleted Added
full compact
inet6.c (78064) inet6.c (78238)
1/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
2/*
3 * Copyright (c) 1983, 1988, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
1/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
2/*
3 * Copyright (c) 1983, 1988, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * $FreeBSD: head/usr.bin/netstat/inet6.c 78064 2001-06-11 12:39:29Z ume $
34 * $FreeBSD: head/usr.bin/netstat/inet6.c 78238 2001-06-15 00:25:44Z assar $
35 */
36
37#ifndef lint
38/*
39static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
40*/
41#endif /* not lint */
42

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

1017 if (delivered || sflag <= 1)
1018 printf("\t%llu delivered\n", (unsigned long long)delivered);
1019 p(rip6s_opackets, "\t%llu datagram%s output\n");
1020#undef p
1021}
1022
1023/*
1024 * Pretty print an Internet address (net address + port).
35 */
36
37#ifndef lint
38/*
39static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
40*/
41#endif /* not lint */
42

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

1017 if (delivered || sflag <= 1)
1018 printf("\t%llu delivered\n", (unsigned long long)delivered);
1019 p(rip6s_opackets, "\t%llu datagram%s output\n");
1020#undef p
1021}
1022
1023/*
1024 * Pretty print an Internet address (net address + port).
1025 * If the nflag was specified, use numbers instead of names.
1025 * Take numeric_addr and numeric_port into consideration.
1026 */
1027#define GETSERVBYPORT6(port, proto, ret)\
1028{\
1029 if (strcmp((proto), "tcp6") == 0)\
1030 (ret) = getservbyport((int)(port), "tcp");\
1031 else if (strcmp((proto), "udp6") == 0)\
1032 (ret) = getservbyport((int)(port), "udp");\
1033 else\

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

1055 else
1056 sprintf(cp, "%d", ntohs((u_short)port));
1057 width = lflag ? 45 : Aflag ? 18 : 22;
1058 printf("%-*.*s ", width, width, line);
1059}
1060
1061/*
1062 * Construct an Internet address representation.
1026 */
1027#define GETSERVBYPORT6(port, proto, ret)\
1028{\
1029 if (strcmp((proto), "tcp6") == 0)\
1030 (ret) = getservbyport((int)(port), "tcp");\
1031 else if (strcmp((proto), "udp6") == 0)\
1032 (ret) = getservbyport((int)(port), "udp");\
1033 else\

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

1055 else
1056 sprintf(cp, "%d", ntohs((u_short)port));
1057 width = lflag ? 45 : Aflag ? 18 : 22;
1058 printf("%-*.*s ", width, width, line);
1059}
1060
1061/*
1062 * Construct an Internet address representation.
1063 * If the nflag has been supplied, give
1063 * If the numeric_addr has been supplied, give
1064 * numeric value, otherwise try for symbolic name.
1065 */
1066
1067char *
1068inet6name(in6p)
1069 struct in6_addr *in6p;
1070{
1071 register char *cp;
1072 static char line[50];
1073 struct hostent *hp;
1074 static char domain[MAXHOSTNAMELEN];
1075 static int first = 1;
1076
1064 * numeric value, otherwise try for symbolic name.
1065 */
1066
1067char *
1068inet6name(in6p)
1069 struct in6_addr *in6p;
1070{
1071 register char *cp;
1072 static char line[50];
1073 struct hostent *hp;
1074 static char domain[MAXHOSTNAMELEN];
1075 static int first = 1;
1076
1077 if (first && !nflag) {
1077 if (first && !numeric_addr) {
1078 first = 0;
1079 if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
1080 (cp = index(domain, '.')))
1081 (void) strcpy(domain, cp + 1);
1082 else
1083 domain[0] = 0;
1084 }
1085 cp = 0;
1078 first = 0;
1079 if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
1080 (cp = index(domain, '.')))
1081 (void) strcpy(domain, cp + 1);
1082 else
1083 domain[0] = 0;
1084 }
1085 cp = 0;
1086 if (!nflag && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
1086 if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
1087 hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6);
1088 if (hp) {
1089 if ((cp = index(hp->h_name, '.')) &&
1090 !strcmp(cp + 1, domain))
1091 *cp = 0;
1092 cp = hp->h_name;
1093 }
1094 }
1095 if (IN6_IS_ADDR_UNSPECIFIED(in6p))
1096 strcpy(line, "*");
1097 else if (cp)
1098 strcpy(line, cp);
1099 else
1100 sprintf(line, "%s",
1101 inet_ntop(AF_INET6, (void *)in6p, ntop_buf,
1102 sizeof(ntop_buf)));
1103 return (line);
1104}
1105#endif /*INET6*/
1087 hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6);
1088 if (hp) {
1089 if ((cp = index(hp->h_name, '.')) &&
1090 !strcmp(cp + 1, domain))
1091 *cp = 0;
1092 cp = hp->h_name;
1093 }
1094 }
1095 if (IN6_IS_ADDR_UNSPECIFIED(in6p))
1096 strcpy(line, "*");
1097 else if (cp)
1098 strcpy(line, cp);
1099 else
1100 sprintf(line, "%s",
1101 inet_ntop(AF_INET6, (void *)in6p, ntop_buf,
1102 sizeof(ntop_buf)));
1103 return (line);
1104}
1105#endif /*INET6*/