コード例 #1
0
ファイル: ct.c プロジェクト: 174high/libnl-iw-android
static int ct_parse_proto(struct nfnl_ct *ct, int repl, struct nlattr *attr)
{
	struct nlattr *tb[CTA_PROTO_MAX+1];
	int err;

	err = nla_parse_nested(tb, CTA_PROTO_MAX, attr, ct_proto_policy);
	if (err < 0)
		return err;

	if (!repl && tb[CTA_PROTO_NUM])
		nfnl_ct_set_proto(ct, nla_get_u8(tb[CTA_PROTO_NUM]));
	if (tb[CTA_PROTO_SRC_PORT])
		nfnl_ct_set_src_port(ct, repl,
			ntohs(nla_get_u16(tb[CTA_PROTO_SRC_PORT])));
	if (tb[CTA_PROTO_DST_PORT])
		nfnl_ct_set_dst_port(ct, repl,
			ntohs(nla_get_u16(tb[CTA_PROTO_DST_PORT])));
	if (tb[CTA_PROTO_ICMP_ID])
		nfnl_ct_set_icmp_id(ct, repl,
			ntohs(nla_get_u16(tb[CTA_PROTO_ICMP_ID])));
	if (tb[CTA_PROTO_ICMP_TYPE])
		nfnl_ct_set_icmp_type(ct, repl,
				nla_get_u8(tb[CTA_PROTO_ICMP_TYPE]));
	if (tb[CTA_PROTO_ICMP_CODE])
		nfnl_ct_set_icmp_code(ct, repl,
				nla_get_u8(tb[CTA_PROTO_ICMP_CODE]));

	return 0;
}
コード例 #2
0
ファイル: ct.c プロジェクト: Distrotech/libnl
void nl_cli_ct_parse_dst_port(struct nfnl_ct *ct, int reply, char *arg)
{
	uint32_t port = nl_cli_parse_u32(arg);
	nfnl_ct_set_dst_port(ct, reply, port);
}