dect
/
libnl
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
libnl/lib/route/pktloc_syntax.y

104 lines
1.4 KiB
Plaintext

%{
#include <netlink-local.h>
#include <netlink-tc.h>
#include <netlink/netlink.h>
#include <netlink/utils.h>
#include <netlink/route/pktloc.h>
%}
%locations
%error-verbose
%define api.pure
%name-prefix "pktloc_"
%parse-param {void *scanner}
%lex-param {void *scanner}
%expect 1
%union {
struct rtnl_pktloc *l;
uint32_t i;
char *s;
}
%{
extern int pktloc_lex(YYSTYPE *, YYLTYPE *, void *);
static void yyerror(YYLTYPE *locp, void *scanner, const char *msg)
{
NL_DBG(1, "Error while parsing packet location file: %s\n", msg);
}
%}
%token <i> ERROR NUMBER LAYER ALIGN
%token <s> NAME
%type <i> mask layer align shift
%type <l> location
%destructor { free($$); } NAME
%start input
%%
input:
/* empty */
| location input
;
location:
NAME align layer NUMBER mask shift
{
struct rtnl_pktloc *loc;
if (!(loc = rtnl_pktloc_alloc())) {
NL_DBG(1, "Allocating a packet location "
"object failed.\n");
YYABORT;
}
loc->name = $1;
loc->align = $2;
loc->layer = $3;
loc->offset = $4;
loc->mask = $5;
loc->shift = $6;
if (rtnl_pktloc_add(loc) < 0) {
NL_DBG(1, "Duplicate packet location entry "
"\"%s\"\n", $1);
}
$$ = loc;
}
;
align:
ALIGN
{ $$ = $1; }
| NUMBER
{ $$ = $1; }
;
layer:
/* empty */
{ $$ = TCF_LAYER_NETWORK; }
| LAYER '+'
{ $$ = $1; }
;
mask:
/* empty */
{ $$ = 0; }
| NUMBER
{ $$ = $1; }
;
shift:
/* empty */
{ $$ = 0; }
| NUMBER
{ $$ = $1; }
;