~ubuntu-branches/ubuntu/trusty/libnl3/trusty

« back to all changes in this revision

Viewing changes to lib/route/pktloc_syntax.y

  • Committer: Bazaar Package Importer
  • Author(s): Heiko Stuebner
  • Date: 2011-05-21 19:25:13 UTC
  • Revision ID: james.westby@ubuntu.com-20110521192513-1ieyu9w9kym4bt16
Tags: upstream-3.0
ImportĀ upstreamĀ versionĀ 3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%{
 
2
#include <netlink-local.h>
 
3
#include <netlink-tc.h>
 
4
#include <netlink/netlink.h>
 
5
#include <netlink/utils.h>
 
6
#include <netlink/route/pktloc.h>
 
7
%}
 
8
 
 
9
%locations
 
10
%error-verbose
 
11
%define api.pure
 
12
%name-prefix "pktloc_"
 
13
 
 
14
%parse-param {void *scanner}
 
15
%lex-param {void *scanner}
 
16
%expect 1
 
17
 
 
18
%union {
 
19
        struct rtnl_pktloc *l;
 
20
        uint32_t i;
 
21
        char *s;
 
22
}
 
23
 
 
24
%{
 
25
extern int pktloc_lex(YYSTYPE *, YYLTYPE *, void *);
 
26
 
 
27
static void yyerror(YYLTYPE *locp, void *scanner, const char *msg)
 
28
{
 
29
        NL_DBG(1, "Error while parsing packet location file: %s\n", msg);
 
30
}
 
31
%}
 
32
 
 
33
%token <i> ERROR NUMBER LAYER ALIGN
 
34
%token <s> NAME
 
35
 
 
36
%type <i> mask layer align shift
 
37
%type <l> location
 
38
 
 
39
%destructor { free($$); } NAME
 
40
 
 
41
%start input
 
42
 
 
43
%%
 
44
 
 
45
input:
 
46
        /* empty */
 
47
        | location input
 
48
        ;
 
49
 
 
50
location:
 
51
        NAME align layer NUMBER mask shift
 
52
                {
 
53
                        struct rtnl_pktloc *loc;
 
54
 
 
55
                        if (!(loc = rtnl_pktloc_alloc())) {
 
56
                                NL_DBG(1, "Allocating a packet location "
 
57
                                          "object failed.\n");
 
58
                                YYABORT;
 
59
                        }
 
60
 
 
61
                        loc->name = $1;
 
62
                        loc->align = $2;
 
63
                        loc->layer = $3;
 
64
                        loc->offset = $4;
 
65
                        loc->mask = $5;
 
66
                        loc->shift = $6;
 
67
 
 
68
                        if (rtnl_pktloc_add(loc) < 0) {
 
69
                                NL_DBG(1, "Duplicate packet location entry "
 
70
                                          "\"%s\"\n", $1);
 
71
                        }
 
72
 
 
73
                        $$ = loc;
 
74
                }
 
75
        ;
 
76
 
 
77
align:
 
78
        ALIGN
 
79
                { $$ = $1; }
 
80
        | NUMBER
 
81
                { $$ = $1; }
 
82
        ;
 
83
 
 
84
layer:
 
85
        /* empty */
 
86
                { $$ = TCF_LAYER_NETWORK; }
 
87
        | LAYER '+' 
 
88
                { $$ = $1; }
 
89
        ;
 
90
 
 
91
mask:
 
92
        /* empty */
 
93
                { $$ = 0; }
 
94
        | NUMBER
 
95
                { $$ = $1; }
 
96
        ;
 
97
 
 
98
shift:
 
99
        /* empty */
 
100
                { $$ = 0; }
 
101
        | NUMBER
 
102
                { $$ = $1; }
 
103
        ;