libnl 3.5.0

ematch.h
1 /*
2 * netlink/route/cls/ematch.h Extended Matches
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 #ifndef NETLINK_CLS_EMATCH_H_
13 #define NETLINK_CLS_EMATCH_H_
14
15 #include <netlink/netlink.h>
16 #include <netlink/msg.h>
17 #include <netlink/route/classifier.h>
18 #include <linux/pkt_cls.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /* FIXME: Should be moved to the kernel header at some point */
25 #define RTNL_EMATCH_PROGID 2
26
27 struct rtnl_ematch;
28 struct rtnl_ematch_tree;
29
30 /**
31 * Extended Match Operations
32 */
33 struct rtnl_ematch_ops
34 {
35 int eo_kind;
36 const char * eo_name;
37 size_t eo_minlen;
38 size_t eo_datalen;
39
40 int (*eo_parse)(struct rtnl_ematch *, void *, size_t);
41 void (*eo_dump)(struct rtnl_ematch *,
42 struct nl_dump_params *);
43 int (*eo_fill)(struct rtnl_ematch *, struct nl_msg *);
44 void (*eo_free)(struct rtnl_ematch *);
45 struct nl_list_head eo_list;
46 };
47
48 extern int rtnl_ematch_register(struct rtnl_ematch_ops *);
49 extern struct rtnl_ematch_ops * rtnl_ematch_lookup_ops(int);
50 extern struct rtnl_ematch_ops * rtnl_ematch_lookup_ops_by_name(const char *);
51
52 extern struct rtnl_ematch * rtnl_ematch_alloc(void);
53 extern int rtnl_ematch_add_child(struct rtnl_ematch *,
54 struct rtnl_ematch *);
55 extern void rtnl_ematch_unlink(struct rtnl_ematch *);
56 extern void rtnl_ematch_free(struct rtnl_ematch *);
57
58 extern void * rtnl_ematch_data(struct rtnl_ematch *);
59 extern void rtnl_ematch_set_flags(struct rtnl_ematch *,
60 uint16_t);
61 extern void rtnl_ematch_unset_flags(struct rtnl_ematch *,
62 uint16_t);
63 extern uint16_t rtnl_ematch_get_flags(struct rtnl_ematch *);
64 extern int rtnl_ematch_set_ops(struct rtnl_ematch *,
65 struct rtnl_ematch_ops *);
66 extern int rtnl_ematch_set_kind(struct rtnl_ematch *,
67 uint16_t);
68 extern int rtnl_ematch_set_name(struct rtnl_ematch *,
69 const char *);
70
71 extern struct rtnl_ematch_tree *rtnl_ematch_tree_alloc(uint16_t);
72 extern void rtnl_ematch_tree_free(struct rtnl_ematch_tree *);
73 extern void rtnl_ematch_tree_add(struct rtnl_ematch_tree *,
74 struct rtnl_ematch *);
75
76 extern struct rtnl_ematch_tree *rtnl_ematch_tree_clone(struct rtnl_ematch_tree *);
77
78 extern int rtnl_ematch_parse_attr(struct nlattr *,
79 struct rtnl_ematch_tree **);
80 extern int rtnl_ematch_fill_attr(struct nl_msg *, int,
81 struct rtnl_ematch_tree *);
82 extern void rtnl_ematch_tree_dump(struct rtnl_ematch_tree *,
83 struct nl_dump_params *);
84
85
86 extern int rtnl_ematch_parse_expr(const char *, char **,
87 struct rtnl_ematch_tree **);
88
89 extern char * rtnl_ematch_offset2txt(uint8_t, uint16_t,
90 char *, size_t);
91 extern char * rtnl_ematch_opnd2txt(uint8_t, char *, size_t);
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif
rtnl_ematch_tree_clone
struct rtnl_ematch_tree * rtnl_ematch_tree_clone(struct rtnl_ematch_tree *)
Clone ematch tree object.
Definition: ematch.c:334
rtnl_ematch_tree_add
void rtnl_ematch_tree_add(struct rtnl_ematch_tree *, struct rtnl_ematch *)
Add ematch object to the end of the ematch tree.
Definition: ematch.c:354
rtnl_ematch_tree_alloc
struct rtnl_ematch_tree * rtnl_ematch_tree_alloc(uint16_t)
Allocate ematch tree object.
Definition: ematch.c:248
rtnl_ematch_tree_free
void rtnl_ematch_tree_free(struct rtnl_ematch_tree *)
Free ematch tree object.
Definition: ematch.c:280
rtnl_ematch_lookup_ops
struct rtnl_ematch_ops * rtnl_ematch_lookup_ops(int)
Lookup ematch module by identification number.
Definition: ematch.c:66
rtnl_ematch_lookup_ops_by_name
struct rtnl_ematch_ops * rtnl_ematch_lookup_ops_by_name(const char *)
Lookup ematch module by name.
Definition: ematch.c:85
rtnl_ematch_alloc
struct rtnl_ematch * rtnl_ematch_alloc(void)
Allocate ematch object.
Definition: ematch.c:109
rtnl_ematch_parse_attr
int rtnl_ematch_parse_attr(struct nlattr *, struct rtnl_ematch_tree **)
Parse ematch netlink attributes.
Definition: ematch.c:398
rtnl_ematch_register
int rtnl_ematch_register(struct rtnl_ematch_ops *)
Register ematch module.
Definition: ematch.c:46
rtnl_ematch_unlink
void rtnl_ematch_unlink(struct rtnl_ematch *)
Remove ematch from the list of ematches it is linked to.
Definition: ematch.c:149
nl_dump_params
Dumping parameters.
Definition: types.h:33
nl_list_head
Definition: list.h:17
rtnl_ematch_ops
Extended Match Operations.
Definition: ematch.h:33
rtnl_ematch_add_child
int rtnl_ematch_add_child(struct rtnl_ematch *, struct rtnl_ematch *)
Add ematch to the end of the parent's list of children.
Definition: ematch.c:131