diff options
author | Thomas Graf <tgraf@suug.ch> | 2010-10-28 22:14:34 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2010-10-28 22:14:34 (GMT) |
commit | 0fe5b29423c1ad97012a865f1cd8b4f7ff37f143 (patch) | |
tree | 2776ab0e83cea83f4582b0f2313901a7c4c918be /lib | |
parent | 65e386c8ba490d405f539322a12e1f1c7ea2eb5c (diff) | |
download | libnl-0fe5b29423c1ad97012a865f1cd8b4f7ff37f143.zip libnl-0fe5b29423c1ad97012a865f1cd8b4f7ff37f143.tar.gz libnl-0fe5b29423c1ad97012a865f1cd8b4f7ff37f143.tar.bz2 |
Extended pktloc to support nbyte locations for ipv6, etc.
The alignment column/field now also takes a number, specifying
the length in bytes of the field described by the location
Diffstat (limited to 'lib')
-rw-r--r-- | lib/route/pktloc.c | 18 | ||||
-rw-r--r-- | lib/route/pktloc_syntax.y | 13 |
2 files changed, 26 insertions, 5 deletions
diff --git a/lib/route/pktloc.c b/lib/route/pktloc.c index faf4bf5..b5e5b77 100644 --- a/lib/route/pktloc.c +++ b/lib/route/pktloc.c @@ -177,6 +177,22 @@ int rtnl_pktloc_lookup(const char *name, struct rtnl_pktloc **result) } /** + * Allocate packet location object + */ +struct rtnl_pktloc *rtnl_pktloc_alloc(void) +{ + struct rtnl_pktloc *loc; + + if (!(loc = calloc(1, sizeof(*loc)))) + return NULL; + + loc->refcnt = 1; + nl_init_list_head(&loc->list); + + return loc; +} + +/** * Return reference of a packet location * @arg loc packet location object. */ @@ -205,8 +221,6 @@ int rtnl_pktloc_add(struct rtnl_pktloc *loc) return -NLE_EXIST; } - loc->refcnt++; - NL_DBG(2, "New packet location entry \"%s\" align=%u layer=%u " "offset=%u mask=%#x refnt=%u\n", loc->name, loc->align, loc->layer, loc->offset, loc->mask, loc->refcnt); diff --git a/lib/route/pktloc_syntax.y b/lib/route/pktloc_syntax.y index bf00549..95cd6f4 100644 --- a/lib/route/pktloc_syntax.y +++ b/lib/route/pktloc_syntax.y @@ -32,7 +32,7 @@ static void yyerror(YYLTYPE *locp, void *scanner, const char *msg) %token <i> ERROR NUMBER LAYER ALIGN %token <s> NAME -%type <i> mask layer +%type <i> mask layer align %type <l> location %destructor { free($$); } NAME @@ -47,11 +47,11 @@ input: ; location: - NAME ALIGN layer NUMBER mask + NAME align layer NUMBER mask { struct rtnl_pktloc *loc; - if (!(loc = calloc(1, sizeof(*loc)))) { + if (!(loc = rtnl_pktloc_alloc())) { NL_DBG(1, "Allocating a packet location " "object failed.\n"); YYABORT; @@ -72,6 +72,13 @@ location: } ; +align: + ALIGN + { $$ = $1; } + | NUMBER + { $$ = $1; } + ; + layer: /* empty */ { $$ = TCF_LAYER_NETWORK; } |