This source file includes following definitions.
- get__netinfo
- tcp_get_info
- udp_get_info
- raw_get_info
- afinet_get_info
- snmp_get_info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #include <asm/system.h>
33 #include <linux/autoconf.h>
34 #include <linux/sched.h>
35 #include <linux/socket.h>
36 #include <linux/net.h>
37 #include <linux/un.h>
38 #include <linux/in.h>
39 #include <linux/param.h>
40 #include <linux/inet.h>
41 #include <linux/netdevice.h>
42 #include <net/ip.h>
43 #include <net/icmp.h>
44 #include <net/protocol.h>
45 #include <net/tcp.h>
46 #include <net/udp.h>
47 #include <linux/skbuff.h>
48 #include <net/sock.h>
49 #include <net/raw.h>
50
51
52
53
54
55
56
57
58 static int
59 get__netinfo(struct proto *pro, char *buffer, int format, char **start, off_t offset, int length)
60 {
61 struct sock **s_array;
62 struct sock *sp;
63 int i;
64 int timer_active;
65 int timer_active1;
66 int timer_active2;
67 unsigned long timer_expires;
68 unsigned long dest, src;
69 unsigned short destp, srcp;
70 int len=0;
71 off_t pos=0;
72 off_t begin=0;
73
74 s_array = pro->sock_array;
75 len += sprintf(buffer, "sl local_address rem_address st tx_queue rx_queue tr tm->when uid\n");
76
77
78
79
80
81
82 for(i = 0; i < SOCK_ARRAY_SIZE; i++)
83 {
84 cli();
85 sp = s_array[i];
86 while(sp != NULL)
87 {
88 dest = sp->daddr;
89 src = sp->saddr;
90 destp = sp->dummy_th.dest;
91 srcp = sp->dummy_th.source;
92
93
94 destp = ntohs(destp);
95 srcp = ntohs(srcp);
96 timer_active1 = del_timer(&sp->retransmit_timer);
97 timer_active2 = del_timer(&sp->timer);
98 if (!timer_active1) sp->retransmit_timer.expires=0;
99 if (!timer_active2) sp->timer.expires=0;
100 timer_active=0;
101 timer_expires=(unsigned)-1;
102 if (timer_active1 &&
103 sp->retransmit_timer.expires < timer_expires) {
104 timer_active=timer_active1;
105 timer_expires=sp->retransmit_timer.expires;
106 }
107 if (timer_active2 &&
108 sp->timer.expires < timer_expires) {
109 timer_active=timer_active2;
110 timer_expires=sp->timer.expires;
111 }
112 len += sprintf(buffer+len, "%2d: %08lX:%04X %08lX:%04X %02X %08lX:%08lX %02X:%08lX %08X %d %d\n",
113 i, src, srcp, dest, destp, sp->state,
114 format==0?sp->write_seq-sp->rcv_ack_seq:sp->rmem_alloc,
115 format==0?sp->acked_seq-sp->copied_seq:sp->wmem_alloc,
116 timer_active, timer_expires-jiffies, (unsigned) sp->retransmits,
117 (sp->socket&&SOCK_INODE(sp->socket))?SOCK_INODE(sp->socket)->i_uid:0,
118 timer_active?sp->timeout:0);
119 if (timer_active1) add_timer(&sp->retransmit_timer);
120 if (timer_active2) add_timer(&sp->timer);
121
122
123
124
125
126 sp = sp->next;
127 pos=begin+len;
128 if(pos<offset)
129 {
130 len=0;
131 begin=pos;
132 }
133 if(pos>offset+length)
134 break;
135 }
136 sti();
137
138
139
140 if(pos>offset+length)
141 break;
142 }
143 *start=buffer+(offset-begin);
144 len-=(offset-begin);
145 if(len>length)
146 len=length;
147 return len;
148 }
149
150
151 int tcp_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
152 {
153 return get__netinfo(&tcp_prot, buffer,0, start, offset, length);
154 }
155
156
157 int udp_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
158 {
159 return get__netinfo(&udp_prot, buffer,1, start, offset, length);
160 }
161
162
163 int raw_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
164 {
165 return get__netinfo(&raw_prot, buffer,1, start, offset, length);
166 }
167
168
169
170
171
172 int afinet_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
173 {
174
175 extern int socket_get_info(char *, char **, off_t, int);
176 extern struct proto packet_prot;
177
178 int len = socket_get_info(buffer,start,offset,length);
179
180 len += sprintf(buffer+len,"SOCK_ARRAY_SIZE=%d\n",SOCK_ARRAY_SIZE);
181 len += sprintf(buffer+len,"TCP: inuse %d highest %d\n",
182 tcp_prot.inuse, tcp_prot.highestinuse);
183 len += sprintf(buffer+len,"UDP: inuse %d highest %d\n",
184 udp_prot.inuse, udp_prot.highestinuse);
185 len += sprintf(buffer+len,"RAW: inuse %d highest %d\n",
186 raw_prot.inuse, raw_prot.highestinuse);
187 len += sprintf(buffer+len,"PAC: inuse %d highest %d\n",
188 packet_prot.inuse, packet_prot.highestinuse);
189 *start = buffer + offset;
190 len -= offset;
191 if (len > length)
192 len = length;
193 return len;
194 }
195
196
197
198
199
200
201 int snmp_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
202 {
203 extern struct tcp_mib tcp_statistics;
204 extern struct udp_mib udp_statistics;
205 int len;
206
207
208
209
210 len = sprintf (buffer,
211 "Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates\n"
212 "Ip: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
213 ip_statistics.IpForwarding, ip_statistics.IpDefaultTTL,
214 ip_statistics.IpInReceives, ip_statistics.IpInHdrErrors,
215 ip_statistics.IpInAddrErrors, ip_statistics.IpForwDatagrams,
216 ip_statistics.IpInUnknownProtos, ip_statistics.IpInDiscards,
217 ip_statistics.IpInDelivers, ip_statistics.IpOutRequests,
218 ip_statistics.IpOutDiscards, ip_statistics.IpOutNoRoutes,
219 ip_statistics.IpReasmTimeout, ip_statistics.IpReasmReqds,
220 ip_statistics.IpReasmOKs, ip_statistics.IpReasmFails,
221 ip_statistics.IpFragOKs, ip_statistics.IpFragFails,
222 ip_statistics.IpFragCreates);
223
224 len += sprintf (buffer + len,
225 "Icmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps\n"
226 "Icmp: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
227 icmp_statistics.IcmpInMsgs, icmp_statistics.IcmpInErrors,
228 icmp_statistics.IcmpInDestUnreachs, icmp_statistics.IcmpInTimeExcds,
229 icmp_statistics.IcmpInParmProbs, icmp_statistics.IcmpInSrcQuenchs,
230 icmp_statistics.IcmpInRedirects, icmp_statistics.IcmpInEchos,
231 icmp_statistics.IcmpInEchoReps, icmp_statistics.IcmpInTimestamps,
232 icmp_statistics.IcmpInTimestampReps, icmp_statistics.IcmpInAddrMasks,
233 icmp_statistics.IcmpInAddrMaskReps, icmp_statistics.IcmpOutMsgs,
234 icmp_statistics.IcmpOutErrors, icmp_statistics.IcmpOutDestUnreachs,
235 icmp_statistics.IcmpOutTimeExcds, icmp_statistics.IcmpOutParmProbs,
236 icmp_statistics.IcmpOutSrcQuenchs, icmp_statistics.IcmpOutRedirects,
237 icmp_statistics.IcmpOutEchos, icmp_statistics.IcmpOutEchoReps,
238 icmp_statistics.IcmpOutTimestamps, icmp_statistics.IcmpOutTimestampReps,
239 icmp_statistics.IcmpOutAddrMasks, icmp_statistics.IcmpOutAddrMaskReps);
240
241 len += sprintf (buffer + len,
242 "Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs\n"
243 "Tcp: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
244 tcp_statistics.TcpRtoAlgorithm, tcp_statistics.TcpRtoMin,
245 tcp_statistics.TcpRtoMax, tcp_statistics.TcpMaxConn,
246 tcp_statistics.TcpActiveOpens, tcp_statistics.TcpPassiveOpens,
247 tcp_statistics.TcpAttemptFails, tcp_statistics.TcpEstabResets,
248 tcp_statistics.TcpCurrEstab, tcp_statistics.TcpInSegs,
249 tcp_statistics.TcpOutSegs, tcp_statistics.TcpRetransSegs);
250
251 len += sprintf (buffer + len,
252 "Udp: InDatagrams NoPorts InErrors OutDatagrams\nUdp: %lu %lu %lu %lu\n",
253 udp_statistics.UdpInDatagrams, udp_statistics.UdpNoPorts,
254 udp_statistics.UdpInErrors, udp_statistics.UdpOutDatagrams);
255
256
257
258
259
260
261 if (offset >= len)
262 {
263 *start = buffer;
264 return 0;
265 }
266 *start = buffer + offset;
267 len -= offset;
268 if (len > length)
269 len = length;
270 return len;
271 }