• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iproute2/misc/

Lines Matching defs:lf

39 static int scan_lines(struct lnstat_file *lf, int i)
43 for (j = 0; j < lf->num_fields; j++)
44 lf->fields[j].values[i] = 0;
46 while(!feof(lf->fp)) {
52 fgets(buf, sizeof(buf)-1, lf->fp);
53 gettimeofday(&lf->last_read, NULL);
55 for (j = 0; j < lf->num_fields; j++) {
58 lf->fields[j].values[i] = f;
60 lf->fields[j].values[i] += f;
83 struct lnstat_file *lf;
89 for (lf = lnstat_files; lf; lf = lf->next) {
90 if (time_after(&lf->last_read, &lf->interval, &tv)) {
94 rewind(lf->fp);
95 if (!lf->compat) {
97 fgets(buf, sizeof(buf)-1, lf->fp);
99 scan_lines(lf, 1);
101 for (i = 0, lfi = &lf->fields[i];
102 i < lf->num_fields; i++, lfi = &lf->fields[i]) {
107 / lf->interval.tv_sec;
110 rewind(lf->fp);
111 fgets(buf, sizeof(buf)-1, lf->fp);
112 scan_lines(lf, 0);
120 static int __lnstat_scan_fields(struct lnstat_file *lf, char *buf)
127 lf->fields[i].file = lf;
128 strncpy(lf->fields[i].name, tok, LNSTAT_MAX_FIELD_NAME_LEN);
133 lf->num_fields = i+1;
140 static int lnstat_scan_fields(struct lnstat_file *lf)
144 rewind(lf->fp);
145 fgets(buf, sizeof(buf)-1, lf->fp);
147 return __lnstat_scan_fields(lf, buf);
151 static int lnstat_scan_compat_rtstat_fields(struct lnstat_file *lf)
157 return __lnstat_scan_fields(lf, buf);
174 struct lnstat_file *lf;
177 lf = malloc(sizeof(*lf));
178 if (!lf)
182 memset(lf, 0, sizeof(*lf));
185 strcpy(lf->basename, file);
186 strcpy(lf->path, path);
187 strcat(lf->path, "/");
188 strcat(lf->path, lf->basename);
191 lf->interval.tv_sec = 1;
194 lf->fp = fopen(lf->path, "r");
195 if (!lf->fp) {
196 free(lf);
200 return lf;
217 struct lnstat_file *lf;
236 lf = alloc_and_open("/proc/net", "rt_cache_stat");
237 if (!lf)
239 lf->compat = 1;
240 strncpy(lf->basename, "rt_cache", sizeof(lf->basename));
243 if (lnstat_scan_compat_rtstat_fields(lf) < 0)
246 lf->next = lnstat_files;
247 lnstat_files = lf;
252 struct lnstat_file *lf;
261 lf = alloc_and_open(path, de->d_name);
262 if (!lf)
266 if (lnstat_scan_fields(lf) < 0)
270 lf->next = lnstat_files;
271 lnstat_files = lf;
280 struct lnstat_file *lf;
282 for (lf = lnstat_files; lf; lf = lf->next) {
285 fprintf(outfd, "%s:\n", lf->path);
287 for (i = 0; i < lf->num_fields; i++)
288 fprintf(outfd, "\t%2u: %s\n", i+1, lf->fields[i].name);
297 struct lnstat_file *lf;
311 for (lf = lnstat_files; lf; lf = lf->next) {
314 if (file && strcmp(file, lf->basename))
317 for (i = 0; i < lf->num_fields; i++) {
318 if (!strcmp(field, lf->fields[i].name)) {
319 ret = &lf->fields[i];