next up previous contents
Next: Tunnels Up: Historical constructs Previous: Limitations   Contents

Redefining fields

Fields can be redefined, e.g. one may simplify the header structure by assuming that packets contain no IP options (e.g. if such packets have been eliminated before reaching traffic control) as follows:

#include "fields.tc"

field ip_nexthdr = ip[20];

Note that, when redefining a field, only the fields that were known at the time of the original definition, are available. It is therefore not possible to construct recursive field definitions.

Fields definitions and redefinitions can appear anywhere where variable definitions are allowed. They follow the same scoping rules as variables, e.g. in

field port = tcp_sport;
prio {
    field port = tcp_dport;
    class if port == 80;
}

port is the TCP destination port in the prio queuing discipline, but becomes the source port again afterwards.



Martin A. Brown 2003-11-06