annotate libpurple/nat-pmp.h @ 15900: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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
1 /**
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
2 * @file nat-pmp.h NAT-PMP Implementation
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
3 * @ingroup core
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
4 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15647
diff changeset
5 * purple
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
6 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15647
diff changeset
7 * Purple is the legal property of its developers, whose names are too numerous
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
9 * source distribution.
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
10 *
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
11 * Most code in nat-pmp.h copyright (C) 2007, R. Tyler Ballance, bleep, LLC.
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
12 * This file is distributed under the 3-clause (modified) BSD license:
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
13 * Redistribution and use in source and binary forms, with or without modification, are permitted
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
14 * provided that the following conditions are met:
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
15 *
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
16 * Redistributions of source code must retain the above copyright notice, this list of conditions and
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
17 * the following disclaimer.
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
18 * Neither the name of the bleep. LLC nor the names of its contributors may be used to endorse or promote
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
19 * products derived from this software without specific prior written permission.
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
20 *
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
28 * OF SUCH DAMAGE.
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
29 */
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
30
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
31 #ifndef _PURPLE_NAT_PMP_H
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
32 #define _PURPLE_NAT_PMP_H
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
33
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
34 #include <stdint.h>
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
35
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
36 #define PURPLE_PMP_LIFETIME 3600 /* seconds */
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
37
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
38 /*
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
39 * uint8_t: version, opcodes
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
40 * uint16_t: resultcode
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
41 * unint32_t: epoch (seconds since mappings reset)
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
42 */
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
43
15856
9b875f0ecb86 nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
44 typedef enum {
9b875f0ecb86 nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
45 PURPLE_PMP_TYPE_UDP,
9b875f0ecb86 nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
46 PURPLE_PMP_TYPE_TCP
9b875f0ecb86 nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
47 } PurplePmpType;
9b875f0ecb86 nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
48
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
49 typedef struct {
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
50 uint8_t version;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
51 uint8_t opcode;
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
52 } PurplePmpIpRequest;
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
53
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
54 typedef struct {
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
55 uint8_t version;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
56 uint8_t opcode; // 128 + n
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
57 uint16_t resultcode;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
58 uint32_t epoch;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
59 uint32_t address;
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
60 } PurplePmpIpResponse;
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
61
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
62 typedef struct {
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
63 uint8_t version;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
64 uint8_t opcode;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
65 char reserved[2];
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
66 uint16_t privateport;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
67 uint16_t publicport;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
68 uint32_t lifetime;
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
69 } PurplePmpMapRequest;
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
70
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
71 typedef struct {
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
72 uint8_t version;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
73 uint8_t opcode;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
74 uint16_t resultcode;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
75 uint32_t epoch;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
76 uint16_t privateport;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
77 uint16_t publicport;
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
78 uint32_t lifetime;
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
79 } PurplePmpMapResponse;
15647
552be3958d6a Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
diff changeset
80
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
81 /**
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
82 *
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
83 */
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
84 /*
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
85 * TODO: This should probably cache the result of this lookup requests
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
86 * so that subsequent calls to this function do not require a
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
87 * round-trip exchange with the local router.
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
88 */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15647
diff changeset
89 char *purple_pmp_get_public_ip();
15900
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
90
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
91 /**
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
92 *
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
93 */
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
94 PurplePmpMapResponse *purple_pmp_create_map(PurplePmpType type, uint16_t privateport, uint16_t publicport, uint32_t lifetime);
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
95
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
96 /**
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
97 *
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
98 */
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
99 PurplePmpMapResponse *purple_pmp_destroy_map(PurplePmpType type, uint16_t privateport);
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
100
9cfe41743c65 More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents: 15856
diff changeset
101 #endif /* _PURPLE_NAT_PMP_H_ */