]> git.pld-linux.org Git - packages/net-tools.git/blob - net-tools-cycle.patch
- strict internal deps, check-files cleanup
[packages/net-tools.git] / net-tools-cycle.patch
1 --- net-tools-1.60/lib/interface.c.cycle        2003-02-11 14:29:29.000000000 +0100
2 +++ net-tools-1.60/lib/interface.c      2003-02-11 14:29:29.000000000 +0100
3 @@ -90,6 +90,7 @@
4  static struct interface *int_list, *int_last;
5  
6  static int if_readlist_proc(char *);
7 +static int if_readlist_rep(char *, struct interface *);
8  
9  static struct interface *add_interface(char *name)
10  {
11 @@ -128,11 +129,13 @@
12  int for_all_interfaces(int (*doit) (struct interface *, void *), void *cookie)
13  {
14      struct interface *ife;
15 +    int err;
16  
17      if (!int_list && (if_readlist() < 0))
18         return -1;
19      for (ife = int_list; ife; ife = ife->next) {
20 -       int err = doit(ife, cookie);
21 +        if_readlist_rep(ife->name, ife);
22 +       err = doit(ife, cookie);
23         if (err)
24             return err;
25      }
26 @@ -369,6 +372,42 @@
27      return err;
28  }
29  
30 +
31 +static int if_readlist_rep(char *target, struct interface *ife)
32 +{
33 +    FILE *fh;
34 +    char buf[512];
35 +    int err;
36 +
37 +    fh = fopen(_PATH_PROCNET_DEV, "r");
38 +    if (!fh) {
39 +               fprintf(stderr, _("Warning: cannot open %s (%s). Limited output.\n"),
40 +                       _PATH_PROCNET_DEV, strerror(errno)); 
41 +               return if_readconf();
42 +       }       
43 +    fgets(buf, sizeof buf, fh);        /* eat line */
44 +    fgets(buf, sizeof buf, fh);
45 +
46 +    procnetdev_vsn = procnetdev_version(buf);
47 +
48 +    err = 0;
49 +    while (fgets(buf, sizeof buf, fh)) {
50 +       char *s, name[IFNAMSIZ];
51 +       s = get_name(name, buf);    
52 +       get_dev_fields(s, ife);
53 +       ife->statistics_valid = 1;
54 +       if (target && !strcmp(target,name))
55 +               break;
56 +    }
57 +    if (ferror(fh)) {
58 +       perror(_PATH_PROCNET_DEV);
59 +       err = -1;
60 +    }
61 +
62 +    fclose(fh);
63 +    return err;
64 +}
65 +
66  int if_readlist(void) 
67  { 
68      int err = if_readlist_proc(NULL); 
69 --- net-tools-1.60/man/en_US/netstat.8.cycle    2001-01-07 13:43:57.000000000 +0100
70 +++ net-tools-1.60/man/en_US/netstat.8  2003-02-11 14:29:29.000000000 +0100
71 @@ -30,6 +30,7 @@
72  .RB [ \-\-program | \-p ]
73  .RB [ \-\-verbose | \-v ]
74  .RB [ \-\-continuous | \-c]
75 +.RB [delay]
76  .P
77  .B netstat 
78  .RB { \-\-route | \-r }
79 @@ -39,6 +40,7 @@
80  .RB [ \-\-numeric | \-n ]
81  .RB [ \-\-numeric-hosts ] [ \-\-numeric-ports ] [ \-\-numeric-ports ]
82  .RB [ \-\-continuous | \-c]
83 +.RB [delay]
84  .P
85  .B netstat
86  .RB { \-\-interfaces | \-i }
87 @@ -50,12 +52,14 @@
88  .RB [ \-\-numeric | \-n ]
89  .RB [ \-\-numeric-hosts ] [ \-\-numeric-ports ] [ \-\-numeric-ports ]
90  .RB [ \-\-continuous | \-c]
91 +.RB [delay]
92  .P
93  .B netstat
94  .RB { \-\-groups | \-g }
95  .RB [ \-\-numeric | \-n ]
96  .RB [ \-\-numeric-hosts ] [ \-\-numeric-ports ] [ \-\-numeric-ports ]
97  .RB [ \-\-continuous | \-c]
98 +.RB [delay]
99  .P
100  .B netstat
101  .RB { \-\-masquerade | \-M }
102 @@ -63,12 +67,14 @@
103  .RB [ \-\-numeric | \-n ]
104  .RB [ \-\-numeric-hosts ] [ \-\-numeric-ports ] [ \-\-numeric-ports ]
105  .RB [ \-\-continuous | \-c]
106 +.RB [delay]
107  .P
108  .B netstat
109  .RB { \-\-statistics | -s }
110  .RB [ \-\-tcp | \-t ]
111  .RB [ \-\-udp | \-u ]
112  .RB [ \-\-raw | \-w ]
113 +.RB [delay]
114  .P
115  .B netstat 
116  .RB { \-\-version | \-V }
117 @@ -170,6 +176,10 @@
118  Print routing information from the FIB.  (This is the default.)
119  .SS "\-C"
120  Print routing information from the route cache.
121 +.SS delay
122 +Netstat will cycle printing through statistics every 
123 +.B delay 
124 +seconds.
125  .IR UP .
126  .P
127  .SH OUTPUT
128 --- net-tools-1.60/netstat.c.cycle      2003-02-11 14:29:29.000000000 +0100
129 +++ net-tools-1.60/netstat.c    2003-02-11 15:07:26.000000000 +0100
130 @@ -102,7 +102,7 @@
131  #endif
132  
133  /* prototypes for statistics.c */
134 -void parsesnmp(int, int, int);
135 +int parsesnmp(int, int, int);
136  void inittab(void);
137  
138  typedef enum {
139 @@ -1440,6 +1440,8 @@
140  
141  static int iface_info(void)
142  {
143 +    static int count=0;
144 +
145      if (skfd < 0) {
146         if ((skfd = sockets_open(0)) < 0) {
147             perror("socket");
148 @@ -1449,20 +1451,21 @@
149      }
150      if (flag_exp < 2) {
151         ife_short = 1;
152 -       printf(_("Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
153 +       if(!(count % 8))
154 +           printf(_("Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
155      }
156  
157      if (for_all_interfaces(do_if_print, &flag_all) < 0) {
158         perror(_("missing interface information"));
159         exit(1);
160      }
161 -    if (flag_cnt)
162 +    if (!flag_cnt) {
163         free_interface_list();
164 -    else {
165         close(skfd);
166         skfd = -1;
167      }
168  
169 +    count++;
170      return 0;
171  }
172  
173 @@ -1478,7 +1481,7 @@
174  {
175      fprintf(stderr, _("usage: netstat [-veenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}\n"));
176      fprintf(stderr, _("       netstat [-vnNcaeol] [<Socket> ...]\n"));
177 -    fprintf(stderr, _("       netstat { [-veenNac] -i | [-cnNe] -M | -s }\n\n"));
178 +    fprintf(stderr, _("       netstat { [-veenNac] -i | [-cnNe] -M | -s } [delay]\n\n"));
179  
180      fprintf(stderr, _("        -r, --route              display routing table\n"));
181      fprintf(stderr, _("        -i, --interfaces         display interface table\n"));
182 @@ -1514,6 +1517,7 @@
183   (int argc, char *argv[]) {
184      int i;
185      int lop;
186 +    int reptimer = 1;
187      struct option longopts[] =
188      {
189         AFTRANS_OPTS,
190 @@ -1655,6 +1659,12 @@
191             flag_sta++;
192         }
193  
194 +    if(argc == optind + 1) {
195 +      if((reptimer = atoi(argv[optind])) <= 0)
196 +       usage();
197 +      flag_cnt++;
198 +    }
199 +    
200      if (flag_int + flag_rou + flag_mas + flag_sta > 1)
201         usage();
202  
203 @@ -1666,7 +1676,7 @@
204  
205      flag_arg = flag_tcp + flag_udp + flag_raw + flag_unx + flag_ipx
206         + flag_ax25 + flag_netrom + flag_igmp + flag_x25;
207 -
208 +    
209      if (flag_mas) {
210  #if HAVE_FW_MASQUERADE && HAVE_AFINET
211  #if MORE_THAN_ONE_MASQ_AF
212 @@ -1678,7 +1688,7 @@
213                              flag_not & FLAG_NUM_PORT, flag_exp);
214             if (i || !flag_cnt)
215                 break;
216 -           sleep(1);
217 +           sleep(reptimer);
218         }
219  #else
220         ENOSUPP("netstat.c", "FW_MASQUERADE");
221 @@ -1688,9 +1698,15 @@
222      }
223  
224      if (flag_sta) {
225 +      for(;;) {
226          inittab();
227 -       parsesnmp(flag_raw, flag_tcp, flag_udp);
228 -       exit(0);
229 +       i = parsesnmp(flag_raw, flag_tcp, flag_udp);
230 +       
231 +       if(i || !flag_cnt)
232 +         break;
233 +       sleep(reptimer);
234 +      }
235 +      return(i);
236      }
237      
238      if (flag_rou) {
239 @@ -1712,7 +1728,7 @@
240             i = route_info(afname, options);
241             if (i || !flag_cnt)
242                 break;
243 -           sleep(1);
244 +           sleep(reptimer);
245         }
246         return (i);
247      }
248 @@ -1721,7 +1737,7 @@
249             i = iface_info();
250             if (!flag_cnt || i)
251                 break;
252 -           sleep(1);
253 +           sleep(reptimer);
254         }
255         return (i);
256      }
257 @@ -1847,7 +1863,7 @@
258         }
259         if (!flag_cnt || i)
260             break;
261 -       sleep(1);
262 +       sleep(reptimer);
263         prg_cache_clear();
264      }
265      return (i);
266 --- net-tools-1.60/statistics.c.cycle   2001-02-02 19:01:23.000000000 +0100
267 +++ net-tools-1.60/statistics.c 2003-02-11 14:29:29.000000000 +0100
268 @@ -338,7 +338,7 @@
269  }
270  
271  
272 -void parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
273 +int parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
274  {
275      FILE *f;
276  
277 @@ -347,12 +347,14 @@
278      f = fopen("/proc/net/snmp", "r");
279      if (!f) {
280         perror(_("cannot open /proc/net/snmp"));
281 -       return;
282 +       return(1);
283      }
284      process_fd(f);
285  
286 -    if (ferror(f))
287 +    if (ferror(f)) {
288         perror("/proc/net/snmp");
289 +       return(1);
290 +    }
291  
292      fclose(f);
293  
294 @@ -361,12 +363,14 @@
295      if (f) {
296         process_fd(f);
297  
298 -        if (ferror(f))
299 -           perror("/proc/net/netstat");
300 +        if (ferror(f)) {
301 +         perror("/proc/net/netstat");
302 +         return(1);
303 +       }
304      
305          fclose(f);
306      }
307 -    return;
308 +    return(0);
309  }
310      
311  
This page took 0.130539 seconds and 3 git commands to generate.