libnl  3.2.7
container.c
1 /*
2  * lib/route/cls/ematch/container.c Container Ematch
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation version 2.1
7  * of the License.
8  *
9  * Copyright (c) 2008-2010 Thomas Graf <tgraf@suug.ch>
10  */
11 
12 #include <netlink-local.h>
13 #include <netlink-tc.h>
14 #include <netlink/netlink.h>
15 #include <netlink/route/cls/ematch.h>
16 
17 static int container_parse(struct rtnl_ematch *e, void *data, size_t len)
18 {
19  memcpy(e->e_data, data, sizeof(uint32_t));
20 
21  return 0;
22 }
23 
24 static int container_fill(struct rtnl_ematch *e, struct nl_msg *msg)
25 {
26  return nlmsg_append(msg, e->e_data, sizeof(uint32_t), 0);
27 }
28 
29 static struct rtnl_ematch_ops container_ops = {
30  .eo_kind = TCF_EM_CONTAINER,
31  .eo_name = "container",
32  .eo_minlen = sizeof(uint32_t),
33  .eo_datalen = sizeof(uint32_t),
34  .eo_parse = container_parse,
35  .eo_fill = container_fill,
36 };
37 
38 static void __init container_init(void)
39 {
40  rtnl_ematch_register(&container_ops);
41 }