| 1 |
/* |
| 2 |
* (C) 2005-2012 by Pablo Neira Ayuso <[email protected]> |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify it |
| 5 |
* under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* This code has been sponsored by Vyatta Inc. <http://www.vyatta.com> |
| 10 |
*/ |
| 11 |
|
| 12 |
#include "internal/internal.h" |
| 13 |
#include <libmnl/libmnl.h> |
| 14 |
|
| 15 |
int |
| 16 |
nfexp_nlmsg_build(struct nlmsghdr *nlh, const struct nf_expect *exp) |
| 17 |
{ |
| 18 |
if (test_bit(ATTR_EXP_EXPECTED, exp->set)) |
| 19 |
nfct_build_tuple(nlh, &exp->expected.orig, CTA_EXPECT_TUPLE); |
| 20 |
|
| 21 |
if (test_bit(ATTR_EXP_MASTER, exp->set)) |
| 22 |
nfct_build_tuple(nlh, &exp->master.orig, CTA_EXPECT_MASTER); |
| 23 |
|
| 24 |
if (test_bit(ATTR_EXP_MASK, exp->set)) |
| 25 |
nfct_build_tuple(nlh, &exp->mask.orig, CTA_EXPECT_MASK); |
| 26 |
|
| 27 |
if (test_bit(ATTR_EXP_TIMEOUT, exp->set)) |
| 28 |
mnl_attr_put_u32(nlh, CTA_EXPECT_TIMEOUT, htonl(exp->timeout)); |
| 29 |
|
| 30 |
if (test_bit(ATTR_EXP_FLAGS, exp->set)) |
| 31 |
mnl_attr_put_u32(nlh, CTA_EXPECT_FLAGS, htonl(exp->flags)); |
| 32 |
|
| 33 |
if (test_bit(ATTR_EXP_ZONE, exp->set)) |
| 34 |
mnl_attr_put_u16(nlh, CTA_EXPECT_ZONE, htons(exp->zone)); |
| 35 |
|
| 36 |
if (test_bit(ATTR_EXP_HELPER_NAME, exp->set)) |
| 37 |
mnl_attr_put_strz(nlh, CTA_EXPECT_HELP_NAME, exp->helper_name); |
| 38 |
|
| 39 |
return 0; |
| 40 |
} |