From 04cbb9c53929173ff0ae261c0bb22b5928ffc23b Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 7 Jun 2013 19:53:46 +0200 Subject: expect: add new cthelper_* functions for SIP helper This patch adds new functions to support the SIP helper in user-space. Signed-off-by: Pablo Neira Ayuso --- expect.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'expect.c') diff --git a/expect.c b/expect.c index fc46a21..072e913 100644 --- a/expect.c +++ b/expect.c @@ -171,6 +171,11 @@ int cthelper_del_expect(struct nf_expect *exp) return 0; } +int cthelper_upd_expect(struct nf_expect *exp) +{ + return 0; +} + int cthelper_upd_ct(struct nf_conntrack *ct) { return 0; @@ -203,3 +208,62 @@ cthelper_get_addr_dst(struct nf_conntrack *ct, int dir, break; } } + +int cthelper_cmp_addr_src(struct nf_conntrack *ct, int dir, + union nfct_attr_grp_addr *addr) +{ + union nfct_attr_grp_addr tmp; + + switch (dir) { + case MYCT_DIR_ORIG: + nfct_get_attr_grp(ct, ATTR_GRP_ORIG_ADDR_SRC, &tmp); + break; + case MYCT_DIR_REPL: + nfct_get_attr_grp(ct, ATTR_GRP_REPL_ADDR_SRC, &tmp); + break; + } + return memcmp(addr, &tmp, sizeof(union nfct_attr_grp_addr)) == 0; +} + +int cthelper_cmp_addr_dst(struct nf_conntrack *ct, int dir, + union nfct_attr_grp_addr *addr) +{ + union nfct_attr_grp_addr tmp; + + switch (dir) { + case MYCT_DIR_ORIG: + nfct_get_attr_grp(ct, ATTR_GRP_ORIG_ADDR_DST, &tmp); + break; + case MYCT_DIR_REPL: + nfct_get_attr_grp(ct, ATTR_GRP_REPL_ADDR_DST, &tmp); + break; + } + return memcmp(addr, &tmp, sizeof(union nfct_attr_grp_addr)) == 0; +} + +int cthelper_cmp_exp_addr_dst(struct nf_expect *exp, + union nfct_attr_grp_addr *addr) +{ + const struct nf_conntrack *tuple = nfexp_get_attr(exp, ATTR_EXP_EXPECTED); + union nfct_attr_grp_addr tmp; + + cthelper_get_addr_dst((struct nf_conntrack *)tuple, MYCT_DIR_ORIG, &tmp); + + return memcmp(addr, &tmp, sizeof(union nfct_attr_grp_addr)) == 0; +} + +int cthelper_iterate_exp(struct nf_conntrack *ct, + int (*cb)(struct nf_expect *exp, void *data), + void *data_cb) +{ + return 0; +} + +struct nf_expect *cthelper_find_expect(union nfct_attr_grp_addr *saddr, + union nfct_attr_grp_addr *daddr, + uint16_t sport, uint16_t dport, + uint8_t l3num, uint8_t l4num, + uint16_t zone) +{ + return NULL; +} -- cgit v1.2.3