2
* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
3
* info.c - Display detailed about the actual state of a network interface.
5
* Luca Deri <deri@ntop.org>
6
* Rocco Carbone <rocco@ntop.org>
7
* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33
* Print current network interface information
34
* in a format readable for humans.
36
int intop_info (int argc, char * argv [])
39
* Notice the command name.
41
char * commandname = argv [0];
45
printf ("Usage: %s [-h]\n\
46
[-i interface]\n", xxx)
47
char * optstring = "hi:";
50
* Reserve here space for the local variables.
52
char * interface = NULL;
61
* Parse command line options to the application via standard system calls.
63
while ((c = getopt (argc, argv, optstring)) != -1)
83
printf ("\nWrong option(s): \" ");
85
printf ("%s ", argv [optind ++]);
93
* Safe to play with the 'active' interface (if any)
94
* in case no specific one was chosen by the user.
96
if (! interface && ! (interface = intop_interface (active)))
98
printf ("No interface is currently enabled for packet sniffing.\n");
103
* Lookup for the given name in the table of enabled interfaces.
105
current = intop_lookup_interface (interface);
108
printf ("%s: unknown interface %s.\n", commandname, interface);
113
* General information about the interface.
116
n = nethandler (current);
119
char * fqdn = intop_iphuman (current);
121
if (strchr (fqdn, '.'))
122
printf ("Network interface: %s [%s] %s [%s] set to %s mode\n",
123
interface, intop_dltype (current),
124
fqdn, intop_ipdot (current),
125
get_intop_flags (current) == INTERFACE_READY ? "non promiscuous" : "promiscuous");
127
printf ("Network interface: %s [%s] %s.%s [%s] set to %s mode\n",
128
interface, intop_dltype (current),
129
fqdn, domainName, intop_ipdot (current),
130
get_intop_flags (current) == INTERFACE_READY ? "non promiscuous" : "promiscuous");
134
printf ("Sampling since : [%s] %s", formatSeconds (now - n -> started), ctime (& n -> started));
137
printf ("Packets:\n");
138
printf (" Received : %s\n", cformatPkts (receivedpkts (current)));
139
printf (" Dropped by program : %s\n", cformatPkts (droppedpkts (current)));
140
printf (" Dropped by kernel : %s\n", cformatPkts (kerneldroppedpkts (current)));
142
printf (" Ethernet : %s\n", cformatPkts (ethpkts (current)));
143
printf (" Unicast : %s\n",
144
cformatPkts (ethpkts (current) - broadcastpkts (current) - multicastpkts (current)));
145
printf (" Broadcast : %s\n", cformatPkts (broadcastpkts (current)));
146
printf (" Multicast : %s\n", cformatPkts (multicastpkts (current)));
152
printf (" Total : %s\n", cformatBytes (ethbytes (current)));
153
printf (" IP : %s\n", cformatBytes (ipbytes (current)));
154
printf (" TCP : %s\n", cformatBytes (tcpbytes (current)));
155
printf (" UDP : %s\n", cformatBytes (udpbytes (current)));
156
printf (" Other IP : %s\n", cformatBytes (otheripbytes (current)));
157
printf (" ICMP : %s\n", cformatBytes (icmpbytes (current)));
158
printf (" NetBIOS : %s\n", cformatBytes (netbiosbytes (current)));
159
printf (" r(ARP) : %s\n", cformatBytes (arpbytes (current)));
160
printf (" AppleTalk : %s\n", cformatBytes (appletalkbytes (current)));
161
printf (" IPX : %s\n", cformatBytes (ipxbytes (current)));
162
printf (" DecNET : %s\n", cformatBytes (decnetbytes (current)));
163
printf (" DLC : %s\n", cformatBytes (dlcbytes (current)));
164
printf (" OSPF : %s\n", cformatBytes (ospfbytes (current)));
165
printf (" EGP : %s\n", cformatBytes (egpbytes (current)));
166
printf (" IGMP : %s\n", cformatBytes (igmpbytes (current)));
167
printf (" OSI : %s\n", cformatBytes (osibytes (current)));
168
printf (" QNX : %s\n", cformatBytes (qnxbytes (current)));
169
printf (" Other : %s\n", cformatBytes (otherbytes (current)));