libpurple/nat-pmp.h

Wed, 06 Feb 2008 18:06:44 +0000

author
John Bailey <rekkanoryo@rekkanoryo.org>
date
Wed, 06 Feb 2008 18:06:44 +0000
branch
cpw.rekkanoryo.yahoop15ft
changeset 22401
5fe1761a4a15
parent 20147
66f05a854eee
child 32787
7072f190d6ad
permissions
-rw-r--r--

Simplified version of the newest patch on #4533 to not try Yahoo protocol
version 15 file transfer on Yahoo Japan.

15708
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
1 /**
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
2 * @file nat-pmp.h NAT-PMP Implementation
15708
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
3 * @ingroup core
20147
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 16964
diff changeset
4 */
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 16964
diff changeset
5
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 16964
diff changeset
6 /* purple
15708
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
7 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15708
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
15708
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
10 * source distribution.
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
11 *
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
12 * Most code in nat-pmp.h copyright (C) 2007, R. Tyler Ballance, bleep, LLC.
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
13 * This file is distributed under the 3-clause (modified) BSD license:
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
14 * Redistribution and use in source and binary forms, with or without modification, are permitted
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
15 * provided that the following conditions are met:
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
16 *
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
17 * Redistributions of source code must retain the above copyright notice, this list of conditions and
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
18 * the following disclaimer.
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
19 * Neither the name of the bleep. LLC nor the names of its contributors may be used to endorse or promote
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
20 * products derived from this software without specific prior written permission.
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
21 *
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
29 * OF SUCH DAMAGE.
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
30 */
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
31
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
32 #ifndef _PURPLE_NAT_PMP_H
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
33 #define _PURPLE_NAT_PMP_H
15708
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
34
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
35 #include <glib.h>
15708
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
36
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
37 #define PURPLE_PMP_LIFETIME 3600 /* 3600 seconds */
15708
979f43512119 Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
diff changeset
38
15933
913ba1d4b81c 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 <evands@pidgin.im>
parents: 15884
diff changeset
39 typedef enum {
913ba1d4b81c 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 <evands@pidgin.im>
parents: 15884
diff changeset
40 PURPLE_PMP_TYPE_UDP,
913ba1d4b81c 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 <evands@pidgin.im>
parents: 15884
diff changeset
41 PURPLE_PMP_TYPE_TCP
913ba1d4b81c 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 <evands@pidgin.im>
parents: 15884
diff changeset
42 } PurplePmpType;
913ba1d4b81c 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 <evands@pidgin.im>
parents: 15884
diff changeset
43
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
44 /**
16035
eb4eda79a147 The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents: 15968
diff changeset
45 * Initialize nat-pmp
eb4eda79a147 The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents: 15968
diff changeset
46 */
eb4eda79a147 The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents: 15968
diff changeset
47 void purple_pmp_init(void);
eb4eda79a147 The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents: 15968
diff changeset
48
eb4eda79a147 The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents: 15968
diff changeset
49 /**
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
50 *
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
51 */
16035
eb4eda79a147 The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents: 15968
diff changeset
52 char *purple_pmp_get_public_ip(void);
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
53
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
54 /**
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
55 * Remove the NAT-PMP mapping for a specified type on a specified port
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
56 *
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
57 * @param type The PurplePmpType
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
58 * @param privateport The private port on which we are listening locally
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
59 * @param publicport The public port on which we are expecting a response
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
60 * @param lifetime The lifetime of the mapping. It is recommended that this be PURPLE_PMP_LIFETIME.
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
61 *
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
62 * @returns TRUE if succesful; FALSE if unsuccessful
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
63 */
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
64 gboolean purple_pmp_create_map(PurplePmpType type, unsigned short privateport, unsigned short publicport, int lifetime);
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
65
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
66 /**
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
67 * Remove the NAT-PMP mapping for a specified type on a specified port
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
68 *
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
69 * @param type The PurplePmpType
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
70 * @param privateport The private port on which the mapping was previously made
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
71 *
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
72 * @returns TRUE if succesful; FALSE if unsuccessful
15961
a3ef09c8ca24 More complete namespacing of nat-pmp
Mark Doliner <markdoliner@pidgin.im>
parents: 15933
diff changeset
73 */
15968
01dcc5c7cf9e Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
Evan Schoenberg <evands@pidgin.im>
parents: 15961
diff changeset
74 gboolean purple_pmp_destroy_map(PurplePmpType type, unsigned short privateport);
16036
d74e95743ae1 fix win32 build for nat-pmp stuff. I haven't tested it, but it compiles.
Daniel Atallah <datallah@pidgin.im>
parents: 16035
diff changeset
75
d74e95743ae1 fix win32 build for nat-pmp stuff. I haven't tested it, but it compiles.
Daniel Atallah <datallah@pidgin.im>
parents: 16035
diff changeset
76 #endif
d74e95743ae1 fix win32 build for nat-pmp stuff. I haven't tested it, but it compiles.
Daniel Atallah <datallah@pidgin.im>
parents: 16035
diff changeset
77

mercurial