File: device.c

package info (click to toggle)
tcng 10b-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,644 kB
  • ctags: 2,515
  • sloc: ansic: 19,040; pascal: 4,640; yacc: 2,619; sh: 1,914; perl: 1,546; lex: 772; makefile: 756
file content (88 lines) | stat: -rw-r--r-- 1,720 bytes parent folder | download | duplicates (3)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * device.c - Device handling
 *
 * Written 2001,2002 by Werner Almesberger
 * Copyright 2001 EPFL-ICA
 * Copyright 2002 Bivio Networks
 */


#include <string.h>

#include "config.h"
#include "error.h"
#include "tc.h"
#include "tree.h"
#include "qdisc.h"
#include "device.h"


int add_fifos = 0; /* add FIFOs default qdisc is used */

DEVICE *devices = NULL;


static const PARAM_DSC *device_opt[] = {
    &prm_pragma,	/* list */
    NULL
};

PARAM_DEF device_def = {
    .required = NULL,
    .optional = device_opt,
};


int guess_mtu(DEVICE *device)
{
    return 1510; /* @@@ */
}


void add_device(DEVICE *device)
{
    DEVICE **walk;

    for (walk = &devices; *walk; walk = &(*walk)->next)
	if (!strcmp((*walk)->name,device->name))
	    yyerror("duplicate device name");
    *walk = device;
}


void check_devices(void)
{
    DEVICE *device;

    for (device = devices; device; device = device->next) {
	if (device->ingress) {
	    device->ingress->number = 0xffff; /* ingress magic number */
	    assign_qdisc_ids(device->ingress);
	    check_qdisc(device->ingress);
	}
	if (device->egress) {
	    if (add_fifos) add_default_fifos(device->egress);
	    assign_qdisc_ids(device->egress);
	    check_qdisc(device->egress);
	}
    }
}


void dump_devices(void)
{
    DEVICE *device;

    for (device = devices; device; device = device->next) {
	if (remove_qdiscs) {
	    tc_more("tc qdisc del dev %s root",device->name);
	    tc_nl();
	    tc_more("tc qdisc del dev %s ingress",device->name);
	    tc_nl();
	}
	if (!device->egress && !device->ingress) continue;
	tc_comment('=',"Device %s",device->name);
	if (device->ingress) dump_qdisc(device->ingress);
	if (device->egress) dump_qdisc(device->egress);
    }
}