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