diff options
author | Li Zhou <li.zhou@windriver.com> | 2016-03-01 16:35:19 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-09 16:58:11 +0000 |
commit | 07919e948cea3f6bc8525ca997c15a2c5b663986 (patch) | |
tree | 9f12e77d715969c383f38346a146985c424726bc | |
parent | e8254bc2f1db15091abca102b8b53239a36ac2ff (diff) | |
download | poky-07919e948cea3f6bc8525ca997c15a2c5b663986.tar.gz |
net-tools: Add SCTP option support
Porting three net-tools SCTP related patches from
<https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/
12/Fedora/source/SRPMS/net-tools-1.60-95.fc12.src.rpm> to add support
for SCTP option.
(From OE-Core rev: 45e09f33b4607317d60e8ca01ce9c8fdb55df0a0)
Signed-off-by: Li Zhou <li.zhou@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
4 files changed, 1033 insertions, 1 deletions
diff --git a/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp1.patch b/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp1.patch new file mode 100644 index 0000000000..12eed17af4 --- /dev/null +++ b/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp1.patch | |||
@@ -0,0 +1,638 @@ | |||
1 | From 23276afe270009420cfbc52bffafdd25ac0817fe Mon Sep 17 00:00:00 2001 | ||
2 | From: Li Zhou <li.zhou@windriver.com> | ||
3 | Date: Thu, 14 Jan 2016 17:01:29 +0800 | ||
4 | Subject: [PATCH 1/3] net-tools: add SCTP support for netstat | ||
5 | |||
6 | Upstream-Status: pending | ||
7 | |||
8 | Signed-off-by: Li Zhou <li.zhou@windriver.com> | ||
9 | --- | ||
10 | netstat.c | 411 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- | ||
11 | statistics.c | 68 +++++++++- | ||
12 | 2 files changed, 465 insertions(+), 14 deletions(-) | ||
13 | |||
14 | diff --git a/netstat.c b/netstat.c | ||
15 | index 1fb9e0c..5d1a4a1 100644 | ||
16 | --- a/netstat.c | ||
17 | +++ b/netstat.c | ||
18 | @@ -58,6 +58,7 @@ | ||
19 | * | ||
20 | *990420 {1.38} Tuan Hoang removed a useless assignment from igmp_do_one() | ||
21 | *20010404 {1.39} Arnaldo Carvalho de Melo - use setlocale | ||
22 | + *20050516 {1.40} Ivan Skytte Joergensen:Added SCTP support | ||
23 | * | ||
24 | * This program is free software; you can redistribute it | ||
25 | * and/or modify it under the terms of the GNU General | ||
26 | @@ -105,7 +106,7 @@ | ||
27 | #endif | ||
28 | |||
29 | /* prototypes for statistics.c */ | ||
30 | -void parsesnmp(int, int, int); | ||
31 | +void parsesnmp(int, int, int, int); | ||
32 | void inittab(void); | ||
33 | void parsesnmp6(int, int, int); | ||
34 | void inittab6(void); | ||
35 | @@ -118,6 +119,28 @@ typedef enum { | ||
36 | SS_DISCONNECTING /* in process of disconnecting */ | ||
37 | } socket_state; | ||
38 | |||
39 | +#define SCTP_NSTATES 9 /* The number of states in array*/ | ||
40 | + | ||
41 | +static const char *sctp_state[] = { | ||
42 | + N_("EMPTY"), | ||
43 | + N_("CLOSED"), | ||
44 | + N_("COOKIE_WAIT"), | ||
45 | + N_("COOKIE_ECHOED"), | ||
46 | + N_("ESTABLISHED"), | ||
47 | + N_("SHUTDOWN_PENDING"), | ||
48 | + N_("SHUTDOWN_SENT"), | ||
49 | + N_("SHUTDOWN_RECEIVED"), | ||
50 | + N_("SHUTDOWN_ACK_SENT") | ||
51 | +}; | ||
52 | + | ||
53 | +#define SCTP_NTYPES 3 /* The number of types in array */ | ||
54 | + | ||
55 | +static const char *sctp_type[] = { | ||
56 | + N_("udp"), | ||
57 | + N_("udp-high-bw"), | ||
58 | + N_("tcp") | ||
59 | +}; | ||
60 | + | ||
61 | #define SO_ACCEPTCON (1<<16) /* performed a listen */ | ||
62 | #define SO_WAITDATA (1<<17) /* wait data to read */ | ||
63 | #define SO_NOSPACE (1<<18) /* no space to write */ | ||
64 | @@ -148,6 +171,7 @@ int flag_opt = 0; | ||
65 | int flag_raw = 0; | ||
66 | int flag_tcp = 0; | ||
67 | int flag_udp = 0; | ||
68 | +int flag_sctp= 0; | ||
69 | int flag_igmp= 0; | ||
70 | int flag_rom = 0; | ||
71 | int flag_exp = 1; | ||
72 | @@ -990,6 +1014,365 @@ static int udp_info(void) | ||
73 | udp_do_one); | ||
74 | } | ||
75 | |||
76 | +static const char *sctp_socket_type_str(int type) { | ||
77 | + if(type>=0 && type<SCTP_NTYPES) | ||
78 | + return sctp_type[type]; | ||
79 | + else { | ||
80 | + static char type_str_buf[64]; | ||
81 | + sprintf(type_str_buf,"UNKNOWN(%d)",type); | ||
82 | + return type_str_buf; | ||
83 | + } | ||
84 | +} | ||
85 | + | ||
86 | +static const char *sctp_state_str(int state) | ||
87 | +{ | ||
88 | + if(state>=0 && state<SCTP_NSTATES) | ||
89 | + return sctp_state[state]; | ||
90 | + else { | ||
91 | + static char state_str_buf[64]; | ||
92 | + sprintf(state_str_buf,"UNKNOWN(%d)",state); | ||
93 | + return state_str_buf; | ||
94 | + } | ||
95 | +} | ||
96 | + | ||
97 | +static const char *sctp_socket_state_str(int state) | ||
98 | +{ | ||
99 | + if(state>=0 && state<=10) | ||
100 | + return tcp_state[state]; | ||
101 | + else { | ||
102 | + static char state_str_buf[64]; | ||
103 | + sprintf(state_str_buf,"UNKNOWN(%d)",state); | ||
104 | + return state_str_buf; | ||
105 | + } | ||
106 | +} | ||
107 | + | ||
108 | +static struct aftype *process_sctp_addr_str(const char *addr_str, struct sockaddr *sa) | ||
109 | +{ | ||
110 | + if (strchr(addr_str,':')) { | ||
111 | +#if HAVE_AFINET6 | ||
112 | + extern struct aftype inet6_aftype; | ||
113 | + /* Demangle what the kernel gives us */ | ||
114 | + struct in6_addr in6; | ||
115 | + char addr6_str[INET6_ADDRSTRLEN]; | ||
116 | + unsigned u0,u1,u2,u3,u4,u5,u6,u7; | ||
117 | + sscanf(addr_str, "%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X", | ||
118 | + &u0, &u1, &u2, &u3, &u4, &u5, &u6, &u7); | ||
119 | + in6.s6_addr16[0] = htons(u0); | ||
120 | + in6.s6_addr16[1] = htons(u1); | ||
121 | + in6.s6_addr16[2] = htons(u2); | ||
122 | + in6.s6_addr16[3] = htons(u3); | ||
123 | + in6.s6_addr16[4] = htons(u4); | ||
124 | + in6.s6_addr16[5] = htons(u5); | ||
125 | + in6.s6_addr16[6] = htons(u6); | ||
126 | + in6.s6_addr16[7] = htons(u7); | ||
127 | + | ||
128 | + inet_ntop(AF_INET6, &in6, addr6_str, sizeof(addr6_str)); | ||
129 | + inet6_aftype.input(1, addr6_str, sa); | ||
130 | + sa->sa_family = AF_INET6; | ||
131 | +#endif | ||
132 | + } else { | ||
133 | + ((struct sockaddr_in*)sa)->sin_addr.s_addr = inet_addr(addr_str); | ||
134 | + sa->sa_family = AF_INET; | ||
135 | + } | ||
136 | + return get_afntype(sa->sa_family); | ||
137 | +} | ||
138 | + | ||
139 | +static void sctp_eps_do_one(int lnr, char *line) | ||
140 | +{ | ||
141 | + char buffer[1024]; | ||
142 | + int type, state, port; | ||
143 | + int uid; | ||
144 | + unsigned long inode; | ||
145 | + | ||
146 | + struct aftype *ap; | ||
147 | +#if HAVE_AFINET6 | ||
148 | + struct sockaddr_in6 localaddr; | ||
149 | +#else | ||
150 | + struct sockaddr_in localaddr; | ||
151 | +#endif | ||
152 | + const char *sty_str; | ||
153 | + const char *sst_str; | ||
154 | + const char *lport_str; | ||
155 | + const char *uid_str; | ||
156 | + const char *inode_str; | ||
157 | + const char *pladdr_str; | ||
158 | + char *laddrs_str; | ||
159 | + | ||
160 | + if(lnr == 0) { | ||
161 | + /* ENDPT SOCK STY SST HBKT LPORT uid inode pladdr LADDRS*/ | ||
162 | + return; | ||
163 | + } | ||
164 | + | ||
165 | + strtok(line," \t\n"); /*skip ptr*/ | ||
166 | + strtok(0," \t\n"); /*skip ptr*/ | ||
167 | + sty_str = strtok(0," \t\n"); | ||
168 | + sst_str = strtok(0," \t\n"); | ||
169 | + strtok(0," \t\n"); /*skip hash bucket*/ | ||
170 | + lport_str=strtok(0," \t\n"); | ||
171 | + uid_str = strtok(0," \t\n"); | ||
172 | + inode_str = strtok(0," \t\n"); | ||
173 | + pladdr_str = strtok(0," \t\n"); | ||
174 | + laddrs_str=strtok(0,"\t\n"); | ||
175 | + | ||
176 | + type = atoi(sty_str); | ||
177 | + state = atoi(sst_str); | ||
178 | + port = atoi(lport_str); | ||
179 | + uid = atoi(uid_str); | ||
180 | + inode = strtoul(inode_str,0,0); | ||
181 | + | ||
182 | + if(flag_sctp<=1) { | ||
183 | + /* only print the primary address */ | ||
184 | + char local_addr[64]; | ||
185 | + char local_port[16]; | ||
186 | + | ||
187 | + ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr); | ||
188 | + if(ap) | ||
189 | + safe_strncpy(local_addr, | ||
190 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
191 | + sizeof(local_addr)); | ||
192 | + else | ||
193 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
194 | + | ||
195 | + snprintf(local_port, sizeof(local_port), "%s", | ||
196 | + get_sname(htons(port), "sctp", | ||
197 | + flag_not & FLAG_NUM_PORT)); | ||
198 | + | ||
199 | + printf("sctp "); | ||
200 | + sprintf(buffer,"%s:%s", local_addr, local_port); | ||
201 | + printf("%-47s", buffer); | ||
202 | + printf(" %-12s", sctp_socket_state_str(state)); | ||
203 | + } else { | ||
204 | + /*print all addresses*/ | ||
205 | + const char *this_local_addr; | ||
206 | + int first=1; | ||
207 | + char local_port[16]; | ||
208 | + snprintf(local_port, sizeof(local_port), "%s", | ||
209 | + get_sname(htons(port), "sctp", | ||
210 | + flag_not & FLAG_NUM_PORT)); | ||
211 | + for(this_local_addr=strtok(laddrs_str," \t\n"); | ||
212 | + this_local_addr; | ||
213 | + this_local_addr=strtok(0," \t\n")) | ||
214 | + { | ||
215 | + char local_addr[64]; | ||
216 | + ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | ||
217 | + if(ap) | ||
218 | + safe_strncpy(local_addr, | ||
219 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
220 | + sizeof(local_addr)); | ||
221 | + else | ||
222 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
223 | + | ||
224 | + if(!first) printf("\n"); | ||
225 | + if(first) | ||
226 | + printf("sctp "); | ||
227 | + else | ||
228 | + printf(" "); | ||
229 | + sprintf(buffer,"%s:%s", local_addr, local_port); | ||
230 | + printf("%-47s", buffer); | ||
231 | + printf(" %-12s", first?sctp_socket_state_str(state):""); | ||
232 | + first = 0; | ||
233 | + } | ||
234 | + } | ||
235 | + | ||
236 | + finish_this_one(uid,inode,""); | ||
237 | +} | ||
238 | + | ||
239 | +static void sctp_assoc_do_one(int lnr, char *line) | ||
240 | +{ | ||
241 | + char buffer[1024]; | ||
242 | + int type, state, state2, lport,rport; | ||
243 | + int uid; | ||
244 | + unsigned rxqueue,txqueue; | ||
245 | + unsigned long inode; | ||
246 | + | ||
247 | + struct aftype *ap; | ||
248 | +#if HAVE_AFINET6 | ||
249 | + struct sockaddr_in6 localaddr,remoteaddr; | ||
250 | +#else | ||
251 | + struct sockaddr_in localaddr,remoteaddr; | ||
252 | +#endif | ||
253 | + const char *sty_str; | ||
254 | + const char *sst_str; | ||
255 | + const char *st_str; | ||
256 | + const char *txqueue_str; | ||
257 | + const char *rxqueue_str; | ||
258 | + const char *lport_str,*rport_str; | ||
259 | + const char *uid_str; | ||
260 | + const char *inode_str; | ||
261 | + const char *pladdr_str; | ||
262 | + char *laddrs_str; | ||
263 | + const char *praddr_str; | ||
264 | + char *raddrs_str; | ||
265 | + | ||
266 | + if(lnr == 0) { | ||
267 | + /* ASSOC SOCK STY SST ST HBKT tx_queue rx_queue uid inode LPORT RPORT pladdr praddr LADDRS <-> RADDRS*/ | ||
268 | + return; | ||
269 | + } | ||
270 | + | ||
271 | + strtok(line," \t\n"); /*skip ptr*/ | ||
272 | + strtok(0," \t\n"); /*skip ptr*/ | ||
273 | + sty_str = strtok(0," \t\n"); | ||
274 | + sst_str = strtok(0," \t\n"); | ||
275 | + st_str = strtok(0," \t\n"); | ||
276 | + strtok(0," \t\n"); /*skip hash bucket*/ | ||
277 | + txqueue_str = strtok(0," \t\n"); | ||
278 | + rxqueue_str = strtok(0," \t\n"); | ||
279 | + uid_str = strtok(0," \t\n"); | ||
280 | + inode_str = strtok(0," \t\n"); | ||
281 | + lport_str=strtok(0," \t\n"); | ||
282 | + rport_str=strtok(0," \t\n"); | ||
283 | + pladdr_str = strtok(0," \t\n"); | ||
284 | + praddr_str = strtok(0," \t\n"); | ||
285 | + laddrs_str=strtok(0,"<->\t\n"); | ||
286 | + raddrs_str=strtok(0,"<->\t\n"); | ||
287 | + | ||
288 | + type = atoi(sty_str); | ||
289 | + state = atoi(sst_str); | ||
290 | + state2 = atoi(st_str); | ||
291 | + txqueue = atoi(txqueue_str); | ||
292 | + rxqueue = atoi(rxqueue_str); | ||
293 | + uid = atoi(uid_str); | ||
294 | + inode = strtoul(inode_str,0,0); | ||
295 | + lport = atoi(lport_str); | ||
296 | + rport = atoi(rport_str); | ||
297 | + | ||
298 | + if(flag_sctp<=1) { | ||
299 | + /* only print the primary addresses */ | ||
300 | + char local_addr[64]; | ||
301 | + char local_port[16]; | ||
302 | + char remote_addr[64]; | ||
303 | + char remote_port[16]; | ||
304 | + | ||
305 | + ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr); | ||
306 | + if(ap) | ||
307 | + safe_strncpy(local_addr, | ||
308 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
309 | + sizeof(local_addr)); | ||
310 | + else | ||
311 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
312 | + | ||
313 | + snprintf(local_port, sizeof(local_port), "%s", | ||
314 | + get_sname(htons(lport), "sctp", | ||
315 | + flag_not & FLAG_NUM_PORT)); | ||
316 | + | ||
317 | + ap = process_sctp_addr_str(praddr_str, (struct sockaddr*)&remoteaddr); | ||
318 | + if(ap) | ||
319 | + safe_strncpy(remote_addr, | ||
320 | + ap->sprint((struct sockaddr *) &remoteaddr, flag_not), | ||
321 | + sizeof(remote_addr)); | ||
322 | + else | ||
323 | + sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | ||
324 | + | ||
325 | + snprintf(remote_port, sizeof(remote_port), "%s", | ||
326 | + get_sname(htons(rport), "sctp", | ||
327 | + flag_not & FLAG_NUM_PORT)); | ||
328 | + | ||
329 | + printf("sctp"); | ||
330 | + printf(" %6u %6u ", rxqueue, txqueue); | ||
331 | + sprintf(buffer,"%s:%s", local_addr, local_port); | ||
332 | + printf("%-23s", buffer); | ||
333 | + printf(" "); | ||
334 | + sprintf(buffer,"%s:%s", remote_addr, remote_port); | ||
335 | + printf("%-23s", buffer); | ||
336 | + printf(" %-12s", sctp_socket_state_str(state)); | ||
337 | + } else { | ||
338 | + /*print all addresses*/ | ||
339 | + const char *this_local_addr; | ||
340 | + const char *this_remote_addr; | ||
341 | + char *ss1,*ss2; | ||
342 | + int first=1; | ||
343 | + char local_port[16]; | ||
344 | + char remote_port[16]; | ||
345 | + snprintf(local_port, sizeof(local_port), "%s", | ||
346 | + get_sname(htons(lport), "sctp", | ||
347 | + flag_not & FLAG_NUM_PORT)); | ||
348 | + snprintf(remote_port, sizeof(remote_port), "%s", | ||
349 | + get_sname(htons(rport), "sctp", | ||
350 | + flag_not & FLAG_NUM_PORT)); | ||
351 | + | ||
352 | + this_local_addr=strtok_r(laddrs_str," \t\n",&ss1); | ||
353 | + this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2); | ||
354 | + while(this_local_addr || this_remote_addr) { | ||
355 | + char local_addr[64]; | ||
356 | + char remote_addr[64]; | ||
357 | + if(this_local_addr) { | ||
358 | + ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | ||
359 | + if(ap) | ||
360 | + safe_strncpy(local_addr, | ||
361 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
362 | + sizeof(local_addr)); | ||
363 | + else | ||
364 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
365 | + } | ||
366 | + if(this_remote_addr) { | ||
367 | + ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr); | ||
368 | + if(ap) | ||
369 | + safe_strncpy(remote_addr, | ||
370 | + ap->sprint((struct sockaddr *) &remoteaddr, flag_not), | ||
371 | + sizeof(remote_addr)); | ||
372 | + else | ||
373 | + sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | ||
374 | + } | ||
375 | + | ||
376 | + if(!first) printf("\n"); | ||
377 | + if(first) | ||
378 | + printf("sctp %6u %6u ", rxqueue, txqueue); | ||
379 | + else | ||
380 | + printf(" "); | ||
381 | + if(this_local_addr) { | ||
382 | + if(first) | ||
383 | + sprintf(buffer,"%s:%s", local_addr, local_port); | ||
384 | + else | ||
385 | + sprintf(buffer,"%s", local_addr); | ||
386 | + printf("%-23s", buffer); | ||
387 | + } else | ||
388 | + printf("%-23s", ""); | ||
389 | + printf(" "); | ||
390 | + if(this_remote_addr) { | ||
391 | + if(first) | ||
392 | + sprintf(buffer,"%s:%s", remote_addr, remote_port); | ||
393 | + else | ||
394 | + sprintf(buffer,"%s", remote_addr); | ||
395 | + printf("%-23s", buffer); | ||
396 | + } else | ||
397 | + printf("%-23s", ""); | ||
398 | + | ||
399 | + printf(" %-12s", first?sctp_socket_state_str(state):""); | ||
400 | + | ||
401 | + first = 0; | ||
402 | + this_local_addr=strtok_r(0," \t\n",&ss1); | ||
403 | + this_remote_addr=strtok_r(0," \t\n",&ss2); | ||
404 | + } | ||
405 | + } | ||
406 | + | ||
407 | + finish_this_one(uid,inode,""); | ||
408 | +} | ||
409 | + | ||
410 | +static int sctp_info_eps(void) | ||
411 | +{ | ||
412 | +#if !defined(_PATH_PROCNET_SCTP_EPS) | ||
413 | +#define _PATH_PROCNET_SCTP_EPS "/proc/net/sctp/eps" | ||
414 | +#endif | ||
415 | + INFO_GUTS(_PATH_PROCNET_SCTP_EPS, "AF INET (sctp)", | ||
416 | + sctp_eps_do_one); | ||
417 | +} | ||
418 | + | ||
419 | +static int sctp_info_assocs(void) | ||
420 | +{ | ||
421 | +#if !defined(_PATH_PROCNET_SCTP_ASSOCS) | ||
422 | +#define _PATH_PROCNET_SCTP_ASSOCS "/proc/net/sctp/assocs" | ||
423 | +#endif | ||
424 | + INFO_GUTS(_PATH_PROCNET_SCTP_ASSOCS, "AF INET (sctp)", | ||
425 | + sctp_assoc_do_one); | ||
426 | +} | ||
427 | + | ||
428 | +static int sctp_info(void) | ||
429 | +{ | ||
430 | + if(flag_all) | ||
431 | + sctp_info_eps(); | ||
432 | + return sctp_info_assocs(); | ||
433 | +} | ||
434 | + | ||
435 | static void raw_do_one(int lnr, const char *line) | ||
436 | { | ||
437 | char buffer[8192], local_addr[64], rem_addr[64]; | ||
438 | @@ -1549,7 +1932,7 @@ static void usage(void) | ||
439 | fprintf(stderr, _(" -F, --fib display Forwarding Information Base (default)\n")); | ||
440 | fprintf(stderr, _(" -C, --cache display routing cache instead of FIB\n\n")); | ||
441 | |||
442 | - fprintf(stderr, _(" <Socket>={-t|--tcp} {-u|--udp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom\n")); | ||
443 | + fprintf(stderr, _(" <Socket>={-t|--tcp} {-u|--udp} {-S|--sctp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom\n")); | ||
444 | fprintf(stderr, _(" <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF); | ||
445 | fprintf(stderr, _(" List of possible address families (which support routing):\n")); | ||
446 | print_aflist(1); /* 1 = routeable */ | ||
447 | @@ -1574,6 +1957,7 @@ int main | ||
448 | {"protocol", 1, 0, 'A'}, | ||
449 | {"tcp", 0, 0, 't'}, | ||
450 | {"udp", 0, 0, 'u'}, | ||
451 | + {"sctp", 0, 0, 'S' }, | ||
452 | {"raw", 0, 0, 'w'}, | ||
453 | {"unix", 0, 0, 'x'}, | ||
454 | {"listening", 0, 0, 'l'}, | ||
455 | @@ -1604,7 +1988,7 @@ int main | ||
456 | getroute_init(); /* Set up AF routing support */ | ||
457 | |||
458 | afname[0] = '\0'; | ||
459 | - while ((i = getopt_long(argc, argv, "MCFA:acdegphinNorstuWVv?wxl64", longopts, &lop)) != EOF) | ||
460 | + while ((i = getopt_long(argc, argv, "MCFA:acdegphinNorstuSWVv?wxl64", longopts, &lop)) != EOF) | ||
461 | switch (i) { | ||
462 | case -1: | ||
463 | break; | ||
464 | @@ -1696,10 +2080,12 @@ int main | ||
465 | case 't': | ||
466 | flag_tcp++; | ||
467 | break; | ||
468 | - | ||
469 | case 'u': | ||
470 | flag_udp++; | ||
471 | break; | ||
472 | + case 'S': | ||
473 | + flag_sctp++; | ||
474 | + break; | ||
475 | case 'w': | ||
476 | flag_raw++; | ||
477 | break; | ||
478 | @@ -1717,13 +2103,13 @@ int main | ||
479 | if (flag_int + flag_rou + flag_mas + flag_sta > 1) | ||
480 | usage(); | ||
481 | |||
482 | - if ((flag_inet || flag_inet6 || flag_sta) && !(flag_tcp || flag_udp || flag_raw)) | ||
483 | - flag_tcp = flag_udp = flag_raw = 1; | ||
484 | + if ((flag_inet || flag_inet6 || flag_sta) && !(flag_tcp || flag_udp || flag_sctp || flag_raw)) | ||
485 | + flag_tcp = flag_udp = flag_sctp = flag_raw = 1; | ||
486 | |||
487 | - if ((flag_tcp || flag_udp || flag_raw || flag_igmp) && !(flag_inet || flag_inet6)) | ||
488 | + if ((flag_tcp || flag_udp || flag_sctp || flag_raw || flag_igmp) && !(flag_inet || flag_inet6)) | ||
489 | flag_inet = flag_inet6 = 1; | ||
490 | |||
491 | - flag_arg = flag_tcp + flag_udp + flag_raw + flag_unx + flag_ipx | ||
492 | + flag_arg = flag_tcp + flag_udp + flag_sctp + flag_raw + flag_unx + flag_ipx | ||
493 | + flag_ax25 + flag_netrom + flag_igmp + flag_x25; | ||
494 | |||
495 | if (flag_mas) { | ||
496 | @@ -1751,7 +2137,7 @@ int main | ||
497 | char buf[256]; | ||
498 | if (!afname[0]) { | ||
499 | inittab(); | ||
500 | - parsesnmp(flag_raw, flag_tcp, flag_udp); | ||
501 | + parsesnmp(flag_raw, flag_tcp, flag_udp, flag_sctp); | ||
502 | } else { | ||
503 | safe_strncpy(buf, afname, sizeof(buf)); | ||
504 | tmp1 = buf; | ||
505 | @@ -1804,7 +2190,7 @@ int main | ||
506 | return (i); | ||
507 | } | ||
508 | for (;;) { | ||
509 | - if (!flag_arg || flag_tcp || flag_udp || flag_raw) { | ||
510 | + if (!flag_arg || flag_tcp || flag_udp || flag_sctp || flag_raw) { | ||
511 | #if HAVE_AFINET | ||
512 | prg_cache_load(); | ||
513 | printf(_("Active Internet connections ")); /* xxx */ | ||
514 | @@ -1843,6 +2229,11 @@ int main | ||
515 | if (i) | ||
516 | return (i); | ||
517 | } | ||
518 | + if (!flag_arg || flag_sctp) { | ||
519 | + i = sctp_info(); | ||
520 | + if (i) | ||
521 | + return (i); | ||
522 | + } | ||
523 | if (!flag_arg || flag_raw) { | ||
524 | i = raw_info(); | ||
525 | if (i) | ||
526 | diff --git a/statistics.c b/statistics.c | ||
527 | index 03600d7..eb8d7dc 100644 | ||
528 | --- a/statistics.c | ||
529 | +++ b/statistics.c | ||
530 | @@ -21,7 +21,7 @@ | ||
531 | #define UFWARN(x) | ||
532 | #endif | ||
533 | |||
534 | -int print_static,f_raw,f_tcp,f_udp,f_unknown = 1; | ||
535 | +int print_static,f_raw,f_tcp,f_udp,f_sctp,f_unknown = 1; | ||
536 | |||
537 | enum State { | ||
538 | number = 0, opt_number, i_forward, i_inp_icmp, i_outp_icmp, i_rto_alg, | ||
539 | @@ -297,6 +297,27 @@ struct entry Tcpexttab[] = | ||
540 | { "TCPRenoRecoveryFail", N_("%u classic Reno fast retransmits failed"), opt_number }, | ||
541 | }; | ||
542 | |||
543 | +struct entry Sctptab[] = | ||
544 | +{ | ||
545 | + {"SctpCurrEstab", N_("%u Current Associations"), number}, | ||
546 | + {"SctpActiveEstabs", N_("%u Active Associations"), number}, | ||
547 | + {"SctpPassiveEstabs", N_("%u Passive Associations"), number}, | ||
548 | + {"SctpAborteds", N_("%u Number of Aborteds "), number}, | ||
549 | + {"SctpShutdowns", N_("%u Number of Graceful Terminations"), number}, | ||
550 | + {"SctpOutOfBlues", N_("%u Number of Out of Blue packets"), number}, | ||
551 | + {"SctpChecksumErrors", N_("%u Number of Packets with invalid Checksum"), number}, | ||
552 | + {"SctpOutCtrlChunks", N_("%u Number of control chunks sent"), number}, | ||
553 | + {"SctpOutOrderChunks", N_("%u Number of ordered chunks sent"), number}, | ||
554 | + {"SctpOutUnorderChunks", N_("%u Number of Unordered chunks sent"), number}, | ||
555 | + {"SctpInCtrlChunks", N_("%u Number of control chunks received"), number}, | ||
556 | + {"SctpInOrderChunks", N_("%u Number of ordered chunks received"), number}, | ||
557 | + {"SctpInUnorderChunks", N_("%u Number of Unordered chunks received"), number}, | ||
558 | + {"SctpFragUsrMsgs", N_("%u Number of messages fragmented"), number}, | ||
559 | + {"SctpReasmUsrMsgs", N_("%u Number of messages reassembled "), number}, | ||
560 | + {"SctpOutSCTPPacks", N_("%u Number of SCTP packets sent"), number}, | ||
561 | + {"SctpInSCTPPacks", N_("%u Number of SCTP packets received"), number}, | ||
562 | +}; | ||
563 | + | ||
564 | struct tabtab { | ||
565 | char *title; | ||
566 | struct entry *tab; | ||
567 | @@ -310,6 +331,7 @@ struct tabtab snmptabs[] = | ||
568 | {"Icmp", Icmptab, sizeof(Icmptab), &f_raw}, | ||
569 | {"Tcp", Tcptab, sizeof(Tcptab), &f_tcp}, | ||
570 | {"Udp", Udptab, sizeof(Udptab), &f_udp}, | ||
571 | + {"Sctp", Sctptab, sizeof(Sctptab), &f_sctp}, | ||
572 | {"TcpExt", Tcpexttab, sizeof(Tcpexttab), &f_tcp}, | ||
573 | {NULL} | ||
574 | }; | ||
575 | @@ -499,12 +521,40 @@ void process6_fd(FILE *f) | ||
576 | |||
577 | } | ||
578 | |||
579 | -void parsesnmp(int flag_raw, int flag_tcp, int flag_udp) | ||
580 | +/* Process a file with name-value lines (like /proc/net/sctp/snmp) */ | ||
581 | +void process_fd2(FILE *f, const char *filename) | ||
582 | +{ | ||
583 | + char buf1[1024]; | ||
584 | + char *sp; | ||
585 | + struct tabtab *tab; | ||
586 | + | ||
587 | + tab = newtable(snmptabs, "Sctp"); | ||
588 | + | ||
589 | + while (fgets(buf1, sizeof buf1, f)) { | ||
590 | + sp = buf1 + strcspn(buf1, " \t\n"); | ||
591 | + if (!sp) | ||
592 | + goto formaterr; | ||
593 | + *sp = '\0'; | ||
594 | + sp++; | ||
595 | + | ||
596 | + sp += strspn(sp, " \t\n"); | ||
597 | + | ||
598 | + if (*sp != '\0' && *(tab->flag)) | ||
599 | + printval(tab, buf1, strtoul(sp, 0, 10)); | ||
600 | + } | ||
601 | + return; | ||
602 | + | ||
603 | +formaterr: | ||
604 | + fprintf(stderr,_("error parsing %s\n"), filename); | ||
605 | + return; | ||
606 | +} | ||
607 | + | ||
608 | +void parsesnmp(int flag_raw, int flag_tcp, int flag_udp, int flag_sctp) | ||
609 | { | ||
610 | FILE *f; | ||
611 | |||
612 | - f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp; | ||
613 | - | ||
614 | + f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp; f_sctp = flag_sctp; | ||
615 | + | ||
616 | f = proc_fopen("/proc/net/snmp"); | ||
617 | if (!f) { | ||
618 | perror(_("cannot open /proc/net/snmp")); | ||
619 | @@ -530,6 +580,16 @@ void parsesnmp(int flag_raw, int flag_tcp, int flag_udp) | ||
620 | |||
621 | fclose(f); | ||
622 | } | ||
623 | + | ||
624 | + f = fopen("/proc/net/sctp/snmp", "r"); | ||
625 | + if (f) { | ||
626 | + process_fd2(f,"/proc/net/sctp/snmp"); | ||
627 | + if (ferror(f)) | ||
628 | + perror("/proc/net/sctp/snmp"); | ||
629 | + | ||
630 | + fclose(f); | ||
631 | + } | ||
632 | + | ||
633 | return; | ||
634 | } | ||
635 | |||
636 | -- | ||
637 | 1.8.5.2.233.g932f7e4 | ||
638 | |||
diff --git a/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp2-quiet.patch b/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp2-quiet.patch new file mode 100644 index 0000000000..d34e651327 --- /dev/null +++ b/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp2-quiet.patch | |||
@@ -0,0 +1,28 @@ | |||
1 | From 14287b594e1f02b811f889fb515c1a51b72c08d4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Li Zhou <li.zhou@windriver.com> | ||
3 | Date: Thu, 14 Jan 2016 17:07:48 +0800 | ||
4 | Subject: [PATCH 2/3] net-tools: add SCTP support for netstat | ||
5 | |||
6 | Upstream-Status: pending | ||
7 | |||
8 | Signed-off-by: Li Zhou <li.zhou@windriver.com> | ||
9 | --- | ||
10 | netstat.c | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/netstat.c b/netstat.c | ||
14 | index 5d1a4a1..56a15c2 100644 | ||
15 | --- a/netstat.c | ||
16 | +++ b/netstat.c | ||
17 | @@ -2104,7 +2104,7 @@ int main | ||
18 | usage(); | ||
19 | |||
20 | if ((flag_inet || flag_inet6 || flag_sta) && !(flag_tcp || flag_udp || flag_sctp || flag_raw)) | ||
21 | - flag_tcp = flag_udp = flag_sctp = flag_raw = 1; | ||
22 | + flag_tcp = flag_udp = flag_raw = 1; | ||
23 | |||
24 | if ((flag_tcp || flag_udp || flag_sctp || flag_raw || flag_igmp) && !(flag_inet || flag_inet6)) | ||
25 | flag_inet = flag_inet6 = 1; | ||
26 | -- | ||
27 | 1.8.5.2.233.g932f7e4 | ||
28 | |||
diff --git a/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp3-addrs.patch b/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp3-addrs.patch new file mode 100644 index 0000000000..8b2ecab707 --- /dev/null +++ b/meta/recipes-extended/net-tools/net-tools/net-tools-1.60-sctp3-addrs.patch | |||
@@ -0,0 +1,363 @@ | |||
1 | From 1d386279a449a1a6b96b88a71f35bf13b14b2c2c Mon Sep 17 00:00:00 2001 | ||
2 | From: Li Zhou <li.zhou@windriver.com> | ||
3 | Date: Thu, 14 Jan 2016 17:11:24 +0800 | ||
4 | Subject: [PATCH 3/3] net-tools: add SCTP support for netstat | ||
5 | |||
6 | Upstream-Status: pending | ||
7 | |||
8 | Signed-off-by: Li Zhou <li.zhou@windriver.com> | ||
9 | --- | ||
10 | netstat.c | 282 ++++++++++++++++++++++++-------------------------------------- | ||
11 | 1 file changed, 108 insertions(+), 174 deletions(-) | ||
12 | |||
13 | diff --git a/netstat.c b/netstat.c | ||
14 | index 56a15c2..86adadb 100644 | ||
15 | --- a/netstat.c | ||
16 | +++ b/netstat.c | ||
17 | @@ -1095,23 +1095,21 @@ static void sctp_eps_do_one(int lnr, char *line) | ||
18 | const char *lport_str; | ||
19 | const char *uid_str; | ||
20 | const char *inode_str; | ||
21 | - const char *pladdr_str; | ||
22 | char *laddrs_str; | ||
23 | |||
24 | if(lnr == 0) { | ||
25 | - /* ENDPT SOCK STY SST HBKT LPORT uid inode pladdr LADDRS*/ | ||
26 | + /* ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS */ | ||
27 | return; | ||
28 | } | ||
29 | |||
30 | - strtok(line," \t\n"); /*skip ptr*/ | ||
31 | - strtok(0," \t\n"); /*skip ptr*/ | ||
32 | + strtok(line," \t\n"); /*skip endpt*/ | ||
33 | + strtok(0," \t\n"); /*skip sock*/ | ||
34 | sty_str = strtok(0," \t\n"); | ||
35 | sst_str = strtok(0," \t\n"); | ||
36 | strtok(0," \t\n"); /*skip hash bucket*/ | ||
37 | lport_str=strtok(0," \t\n"); | ||
38 | uid_str = strtok(0," \t\n"); | ||
39 | inode_str = strtok(0," \t\n"); | ||
40 | - pladdr_str = strtok(0," \t\n"); | ||
41 | laddrs_str=strtok(0,"\t\n"); | ||
42 | |||
43 | type = atoi(sty_str); | ||
44 | @@ -1119,61 +1117,35 @@ static void sctp_eps_do_one(int lnr, char *line) | ||
45 | port = atoi(lport_str); | ||
46 | uid = atoi(uid_str); | ||
47 | inode = strtoul(inode_str,0,0); | ||
48 | - | ||
49 | - if(flag_sctp<=1) { | ||
50 | - /* only print the primary address */ | ||
51 | - char local_addr[64]; | ||
52 | - char local_port[16]; | ||
53 | - | ||
54 | - ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr); | ||
55 | - if(ap) | ||
56 | - safe_strncpy(local_addr, | ||
57 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
58 | - sizeof(local_addr)); | ||
59 | - else | ||
60 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
61 | - | ||
62 | - snprintf(local_port, sizeof(local_port), "%s", | ||
63 | - get_sname(htons(port), "sctp", | ||
64 | - flag_not & FLAG_NUM_PORT)); | ||
65 | - | ||
66 | - printf("sctp "); | ||
67 | - sprintf(buffer,"%s:%s", local_addr, local_port); | ||
68 | - printf("%-47s", buffer); | ||
69 | - printf(" %-12s", sctp_socket_state_str(state)); | ||
70 | - } else { | ||
71 | - /*print all addresses*/ | ||
72 | - const char *this_local_addr; | ||
73 | - int first=1; | ||
74 | - char local_port[16]; | ||
75 | - snprintf(local_port, sizeof(local_port), "%s", | ||
76 | - get_sname(htons(port), "sctp", | ||
77 | - flag_not & FLAG_NUM_PORT)); | ||
78 | - for(this_local_addr=strtok(laddrs_str," \t\n"); | ||
79 | - this_local_addr; | ||
80 | - this_local_addr=strtok(0," \t\n")) | ||
81 | - { | ||
82 | - char local_addr[64]; | ||
83 | - ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | ||
84 | - if(ap) | ||
85 | - safe_strncpy(local_addr, | ||
86 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
87 | - sizeof(local_addr)); | ||
88 | - else | ||
89 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
90 | |||
91 | - if(!first) printf("\n"); | ||
92 | - if(first) | ||
93 | - printf("sctp "); | ||
94 | - else | ||
95 | - printf(" "); | ||
96 | - sprintf(buffer,"%s:%s", local_addr, local_port); | ||
97 | - printf("%-47s", buffer); | ||
98 | - printf(" %-12s", first?sctp_socket_state_str(state):""); | ||
99 | - first = 0; | ||
100 | - } | ||
101 | + const char *this_local_addr; | ||
102 | + int first=1; | ||
103 | + char local_port[16]; | ||
104 | + snprintf(local_port, sizeof(local_port), "%s", | ||
105 | + get_sname(htons(port), "sctp", flag_not & FLAG_NUM_PORT)); | ||
106 | + for(this_local_addr=strtok(laddrs_str," \t\n"); | ||
107 | + this_local_addr; | ||
108 | + this_local_addr=strtok(0," \t\n")) | ||
109 | + { | ||
110 | + char local_addr[64]; | ||
111 | + ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | ||
112 | + if(ap) | ||
113 | + safe_strncpy(local_addr, | ||
114 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
115 | + sizeof(local_addr)); | ||
116 | + else | ||
117 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
118 | + | ||
119 | + if(!first) printf("\n"); | ||
120 | + if(first) | ||
121 | + printf("sctp "); | ||
122 | + else | ||
123 | + printf(" "); | ||
124 | + sprintf(buffer,"%s:%s", local_addr, local_port); | ||
125 | + printf("%-55s", buffer); | ||
126 | + printf(" %-12s", first?sctp_socket_state_str(state):""); | ||
127 | + first = 0; | ||
128 | } | ||
129 | - | ||
130 | finish_this_one(uid,inode,""); | ||
131 | } | ||
132 | |||
133 | @@ -1199,32 +1171,29 @@ static void sctp_assoc_do_one(int lnr, char *line) | ||
134 | const char *lport_str,*rport_str; | ||
135 | const char *uid_str; | ||
136 | const char *inode_str; | ||
137 | - const char *pladdr_str; | ||
138 | char *laddrs_str; | ||
139 | - const char *praddr_str; | ||
140 | char *raddrs_str; | ||
141 | - | ||
142 | + | ||
143 | if(lnr == 0) { | ||
144 | - /* ASSOC SOCK STY SST ST HBKT tx_queue rx_queue uid inode LPORT RPORT pladdr praddr LADDRS <-> RADDRS*/ | ||
145 | + /* ASSOC SOCK STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS */ | ||
146 | return; | ||
147 | } | ||
148 | - | ||
149 | - strtok(line," \t\n"); /*skip ptr*/ | ||
150 | - strtok(0," \t\n"); /*skip ptr*/ | ||
151 | + | ||
152 | + strtok(line," \t\n"); /*skip assoc*/ | ||
153 | + strtok(0," \t\n"); /*skip sock*/ | ||
154 | sty_str = strtok(0," \t\n"); | ||
155 | sst_str = strtok(0," \t\n"); | ||
156 | st_str = strtok(0," \t\n"); | ||
157 | strtok(0," \t\n"); /*skip hash bucket*/ | ||
158 | + strtok(0," \t\n"); /*skip hash assoc-id*/ | ||
159 | txqueue_str = strtok(0," \t\n"); | ||
160 | rxqueue_str = strtok(0," \t\n"); | ||
161 | uid_str = strtok(0," \t\n"); | ||
162 | inode_str = strtok(0," \t\n"); | ||
163 | lport_str=strtok(0," \t\n"); | ||
164 | rport_str=strtok(0," \t\n"); | ||
165 | - pladdr_str = strtok(0," \t\n"); | ||
166 | - praddr_str = strtok(0," \t\n"); | ||
167 | - laddrs_str=strtok(0,"<->\t\n"); | ||
168 | - raddrs_str=strtok(0,"<->\t\n"); | ||
169 | + laddrs_str = strtok(0,"<->\t\n"); | ||
170 | + raddrs_str = strtok(0,"<->\t\n"); | ||
171 | |||
172 | type = atoi(sty_str); | ||
173 | state = atoi(sst_str); | ||
174 | @@ -1235,116 +1204,81 @@ static void sctp_assoc_do_one(int lnr, char *line) | ||
175 | inode = strtoul(inode_str,0,0); | ||
176 | lport = atoi(lport_str); | ||
177 | rport = atoi(rport_str); | ||
178 | - | ||
179 | - if(flag_sctp<=1) { | ||
180 | - /* only print the primary addresses */ | ||
181 | - char local_addr[64]; | ||
182 | - char local_port[16]; | ||
183 | - char remote_addr[64]; | ||
184 | - char remote_port[16]; | ||
185 | - | ||
186 | - ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr); | ||
187 | - if(ap) | ||
188 | - safe_strncpy(local_addr, | ||
189 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
190 | - sizeof(local_addr)); | ||
191 | - else | ||
192 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
193 | - | ||
194 | - snprintf(local_port, sizeof(local_port), "%s", | ||
195 | - get_sname(htons(lport), "sctp", | ||
196 | - flag_not & FLAG_NUM_PORT)); | ||
197 | - | ||
198 | - ap = process_sctp_addr_str(praddr_str, (struct sockaddr*)&remoteaddr); | ||
199 | - if(ap) | ||
200 | - safe_strncpy(remote_addr, | ||
201 | - ap->sprint((struct sockaddr *) &remoteaddr, flag_not), | ||
202 | - sizeof(remote_addr)); | ||
203 | - else | ||
204 | - sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | ||
205 | - | ||
206 | - snprintf(remote_port, sizeof(remote_port), "%s", | ||
207 | - get_sname(htons(rport), "sctp", | ||
208 | - flag_not & FLAG_NUM_PORT)); | ||
209 | - | ||
210 | - printf("sctp"); | ||
211 | - printf(" %6u %6u ", rxqueue, txqueue); | ||
212 | - sprintf(buffer,"%s:%s", local_addr, local_port); | ||
213 | - printf("%-23s", buffer); | ||
214 | - printf(" "); | ||
215 | - sprintf(buffer,"%s:%s", remote_addr, remote_port); | ||
216 | - printf("%-23s", buffer); | ||
217 | - printf(" %-12s", sctp_socket_state_str(state)); | ||
218 | - } else { | ||
219 | - /*print all addresses*/ | ||
220 | - const char *this_local_addr; | ||
221 | - const char *this_remote_addr; | ||
222 | - char *ss1,*ss2; | ||
223 | - int first=1; | ||
224 | - char local_port[16]; | ||
225 | - char remote_port[16]; | ||
226 | - snprintf(local_port, sizeof(local_port), "%s", | ||
227 | - get_sname(htons(lport), "sctp", | ||
228 | - flag_not & FLAG_NUM_PORT)); | ||
229 | - snprintf(remote_port, sizeof(remote_port), "%s", | ||
230 | - get_sname(htons(rport), "sctp", | ||
231 | - flag_not & FLAG_NUM_PORT)); | ||
232 | - | ||
233 | - this_local_addr=strtok_r(laddrs_str," \t\n",&ss1); | ||
234 | - this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2); | ||
235 | - while(this_local_addr || this_remote_addr) { | ||
236 | - char local_addr[64]; | ||
237 | - char remote_addr[64]; | ||
238 | - if(this_local_addr) { | ||
239 | - ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | ||
240 | - if(ap) | ||
241 | - safe_strncpy(local_addr, | ||
242 | - ap->sprint((struct sockaddr *) &localaddr, flag_not), | ||
243 | - sizeof(local_addr)); | ||
244 | - else | ||
245 | - sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
246 | - } | ||
247 | - if(this_remote_addr) { | ||
248 | - ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr); | ||
249 | - if(ap) | ||
250 | - safe_strncpy(remote_addr, | ||
251 | - ap->sprint((struct sockaddr *) &remoteaddr, flag_not), | ||
252 | - sizeof(remote_addr)); | ||
253 | - else | ||
254 | - sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | ||
255 | - } | ||
256 | |||
257 | - if(!first) printf("\n"); | ||
258 | - if(first) | ||
259 | - printf("sctp %6u %6u ", rxqueue, txqueue); | ||
260 | - else | ||
261 | - printf(" "); | ||
262 | - if(this_local_addr) { | ||
263 | - if(first) | ||
264 | - sprintf(buffer,"%s:%s", local_addr, local_port); | ||
265 | + /*print all addresses*/ | ||
266 | + const char *this_local_addr; | ||
267 | + const char *this_remote_addr; | ||
268 | + char *ss1,*ss2; | ||
269 | + int first=1; | ||
270 | + char local_port[16]; | ||
271 | + char remote_port[16]; | ||
272 | + snprintf(local_port, sizeof(local_port), "%s", | ||
273 | + get_sname(htons(lport), "sctp", | ||
274 | + flag_not & FLAG_NUM_PORT)); | ||
275 | + snprintf(remote_port, sizeof(remote_port), "%s", | ||
276 | + get_sname(htons(rport), "sctp", | ||
277 | + flag_not & FLAG_NUM_PORT)); | ||
278 | + | ||
279 | + this_local_addr=strtok_r(laddrs_str," \t\n",&ss1); | ||
280 | + this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2); | ||
281 | + while(this_local_addr || this_remote_addr) { | ||
282 | + char local_addr[64]; | ||
283 | + char remote_addr[64]; | ||
284 | + | ||
285 | + if(this_local_addr) { | ||
286 | + if (this_local_addr[0] == '*') { | ||
287 | + /* skip * */ | ||
288 | + this_local_addr++; | ||
289 | + } | ||
290 | + ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); | ||
291 | + if(ap) | ||
292 | + safe_strncpy(local_addr, | ||
293 | + ap->sprint((struct sockaddr *) &localaddr, flag_not), sizeof(local_addr)); | ||
294 | else | ||
295 | - sprintf(buffer,"%s", local_addr); | ||
296 | - printf("%-23s", buffer); | ||
297 | - } else | ||
298 | - printf("%-23s", ""); | ||
299 | - printf(" "); | ||
300 | - if(this_remote_addr) { | ||
301 | - if(first) | ||
302 | - sprintf(buffer,"%s:%s", remote_addr, remote_port); | ||
303 | + sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); | ||
304 | + } | ||
305 | + if(this_remote_addr) { | ||
306 | + if (this_remote_addr[0] == '*') { | ||
307 | + /* skip * */ | ||
308 | + this_remote_addr++; | ||
309 | + } | ||
310 | + ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr); | ||
311 | + if(ap) | ||
312 | + safe_strncpy(remote_addr, | ||
313 | + ap->sprint((struct sockaddr *) &remoteaddr, flag_not), sizeof(remote_addr)); | ||
314 | else | ||
315 | - sprintf(buffer,"%s", remote_addr); | ||
316 | - printf("%-23s", buffer); | ||
317 | - } else | ||
318 | - printf("%-23s", ""); | ||
319 | - | ||
320 | - printf(" %-12s", first?sctp_socket_state_str(state):""); | ||
321 | + sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); | ||
322 | + } | ||
323 | |||
324 | - first = 0; | ||
325 | - this_local_addr=strtok_r(0," \t\n",&ss1); | ||
326 | - this_remote_addr=strtok_r(0," \t\n",&ss2); | ||
327 | - } | ||
328 | + if(!first) printf("\n"); | ||
329 | + if(first) | ||
330 | + printf("sctp %6u %6u ", rxqueue, txqueue); | ||
331 | + else | ||
332 | + printf(" "); | ||
333 | + if(this_local_addr) { | ||
334 | + if(first) | ||
335 | + sprintf(buffer,"%s:%s", local_addr, local_port); | ||
336 | + else | ||
337 | + sprintf(buffer,"%s", local_addr); | ||
338 | + printf("%-27s", buffer); | ||
339 | + } else | ||
340 | + printf("%-27s", ""); | ||
341 | + printf(" "); | ||
342 | + if(this_remote_addr) { | ||
343 | + if(first) | ||
344 | + sprintf(buffer,"%s:%s", remote_addr, remote_port); | ||
345 | + else | ||
346 | + sprintf(buffer,"%s", remote_addr); | ||
347 | + printf("%-27s", buffer); | ||
348 | + } else | ||
349 | + printf("%-27s", ""); | ||
350 | + | ||
351 | + printf(" %-12s", first?sctp_socket_state_str(state):""); | ||
352 | + | ||
353 | + first = 0; | ||
354 | + this_local_addr=strtok_r(0," \t\n",&ss1); | ||
355 | + this_remote_addr=strtok_r(0," \t\n",&ss2); | ||
356 | } | ||
357 | - | ||
358 | finish_this_one(uid,inode,""); | ||
359 | } | ||
360 | |||
361 | -- | ||
362 | 1.8.5.2.233.g932f7e4 | ||
363 | |||
diff --git a/meta/recipes-extended/net-tools/net-tools_1.60-26.bb b/meta/recipes-extended/net-tools/net-tools_1.60-26.bb index 40a021a09e..63b2051bad 100644 --- a/meta/recipes-extended/net-tools/net-tools_1.60-26.bb +++ b/meta/recipes-extended/net-tools/net-tools_1.60-26.bb | |||
@@ -12,7 +12,10 @@ SRC_URI = "http://snapshot.debian.org/archive/debian/20050312T000000Z/pool/main/ | |||
12 | file://net-tools-config.make \ | 12 | file://net-tools-config.make \ |
13 | file://ifconfig-interface-0-del-IP-will-remove-the-aliased-.patch \ | 13 | file://ifconfig-interface-0-del-IP-will-remove-the-aliased-.patch \ |
14 | file://musl-fixes.patch \ | 14 | file://musl-fixes.patch \ |
15 | " | 15 | file://net-tools-1.60-sctp1.patch \ |
16 | file://net-tools-1.60-sctp2-quiet.patch \ | ||
17 | file://net-tools-1.60-sctp3-addrs.patch \ | ||
18 | " | ||
16 | 19 | ||
17 | # for this package we're mostly interested in tracking debian patches, | 20 | # for this package we're mostly interested in tracking debian patches, |
18 | # and not in the upstream version where all development has effectively stopped | 21 | # and not in the upstream version where all development has effectively stopped |