summaryrefslogtreecommitdiff
path: root/src/build.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/build.c')
-rw-r--r--src/build.c39
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