diff options
| author | Alexander Wirt <formorer@debian.org> | 2014-09-19 10:15:14 +0200 |
|---|---|---|
| committer | Alexander Wirt <formorer@debian.org> | 2014-09-19 10:15:14 +0200 |
| commit | c31a7efc19b438188e96cab1ca34116a51f3e914 (patch) | |
| tree | 38101c9c0d76567fe99608fe7c7c39e8070bd6e4 /src/build.c | |
| parent | 45669cfafbb57da51e1c0beeec392c380c6cd2cf (diff) | |
| parent | 9f760e5d3f6b44ecf5bb7144517e022fd987fa76 (diff) | |
| download | conntrack-tools-c31a7efc19b438188e96cab1ca34116a51f3e914.tar.gz conntrack-tools-c31a7efc19b438188e96cab1ca34116a51f3e914.zip | |
Merge tag 'upstream/1.4.2'
Upstream version 1.4.2
Diffstat (limited to 'src/build.c')
| -rw-r--r-- | src/build.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/build.c b/src/build.c index e15eb4f..5799b51 100644 --- a/src/build.c +++ b/src/build.c @@ -158,6 +158,42 @@ static void build_l4proto_udp(const struct nf_conntrack *ct, struct nethdr *n) sizeof(struct nfct_attr_grp_port)); } +static void ct_build_clabel(const struct nf_conntrack *ct, struct nethdr *n) +{ + const struct nfct_bitmask *b; + uint32_t *words; + unsigned int wordcount, i, maxbit; + + if (!nfct_attr_is_set(ct, ATTR_CONNLABELS)) + return; + + b = nfct_get_attr(ct, ATTR_CONNLABELS); + + maxbit = nfct_bitmask_maxbit(b); + for (i=0; i <= maxbit; i++) { + if (nfct_bitmask_test_bit(b, i)) + break; + } + + if (i > maxbit) + return; + + wordcount = (nfct_bitmask_maxbit(b) / 32) + 1; + words = put_header(n, NTA_LABELS, wordcount * sizeof(*words)); + + for (i=0; i < wordcount; i++) { + int bit = 31; + uint32_t tmp = 0; + + do { + if (nfct_bitmask_test_bit(b, (32 * i) + bit)) + tmp |= (1 << bit); + } while (--bit >= 0); + + words[i] = htonl(tmp); + } +} + #ifndef IPPROTO_DCCP #define IPPROTO_DCCP 33 #endif @@ -233,6 +269,9 @@ void ct2msg(const struct nf_conntrack *ct, struct nethdr *n) if (nfct_attr_is_set(ct, ATTR_HELPER_NAME)) ct_build_str(ct, ATTR_HELPER_NAME, n, NTA_HELPER_NAME); + + if (nfct_attr_is_set(ct, ATTR_CONNLABELS)) + ct_build_clabel(ct, n); } static void |
