Deleted Added
full compact
inet.c (78064) inet.c (78238)
1/*
2 * Copyright (c) 1983, 1988, 1993, 1995
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/*
36static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
37*/
38static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1988, 1993, 1995
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/*
36static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
37*/
38static const char rcsid[] =
39 "$FreeBSD: head/usr.bin/netstat/inet.c 78064 2001-06-11 12:39:29Z ume $";
39 "$FreeBSD: head/usr.bin/netstat/inet.c 78238 2001-06-15 00:25:44Z assar $";
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/queue.h>
44#include <sys/socket.h>
45#include <sys/socketvar.h>
46#include <sys/sysctl.h>
47#include <sys/protosw.h>

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

254#endif
255 vchar = ((inp->inp_vflag & INP_IPV4) != 0)
256 ? "4 " : " ";
257
258 printf("%-3.3s%-2.2s %6ld %6ld ", name, vchar,
259 so->so_rcv.sb_cc,
260 so->so_snd.sb_cc);
261 }
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/queue.h>
44#include <sys/socket.h>
45#include <sys/socketvar.h>
46#include <sys/sysctl.h>
47#include <sys/protosw.h>

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

254#endif
255 vchar = ((inp->inp_vflag & INP_IPV4) != 0)
256 ? "4 " : " ";
257
258 printf("%-3.3s%-2.2s %6ld %6ld ", name, vchar,
259 so->so_rcv.sb_cc,
260 so->so_snd.sb_cc);
261 }
262 if (nflag) {
262 if (numeric_port) {
263 if (inp->inp_vflag & INP_IPV4) {
264 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
265 name, 1);
266 if (!Lflag)
267 inetprint(&inp->inp_faddr,
268 (int)inp->inp_fport, name, 1);
269 }
270#ifdef INET6

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

681#undef p
682#undef py
683}
684
685/*
686 * Pretty print an Internet address (net address + port).
687 */
688void
263 if (inp->inp_vflag & INP_IPV4) {
264 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
265 name, 1);
266 if (!Lflag)
267 inetprint(&inp->inp_faddr,
268 (int)inp->inp_fport, name, 1);
269 }
270#ifdef INET6

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

681#undef p
682#undef py
683}
684
685/*
686 * Pretty print an Internet address (net address + port).
687 */
688void
689inetprint(in, port, proto,numeric)
689inetprint(in, port, proto, numeric_port)
690 register struct in_addr *in;
691 int port;
692 char *proto;
690 register struct in_addr *in;
691 int port;
692 char *proto;
693 int numeric;
693 int numeric_port;
694{
695 struct servent *sp = 0;
696 char line[80], *cp;
697 int width;
698
699 if (Wflag)
700 sprintf(line, "%s.", inetname(in));
701 else
694{
695 struct servent *sp = 0;
696 char line[80], *cp;
697 int width;
698
699 if (Wflag)
700 sprintf(line, "%s.", inetname(in));
701 else
702 sprintf(line, "%.*s.", (Aflag && !numeric) ? 12 : 16, inetname(in));
702 sprintf(line, "%.*s.", (Aflag && !numeric_port) ? 12 : 16, inetname(in));
703 cp = index(line, '\0');
703 cp = index(line, '\0');
704 if (!numeric && port)
704 if (!numeric_port && port)
705 sp = getservbyport((int)port, proto);
706 if (sp || port == 0)
707 sprintf(cp, "%.15s ", sp ? sp->s_name : "*");
708 else
709 sprintf(cp, "%d ", ntohs((u_short)port));
710 width = (Aflag && !Wflag) ? 18 : 22;
711 if (Wflag)
712 printf("%-*s ", width, line);
713 else
714 printf("%-*.*s ", width, width, line);
715}
716
717/*
718 * Construct an Internet address representation.
705 sp = getservbyport((int)port, proto);
706 if (sp || port == 0)
707 sprintf(cp, "%.15s ", sp ? sp->s_name : "*");
708 else
709 sprintf(cp, "%d ", ntohs((u_short)port));
710 width = (Aflag && !Wflag) ? 18 : 22;
711 if (Wflag)
712 printf("%-*s ", width, line);
713 else
714 printf("%-*.*s ", width, width, line);
715}
716
717/*
718 * Construct an Internet address representation.
719 * If the nflag has been supplied, give
719 * If numeric_addr has been supplied, give
720 * numeric value, otherwise try for symbolic name.
721 */
722char *
723inetname(inp)
724 struct in_addr *inp;
725{
726 register char *cp;
727 static char line[MAXHOSTNAMELEN];
728 struct hostent *hp;
729 struct netent *np;
730
731 cp = 0;
720 * numeric value, otherwise try for symbolic name.
721 */
722char *
723inetname(inp)
724 struct in_addr *inp;
725{
726 register char *cp;
727 static char line[MAXHOSTNAMELEN];
728 struct hostent *hp;
729 struct netent *np;
730
731 cp = 0;
732 if (!nflag && inp->s_addr != INADDR_ANY) {
732 if (!numeric_addr && inp->s_addr != INADDR_ANY) {
733 int net = inet_netof(*inp);
734 int lna = inet_lnaof(*inp);
735
736 if (lna == INADDR_ANY) {
737 np = getnetbyaddr(net, AF_INET);
738 if (np)
739 cp = np->n_name;
740 }

--- 21 unchanged lines hidden ---
733 int net = inet_netof(*inp);
734 int lna = inet_lnaof(*inp);
735
736 if (lna == INADDR_ANY) {
737 np = getnetbyaddr(net, AF_INET);
738 if (np)
739 cp = np->n_name;
740 }

--- 21 unchanged lines hidden ---