1 /*
2 * (C) 2005-2011 by Pablo Neira Ayuso <pablo@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
set_exp_attr_master(struct nf_expect * exp,const void * value)12 static void set_exp_attr_master(struct nf_expect *exp, const void *value)
13 {
14 exp->master = *((struct nfct_tuple_head *) value);
15 }
16
set_exp_attr_expected(struct nf_expect * exp,const void * value)17 static void set_exp_attr_expected(struct nf_expect *exp, const void *value)
18 {
19 exp->expected = *((struct nfct_tuple_head *) value);
20 }
21
set_exp_attr_mask(struct nf_expect * exp,const void * value)22 static void set_exp_attr_mask(struct nf_expect *exp, const void *value)
23 {
24 exp->mask = *((struct nfct_tuple_head *) value);
25 }
26
set_exp_attr_timeout(struct nf_expect * exp,const void * value)27 static void set_exp_attr_timeout(struct nf_expect *exp, const void *value)
28 {
29 exp->timeout = *((uint32_t *) value);
30 }
31
set_exp_attr_zone(struct nf_expect * exp,const void * value)32 static void set_exp_attr_zone(struct nf_expect *exp, const void *value)
33 {
34 exp->zone = *((uint16_t *) value);
35 }
36
set_exp_attr_flags(struct nf_expect * exp,const void * value)37 static void set_exp_attr_flags(struct nf_expect *exp, const void *value)
38 {
39 exp->flags = *((uint32_t *) value);
40 }
41
set_exp_attr_class(struct nf_expect * exp,const void * value)42 static void set_exp_attr_class(struct nf_expect *exp, const void *value)
43 {
44 exp->class = *((uint32_t *) value);
45 }
46
set_exp_attr_helper_name(struct nf_expect * exp,const void * value)47 static void set_exp_attr_helper_name(struct nf_expect *exp, const void *value)
48 {
49 strncpy(exp->helper_name, value, NFCT_HELPER_NAME_MAX);
50 exp->helper_name[NFCT_HELPER_NAME_MAX-1] = '\0';
51 }
52
set_exp_attr_nat_dir(struct nf_expect * exp,const void * value)53 static void set_exp_attr_nat_dir(struct nf_expect *exp, const void *value)
54 {
55 exp->nat_dir = *((uint32_t *) value);
56 }
57
set_exp_attr_nat_tuple(struct nf_expect * exp,const void * value)58 static void set_exp_attr_nat_tuple(struct nf_expect *exp, const void *value)
59 {
60 exp->nat = *((struct nfct_tuple_head *) value);
61 }
62
set_exp_attr_expectfn(struct nf_expect * exp,const void * value)63 static void set_exp_attr_expectfn(struct nf_expect *exp, const void *value)
64 {
65 strncpy(exp->expectfn, value, __NFCT_EXPECTFN_MAX);
66 exp->expectfn[__NFCT_EXPECTFN_MAX-1] = '\0';
67 }
68
69 const set_exp_attr set_exp_attr_array[ATTR_EXP_MAX] = {
70 [ATTR_EXP_MASTER] = set_exp_attr_master,
71 [ATTR_EXP_EXPECTED] = set_exp_attr_expected,
72 [ATTR_EXP_MASK] = set_exp_attr_mask,
73 [ATTR_EXP_TIMEOUT] = set_exp_attr_timeout,
74 [ATTR_EXP_ZONE] = set_exp_attr_zone,
75 [ATTR_EXP_FLAGS] = set_exp_attr_flags,
76 [ATTR_EXP_HELPER_NAME] = set_exp_attr_helper_name,
77 [ATTR_EXP_CLASS] = set_exp_attr_class,
78 [ATTR_EXP_NAT_TUPLE] = set_exp_attr_nat_tuple,
79 [ATTR_EXP_NAT_DIR] = set_exp_attr_nat_dir,
80 [ATTR_EXP_FN] = set_exp_attr_expectfn,
81 };
82