Пример #1
0
static int nft_rule_expr_match_export(char *buf, size_t size,
				      struct nft_rule_expr *e, int type)
{
	struct nft_expr_match *mt = nft_expr_data(e);
	NFT_BUF_INIT(b, buf, size);

	if (e->flags & (1 << NFT_EXPR_MT_NAME))
		nft_buf_str(&b, type, mt->name, NAME);

	return nft_buf_done(&b);
}
Пример #2
0
static int nft_rule_expr_queue_export(char *buf, size_t size,
				      struct nft_rule_expr *e, int type)
{
	struct nft_expr_queue *queue = nft_expr_data(e);
	NFT_BUF_INIT(b, buf, size);

	if (e->flags & (1 << NFT_EXPR_QUEUE_NUM))
		nft_buf_u32(&b, type, queue->queuenum, NUM);
	if (e->flags & (1 << NFT_EXPR_QUEUE_TOTAL))
		nft_buf_u32(&b, type, queue->queues_total, TOTAL);
	if (e->flags & (1 << NFT_EXPR_QUEUE_FLAGS))
		nft_buf_u32(&b, type, queue->flags, FLAGS);

	return nft_buf_done(&b);
}
Пример #3
0
static int
nft_expr_ct_export(char *buf, size_t size, struct nft_rule_expr *e, int type)
{
	struct nft_expr_ct *ct = nft_expr_data(e);
	NFT_BUF_INIT(b, buf, size);

	if (e->flags & (1 << NFT_EXPR_CT_SREG))
		nft_buf_u32(&b, type, ct->sreg, SREG);
	if (e->flags & (1 << NFT_EXPR_CT_DREG))
		nft_buf_u32(&b, type, ct->dreg, DREG);
	if (e->flags & (1 << NFT_EXPR_CT_KEY))
		nft_buf_str(&b, type, ctkey2str(ct->key), KEY);
	if (e->flags & (1 << NFT_EXPR_CT_DIR))
		nft_buf_str(&b, type, ctdir2str(ct->dir), DIR);

	return nft_buf_done(&b);
}
Пример #4
0
static int nft_rule_expr_bitwise_export(char *buf, size_t size,
					struct nft_rule_expr *e, int type)
{
	struct nft_expr_bitwise *bitwise = nft_expr_data(e);
	NFT_BUF_INIT(b, buf, size);

	if (e->flags & (1 << NFT_EXPR_BITWISE_SREG))
		nft_buf_u32(&b, type, bitwise->sreg, SREG);
	if (e->flags & (1 << NFT_EXPR_BITWISE_DREG))
		nft_buf_u32(&b, type, bitwise->dreg, DREG);
	if (e->flags & (1 << NFT_EXPR_BITWISE_LEN))
		nft_buf_u32(&b, type, bitwise->len, LEN);
	if (e->flags & (1 << NFT_EXPR_BITWISE_MASK))
		nft_buf_reg(&b, type, &bitwise->mask, DATA_VALUE, MASK);
	if (e->flags & (1 << NFT_EXPR_BITWISE_XOR))
		nft_buf_reg(&b, type, &bitwise->xor, DATA_VALUE, XOR);

	return nft_buf_done(&b);
}
Пример #5
0
static int nft_rule_expr_byteorder_export(char *buf, size_t size,
					  struct nft_rule_expr *e, int type)
{
	struct nft_expr_byteorder *byteorder = nft_expr_data(e);
	NFT_BUF_INIT(b, buf, size);

	if (e->flags & (1 << NFT_EXPR_BYTEORDER_SREG))
		nft_buf_u32(&b, type, byteorder->sreg, SREG);
	if (e->flags & (1 << NFT_EXPR_BYTEORDER_DREG))
		nft_buf_u32(&b, type, byteorder->dreg, DREG);
	if (e->flags & (1 << NFT_EXPR_BYTEORDER_OP))
		nft_buf_str(&b, type, bo2str(byteorder->op), OP);
	if (e->flags & (1 << NFT_EXPR_BYTEORDER_LEN))
		nft_buf_u32(&b, type, byteorder->len, LEN);
	if (e->flags & (1 << NFT_EXPR_BYTEORDER_SIZE))
		nft_buf_u32(&b, type, byteorder->size, SIZE);

	return nft_buf_done(&b);
}
Пример #6
0
static int nft_rule_expr_log_export(char *buf, size_t size,
				    struct nft_rule_expr *e, int type)
{
	struct nft_expr_log *log = nft_expr_data(e);
	NFT_BUF_INIT(b, buf, size);

	if (e->flags & (1 << NFT_EXPR_LOG_PREFIX))
		nft_buf_str(&b, type, log->prefix, PREFIX);
	if (e->flags & (1 << NFT_EXPR_LOG_GROUP))
		nft_buf_u32(&b, type, log->group, GROUP);
	if (e->flags & (1 << NFT_EXPR_LOG_SNAPLEN))
		nft_buf_u32(&b, type, log->snaplen, SNAPLEN);
	if (e->flags & (1 << NFT_EXPR_LOG_QTHRESHOLD))
		nft_buf_u32(&b, type, log->qthreshold, QTHRESH);
	if (e->flags & (1 << NFT_EXPR_LOG_LEVEL))
		nft_buf_u32(&b, type, log->level, LEVEL);
	if (e->flags & (1 << NFT_EXPR_LOG_FLAGS))
		nft_buf_u32(&b, type, log->level, FLAGS);

	return nft_buf_done(&b);
}
Пример #7
0
static int nft_rule_expr_nat_export(char *buf, size_t size,
				    struct nft_rule_expr *e, int type)
{
	struct nft_expr_nat *nat = nft_expr_data(e);
	NFT_BUF_INIT(b, buf, size);

	if (e->flags & (1 << NFT_EXPR_NAT_TYPE))
		nft_buf_str(&b, type, nat2str(nat->type), NAT_TYPE);
	if (e->flags & (1 << NFT_EXPR_NAT_FAMILY))
		nft_buf_str(&b, type, nft_family2str(nat->family), FAMILY);
	if (e->flags & (1 << NFT_EXPR_NAT_REG_ADDR_MIN))
		nft_buf_u32(&b, type, nat->sreg_addr_min, SREG_ADDR_MIN);
	if (e->flags & (1 << NFT_EXPR_NAT_REG_ADDR_MAX))
		nft_buf_u32(&b, type, nat->sreg_addr_max, SREG_ADDR_MAX);
	if (e->flags & (1 << NFT_EXPR_NAT_REG_PROTO_MIN))
		nft_buf_u32(&b, type, nat->sreg_proto_min, SREG_PROTO_MIN);
	if (e->flags & (1 << NFT_EXPR_NAT_REG_PROTO_MAX))
		nft_buf_u32(&b, type, nat->sreg_proto_max, SREG_PROTO_MAX);
	if (e->flags & (1 << NFT_EXPR_NAT_FLAGS))
		nft_buf_u32(&b, type, nat->flags, FLAGS);

	return nft_buf_done(&b);
}