summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-10-07 15:06:00 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-10-07 15:06:00 +0200
commit34a4c4da11dda9867ca6d11a184d9f17933f6b72 (patch)
tree63f8b677c72be2394d00b8f2fd828dcb275a4096
parent41dbf72cd7784eaa4525ed70c643d7f4a280a81c (diff)
expect: add cthelper_get_port_src and cthelper_get_port_port
-rw-r--r--expect.c24
-rw-r--r--include/helper.h4
2 files changed, 28 insertions, 0 deletions
diff --git a/expect.c b/expect.c
index 072e913..3d59f9e 100644
--- a/expect.c
+++ b/expect.c
@@ -241,6 +241,30 @@ int cthelper_cmp_addr_dst(struct nf_conntrack *ct, int dir,
return memcmp(addr, &tmp, sizeof(union nfct_attr_grp_addr)) == 0;
}
+void cthelper_get_port_src(struct nf_conntrack *ct, int dir, uint16_t *port)
+{
+ switch (dir) {
+ case MYCT_DIR_ORIG:
+ *port = nfct_get_attr_u16(ct, ATTR_PORT_SRC);
+ break;
+ case MYCT_DIR_REPL:
+ *port = nfct_get_attr_u16(ct, ATTR_REPL_PORT_SRC);
+ break;
+ }
+}
+
+void cthelper_get_port_dst(struct nf_conntrack *ct, int dir, uint16_t *port)
+{
+ switch (dir) {
+ case MYCT_DIR_ORIG:
+ *port = nfct_get_attr_u16(ct, ATTR_PORT_DST);
+ break;
+ case MYCT_DIR_REPL:
+ *port = nfct_get_attr_u16(ct, ATTR_REPL_PORT_DST);
+ break;
+ }
+}
+
int cthelper_cmp_exp_addr_dst(struct nf_expect *exp,
union nfct_attr_grp_addr *addr)
{
diff --git a/include/helper.h b/include/helper.h
index ba3f773..4a2c62a 100644
--- a/include/helper.h
+++ b/include/helper.h
@@ -58,6 +58,10 @@ int cthelper_iterate_exp(struct nf_conntrack *ct, int (*cb)(struct nf_expect *ex
extern void cthelper_get_addr_src(struct nf_conntrack *ct, int dir, union nfct_attr_grp_addr *addr);
extern void cthelper_get_addr_dst(struct nf_conntrack *ct, int dir, union nfct_attr_grp_addr *addr);
+
+void cthelper_get_port_src(struct nf_conntrack *ct, int dir, uint16_t *port);
+void cthelper_get_port_dst(struct nf_conntrack *ct, int dir, uint16_t *port);
+
int cthelper_cmp_addr_src(struct nf_conntrack *ct, int dir, union nfct_attr_grp_addr *addr);
int cthelper_cmp_addr_dst(struct nf_conntrack *ct, int dir, union nfct_attr_grp_addr *addr);
int cthelper_cmp_exp_addr_dst(struct nf_expect *exp, union nfct_attr_grp_addr *addr);