libnl 3.5.0

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-2013 Thomas Graf <tgraf@suug.ch>
10 */
11
12 #include <netlink-private/netlink.h>
13 #include <netlink-private/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 __attribute__((unused)))
18 {
19 /*
20 The kernel may provide more than 4 bytes of data in the future and we want
21 older libnl versions to be ok with that. We want interfaces to be growable
22 so we only ever enforce a minimum data length and copy as much as we are
23 aware of. Thomas Graf.
24 */
25 memcpy(e->e_data, data, sizeof(uint32_t));
26
27 return 0;
28 }
29
30 static int container_fill(struct rtnl_ematch *e, struct nl_msg *msg)
31 {
32 return nlmsg_append(msg, e->e_data, sizeof(uint32_t), 0);
33 }
34
35 static struct rtnl_ematch_ops container_ops = {
36 .eo_kind = TCF_EM_CONTAINER,
37 .eo_name = "container",
38 .eo_minlen = sizeof(uint32_t),
39 .eo_datalen = sizeof(uint32_t),
40 .eo_parse = container_parse,
41 .eo_fill = container_fill,
42 };
43
44 static void __init container_init(void)
45 {
46 rtnl_ematch_register(&container_ops);
47 }
rtnl_ematch_register
int rtnl_ematch_register(struct rtnl_ematch_ops *ops)
Register ematch module.
Definition: ematch.c:46
nlmsg_append
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
Definition: msg.c:449
rtnl_ematch_ops
Extended Match Operations.
Definition: ematch.h:33