libnl: /data/src/libnl/lib/route/cls/ematch/container.c Source File

libnl 3.12.0

container.c
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2008-2013 Thomas Graf <tgraf@suug.ch>
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
13static 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
26static 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
31static 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
40static void _nl_init container_init(void)
41{
42 rtnl_ematch_register(&container_ops);
43}
rtnl_ematch_register
int rtnl_ematch_register(struct rtnl_ematch_ops *ops)
Register ematch module.
Definition ematch.c:44
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:456
rtnl_ematch_ops
Extended Match Operations.
Definition ematch.h:28