Home | History | Annotate | Download | only in cls

Lines Matching refs:ematch

2  * lib/route/cls/ematch.c	Extended Matches
14 * @defgroup ematch Extended Match
23 #include <netlink/route/cls/ematch.h>
24 #include <netlink/route/cls/ematch/cmp.h>
37 * Register ematch module
40 * This function must be called by each ematch module at initialization
50 NL_DBG(1, "ematch module \"%s\" registered\n", ops->eo_name);
58 * Lookup ematch module by identification number.
61 * Searches the list of registered ematch modules for match and returns it.
77 * Lookup ematch module by name
78 * @arg name Name of ematch module.
80 * Searches the list of registered ematch modules for a match and returns it.
102 * Allocate ematch object.
104 * Allocates and initializes an ematch object.
106 * @return New ematch object or NULL.
115 NL_DBG(2, "allocated ematch %p\n", e);
124 * Add ematch to the end of the parent's list of children.
125 * @arg parent parent ematch object
126 * @arg child ematch object to be added to parent
128 * The parent must be a container ematch.
136 NL_DBG(2, "added ematch %p \"%s\" to container %p\n",
145 * Remove ematch from the list of ematches it is linked to.
146 * @arg ematch ematch object
148 void rtnl_ematch_unlink(struct rtnl_ematch *ematch)
150 NL_DBG(2, "unlinked ematch %p from any lists\n", ematch);
152 if (!nl_list_empty(&ematch->e_childs))
153 NL_DBG(1, "warning: ematch %p with childs was unlinked\n",
154 ematch);
156 nl_list_del(&ematch->e_list);
157 nl_init_list_head(&ematch->e_list);
160 void rtnl_ematch_free(struct rtnl_ematch *ematch)
162 NL_DBG(2, "freed ematch %p\n", ematch);
163 rtnl_ematch_unlink(ematch);
164 free(ematch->e_data);
165 free(ematch);
168 int rtnl_ematch_set_ops(struct rtnl_ematch *ematch, struct rtnl_ematch_ops *ops)
170 if (ematch->e_ops)
173 ematch->e_ops = ops;
174 ematch->e_kind = ops->eo_kind;
177 ematch->e_data = calloc(1, ops->eo_datalen);
178 if (!ematch->e_data)
181 ematch->e_datalen = ops->eo_datalen;
187 int rtnl_ematch_set_kind(struct rtnl_ematch *ematch, uint16_t kind)
191 if (ematch->e_kind)
194 ematch->e_kind = kind;
197 rtnl_ematch_set_ops(ematch, ops);
202 int rtnl_ematch_set_name(struct rtnl_ematch *ematch, const char *name)
206 if (ematch->e_kind)
212 rtnl_ematch_set_ops(ematch, ops);
217 void rtnl_ematch_set_flags(struct rtnl_ematch *ematch, uint16_t flags)
219 ematch->e_flags |= flags;
222 void rtnl_ematch_unset_flags(struct rtnl_ematch *ematch, uint16_t flags)
224 ematch->e_flags &= ~flags;
227 uint16_t rtnl_ematch_get_flags(struct rtnl_ematch *ematch)
229 return ematch->e_flags;
232 void *rtnl_ematch_data(struct rtnl_ematch *ematch)
234 return ematch->e_data;
244 * Allocate ematch tree object
257 NL_DBG(2, "allocated new ematch tree %p, progid=%u\n", tree, progid);
274 * Free ematch tree object
275 * @arg tree ematch tree object
277 * This function frees the ematch tree and all ematches attached to it.
286 NL_DBG(2, "Freed ematch tree %p\n", tree);
292 * Add ematch object to the end of the ematch tree
293 * @arg tree ematch tree object
294 * @arg ematch ematch object to add
297 struct rtnl_ematch *ematch)
299 nl_list_add_tail(&ematch->e_list, &tree->et_list);
302 static inline uint32_t container_ref(struct rtnl_ematch *ematch)
304 return *((uint32_t *) rtnl_ematch_data(ematch));
310 struct rtnl_ematch *ematch;
314 ematch = index[i];
316 nl_list_add_tail(&ematch->e_list, root);
318 if (ematch->e_kind == TCF_EM_CONTAINER)
319 link_tree(index, nmatches, container_ref(ematch),
320 &ematch->e_childs);
322 if (!(ematch->e_flags & TCF_EM_REL_MASK))
336 * Parse ematch netlink attributes
348 NL_DBG(2, "Parsing attribute %p as ematch tree\n", attr);
361 NL_DBG(2, "Ignoring empty ematch configuration\n");
368 NL_DBG(2, "ematch tree found with nmatches=%u, progid=%u\n",
373 * index[thdr->nmatches]. Calculate how many ematch headers fit into
391 struct rtnl_ematch *ematch;
395 NL_DBG(3, "parsing ematch attribute %d, len=%u\n",
413 NL_DBG(3, "ematch attribute matchid=%u, kind=%u, flags=%u\n",
426 if (!(ematch = rtnl_ematch_alloc())) {
431 ematch->e_id = hdr->matchid;
432 ematch->e_kind = hdr->kind;
433 ematch->e_flags = hdr->flags;
437 rtnl_ematch_free(ematch);
442 rtnl_ematch_set_ops(ematch, ops);
445 (err = ops->eo_parse(ematch, data, len)) < 0) {
446 rtnl_ematch_free(ematch);
451 NL_DBG(3, "index[%d] = %p\n", nmatches, ematch);
452 index[nmatches++] = ematch;
489 nl_dump(p, "[unknown ematch %d]", match->e_kind);
505 /* end of first level ematch sequence */
572 NL_DBG(3, "msg %p: added ematch [%d] id=%d kind=%d flags=%d\n",
599 /* Assign index number to each ematch to allow for references
639 NL_DBG(2, "Parsing ematch expression \"%s\"\n", expr);