Home | History | Annotate | Download | only in conntrack
      1 /*
      2  * (C) 2005-2012 by Pablo Neira Ayuso <pablo (at) netfilter.org>
      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 
     10 #include "internal/internal.h"
     11 
     12 static void
     13 set_filter_dump_attr_mark(struct nfct_filter_dump *filter_dump,
     14 			  const void *value)
     15 {
     16 	const struct nfct_filter_dump_mark *this = value;
     17 
     18 	filter_dump->mark.val = this->val;
     19 	filter_dump->mark.mask = this->mask;
     20 }
     21 
     22 static void
     23 set_filter_dump_attr_family(struct nfct_filter_dump *filter_dump,
     24 			    const void *value)
     25 {
     26 	filter_dump->l3num = *((uint8_t *)value);
     27 }
     28 
     29 const set_filter_dump_attr set_filter_dump_attr_array[NFCT_FILTER_DUMP_MAX] = {
     30 	[NFCT_FILTER_DUMP_MARK]		= set_filter_dump_attr_mark,
     31 	[NFCT_FILTER_DUMP_L3NUM]	= set_filter_dump_attr_family,
     32 };
     33 
     34 void __build_filter_dump(struct nfnlhdr *req, size_t size,
     35 			 const struct nfct_filter_dump *filter_dump)
     36 {
     37 	if (filter_dump->set & (1 << NFCT_FILTER_DUMP_MARK)) {
     38 		nfnl_addattr32(&req->nlh, size, CTA_MARK,
     39 				htonl(filter_dump->mark.val));
     40 		nfnl_addattr32(&req->nlh, size, CTA_MARK_MASK,
     41 				htonl(filter_dump->mark.mask));
     42 	}
     43 	if (filter_dump->set & (1 << NFCT_FILTER_DUMP_L3NUM)) {
     44 		struct nfgenmsg *nfg = NLMSG_DATA(&req->nlh);
     45 		nfg->nfgen_family = filter_dump->l3num;
     46 	}
     47 }
     48