Deleted Added
full compact
inet6.c (228700) inet6.c (229403)
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:

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

30
31#if 0
32#ifndef lint
33static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
34#endif /* not lint */
35#endif
36
37#include <sys/cdefs.h>
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:

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

30
31#if 0
32#ifndef lint
33static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
34#endif /* not lint */
35#endif
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/usr.bin/netstat/inet6.c 228700 2011-12-19 05:50:34Z maxim $");
38__FBSDID("$FreeBSD: head/usr.bin/netstat/inet6.c 229403 2012-01-03 18:51:58Z ed $");
39
40#ifdef INET6
41#include <sys/param.h>
42#include <sys/socket.h>
43#include <sys/socketvar.h>
44#include <sys/ioctl.h>
45#include <sys/mbuf.h>
46#include <sys/protosw.h>

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

1095inet6print(struct in6_addr *in6, int port, const char *proto, int numeric)
1096{
1097 struct servent *sp = 0;
1098 char line[80], *cp;
1099 int width;
1100
1101 sprintf(line, "%.*s.", Wflag ? 39 :
1102 (Aflag && !numeric) ? 12 : 16, inet6name(in6));
39
40#ifdef INET6
41#include <sys/param.h>
42#include <sys/socket.h>
43#include <sys/socketvar.h>
44#include <sys/ioctl.h>
45#include <sys/mbuf.h>
46#include <sys/protosw.h>

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

1095inet6print(struct in6_addr *in6, int port, const char *proto, int numeric)
1096{
1097 struct servent *sp = 0;
1098 char line[80], *cp;
1099 int width;
1100
1101 sprintf(line, "%.*s.", Wflag ? 39 :
1102 (Aflag && !numeric) ? 12 : 16, inet6name(in6));
1103 cp = index(line, '\0');
1103 cp = strchr(line, '\0');
1104 if (!numeric && port)
1105 GETSERVBYPORT6(port, proto, sp);
1106 if (sp || port == 0)
1107 sprintf(cp, "%.15s", sp ? sp->s_name : "*");
1108 else
1109 sprintf(cp, "%d", ntohs((u_short)port));
1110 width = Wflag ? 45 : Aflag ? 18 : 22;
1111 printf("%-*.*s ", width, width, line);

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

1124 static char line[50];
1125 struct hostent *hp;
1126 static char domain[MAXHOSTNAMELEN];
1127 static int first = 1;
1128
1129 if (first && !numeric_addr) {
1130 first = 0;
1131 if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
1104 if (!numeric && port)
1105 GETSERVBYPORT6(port, proto, sp);
1106 if (sp || port == 0)
1107 sprintf(cp, "%.15s", sp ? sp->s_name : "*");
1108 else
1109 sprintf(cp, "%d", ntohs((u_short)port));
1110 width = Wflag ? 45 : Aflag ? 18 : 22;
1111 printf("%-*.*s ", width, width, line);

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

1124 static char line[50];
1125 struct hostent *hp;
1126 static char domain[MAXHOSTNAMELEN];
1127 static int first = 1;
1128
1129 if (first && !numeric_addr) {
1130 first = 0;
1131 if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
1132 (cp = index(domain, '.')))
1132 (cp = strchr(domain, '.')))
1133 (void) strcpy(domain, cp + 1);
1134 else
1135 domain[0] = 0;
1136 }
1137 cp = 0;
1138 if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
1139 hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6);
1140 if (hp) {
1133 (void) strcpy(domain, cp + 1);
1134 else
1135 domain[0] = 0;
1136 }
1137 cp = 0;
1138 if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
1139 hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6);
1140 if (hp) {
1141 if ((cp = index(hp->h_name, '.')) &&
1141 if ((cp = strchr(hp->h_name, '.')) &&
1142 !strcmp(cp + 1, domain))
1143 *cp = 0;
1144 cp = hp->h_name;
1145 }
1146 }
1147 if (IN6_IS_ADDR_UNSPECIFIED(in6p))
1148 strcpy(line, "*");
1149 else if (cp)
1150 strcpy(line, cp);
1151 else
1152 sprintf(line, "%s",
1153 inet_ntop(AF_INET6, (void *)in6p, ntop_buf,
1154 sizeof(ntop_buf)));
1155 return (line);
1156}
1157#endif /*INET6*/
1142 !strcmp(cp + 1, domain))
1143 *cp = 0;
1144 cp = hp->h_name;
1145 }
1146 }
1147 if (IN6_IS_ADDR_UNSPECIFIED(in6p))
1148 strcpy(line, "*");
1149 else if (cp)
1150 strcpy(line, cp);
1151 else
1152 sprintf(line, "%s",
1153 inet_ntop(AF_INET6, (void *)in6p, ntop_buf,
1154 sizeof(ntop_buf)));
1155 return (line);
1156}
1157#endif /*INET6*/