Mercurial > pidgin
annotate libpurple/nat-pmp.h @ 32443:16925948a003
Use accessor functions where available.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Wed, 04 Jan 2012 02:34:24 +0000 |
parents | a6cc3de38233 |
children |
rev | line source |
---|---|
15646
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 /** |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
2 * @file nat-pmp.h NAT-PMP Implementation |
15646
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 |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
16907
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
16907
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
16907
diff
changeset
|
6 /* purple |
15646
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
|
7 * |
15822 | 8 * Purple is the legal property of its developers, whose names are too numerous |
15646
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 * 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
|
10 * 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
|
11 * |
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 * 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
|
13 * 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
|
14 * 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
|
15 * 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
|
16 * |
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 * 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
|
18 * 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
|
19 * 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
|
20 * 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
|
21 * |
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 * 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
|
23 * 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
|
24 * 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
|
25 * 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
|
26 * 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
|
27 * 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
|
28 * 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
|
29 * 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
|
30 */ |
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
|
31 |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
32 #ifndef _PURPLE_NAT_PMP_H |
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
33 #define _PURPLE_NAT_PMP_H |
15646
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
|
34 |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
35 #include <glib.h> |
15646
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
|
36 |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
37 #define PURPLE_PMP_LIFETIME 3600 /* 3600 seconds */ |
15646
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 |
15855
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:
15822
diff
changeset
|
39 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:
15822
diff
changeset
|
40 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:
15822
diff
changeset
|
41 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:
15822
diff
changeset
|
42 } 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:
15822
diff
changeset
|
43 |
32433
98520ee78f12
Use G_BEGIN/END_DECLS in public libpurple files. This was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20074
diff
changeset
|
44 G_BEGIN_DECLS |
98520ee78f12
Use G_BEGIN/END_DECLS in public libpurple files. This was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20074
diff
changeset
|
45 |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
46 /** |
15974
1a12ce76c4f4
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 <evan.s@dreskin.net>
parents:
15905
diff
changeset
|
47 * Initialize nat-pmp |
1a12ce76c4f4
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 <evan.s@dreskin.net>
parents:
15905
diff
changeset
|
48 */ |
1a12ce76c4f4
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 <evan.s@dreskin.net>
parents:
15905
diff
changeset
|
49 void purple_pmp_init(void); |
1a12ce76c4f4
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 <evan.s@dreskin.net>
parents:
15905
diff
changeset
|
50 |
1a12ce76c4f4
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 <evan.s@dreskin.net>
parents:
15905
diff
changeset
|
51 /** |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
52 * |
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
53 */ |
15974
1a12ce76c4f4
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 <evan.s@dreskin.net>
parents:
15905
diff
changeset
|
54 char *purple_pmp_get_public_ip(void); |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
55 |
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
56 /** |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
57 * Remove the NAT-PMP mapping for a specified type on a specified port |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
58 * |
32435
a6cc3de38233
Re-align stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32434
diff
changeset
|
59 * @param type The PurplePmpType |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
60 * @param privateport The private port on which we are listening locally |
32435
a6cc3de38233
Re-align stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32434
diff
changeset
|
61 * @param publicport The public port on which we are expecting a response |
a6cc3de38233
Re-align stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32434
diff
changeset
|
62 * @param lifetime The lifetime of the mapping. It is recommended that this |
a6cc3de38233
Re-align stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32434
diff
changeset
|
63 * be PURPLE_PMP_LIFETIME. |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
64 * |
32434
6ef08ec013d2
Fix some spelling.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32433
diff
changeset
|
65 * @returns TRUE if successful; FALSE if unsuccessful |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
66 */ |
32435
a6cc3de38233
Re-align stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32434
diff
changeset
|
67 gboolean purple_pmp_create_map(PurplePmpType type, unsigned short privateport, |
a6cc3de38233
Re-align stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32434
diff
changeset
|
68 unsigned short publicport, int lifetime); |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
69 |
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
70 /** |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
71 * Remove the NAT-PMP mapping for a specified type on a specified port |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
72 * |
32435
a6cc3de38233
Re-align stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32434
diff
changeset
|
73 * @param type The PurplePmpType |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
74 * @param privateport The private port on which the mapping was previously made |
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
75 * |
32434
6ef08ec013d2
Fix some spelling.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32433
diff
changeset
|
76 * @returns TRUE if successful; FALSE if unsuccessful |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
77 */ |
15905
2cf21661f828
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 <evan.s@dreskin.net>
parents:
15898
diff
changeset
|
78 gboolean purple_pmp_destroy_map(PurplePmpType type, unsigned short privateport); |
15975
328ae2c041c3
fix win32 build for nat-pmp stuff. I haven't tested it, but it compiles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15974
diff
changeset
|
79 |
32433
98520ee78f12
Use G_BEGIN/END_DECLS in public libpurple files. This was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20074
diff
changeset
|
80 G_END_DECLS |
98520ee78f12
Use G_BEGIN/END_DECLS in public libpurple files. This was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20074
diff
changeset
|
81 |
15975
328ae2c041c3
fix win32 build for nat-pmp stuff. I haven't tested it, but it compiles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15974
diff
changeset
|
82 #endif |
328ae2c041c3
fix win32 build for nat-pmp stuff. I haven't tested it, but it compiles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15974
diff
changeset
|
83 |