static int nftnl_rule_exp_target_export(char *buf, size_t size, const struct nftnl_expr *e, int type) { struct nftnl_expr_target *target = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); if (e->flags & (1 << NFTNL_EXPR_TG_NAME)) nftnl_buf_str(&b, type, target->name, NAME); return nftnl_buf_done(&b); }
static int nftnl_expr_match_export(char *buf, size_t size, struct nftnl_expr *e, int type) { struct nftnl_expr_match *mt = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); if (e->flags & (1 << NFTNL_EXPR_MT_NAME)) nftnl_buf_str(&b, type, mt->name, NAME); return nftnl_buf_done(&b); }
static int nftnl_expr_lookup_export(char *buf, size_t size, struct nftnl_expr *e, int type) { struct nftnl_expr_lookup *l = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); if (e->flags & (1 << NFTNL_EXPR_LOOKUP_SET)) nftnl_buf_str(&b, type, l->set_name, SET); if (e->flags & (1 << NFTNL_EXPR_LOOKUP_SREG)) nftnl_buf_u32(&b, type, l->sreg, SREG); if (e->flags & (1 << NFTNL_EXPR_LOOKUP_DREG)) nftnl_buf_u32(&b, type, l->dreg, DREG); return nftnl_buf_done(&b); }
static int nftnl_expr_payload_export(char *buf, size_t size, uint32_t flags, struct nftnl_expr *e, int type) { struct nftnl_expr_payload *payload = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); if (e->flags & (1 << NFTNL_EXPR_PAYLOAD_DREG)) nftnl_buf_u32(&b, type, payload->dreg, DREG); if (e->flags & (1 << NFTNL_EXPR_PAYLOAD_OFFSET)) nftnl_buf_u32(&b, type, payload->offset, OFFSET); if (e->flags & (1 << NFTNL_EXPR_PAYLOAD_LEN)) nftnl_buf_u32(&b, type, payload->len, LEN); if (e->flags & (1 << NFTNL_EXPR_PAYLOAD_BASE)) nftnl_buf_str(&b, type, base2str(payload->base), BASE); return nftnl_buf_done(&b); }
static int nftnl_expr_log_export(char *buf, size_t size, struct nftnl_expr *e, int type) { struct nftnl_expr_log *log = nftnl_expr_data(e); NFTNL_BUF_INIT(b, buf, size); if (e->flags & (1 << NFTNL_EXPR_LOG_PREFIX)) nftnl_buf_str(&b, type, log->prefix, PREFIX); if (e->flags & (1 << NFTNL_EXPR_LOG_GROUP)) nftnl_buf_u32(&b, type, log->group, GROUP); if (e->flags & (1 << NFTNL_EXPR_LOG_SNAPLEN)) nftnl_buf_u32(&b, type, log->snaplen, SNAPLEN); if (e->flags & (1 << NFTNL_EXPR_LOG_QTHRESHOLD)) nftnl_buf_u32(&b, type, log->qthreshold, QTHRESH); if (e->flags & (1 << NFTNL_EXPR_LOG_LEVEL)) nftnl_buf_u32(&b, type, log->level, LEVEL); if (e->flags & (1 << NFTNL_EXPR_LOG_FLAGS)) nftnl_buf_u32(&b, type, log->level, FLAGS); return nftnl_buf_done(&b); }