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