iPXE
ipstat.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25FILE_SECBOOT ( PERMITTED );
26
27#include <stdio.h>
28#include <ipxe/tcp.h>
29#include <ipxe/ipstat.h>
30#include <usr/ipstat.h>
31
32/** @file
33 *
34 * TCP/IP statistics
35 *
36 */
37
38/**
39 * Print TCP/IP statistics
40 *
41 */
42void ipstat ( void ) {
43 struct ip_statistics_family *family;
44 struct ip_statistics *stats;
45
46 /* Print per-family statistics */
48 stats = family->stats;
49 printf ( "IP version %d:\n", family->version );
50 printf ( " InReceives:%ld InMcastPkts:%ld InBcastPkts:%ld "
51 "InOctets:%ld\n", stats->in_receives,
52 stats->in_mcast_pkts, stats->in_bcast_pkts,
53 stats->in_octets );
54 printf ( " InHdrErrors:%ld InAddrErrors:%ld "
55 "InUnknownProtos:%ld InTruncatedPkts:%ld\n",
56 stats->in_hdr_errors, stats->in_addr_errors,
57 stats->in_unknown_protos, stats->in_truncated_pkts );
58 printf ( " ReasmReqds:%ld ReasmOKs:%ld ReasmFails:%ld\n",
59 stats->reasm_reqds, stats->reasm_oks,
60 stats->reasm_fails );
61 printf ( " InDelivers:%ld OutRequests:%ld OutNoRoutes:%ld\n",
62 stats->in_delivers, stats->out_requests,
63 stats->out_no_routes );
64 printf ( " OutTransmits:%ld OutMcastPkts:%ld OutBcastPkts:%ld "
65 "OutOctets:%ld\n", stats->out_transmits,
66 stats->out_mcast_pkts, stats->out_bcast_pkts,
67 stats->out_octets );
68 }
69
70 /* Print TCP statistics */
71 printf ( "TCP:\n" );
72 printf ( " InSegs:%ld InOctets:%ld InOctetsGood:%ld\n",
73 tcp_stats.in_segs, tcp_stats.in_octets,
74 tcp_stats.in_octets_good );
75 printf ( " InDiscards:%ld InOutOfOrder:%ld\n",
76 tcp_stats.in_discards, tcp_stats.in_out_of_order );
77}
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
void ipstat(void)
Print TCP/IP statistics.
Definition ipstat.c:42
IP statistics.
#define IP_STATISTICS_FAMILIES
IP system statistics family table.
Definition ipstat.h:178
An IP system statistics family.
Definition ipstat.h:170
struct ip_statistics * stats
Statistics.
Definition ipstat.h:174
unsigned int version
IP version.
Definition ipstat.h:172
IP system statistics.
Definition ipstat.h:45
unsigned long in_truncated_pkts
ipSystemStatsInTruncatedPkts
Definition ipstat.h:90
unsigned long in_unknown_protos
ipSystemStatsInUnknownProtos
Definition ipstat.h:84
unsigned long reasm_reqds
ipSystemStatsReasmReqds
Definition ipstat.h:96
unsigned long out_octets
ipSystemStatsOutOctets
Definition ipstat.h:146
unsigned long out_no_routes
ipSystemStatsOutNoRoutes
Definition ipstat.h:131
unsigned long reasm_oks
ipSystemStatsReasmOks
Definition ipstat.h:101
unsigned long out_mcast_pkts
ipSystemStatsOutMcastPkts
Definition ipstat.h:156
unsigned long in_addr_errors
ipSystemStatsInAddrErrors
Definition ipstat.h:77
unsigned long in_mcast_pkts
ipSystemStatsInMcastPkts
Definition ipstat.h:151
unsigned long in_receives
ipSystemStatsInReceives
Definition ipstat.h:51
unsigned long out_requests
ipSystemStatsOutRequests
Definition ipstat.h:124
unsigned long reasm_fails
ipSystemStatsReasmFails
Definition ipstat.h:111
unsigned long in_octets
ipSystemStatsInOctets
Definition ipstat.h:58
unsigned long out_bcast_pkts
ipSystemStatsOutBcastPkts
Definition ipstat.h:166
unsigned long in_hdr_errors
ipSystemStatsInHdrErrors
Definition ipstat.h:66
unsigned long out_transmits
ipSystemStatsOutTransmits
Definition ipstat.h:139
unsigned long in_delivers
ipSystemStatsInDelivers
Definition ipstat.h:117
unsigned long in_bcast_pkts
ipSystemStatsInBcastPkts
Definition ipstat.h:161
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition tables.h:386
struct tcp_statistics tcp_stats
TCP statistics.
Definition tcp.c:172
TCP protocol.
IP statistics.
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465