summaryrefslogtreecommitdiff
path: root/sysdep/linux/netlink.Y
blob: 9b07e9bb76dfc5d1c9ffd8aa7baf5e2e4e200ee0 (plain)
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
/*
 *	BIRD -- Linux Netlink Configuration
 *
 *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

CF_HDR

CF_DECLS

CF_KEYWORDS(KERNEL, TABLE, METRIC, NETLINK, RX, BUFFER,
	    KRT_LOCK_MTU, KRT_LOCK_WINDOW, KRT_LOCK_RTT, KRT_LOCK_RTTVAR,
	    KRT_LOCK_SSTRESH, KRT_LOCK_CWND, KRT_LOCK_ADVMSS, KRT_LOCK_REORDERING,
	    KRT_LOCK_HOPLIMIT, KRT_LOCK_RTO_MIN, KRT_FEATURE_ECN, KRT_FEATURE_ALLFRAG)

%type <fab> attr_bit

CF_GRAMMAR

kern_proto: kern_proto kern_sys_item ';' ;

kern_sys_item:
   KERNEL TABLE expr { THIS_KRT->sys.table_id = $3; }
 | METRIC expr { THIS_KRT->sys.metric = $2; }
 | NETLINK RX BUFFER expr { THIS_KRT->sys.netlink_rx_buffer = $4; }
 ;

/* Bits of EA_KRT_LOCK, based on RTAX_* constants */

attr_bit: KRT_LOCK_MTU	{ $$ = f_new_dynamic_attr_bit(2, "krt_lock"); } ;
attr_bit: KRT_LOCK_WINDOW	{ $$ = f_new_dynamic_attr_bit(3, "krt_lock"); } ;
attr_bit: KRT_LOCK_RTT	{ $$ = f_new_dynamic_attr_bit(4, "krt_lock"); } ;
attr_bit: KRT_LOCK_RTTVAR	{ $$ = f_new_dynamic_attr_bit(5, "krt_lock"); } ;
attr_bit: KRT_LOCK_SSTRESH	{ $$ = f_new_dynamic_attr_bit(6, "krt_lock"); } ;
attr_bit: KRT_LOCK_CWND	{ $$ = f_new_dynamic_attr_bit(7, "krt_lock"); } ;
attr_bit: KRT_LOCK_ADVMSS	{ $$ = f_new_dynamic_attr_bit(8, "krt_lock"); } ;
attr_bit: KRT_LOCK_REORDERING { $$ = f_new_dynamic_attr_bit(9, "krt_lock"); } ;
attr_bit: KRT_LOCK_HOPLIMIT { $$ = f_new_dynamic_attr_bit(10, "krt_lock"); } ;
attr_bit: KRT_LOCK_RTO_MIN { $$ = f_new_dynamic_attr_bit(13, "krt_lock"); } ;

/* Bits of EA_KRT_FEATURES */
attr_bit: KRT_FEATURE_ECN	{ $$ = f_new_dynamic_attr_bit(0, "krt_features"); } ;
attr_bit: KRT_FEATURE_ALLFRAG { $$ = f_new_dynamic_attr_bit(3, "krt_features"); } ;

/* Getting attribute bits (moved here to not confuse Bison on *BSD) */
term:
   attr_bit {
    struct f_inst *c = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)});
    $$ = f_new_inst(FI_EQ, c, f_new_inst(FI_BITAND, f_new_inst(FI_EA_GET, $1.class), c));
  }
 ;

/* Setting attribute bits (moved here to not confuse Bison on *BSD) */
cmd:
   attr_bit '=' term ';' {
     $$ = f_new_inst(FI_CONDITION, $3,
	f_generate_complex_default(FI_BITOR, $1.class,
	      f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)}), 0),
	f_generate_complex_default(FI_BITAND, $1.class,
	      f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = ~(1U << $1.bit)}), 0)
     );
   }
 ;

CF_CODE

CF_END