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