summaryrefslogtreecommitdiff
path: root/include/libct_proto.h
blob: b358e1a0d8e2fdf5e29e24094a985ac24b5ca5e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _LIBCT_PROTO_H
#define _LIBCT_PROTO_H

/* FIXME: Rename this file pablo... */

#include "linux_list.h"
#include <getopt.h>
#include <libnfnetlink_conntrack/libnfnetlink_conntrack.h>

#define LIBCT_VERSION	"0.1.0"

/* FIXME: These should be independent from kernel space */
#define IPS_ASSURED (1 << 2)
#define IPS_SEEN_REPLY (1 << 1)
#define IPS_SRC_NAT_DONE (1 << 7)
#define IPS_DST_NAT_DONE (1 << 8)
#define IPS_CONFIRMED (1 << 3)

struct cta_proto;

struct ctproto_handler {
	struct list_head 	head;

	char 			*name;
	u_int16_t 		protonum;
	char			*version;

	enum ctattr_protoinfo	protoinfo_attr;
	
	int (*parse_opts)(char c, char *argv[], 
		     struct ctnl_tuple *orig,
		     struct ctnl_tuple *reply,
		     struct ctnl_tuple *mask,
		     union ctnl_protoinfo *proto,
		     unsigned int *flags);
	void (*parse_proto)(struct nfattr *cda[], struct ctnl_tuple *tuple);
	void (*parse_protoinfo)(struct nfattr *cda[], 
				struct ctnl_conntrack *ct);
	void (*print_proto)(struct ctnl_tuple *t);
	void (*print_protoinfo)(union ctnl_protoinfo *protoinfo);

	int (*final_check)(unsigned int flags,
			   struct ctnl_tuple *orig,
			   struct ctnl_tuple *reply);

	void (*help)();

	struct option 		*opts;

	unsigned int		option_offset;
};

extern void register_proto(struct ctproto_handler *h);
extern void unregister_proto(struct ctproto_handler *h);

extern struct ctproto_handler *findproto(char *name);

#define NIPQUAD(addr) \
	((unsigned char *)&addr)[0], \
	((unsigned char *)&addr)[1], \
	((unsigned char *)&addr)[2], \
	((unsigned char *)&addr)[3]

#endif