Mercurial > pidgin
comparison libpurple/nat-pmp.h @ 15898:9cfe41743c65
More complete namespacing of nat-pmp
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 25 Mar 2007 00:41:31 +0000 |
parents | 9b875f0ecb86 |
children | 2cf21661f828 |
comparison
equal
deleted
inserted
replaced
15897:4e44a9eaceec | 15898:9cfe41743c65 |
---|---|
1 /** | 1 /** |
2 * @file nat-pmp.h NAT-PMP Implementation | 2 * @file nat-pmp.h NAT-PMP Implementation |
3 * @ingroup core | 3 * @ingroup core |
4 * | 4 * |
5 * purple | 5 * purple |
6 * | 6 * |
7 * Purple is the legal property of its developers, whose names are too numerous | 7 * Purple is the legal property of its developers, whose names are too numerous |
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | 27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
28 * OF SUCH DAMAGE. | 28 * OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef _PMPMAPPER_H | 31 #ifndef _PURPLE_NAT_PMP_H |
32 #define _PMPMAPPER_H | 32 #define _PURPLE_NAT_PMP_H |
33 | 33 |
34 #include <stdio.h> | 34 #include <stdint.h> |
35 #include <stdlib.h> | |
36 #include <errno.h> | |
37 #include <assert.h> | |
38 #include <sys/socket.h> | |
39 #include <sys/sysctl.h> | |
40 #include <sys/types.h> | |
41 #include <net/if.h> | |
42 #include <net/route.h> | |
43 | 35 |
44 #define PURPLE_PMP_LIFETIME 3600 // 3600 seconds | 36 #define PURPLE_PMP_LIFETIME 3600 /* seconds */ |
45 | 37 |
46 /* | 38 /* |
47 * uint8_t: version, opcodes | 39 * uint8_t: version, opcodes |
48 * uint16_t: resultcode | 40 * uint16_t: resultcode |
49 * unint32_t: epoch (seconds since mappings reset) | 41 * unint32_t: epoch (seconds since mappings reset) |
55 } PurplePmpType; | 47 } PurplePmpType; |
56 | 48 |
57 typedef struct { | 49 typedef struct { |
58 uint8_t version; | 50 uint8_t version; |
59 uint8_t opcode; | 51 uint8_t opcode; |
60 } pmp_ip_request_t; | 52 } PurplePmpIpRequest; |
61 | 53 |
62 typedef struct { | 54 typedef struct { |
63 uint8_t version; | 55 uint8_t version; |
64 uint8_t opcode; // 128 + n | 56 uint8_t opcode; // 128 + n |
65 uint16_t resultcode; | 57 uint16_t resultcode; |
66 uint32_t epoch; | 58 uint32_t epoch; |
67 uint32_t address; | 59 uint32_t address; |
68 } pmp_ip_response_t; | 60 } PurplePmpIpResponse; |
69 | 61 |
70 typedef struct { | 62 typedef struct { |
71 uint8_t version; | 63 uint8_t version; |
72 uint8_t opcode; | 64 uint8_t opcode; |
73 char reserved[2]; | 65 char reserved[2]; |
74 uint16_t privateport; | 66 uint16_t privateport; |
75 uint16_t publicport; | 67 uint16_t publicport; |
76 uint32_t lifetime; | 68 uint32_t lifetime; |
77 } pmp_map_request_t; | 69 } PurplePmpMapRequest; |
78 | 70 |
79 typedef struct { | 71 typedef struct { |
80 uint8_t version; | 72 uint8_t version; |
81 uint8_t opcode; | 73 uint8_t opcode; |
82 uint16_t resultcode; | 74 uint16_t resultcode; |
83 uint32_t epoch; | 75 uint32_t epoch; |
84 uint16_t privateport; | 76 uint16_t privateport; |
85 uint16_t publicport; | 77 uint16_t publicport; |
86 uint32_t lifetime; | 78 uint32_t lifetime; |
87 } pmp_map_response_t; | 79 } PurplePmpMapResponse; |
88 | 80 |
81 /** | |
82 * | |
83 */ | |
84 /* | |
85 * TODO: This should probably cache the result of this lookup requests | |
86 * so that subsequent calls to this function do not require a | |
87 * round-trip exchange with the local router. | |
88 */ | |
89 char *purple_pmp_get_public_ip(); | 89 char *purple_pmp_get_public_ip(); |
90 pmp_map_response_t *purple_pmp_create_map(PurplePmpType type, uint16_t privateport, uint16_t publicport, uint32_t lifetime); | 90 |
91 pmp_map_response_t *purple_pmp_destroy_map(PurplePmpType type, uint16_t privateport); | 91 /** |
92 | 92 * |
93 #endif | 93 */ |
94 PurplePmpMapResponse *purple_pmp_create_map(PurplePmpType type, uint16_t privateport, uint16_t publicport, uint32_t lifetime); | |
95 | |
96 /** | |
97 * | |
98 */ | |
99 PurplePmpMapResponse *purple_pmp_destroy_map(PurplePmpType type, uint16_t privateport); | |
100 | |
101 #endif /* _PURPLE_NAT_PMP_H_ */ |