]>
Commit | Line | Data |
---|---|---|
236898d6 MT |
1 | --- net-tools-1.60/netstat.c.sctp-addrs 2008-06-18 14:41:29.000000000 +0200 |
2 | +++ net-tools-1.60/netstat.c 2008-06-18 14:12:03.000000000 +0200 | |
3 | @@ -1299,23 +1299,21 @@ static void sctp_eps_do_one(int lnr, cha | |
4 | const char *lport_str; | |
5 | const char *uid_str; | |
6 | const char *inode_str; | |
7 | - const char *pladdr_str; | |
8 | char *laddrs_str; | |
9 | ||
10 | if(lnr == 0) { | |
11 | - /* ENDPT SOCK STY SST HBKT LPORT uid inode pladdr LADDRS*/ | |
12 | + /* ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS */ | |
13 | return; | |
14 | } | |
15 | ||
16 | - strtok(line," \t\n"); /*skip ptr*/ | |
17 | - strtok(0," \t\n"); /*skip ptr*/ | |
18 | + strtok(line," \t\n"); /*skip endpt*/ | |
19 | + strtok(0," \t\n"); /*skip sock*/ | |
20 | sty_str = strtok(0," \t\n"); | |
21 | sst_str = strtok(0," \t\n"); | |
22 | strtok(0," \t\n"); /*skip hash bucket*/ | |
23 | lport_str=strtok(0," \t\n"); | |
24 | uid_str = strtok(0," \t\n"); | |
25 | inode_str = strtok(0," \t\n"); | |
26 | - pladdr_str = strtok(0," \t\n"); | |
27 | laddrs_str=strtok(0,"\t\n"); | |
28 | ||
29 | type = atoi(sty_str); | |
30 | @@ -1323,61 +1321,35 @@ static void sctp_eps_do_one(int lnr, cha | |
31 | port = atoi(lport_str); | |
32 | uid = atoi(uid_str); | |
33 | inode = strtoul(inode_str,0,0); | |
34 | - | |
35 | - if(flag_sctp<=1) { | |
36 | - /* only print the primary address */ | |
37 | - char local_addr[64]; | |
38 | - char local_port[16]; | |
39 | - | |
40 | - ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr); | |
41 | - if(ap) | |
42 | - safe_strncpy(local_addr, | |
43 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | |
44 | - sizeof(local_addr)); | |
45 | - else | |
46 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | |
47 | - | |
48 | - snprintf(local_port, sizeof(local_port), "%s", | |
49 | - get_sname(htons(port), "sctp", | |
50 | - flag_not & FLAG_NUM_PORT)); | |
51 | - | |
52 | - printf("sctp "); | |
53 | - sprintf(buffer,"%s:%s", local_addr, local_port); | |
54 | - printf("%-47s", buffer); | |
55 | - printf(" %-12s", sctp_socket_state_str(state)); | |
56 | - } else { | |
57 | - /*print all addresses*/ | |
58 | - const char *this_local_addr; | |
59 | - int first=1; | |
60 | - char local_port[16]; | |
61 | - snprintf(local_port, sizeof(local_port), "%s", | |
62 | - get_sname(htons(port), "sctp", | |
63 | - flag_not & FLAG_NUM_PORT)); | |
64 | - for(this_local_addr=strtok(laddrs_str," \t\n"); | |
65 | - this_local_addr; | |
66 | - this_local_addr=strtok(0," \t\n")) | |
67 | - { | |
68 | - char local_addr[64]; | |
69 | - ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | |
70 | - if(ap) | |
71 | - safe_strncpy(local_addr, | |
72 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | |
73 | - sizeof(local_addr)); | |
74 | - else | |
75 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | |
76 | ||
77 | - if(!first) printf("\n"); | |
78 | - if(first) | |
79 | - printf("sctp "); | |
80 | - else | |
81 | - printf(" "); | |
82 | - sprintf(buffer,"%s:%s", local_addr, local_port); | |
83 | - printf("%-47s", buffer); | |
84 | - printf(" %-12s", first?sctp_socket_state_str(state):""); | |
85 | - first = 0; | |
86 | - } | |
87 | + const char *this_local_addr; | |
88 | + int first=1; | |
89 | + char local_port[16]; | |
90 | + snprintf(local_port, sizeof(local_port), "%s", | |
91 | + get_sname(htons(port), "sctp", flag_not & FLAG_NUM_PORT)); | |
92 | + for(this_local_addr=strtok(laddrs_str," \t\n"); | |
93 | + this_local_addr; | |
94 | + this_local_addr=strtok(0," \t\n")) | |
95 | + { | |
96 | + char local_addr[64]; | |
97 | + ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | |
98 | + if(ap) | |
99 | + safe_strncpy(local_addr, | |
100 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), | |
101 | + sizeof(local_addr)); | |
102 | + else | |
103 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | |
104 | + | |
105 | + if(!first) printf("\n"); | |
106 | + if(first) | |
107 | + printf("sctp "); | |
108 | + else | |
109 | + printf(" "); | |
110 | + sprintf(buffer,"%s:%s", local_addr, local_port); | |
111 | + printf("%-55s", buffer); | |
112 | + printf(" %-12s", first?sctp_socket_state_str(state):""); | |
113 | + first = 0; | |
114 | } | |
115 | - | |
116 | finish_this_one(uid,inode,""); | |
117 | } | |
118 | ||
119 | @@ -1403,32 +1375,29 @@ static void sctp_assoc_do_one(int lnr, c | |
120 | const char *lport_str,*rport_str; | |
121 | const char *uid_str; | |
122 | const char *inode_str; | |
123 | - const char *pladdr_str; | |
124 | char *laddrs_str; | |
125 | - const char *praddr_str; | |
126 | char *raddrs_str; | |
127 | - | |
128 | + | |
129 | if(lnr == 0) { | |
130 | - /* ASSOC SOCK STY SST ST HBKT tx_queue rx_queue uid inode LPORT RPORT pladdr praddr LADDRS <-> RADDRS*/ | |
131 | + /* ASSOC SOCK STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS */ | |
132 | return; | |
133 | } | |
134 | - | |
135 | - strtok(line," \t\n"); /*skip ptr*/ | |
136 | - strtok(0," \t\n"); /*skip ptr*/ | |
137 | + | |
138 | + strtok(line," \t\n"); /*skip assoc*/ | |
139 | + strtok(0," \t\n"); /*skip sock*/ | |
140 | sty_str = strtok(0," \t\n"); | |
141 | sst_str = strtok(0," \t\n"); | |
142 | st_str = strtok(0," \t\n"); | |
143 | strtok(0," \t\n"); /*skip hash bucket*/ | |
144 | + strtok(0," \t\n"); /*skip hash assoc-id*/ | |
145 | txqueue_str = strtok(0," \t\n"); | |
146 | rxqueue_str = strtok(0," \t\n"); | |
147 | uid_str = strtok(0," \t\n"); | |
148 | inode_str = strtok(0," \t\n"); | |
149 | lport_str=strtok(0," \t\n"); | |
150 | rport_str=strtok(0," \t\n"); | |
151 | - pladdr_str = strtok(0," \t\n"); | |
152 | - praddr_str = strtok(0," \t\n"); | |
153 | - laddrs_str=strtok(0,"<->\t\n"); | |
154 | - raddrs_str=strtok(0,"<->\t\n"); | |
155 | + laddrs_str = strtok(0,"<->\t\n"); | |
156 | + raddrs_str = strtok(0,"<->\t\n"); | |
157 | ||
158 | type = atoi(sty_str); | |
159 | state = atoi(sst_str); | |
160 | @@ -1439,116 +1408,81 @@ static void sctp_assoc_do_one(int lnr, c | |
161 | inode = strtoul(inode_str,0,0); | |
162 | lport = atoi(lport_str); | |
163 | rport = atoi(rport_str); | |
164 | - | |
165 | - if(flag_sctp<=1) { | |
166 | - /* only print the primary addresses */ | |
167 | - char local_addr[64]; | |
168 | - char local_port[16]; | |
169 | - char remote_addr[64]; | |
170 | - char remote_port[16]; | |
171 | - | |
172 | - ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr); | |
173 | - if(ap) | |
174 | - safe_strncpy(local_addr, | |
175 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | |
176 | - sizeof(local_addr)); | |
177 | - else | |
178 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | |
179 | - | |
180 | - snprintf(local_port, sizeof(local_port), "%s", | |
181 | - get_sname(htons(lport), "sctp", | |
182 | - flag_not & FLAG_NUM_PORT)); | |
183 | - | |
184 | - ap = process_sctp_addr_str(praddr_str, (struct sockaddr*)&remoteaddr); | |
185 | - if(ap) | |
186 | - safe_strncpy(remote_addr, | |
187 | - ap->sprint((struct sockaddr *) &remoteaddr, flag_not), | |
188 | - sizeof(remote_addr)); | |
189 | - else | |
190 | - sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | |
191 | - | |
192 | - snprintf(remote_port, sizeof(remote_port), "%s", | |
193 | - get_sname(htons(rport), "sctp", | |
194 | - flag_not & FLAG_NUM_PORT)); | |
195 | - | |
196 | - printf("sctp"); | |
197 | - printf(" %6u %6u ", rxqueue, txqueue); | |
198 | - sprintf(buffer,"%s:%s", local_addr, local_port); | |
199 | - printf("%-23s", buffer); | |
200 | - printf(" "); | |
201 | - sprintf(buffer,"%s:%s", remote_addr, remote_port); | |
202 | - printf("%-23s", buffer); | |
203 | - printf(" %-12s", sctp_socket_state_str(state)); | |
204 | - } else { | |
205 | - /*print all addresses*/ | |
206 | - const char *this_local_addr; | |
207 | - const char *this_remote_addr; | |
208 | - char *ss1,*ss2; | |
209 | - int first=1; | |
210 | - char local_port[16]; | |
211 | - char remote_port[16]; | |
212 | - snprintf(local_port, sizeof(local_port), "%s", | |
213 | - get_sname(htons(lport), "sctp", | |
214 | - flag_not & FLAG_NUM_PORT)); | |
215 | - snprintf(remote_port, sizeof(remote_port), "%s", | |
216 | - get_sname(htons(rport), "sctp", | |
217 | - flag_not & FLAG_NUM_PORT)); | |
218 | - | |
219 | - this_local_addr=strtok_r(laddrs_str," \t\n",&ss1); | |
220 | - this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2); | |
221 | - while(this_local_addr || this_remote_addr) { | |
222 | - char local_addr[64]; | |
223 | - char remote_addr[64]; | |
224 | - if(this_local_addr) { | |
225 | - ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | |
226 | - if(ap) | |
227 | - safe_strncpy(local_addr, | |
228 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | |
229 | - sizeof(local_addr)); | |
230 | - else | |
231 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | |
232 | - } | |
233 | - if(this_remote_addr) { | |
234 | - ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr); | |
235 | - if(ap) | |
236 | - safe_strncpy(remote_addr, | |
237 | - ap->sprint((struct sockaddr *) &remoteaddr, flag_not), | |
238 | - sizeof(remote_addr)); | |
239 | - else | |
240 | - sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | |
241 | - } | |
242 | ||
243 | - if(!first) printf("\n"); | |
244 | - if(first) | |
245 | - printf("sctp %6u %6u ", rxqueue, txqueue); | |
246 | - else | |
247 | - printf(" "); | |
248 | - if(this_local_addr) { | |
249 | - if(first) | |
250 | - sprintf(buffer,"%s:%s", local_addr, local_port); | |
251 | + /*print all addresses*/ | |
252 | + const char *this_local_addr; | |
253 | + const char *this_remote_addr; | |
254 | + char *ss1,*ss2; | |
255 | + int first=1; | |
256 | + char local_port[16]; | |
257 | + char remote_port[16]; | |
258 | + snprintf(local_port, sizeof(local_port), "%s", | |
259 | + get_sname(htons(lport), "sctp", | |
260 | + flag_not & FLAG_NUM_PORT)); | |
261 | + snprintf(remote_port, sizeof(remote_port), "%s", | |
262 | + get_sname(htons(rport), "sctp", | |
263 | + flag_not & FLAG_NUM_PORT)); | |
264 | + | |
265 | + this_local_addr=strtok_r(laddrs_str," \t\n",&ss1); | |
266 | + this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2); | |
267 | + while(this_local_addr || this_remote_addr) { | |
268 | + char local_addr[64]; | |
269 | + char remote_addr[64]; | |
270 | + | |
271 | + if(this_local_addr) { | |
272 | + if (this_local_addr[0] == '*') { | |
273 | + /* skip * */ | |
274 | + this_local_addr++; | |
275 | + } | |
276 | + ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | |
277 | + if(ap) | |
278 | + safe_strncpy(local_addr, | |
279 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), sizeof(local_addr)); | |
280 | else | |
281 | - sprintf(buffer,"%s", local_addr); | |
282 | - printf("%-23s", buffer); | |
283 | - } else | |
284 | - printf("%-23s", ""); | |
285 | - printf(" "); | |
286 | - if(this_remote_addr) { | |
287 | - if(first) | |
288 | - sprintf(buffer,"%s:%s", remote_addr, remote_port); | |
289 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | |
290 | + } | |
291 | + if(this_remote_addr) { | |
292 | + if (this_remote_addr[0] == '*') { | |
293 | + /* skip * */ | |
294 | + this_remote_addr++; | |
295 | + } | |
296 | + ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr); | |
297 | + if(ap) | |
298 | + safe_strncpy(remote_addr, | |
299 | + ap->sprint((struct sockaddr *) &remoteaddr, flag_not), sizeof(remote_addr)); | |
300 | else | |
301 | - sprintf(buffer,"%s", remote_addr); | |
302 | - printf("%-23s", buffer); | |
303 | - } else | |
304 | - printf("%-23s", ""); | |
305 | - | |
306 | - printf(" %-12s", first?sctp_socket_state_str(state):""); | |
307 | + sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | |
308 | + } | |
309 | ||
310 | - first = 0; | |
311 | - this_local_addr=strtok_r(0," \t\n",&ss1); | |
312 | - this_remote_addr=strtok_r(0," \t\n",&ss2); | |
313 | - } | |
314 | + if(!first) printf("\n"); | |
315 | + if(first) | |
316 | + printf("sctp %6u %6u ", rxqueue, txqueue); | |
317 | + else | |
318 | + printf(" "); | |
319 | + if(this_local_addr) { | |
320 | + if(first) | |
321 | + sprintf(buffer,"%s:%s", local_addr, local_port); | |
322 | + else | |
323 | + sprintf(buffer,"%s", local_addr); | |
324 | + printf("%-27s", buffer); | |
325 | + } else | |
326 | + printf("%-27s", ""); | |
327 | + printf(" "); | |
328 | + if(this_remote_addr) { | |
329 | + if(first) | |
330 | + sprintf(buffer,"%s:%s", remote_addr, remote_port); | |
331 | + else | |
332 | + sprintf(buffer,"%s", remote_addr); | |
333 | + printf("%-27s", buffer); | |
334 | + } else | |
335 | + printf("%-27s", ""); | |
336 | + | |
337 | + printf(" %-12s", first?sctp_socket_state_str(state):""); | |
338 | + | |
339 | + first = 0; | |
340 | + this_local_addr=strtok_r(0," \t\n",&ss1); | |
341 | + this_remote_addr=strtok_r(0," \t\n",&ss2); | |
342 | } | |
343 | - | |
344 | finish_this_one(uid,inode,""); | |
345 | } | |
346 |