Mercurial > pidgin
annotate libpurple/nat-pmp.h @ 17958:58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
parse the emoticon code we send (although the official client can, and the
emoticon code from the official client can be parsed).
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Fri, 20 Jul 2007 06:06:52 +0000 |
parents | 533ebd404184 |
children | 6bf32c9e15a7 |
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 |
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 * |
15822 | 5 * 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
|
6 * |
15822 | 7 * 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
|
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 |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
31 #ifndef _PURPLE_NAT_PMP_H |
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
32 #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
|
33 |
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
|
34 #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
|
35 |
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
|
36 #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
|
37 |
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
|
38 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
|
39 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
|
40 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
|
41 } 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
|
42 |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
43 /** |
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
|
44 * 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
|
45 */ |
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
|
46 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
|
47 |
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 /** |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
49 * |
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
50 */ |
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
|
51 char *purple_pmp_get_public_ip(void); |
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 /** |
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
|
54 * 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
|
55 * |
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
|
56 * @param type The PurplePmpType |
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 * @param privateport The private port on which we are listening locally |
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
|
58 * @param publicport The public port on which we are expecting a response |
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
|
59 * @param lifetime The lifetime of the mapping. It is recommended that this be PURPLE_PMP_LIFETIME. |
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 * |
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
|
61 * @returns TRUE if succesful; FALSE if unsuccessful |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
62 */ |
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
|
63 gboolean purple_pmp_create_map(PurplePmpType type, unsigned short privateport, unsigned short publicport, int lifetime); |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
64 |
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
65 /** |
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
|
66 * 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
|
67 * |
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
|
68 * @param type The PurplePmpType |
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
|
69 * @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
|
70 * |
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 * @returns TRUE if succesful; FALSE if unsuccessful |
15898
9cfe41743c65
More complete namespacing of nat-pmp
Mark Doliner <mark@kingant.net>
parents:
15855
diff
changeset
|
72 */ |
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
|
73 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
|
74 |
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
|
75 #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
|
76 |