File: re_natbd.h

package info (click to toggle)
libre 2.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,556 kB
  • sloc: ansic: 41,621; makefile: 143; sh: 1
file content (128 lines) | stat: -rw-r--r-- 3,331 bytes parent folder | download | duplicates (4)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
 * @file re_natbd.h  NAT Behavior Discovery Using STUN (RFC 5780)
 *
 * Copyright (C) 2010 Creytiv.com
 */


/** NAT Mapping/Filtering types - See RFC 4787 for definitions */
enum nat_type {
	NAT_TYPE_UNKNOWN       = 0,  /**< Unknown type               */
	NAT_TYPE_ENDP_INDEP    = 1,  /**< Endpoint-Independent       */
	NAT_TYPE_ADDR_DEP      = 2,  /**< Address-Dependent          */
	NAT_TYPE_ADDR_PORT_DEP = 3   /**< Address and Port-Dependent */
};


/* Strings */
const char *nat_type_str(enum nat_type type);


/*
 * Diagnosing NAT Hairpinning
 */
struct nat_hairpinning;
/**
 * Defines the NAT Hairpinning handler
 */
typedef void (nat_hairpinning_h)(int err, bool supported, void *arg);

int nat_hairpinning_alloc(struct nat_hairpinning **nhp,
			  const struct sa *srv, int proto,
			  const struct stun_conf *conf,
			  nat_hairpinning_h *hph, void *arg);
int nat_hairpinning_start(struct nat_hairpinning *nh);


/*
 * Determining NAT Mapping Behavior
 */
struct nat_mapping;

/**
 * Defines the NAT Mapping handler
 *
 * @param err  Errorcode
 * @param type NAT Mapping type
 * @param arg  Handler argument
 */
typedef void (nat_mapping_h)(int err, enum nat_type map, void *arg);

int nat_mapping_alloc(struct nat_mapping **nmp, const struct sa *laddr,
		      const struct sa *srv, int proto,
		      const struct stun_conf *conf,
		      nat_mapping_h *mh, void *arg);
int nat_mapping_start(struct nat_mapping *nm);


/*
 * Determining NAT Filtering Behavior
 */
struct nat_filtering;

/**
 * Defines the NAT Filtering handler
 *
 * @param err  Errorcode
 * @param type NAT Filtering type
 * @param arg  Handler argument
 */
typedef void (nat_filtering_h)(int err, enum nat_type filt, void *arg);

int nat_filtering_alloc(struct nat_filtering **nfp, const struct sa *srv,
			const struct stun_conf *conf,
			nat_filtering_h *fh, void *arg);
int nat_filtering_start(struct nat_filtering *nf);


/*
 * Binding Lifetime Discovery
 */

struct nat_lifetime;

/** Defines the NAT lifetime interval */
struct nat_lifetime_interval {
	uint32_t min;  /**< Minimum lifetime interval in [seconds] */
	uint32_t cur;  /**< Current lifetime interval in [seconds] */
	uint32_t max;  /**< Maximum lifetime interval in [seconds] */
};


/**
 * Defines the NAT Lifetime handler
 *
 * @param err Errorcode
 * @param i   NAT Lifetime intervals
 * @param arg Handler argument
 */
typedef void (nat_lifetime_h)(int err, const struct nat_lifetime_interval *i,
			      void *arg);

int  nat_lifetime_alloc(struct nat_lifetime **nlp, const struct sa *srv,
			uint32_t interval, const struct stun_conf *conf,
			nat_lifetime_h *lh, void *arg);
int  nat_lifetime_start(struct nat_lifetime *nl);


/*
 * Detecting Generic ALGs
 */
struct nat_genalg;

/**
 * Defines the NAT Generic ALG handler
 *
 * @param err     Errorcode
 * @param errcode STUN Error code (if set)
 * @param status  Generic ALG status (-1=not detected, 1=detected)
 * @param map     Mapped network address
 * @param arg     Handler argument
 */
typedef void (nat_genalg_h)(int err, uint16_t scode, const char *reason,
			    int status, const struct sa *map, void *arg);

int nat_genalg_alloc(struct nat_genalg **ngp, const struct sa *srv, int proto,
		     const struct stun_conf *conf,
		     nat_genalg_h *gh, void *arg);
int nat_genalg_start(struct nat_genalg *ng);