Lines Matching refs:ematch
148 void rtnl_ematch_unlink(struct rtnl_ematch *ematch) in rtnl_ematch_unlink() argument
150 NL_DBG(2, "unlinked ematch %p from any lists\n", ematch); in rtnl_ematch_unlink()
152 if (!nl_list_empty(&ematch->e_childs)) in rtnl_ematch_unlink()
154 ematch); in rtnl_ematch_unlink()
156 nl_list_del(&ematch->e_list); in rtnl_ematch_unlink()
157 nl_init_list_head(&ematch->e_list); in rtnl_ematch_unlink()
160 void rtnl_ematch_free(struct rtnl_ematch *ematch) in rtnl_ematch_free() argument
162 NL_DBG(2, "freed ematch %p\n", ematch); in rtnl_ematch_free()
163 rtnl_ematch_unlink(ematch); in rtnl_ematch_free()
164 free(ematch->e_data); in rtnl_ematch_free()
165 free(ematch); in rtnl_ematch_free()
168 int rtnl_ematch_set_ops(struct rtnl_ematch *ematch, struct rtnl_ematch_ops *ops) in rtnl_ematch_set_ops() argument
170 if (ematch->e_ops) in rtnl_ematch_set_ops()
173 ematch->e_ops = ops; in rtnl_ematch_set_ops()
174 ematch->e_kind = ops->eo_kind; in rtnl_ematch_set_ops()
177 ematch->e_data = calloc(1, ops->eo_datalen); in rtnl_ematch_set_ops()
178 if (!ematch->e_data) in rtnl_ematch_set_ops()
181 ematch->e_datalen = ops->eo_datalen; in rtnl_ematch_set_ops()
187 int rtnl_ematch_set_kind(struct rtnl_ematch *ematch, uint16_t kind) in rtnl_ematch_set_kind() argument
191 if (ematch->e_kind) in rtnl_ematch_set_kind()
194 ematch->e_kind = kind; in rtnl_ematch_set_kind()
197 rtnl_ematch_set_ops(ematch, ops); in rtnl_ematch_set_kind()
202 int rtnl_ematch_set_name(struct rtnl_ematch *ematch, const char *name) in rtnl_ematch_set_name() argument
206 if (ematch->e_kind) in rtnl_ematch_set_name()
212 rtnl_ematch_set_ops(ematch, ops); in rtnl_ematch_set_name()
217 void rtnl_ematch_set_flags(struct rtnl_ematch *ematch, uint16_t flags) in rtnl_ematch_set_flags() argument
219 ematch->e_flags |= flags; in rtnl_ematch_set_flags()
222 void rtnl_ematch_unset_flags(struct rtnl_ematch *ematch, uint16_t flags) in rtnl_ematch_unset_flags() argument
224 ematch->e_flags &= ~flags; in rtnl_ematch_unset_flags()
227 uint16_t rtnl_ematch_get_flags(struct rtnl_ematch *ematch) in rtnl_ematch_get_flags() argument
229 return ematch->e_flags; in rtnl_ematch_get_flags()
232 void *rtnl_ematch_data(struct rtnl_ematch *ematch) in rtnl_ematch_data() argument
234 return ematch->e_data; in rtnl_ematch_data()
297 struct rtnl_ematch *ematch) in rtnl_ematch_tree_add() argument
299 nl_list_add_tail(&ematch->e_list, &tree->et_list); in rtnl_ematch_tree_add()
302 static inline uint32_t container_ref(struct rtnl_ematch *ematch) in container_ref() argument
304 return *((uint32_t *) rtnl_ematch_data(ematch)); in container_ref()
310 struct rtnl_ematch *ematch; in link_tree() local
314 ematch = index[i]; in link_tree()
316 nl_list_add_tail(&ematch->e_list, root); in link_tree()
318 if (ematch->e_kind == TCF_EM_CONTAINER) in link_tree()
319 link_tree(index, nmatches, container_ref(ematch), in link_tree()
320 &ematch->e_childs); in link_tree()
322 if (!(ematch->e_flags & TCF_EM_REL_MASK)) in link_tree()
391 struct rtnl_ematch *ematch; in rtnl_ematch_parse_attr() local
426 if (!(ematch = rtnl_ematch_alloc())) { in rtnl_ematch_parse_attr()
431 ematch->e_id = hdr->matchid; in rtnl_ematch_parse_attr()
432 ematch->e_kind = hdr->kind; in rtnl_ematch_parse_attr()
433 ematch->e_flags = hdr->flags; in rtnl_ematch_parse_attr()
437 rtnl_ematch_free(ematch); in rtnl_ematch_parse_attr()
442 rtnl_ematch_set_ops(ematch, ops); in rtnl_ematch_parse_attr()
445 (err = ops->eo_parse(ematch, data, len)) < 0) { in rtnl_ematch_parse_attr()
446 rtnl_ematch_free(ematch); in rtnl_ematch_parse_attr()
451 NL_DBG(3, "index[%d] = %p\n", nmatches, ematch); in rtnl_ematch_parse_attr()
452 index[nmatches++] = ematch; in rtnl_ematch_parse_attr()