2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * This file implements the various access functions for the
7 * PROC file system. This is very similar to the IPv4 version,
8 * except it reports the sockets in the INET6 address family.
10 * Version: $Id: proc.c,v 1.13 2000/01/09 02:19:55 davem Exp $
12 * Authors: David S. Miller (davem@caip.rutgers.edu)
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
19 #include <linux/sched.h>
20 #include <linux/socket.h>
21 #include <linux/net.h>
22 #include <linux/in6.h>
23 #include <linux/stddef.h>
26 #include <net/transp_v6.h>
29 static int fold_prot_inuse(struct proto
*proto
)
34 for (cpu
=0; cpu
<smp_num_cpus
; cpu
++)
35 res
+= proto
->stats
[cpu
].inuse
;
40 int afinet6_get_info(char *buffer
, char **start
, off_t offset
, int length
, int dummy
)
43 len
+= sprintf(buffer
+len
, "TCP6: inuse %d\n",
44 fold_prot_inuse(&tcpv6_prot
));
45 len
+= sprintf(buffer
+len
, "UDP6: inuse %d\n",
46 fold_prot_inuse(&udpv6_prot
));
47 len
+= sprintf(buffer
+len
, "RAW6: inuse %d\n",
48 fold_prot_inuse(&rawv6_prot
));
49 *start
= buffer
+ offset
;
63 /* ipv6 mib according to draft-ietf-ipngwg-ipv6-mib-04 */
64 #define SNMP6_GEN(x) { #x , &ipv6_statistics[0].x, sizeof(struct ipv6_mib)/sizeof(unsigned long) }
65 SNMP6_GEN(Ip6InReceives
),
66 SNMP6_GEN(Ip6InHdrErrors
),
67 SNMP6_GEN(Ip6InTooBigErrors
),
68 SNMP6_GEN(Ip6InNoRoutes
),
69 SNMP6_GEN(Ip6InAddrErrors
),
70 SNMP6_GEN(Ip6InUnknownProtos
),
71 SNMP6_GEN(Ip6InTruncatedPkts
),
72 SNMP6_GEN(Ip6InDiscards
),
73 SNMP6_GEN(Ip6InDelivers
),
74 SNMP6_GEN(Ip6OutForwDatagrams
),
75 SNMP6_GEN(Ip6OutRequests
),
76 SNMP6_GEN(Ip6OutDiscards
),
77 SNMP6_GEN(Ip6OutNoRoutes
),
78 SNMP6_GEN(Ip6ReasmTimeout
),
79 SNMP6_GEN(Ip6ReasmReqds
),
80 SNMP6_GEN(Ip6ReasmOKs
),
81 SNMP6_GEN(Ip6ReasmFails
),
82 SNMP6_GEN(Ip6FragOKs
),
83 SNMP6_GEN(Ip6FragFails
),
84 SNMP6_GEN(Ip6FragCreates
),
85 SNMP6_GEN(Ip6InMcastPkts
),
86 SNMP6_GEN(Ip6OutMcastPkts
),
88 /* icmpv6 mib according to draft-ietf-ipngwg-ipv6-icmp-mib-02
90 Exceptions: {In|Out}AdminProhibs are removed, because I see
91 no good reasons to account them separately
92 of another dest.unreachs.
93 OutErrs is zero identically.
95 OutRouterAdvertisements too.
96 OutGroupMembQueries too.
98 #define SNMP6_GEN(x) { #x , &icmpv6_statistics[0].x, sizeof(struct icmpv6_mib)/sizeof(unsigned long) }
99 SNMP6_GEN(Icmp6InMsgs
),
100 SNMP6_GEN(Icmp6InErrors
),
101 SNMP6_GEN(Icmp6InDestUnreachs
),
102 SNMP6_GEN(Icmp6InPktTooBigs
),
103 SNMP6_GEN(Icmp6InTimeExcds
),
104 SNMP6_GEN(Icmp6InParmProblems
),
105 SNMP6_GEN(Icmp6InEchos
),
106 SNMP6_GEN(Icmp6InEchoReplies
),
107 SNMP6_GEN(Icmp6InGroupMembQueries
),
108 SNMP6_GEN(Icmp6InGroupMembResponses
),
109 SNMP6_GEN(Icmp6InGroupMembReductions
),
110 SNMP6_GEN(Icmp6InRouterSolicits
),
111 SNMP6_GEN(Icmp6InRouterAdvertisements
),
112 SNMP6_GEN(Icmp6InNeighborSolicits
),
113 SNMP6_GEN(Icmp6InNeighborAdvertisements
),
114 SNMP6_GEN(Icmp6InRedirects
),
115 SNMP6_GEN(Icmp6OutMsgs
),
116 SNMP6_GEN(Icmp6OutDestUnreachs
),
117 SNMP6_GEN(Icmp6OutPktTooBigs
),
118 SNMP6_GEN(Icmp6OutTimeExcds
),
119 SNMP6_GEN(Icmp6OutParmProblems
),
120 SNMP6_GEN(Icmp6OutEchoReplies
),
121 SNMP6_GEN(Icmp6OutRouterSolicits
),
122 SNMP6_GEN(Icmp6OutNeighborSolicits
),
123 SNMP6_GEN(Icmp6OutNeighborAdvertisements
),
124 SNMP6_GEN(Icmp6OutRedirects
),
125 SNMP6_GEN(Icmp6OutGroupMembResponses
),
126 SNMP6_GEN(Icmp6OutGroupMembReductions
),
128 #define SNMP6_GEN(x) { "Udp6" #x , &udp_stats_in6[0].Udp##x, sizeof(struct udp_mib)/sizeof(unsigned long) }
129 SNMP6_GEN(InDatagrams
),
132 SNMP6_GEN(OutDatagrams
)
136 static unsigned long fold_field(unsigned long *ptr
, int size
)
138 unsigned long res
= 0;
141 for (i
=0; i
<smp_num_cpus
; i
++)
147 int afinet6_get_snmp(char *buffer
, char **start
, off_t offset
, int length
)
152 for (i
=0; i
<sizeof(snmp6_list
)/sizeof(snmp6_list
[0]); i
++)
153 len
+= sprintf(buffer
+len
, "%-32s\t%ld\n", snmp6_list
[i
].name
,
154 fold_field(snmp6_list
[i
].ptr
, snmp6_list
[i
].mibsize
));
163 *start
= buffer
+ offset
;