Debian Codegraph @

lib/route/cls/ematch/container.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3 * Copyright (c) 2008-2013 Thomas Graf <[email protected]>
4 */
5
6 #include "nl-default.h"
7
8 #include <netlink/netlink.h>
9 #include <netlink/route/cls/ematch.h>
10
11 #include "nl-route.h"
12
13 static int container_parse(struct rtnl_ematch *e, void *data, size_t len)
14 {
15 /*
16 The kernel may provide more than 4 bytes of data in the future and we want
17 older libnl versions to be ok with that. We want interfaces to be growable
18 so we only ever enforce a minimum data length and copy as much as we are
19 aware of. Thomas Graf.
20 */
21 memcpy(e->e_data, data, sizeof(uint32_t));
22
23 return 0;
24 }
25
26 static int container_fill(struct rtnl_ematch *e, struct nl_msg *msg)
27 {
28 return nlmsg_append(msg, e->e_data, sizeof(uint32_t), 0);
29 }
30
31 static struct rtnl_ematch_ops container_ops = {
32 .eo_kind = TCF_EM_CONTAINER,
33 .eo_name = "container",
34 .eo_minlen = sizeof(uint32_t),
35 .eo_datalen = sizeof(uint32_t),
36 .eo_parse = container_parse,
37 .eo_fill = container_fill,
38 };
39
40 static void _nl_init container_init(void)
41 {
42 rtnl_ematch_register(&container_ops);
43 }