File: tree.h

package info (click to toggle)
tcng 10b-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,644 kB
  • sloc: ansic: 19,040; pascal: 4,640; yacc: 2,619; sh: 1,914; perl: 1,546; lex: 772; makefile: 751
file content (148 lines) | stat: -rw-r--r-- 3,398 bytes parent folder | download | duplicates (5)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 * tree.h - All qdisc/class/filter data structures
 *
 * Written 2001-2003 by Werner Almesberger
 * Copyright 2001 EPFL-ICA, Network Robots
 * Copyright 2002 Bivio Networks, Network Robots
 * Copyright 2003 Werner Almesberger
 */


#ifndef TREE_H
#define TREE_H

#include <stdint.h>
#include <stdio.h>

#include "location.h"
#include "param.h"


struct _device;
struct _qdisc;
struct _class;
struct _filter;
struct _tunnel;


typedef struct {
    struct _device *device;
    struct _qdisc *qdisc;
    struct _class *class;
    struct _filter *filter;
    struct _tunnel *tunnel;
} PARENT;

typedef enum {
    pd_invalid = 0,
    pd_ok = 1,
    pd_drop = 2,
    pd_continue = 4,
    pd_reclassify = 8,
} DECISION;

typedef struct _police {
    uint32_t number;
    LOCATION location;
    PARAM *params;
    DECISION in_profile;
    DECISION out_profile;
    int used; /* 0 if policer is not referenced */
    int created; /* if non-zero, we can just reference it */
    struct _police *next;
} POLICE;

typedef struct _element {
    PARENT parent;
    uint32_t number;
    LOCATION location;
    PARAM *params;
    POLICE *police;
    struct _element *next;
} ELEMENT;

typedef struct {
    const char *name;
    PARAM_DEF *filter_param;
    PARAM_DEF *element_param;
    void (*check)(struct _filter *filter);
    void (*dump_tc)(struct _filter *filter);
} FILTER_DSC;

typedef struct _filter {
    PARENT parent;
    uint32_t number;
    LOCATION location;
    const FILTER_DSC *dsc;
    PARAM *params;
    ELEMENT *elements;
    struct _filter *next;
} FILTER;

typedef struct _tunnel {
    PARENT parent;
    uint32_t number;
    LOCATION location;
    PARAM *params;
} TUNNEL;

typedef struct _class {
    PARENT parent;
    uint32_t number;
    LOCATION location;
    PARAM *params;
    struct _qdisc *qdisc;
    FILTER *filters;
    struct _class *child;
    struct _class *next;
    int implicit; /* @@@ temporary: flag implicitly generated class */
} CLASS;

#define QDISC_HAS_CLASSES	1	/* qdisc has classes (see below) */
#define QDISC_HAS_FILTERS	2	/* classes have filters */
#define QDISC_CHILD_QDISCS	8	/* qdisc's classes have child qdiscs */
#define QDISC_SHARED_QDISC	16	/* all classes share one qdisc */
#define QDISC_CLASS_SEL_PATHS	32	/* qdisc can generate class sel paths */

/*
 * Note that QDISC_CHILD_QDISCS does not imply QDISC_HAS_CLASSES. E.g. TBF can
 * have one child qdisc, but no classes. Nevertheless, tcc adds a dummy class
 * for internal use and also for the external interface.
 */

typedef struct {
    const char *name;
    int flags;
    PARAM_DEF *qdisc_param;
    PARAM_DEF *class_param; /* undefined if classless */
    void (*check)(struct _qdisc *qdisc); /* assign IDs and check parameters */
    void (*default_class)(DATA *d,struct _qdisc *qdisc);
	/* undefined if classless */
    void (*dump_tc)(struct _qdisc *qdisc);
    void (*dump_ext)(FILE *file,struct _qdisc *qdisc);
} QDISC_DSC;

typedef struct _qdisc {
    PARENT parent;
    QDISC_DSC *dsc;
    uint32_t number;
    LOCATION location;
    PARAM *params;
    CLASS *classes;
    FILTER *filters;
    DATA if_expr; /* dt_none if we don't have if */
} QDISC;

typedef struct _device {
    const char *name;
    LOCATION location;
    PARAM *params;
    QDISC *egress;
    QDISC *ingress;
    struct _device *next;
} DEVICE;


extern DATA_LIST *pragma; /* global pragma */

#endif /* TREE_H */