-
Notifications
You must be signed in to change notification settings - Fork 1
/
bitwise.c
30 lines (23 loc) · 907 Bytes
/
bitwise.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
static int
nft_rule_expr_bitwise_snprintf_json(char *buf, size_t size,
struct nft_expr_bitwise *bitwise)
{
int len = size, offset = 0, ret;
ret = snprintf(buf, len, "\"sreg\" : %u,"
"\"dreg\" : %u,",
bitwise->sreg, bitwise->dreg);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
ret = snprintf(buf+offset, len, "\"mask\" : \"");
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->mask,
NFT_RULE_O_XML, 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
ret = snprintf(buf+offset, len, "\",\"xor\" : \"");
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->xor,
NFT_RULE_O_XML, 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
ret = snprintf(buf+offset, len, "\"");
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
return offset;
}