Mon, 11 Nov 2019 20:43:31 -0600
closing merged branch
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* purple |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
5 | * source distribution. |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
6 | * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
7 | * This program is free software; you can redistribute it and/or modify |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
8 | * it under the terms of the GNU General Public License as published by |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
9 | * the Free Software Foundation; either version 2 of the License, or |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
10 | * (at your option) any later version. |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
11 | * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
12 | * This program is distributed in the hope that it will be useful, |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
15 | * GNU General Public License for more details. |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
16 | * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
17 | * You should have received a copy of the GNU General Public License |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
18 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16035
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
20 | */ |
|
37489
cbf9ccc715ab
Move everything in libpurple that was using the network-changed signal to use the gio one
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
21 | #include <gio/gio.h> |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
22 | #include <libsoup/soup.h> |
|
37489
cbf9ccc715ab
Move everything in libpurple that was using the network-changed signal to use the gio one
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
23 | |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
24 | #include "internal.h" |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
25 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
26 | #include "upnp.h" |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
27 | |
|
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:
15884
diff
changeset
|
28 | #include "debug.h" |
|
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:
15884
diff
changeset
|
29 | #include "eventloop.h" |
|
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:
15884
diff
changeset
|
30 | #include "network.h" |
|
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:
15884
diff
changeset
|
31 | #include "proxy.h" |
|
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:
15884
diff
changeset
|
32 | #include "signals.h" |
|
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:
15884
diff
changeset
|
33 | #include "util.h" |
|
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:
15884
diff
changeset
|
34 | #include "xmlnode.h" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
35 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
36 | /*************************************************************** |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
37 | ** General Defines * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
38 | ****************************************************************/ |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
39 | #define HTTP_OK "200 OK" |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
40 | #define DEFAULT_HTTP_PORT 80 |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
41 | #define DISCOVERY_TIMEOUT 1000 |
|
24011
0cff24bf7dba
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
42 | /* limit UPnP-triggered http downloads to 128k */ |
|
0cff24bf7dba
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
43 | #define MAX_UPNP_DOWNLOAD (128 * 1024) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
44 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
45 | /*************************************************************** |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
46 | ** Discovery/Description Defines * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
47 | ****************************************************************/ |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
48 | #define NUM_UDP_ATTEMPTS 2 |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
49 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
50 | /* Address and port of an SSDP request used for discovery */ |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
51 | #define HTTPMU_HOST_ADDRESS "239.255.255.250" |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
52 | #define HTTPMU_HOST_PORT 1900 |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
53 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
54 | #define SEARCH_REQUEST_DEVICE "urn:schemas-upnp-org:service:%s" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
55 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
56 | #define SEARCH_REQUEST_STRING \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
57 | "M-SEARCH * HTTP/1.1\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
58 | "MX: 2\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
59 | "HOST: 239.255.255.250:1900\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
60 | "MAN: \"ssdp:discover\"\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
61 | "ST: urn:schemas-upnp-org:service:%s\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
62 | "\r\n" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
63 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
64 | #define WAN_IP_CONN_SERVICE "WANIPConnection:1" |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
65 | #define WAN_PPP_CONN_SERVICE "WANPPPConnection:1" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
66 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
67 | /****************************************************************** |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
68 | ** Action Defines * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
69 | *******************************************************************/ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
70 | #define SOAP_ACTION \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
71 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
72 | "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" " \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
73 | "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
74 | "<s:Body>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
75 | "<u:%s xmlns:u=\"urn:schemas-upnp-org:service:%s\">\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
76 | "%s" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
77 | "</u:%s>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
78 | "</s:Body>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
79 | "</s:Envelope>" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
80 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
81 | #define PORT_MAPPING_LEASE_TIME "0" |
| 15884 | 82 | #define PORT_MAPPING_DESCRIPTION "PURPLE_UPNP_PORT_FORWARD" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
83 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
84 | #define ADD_PORT_MAPPING_PARAMS \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
85 | "<NewRemoteHost></NewRemoteHost>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
86 | "<NewExternalPort>%i</NewExternalPort>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
87 | "<NewProtocol>%s</NewProtocol>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
88 | "<NewInternalPort>%i</NewInternalPort>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
89 | "<NewInternalClient>%s</NewInternalClient>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
90 | "<NewEnabled>1</NewEnabled>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
91 | "<NewPortMappingDescription>" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
92 | PORT_MAPPING_DESCRIPTION \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
93 | "</NewPortMappingDescription>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
94 | "<NewLeaseDuration>" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
95 | PORT_MAPPING_LEASE_TIME \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
96 | "</NewLeaseDuration>\r\n" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
97 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
98 | #define DELETE_PORT_MAPPING_PARAMS \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
99 | "<NewRemoteHost></NewRemoteHost>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
100 | "<NewExternalPort>%i</NewExternalPort>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
101 | "<NewProtocol>%s</NewProtocol>\r\n" |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
102 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
103 | typedef enum { |
| 15884 | 104 | PURPLE_UPNP_STATUS_UNDISCOVERED = -1, |
| 105 | PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER, | |
| 106 | PURPLE_UPNP_STATUS_DISCOVERING, | |
| 107 | PURPLE_UPNP_STATUS_DISCOVERED | |
| 108 | } PurpleUPnPStatus; | |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
109 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
110 | typedef struct { |
| 15884 | 111 | PurpleUPnPStatus status; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
112 | gchar* control_url; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
113 | gchar service_type[20]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
114 | char publicip[16]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
115 | char internalip[16]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
116 | time_t lookup_time; |
| 15884 | 117 | } PurpleUPnPControlInfo; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
118 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
119 | typedef struct { |
| 15884 | 120 | guint inpa; /* purple_input_add handle */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
121 | guint tima; /* g_timeout_add handle */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
122 | int fd; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
123 | struct sockaddr_in server; |
|
27000
668af87393da
Use matching buffer lengths to avoid confusion.
Daniel Atallah <datallah@pidgin.im>
parents:
25911
diff
changeset
|
124 | gchar service_type[20]; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
125 | int retry_count; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
126 | gchar *full_url; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
127 | } UPnPDiscoveryData; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
128 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
129 | struct _PurpleUPnPMappingAddRemove |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
130 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
131 | unsigned short portmap; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
132 | gchar protocol[4]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
133 | gboolean add; |
| 15884 | 134 | PurpleUPnPCallback cb; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
135 | gpointer cb_data; |
|
31273
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
136 | gboolean success; |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
137 | guint tima; /* g_timeout_add handle */ |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
138 | SoupMessage *msg; |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
139 | }; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
140 | |
| 15884 | 141 | static PurpleUPnPControlInfo control_info = { |
| 142 | PURPLE_UPNP_STATUS_UNDISCOVERED, | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
143 | NULL, "\0", "\0", "\0", 0}; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
144 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
145 | static SoupSession *session = NULL; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
146 | static GSList *discovery_callbacks = NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
147 | |
| 15884 | 148 | static void purple_upnp_discover_send_broadcast(UPnPDiscoveryData *dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
149 | static void lookup_public_ip(void); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
150 | static void lookup_internal_ip(void); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
151 | |
|
31273
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
152 | static gboolean |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
153 | fire_ar_cb_async_and_free(gpointer data) |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
154 | { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
155 | PurpleUPnPMappingAddRemove *ar = data; |
|
31273
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
156 | if (ar) { |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
157 | if (ar->cb) |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
158 | ar->cb(ar->success, ar->cb_data); |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
159 | g_free(ar); |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
160 | } |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
161 | |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
162 | return FALSE; |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
163 | } |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
164 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
165 | static void |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
166 | fire_discovery_callbacks(gboolean success) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
167 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
168 | while(discovery_callbacks) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
169 | gpointer data; |
| 15884 | 170 | PurpleUPnPCallback cb = discovery_callbacks->data; |
|
31190
107e045ff742
I prefer this syntax. Plus, it's slightly faster... right?
Mark Doliner <markdoliner@pidgin.im>
parents:
30514
diff
changeset
|
171 | discovery_callbacks = g_slist_delete_link(discovery_callbacks, discovery_callbacks); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
172 | data = discovery_callbacks->data; |
|
31190
107e045ff742
I prefer this syntax. Plus, it's slightly faster... right?
Mark Doliner <markdoliner@pidgin.im>
parents:
30514
diff
changeset
|
173 | discovery_callbacks = g_slist_delete_link(discovery_callbacks, discovery_callbacks); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
174 | cb(success, data); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
175 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
176 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
177 | |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
178 | static gboolean |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
179 | purple_upnp_compare_device(const PurpleXmlNode* device, const gchar* deviceType) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
180 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
181 | PurpleXmlNode* deviceTypeNode = purple_xmlnode_get_child(device, "deviceType"); |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
182 | char *tmp; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
183 | gboolean ret; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
184 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
185 | if(deviceTypeNode == NULL) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
186 | return FALSE; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
187 | } |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
188 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
189 | tmp = purple_xmlnode_get_data(deviceTypeNode); |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
190 | ret = !g_ascii_strcasecmp(tmp, deviceType); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
191 | g_free(tmp); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
192 | |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
193 | return ret; |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
194 | } |
|
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
195 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
196 | static gboolean |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
197 | purple_upnp_compare_service(const PurpleXmlNode* service, const gchar* serviceType) |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
198 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
199 | PurpleXmlNode* serviceTypeNode; |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
200 | char *tmp; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
201 | gboolean ret; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
202 | |
| 13793 | 203 | if(service == NULL) { |
| 204 | return FALSE; | |
| 205 | } | |
| 206 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
207 | serviceTypeNode = purple_xmlnode_get_child(service, "serviceType"); |
| 13793 | 208 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
209 | if(serviceTypeNode == NULL) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
210 | return FALSE; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
211 | } |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
212 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
213 | tmp = purple_xmlnode_get_data(serviceTypeNode); |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
214 | ret = !g_ascii_strcasecmp(tmp, serviceType); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
215 | g_free(tmp); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
216 | |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
217 | return ret; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
218 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
219 | |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
220 | static gchar* |
| 15884 | 221 | purple_upnp_parse_description_response(const gchar* httpResponse, gsize len, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
222 | const gchar* httpURL, const gchar* serviceType) |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
223 | { |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
224 | gchar *baseURL, *controlURL, *service; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
225 | PurpleXmlNode *xmlRootNode, *serviceTypeNode, *controlURLNode, *baseURLNode; |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
226 | char *tmp; |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
227 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
228 | /* create the xml root node */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
229 | if ((xmlRootNode = purple_xmlnode_from_str(httpResponse, len)) == NULL) { |
| 15884 | 230 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
231 | "parse_description_response(): Could not parse xml root node\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
232 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
233 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
234 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
235 | /* get the baseURL of the device */ |
|
33560
3f178b52c209
Fix a crash in upnp code introduced 3 weeks ago.
Mark Doliner <mark@kingant.net>
parents:
33542
diff
changeset
|
236 | baseURL = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
237 | if((baseURLNode = purple_xmlnode_get_child(xmlRootNode, "URLBase")) != NULL) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
238 | baseURL = purple_xmlnode_get_data(baseURLNode); |
|
33542
d79e18b1b043
Fix UPNP mapping on some weird routers. Fixes #15373.
Ferdinand Stehle <unknown>
parents:
31949
diff
changeset
|
239 | } |
|
d79e18b1b043
Fix UPNP mapping on some weird routers. Fixes #15373.
Ferdinand Stehle <unknown>
parents:
31949
diff
changeset
|
240 | /* fixes upnp-descriptions with empty urlbase-element */ |
|
d79e18b1b043
Fix UPNP mapping on some weird routers. Fixes #15373.
Ferdinand Stehle <unknown>
parents:
31949
diff
changeset
|
241 | if(baseURL == NULL){ |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
242 | baseURL = g_strdup(httpURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
243 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
244 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
245 | /* get the serviceType child that has the service type as its data */ |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
246 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
247 | /* get urn:schemas-upnp-org:device:InternetGatewayDevice:1 and its devicelist */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
248 | serviceTypeNode = purple_xmlnode_get_child(xmlRootNode, "device"); |
| 15884 | 249 | while(!purple_upnp_compare_device(serviceTypeNode, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
250 | "urn:schemas-upnp-org:device:InternetGatewayDevice:1") && |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
251 | serviceTypeNode != NULL) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
252 | serviceTypeNode = purple_xmlnode_get_next_twin(serviceTypeNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
253 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
254 | if(serviceTypeNode == NULL) { |
| 15884 | 255 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
256 | "parse_description_response(): could not get serviceTypeNode 1\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
257 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
258 | purple_xmlnode_free(xmlRootNode); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
259 | return NULL; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
260 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
261 | serviceTypeNode = purple_xmlnode_get_child(serviceTypeNode, "deviceList"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
262 | if(serviceTypeNode == NULL) { |
| 15884 | 263 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
264 | "parse_description_response(): could not get serviceTypeNode 2\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
265 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
266 | purple_xmlnode_free(xmlRootNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
267 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
268 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
269 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
270 | /* get urn:schemas-upnp-org:device:WANDevice:1 and its devicelist */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
271 | serviceTypeNode = purple_xmlnode_get_child(serviceTypeNode, "device"); |
| 15884 | 272 | while(!purple_upnp_compare_device(serviceTypeNode, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
273 | "urn:schemas-upnp-org:device:WANDevice:1") && |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
274 | serviceTypeNode != NULL) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
275 | serviceTypeNode = purple_xmlnode_get_next_twin(serviceTypeNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
276 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
277 | if(serviceTypeNode == NULL) { |
| 15884 | 278 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
279 | "parse_description_response(): could not get serviceTypeNode 3\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
280 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
281 | purple_xmlnode_free(xmlRootNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
282 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
283 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
284 | serviceTypeNode = purple_xmlnode_get_child(serviceTypeNode, "deviceList"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
285 | if(serviceTypeNode == NULL) { |
| 15884 | 286 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
287 | "parse_description_response(): could not get serviceTypeNode 4\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
288 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
289 | purple_xmlnode_free(xmlRootNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
290 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
291 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
292 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
293 | /* get urn:schemas-upnp-org:device:WANConnectionDevice:1 and its servicelist */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
294 | serviceTypeNode = purple_xmlnode_get_child(serviceTypeNode, "device"); |
| 15884 | 295 | while(serviceTypeNode && !purple_upnp_compare_device(serviceTypeNode, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
296 | "urn:schemas-upnp-org:device:WANConnectionDevice:1")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
297 | serviceTypeNode = purple_xmlnode_get_next_twin(serviceTypeNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
298 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
299 | if(serviceTypeNode == NULL) { |
| 15884 | 300 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
301 | "parse_description_response(): could not get serviceTypeNode 5\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
302 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
303 | purple_xmlnode_free(xmlRootNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
304 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
305 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
306 | serviceTypeNode = purple_xmlnode_get_child(serviceTypeNode, "serviceList"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
307 | if(serviceTypeNode == NULL) { |
| 15884 | 308 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
309 | "parse_description_response(): could not get serviceTypeNode 6\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
310 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
311 | purple_xmlnode_free(xmlRootNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
312 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
313 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
314 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
315 | /* get the serviceType variable passed to this function */ |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
316 | service = g_strdup_printf(SEARCH_REQUEST_DEVICE, serviceType); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
317 | serviceTypeNode = purple_xmlnode_get_child(serviceTypeNode, "service"); |
| 15884 | 318 | while(!purple_upnp_compare_service(serviceTypeNode, service) && |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
319 | serviceTypeNode != NULL) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
320 | serviceTypeNode = purple_xmlnode_get_next_twin(serviceTypeNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
321 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
322 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
323 | g_free(service); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
324 | if(serviceTypeNode == NULL) { |
| 15884 | 325 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
326 | "parse_description_response(): could not get serviceTypeNode 7\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
327 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
328 | purple_xmlnode_free(xmlRootNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
329 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
330 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
331 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
332 | /* get the controlURL of the service */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
333 | if((controlURLNode = purple_xmlnode_get_child(serviceTypeNode, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
334 | "controlURL")) == NULL) { |
| 15884 | 335 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
336 | "parse_description_response(): Could not find controlURL\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
337 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
338 | purple_xmlnode_free(xmlRootNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
339 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
340 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
341 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
342 | tmp = purple_xmlnode_get_data(controlURLNode); |
|
40125
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40058
diff
changeset
|
343 | if (baseURL && !g_str_has_prefix(tmp, "http://") && |
|
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40058
diff
changeset
|
344 | !g_str_has_prefix(tmp, "HTTP://")) { |
| 15348 | 345 | /* Handle absolute paths in a relative URL. This probably |
| 346 | * belongs in util.c. */ | |
| 347 | if (tmp[0] == '/') { | |
| 348 | size_t length; | |
| 349 | const char *path, *start = strstr(baseURL, "://"); | |
| 350 | start = start ? start + 3 : baseURL; | |
| 351 | path = strchr(start, '/'); | |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33770
diff
changeset
|
352 | length = path ? (gsize)(path - baseURL) : strlen(baseURL); |
| 15683 | 353 | controlURL = g_strdup_printf("%.*s%s", (int)length, baseURL, tmp); |
| 15348 | 354 | } else { |
| 355 | controlURL = g_strdup_printf("%s%s", baseURL, tmp); | |
| 356 | } | |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
357 | g_free(tmp); |
|
40125
a7acc7b00d79
Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40058
diff
changeset
|
358 | } else { |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
359 | controlURL = tmp; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
360 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
361 | g_free(baseURL); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34304
diff
changeset
|
362 | purple_xmlnode_free(xmlRootNode); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
363 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
364 | return controlURL; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
365 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
366 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
367 | static void |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
368 | upnp_parse_description_cb(G_GNUC_UNUSED SoupSession *session, SoupMessage *msg, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
369 | gpointer _dd) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
370 | { |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
371 | UPnPDiscoveryData *dd = _dd; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
372 | gchar *control_url = NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
373 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
374 | if (msg && SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) { |
| 15884 | 375 | control_url = purple_upnp_parse_description_response( |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
376 | msg->response_body->data, msg->response_body->length, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
377 | dd->full_url, dd->service_type); |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
378 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
379 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
380 | g_free(dd->full_url); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
381 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
382 | if(control_url == NULL) { |
| 15884 | 383 | purple_debug_error("upnp", |
| 384 | "purple_upnp_parse_description(): control URL is NULL\n"); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
385 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
386 | |
| 15884 | 387 | control_info.status = control_url ? PURPLE_UPNP_STATUS_DISCOVERED |
| 388 | : PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER; | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
389 | control_info.lookup_time = time(NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
390 | control_info.control_url = control_url; |
|
33746
ad7e7fb98db3
Fix a crash when receiving UPnP responses with abnormally long values.
Mark Doliner <mark@kingant.net>
parents:
33560
diff
changeset
|
391 | g_strlcpy(control_info.service_type, dd->service_type, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
392 | sizeof(control_info.service_type)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
393 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
394 | fire_discovery_callbacks(control_url != NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
395 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
396 | /* Look up the public and internal IPs */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
397 | if(control_url != NULL) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
398 | lookup_public_ip(); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
399 | lookup_internal_ip(); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
400 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
401 | |
|
30514
b098c4f6eb80
Remove some timeout/input handlers for upnp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30384
diff
changeset
|
402 | if (dd->inpa > 0) |
|
b098c4f6eb80
Remove some timeout/input handlers for upnp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30384
diff
changeset
|
403 | purple_input_remove(dd->inpa); |
|
b098c4f6eb80
Remove some timeout/input handlers for upnp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30384
diff
changeset
|
404 | if (dd->tima > 0) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
405 | g_source_remove(dd->tima); |
|
30514
b098c4f6eb80
Remove some timeout/input handlers for upnp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30384
diff
changeset
|
406 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
407 | g_free(dd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
408 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
409 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
410 | static void |
| 15884 | 411 | purple_upnp_parse_description(const gchar* descriptionURL, UPnPDiscoveryData *dd) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
412 | { |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
413 | SoupMessage *msg; |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
414 | SoupURI *uri; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
415 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
416 | /* Remove the timeout because everything it is waiting for has |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
417 | * successfully completed */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
418 | g_source_remove(dd->tima); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
419 | dd->tima = 0; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
420 | |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
421 | /* Extract base url out of the descriptionURL. |
|
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
422 | * Example description URL: http://192.168.1.1:5678/rootDesc.xml |
|
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
423 | */ |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
424 | uri = soup_uri_new(descriptionURL); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
425 | if (!uri) { |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
426 | upnp_parse_description_cb(NULL, NULL, dd); |
|
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
427 | return; |
|
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
428 | } |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
429 | dd->full_url = g_strdup_printf("http://%s:%d", uri->host, uri->port); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
430 | soup_uri_free(uri); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
431 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
432 | msg = soup_message_new("GET", descriptionURL); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
433 | // purple_http_request_set_max_len(msg, MAX_UPNP_DOWNLOAD); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
434 | soup_session_queue_message(session, msg, upnp_parse_description_cb, dd); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
435 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
436 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
437 | static void |
| 15884 | 438 | purple_upnp_parse_discover_response(const gchar* buf, unsigned int buf_len, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
439 | UPnPDiscoveryData *dd) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
440 | { |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
441 | gchar* startDescURL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
442 | gchar* endDescURL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
443 | gchar* descURL; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
444 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
445 | if(g_strstr_len(buf, buf_len, HTTP_OK) == NULL) { |
| 15884 | 446 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
447 | "parse_discover_response(): Failed In HTTP_OK\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
448 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
449 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
450 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
451 | if((startDescURL = g_strstr_len(buf, buf_len, "http://")) == NULL) { |
| 15884 | 452 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
453 | "parse_discover_response(): Failed In finding http://\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
454 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
455 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
456 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
457 | endDescURL = g_strstr_len(startDescURL, buf_len - (startDescURL - buf), |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
458 | "\r"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
459 | if(endDescURL == NULL) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
460 | endDescURL = g_strstr_len(startDescURL, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
461 | buf_len - (startDescURL - buf), "\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
462 | if(endDescURL == NULL) { |
| 15884 | 463 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
464 | "parse_discover_response(): Failed In endDescURL\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
465 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
466 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
467 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
468 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
469 | /* XXX: I'm not sure how this could ever happen */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
470 | if(endDescURL == startDescURL) { |
| 15884 | 471 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
472 | "parse_discover_response(): endDescURL == startDescURL\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
473 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
474 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
475 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
476 | descURL = g_strndup(startDescURL, endDescURL - startDescURL); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
477 | |
| 15884 | 478 | purple_upnp_parse_description(descURL, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
479 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
480 | g_free(descURL); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
481 | |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
482 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
483 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
484 | static gboolean |
| 15884 | 485 | purple_upnp_discover_timeout(gpointer data) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
486 | { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
487 | UPnPDiscoveryData* dd = data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
488 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
489 | if (dd->inpa) |
| 15884 | 490 | purple_input_remove(dd->inpa); |
|
30514
b098c4f6eb80
Remove some timeout/input handlers for upnp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30384
diff
changeset
|
491 | if (dd->tima > 0) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
492 | g_source_remove(dd->tima); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
493 | dd->inpa = 0; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
494 | dd->tima = 0; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
495 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
496 | if (dd->retry_count < NUM_UDP_ATTEMPTS) { |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
497 | /* TODO: We probably shouldn't be incrementing retry_count in two places */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
498 | dd->retry_count++; |
| 15884 | 499 | purple_upnp_discover_send_broadcast(dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
500 | } else { |
|
31949
f141aee90086
Fix some closes on invalid fds, which can crash on Windows.
Florian Quèze <florian@instantbird.org>
parents:
31273
diff
changeset
|
501 | if (dd->fd != -1) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
502 | close(dd->fd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
503 | |
| 15884 | 504 | control_info.status = PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
505 | control_info.lookup_time = time(NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
506 | control_info.service_type[0] = '\0'; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
507 | g_free(control_info.control_url); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
508 | control_info.control_url = NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
509 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
510 | fire_discovery_callbacks(FALSE); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
511 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
512 | g_free(dd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
513 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
514 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
515 | return FALSE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
516 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
517 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
518 | static void |
| 15884 | 519 | purple_upnp_discover_udp_read(gpointer data, gint sock, PurpleInputCondition cond) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
520 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
521 | int len; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
522 | UPnPDiscoveryData *dd = data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
523 | gchar buf[65536]; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
524 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
525 | do { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
526 | len = recv(dd->fd, buf, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
527 | sizeof(buf) - 1, 0); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
528 | |
|
29810
8cb17c0c8fe5
Handle read of length 0 in upnp code.
Ethan Blanton <elb@pidgin.im>
parents:
27497
diff
changeset
|
529 | if(len >= 0) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
530 | buf[len] = '\0'; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
531 | break; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
532 | } else if(errno != EINTR) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
533 | /* We'll either get called again, or time out */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
534 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
535 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
536 | } while (errno == EINTR); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
537 | |
| 15884 | 538 | purple_input_remove(dd->inpa); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
539 | dd->inpa = 0; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
540 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
541 | close(dd->fd); |
|
20044
2b66cf7c7266
grab revision 24d76e86b06c5b1ab5f0a3ea37bd69ced034e0d0 (Reset file descriptors to -1 instead of 0 to fix some weird unexpected crashes in finch
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
542 | dd->fd = -1; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
543 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
544 | /* parse the response, and see if it was a success */ |
| 15884 | 545 | purple_upnp_parse_discover_response(buf, len, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
546 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
547 | /* We'll either time out or continue successfully */ |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
548 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
549 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
550 | static void |
| 15884 | 551 | purple_upnp_discover_send_broadcast(UPnPDiscoveryData *dd) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
552 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
553 | gchar *sendMessage = NULL; |
|
25571
4cb4b6a61da6
Fix a null ptr deref/double free. Fixes #8336.
Daniel Atallah <datallah@pidgin.im>
parents:
24672
diff
changeset
|
554 | size_t totalSize; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
555 | gboolean sentSuccess; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
556 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
557 | /* because we are sending over UDP, if there is a failure |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
558 | we should retry the send NUM_UDP_ATTEMPTS times. Also, |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
559 | try different requests for WANIPConnection and WANPPPConnection*/ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
560 | for(; dd->retry_count < NUM_UDP_ATTEMPTS; dd->retry_count++) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13097
diff
changeset
|
561 | sentSuccess = FALSE; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
562 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
563 | if((dd->retry_count % 2) == 0) { |
|
33746
ad7e7fb98db3
Fix a crash when receiving UPnP responses with abnormally long values.
Mark Doliner <mark@kingant.net>
parents:
33560
diff
changeset
|
564 | g_strlcpy(dd->service_type, WAN_IP_CONN_SERVICE, sizeof(dd->service_type)); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
565 | } else { |
|
33746
ad7e7fb98db3
Fix a crash when receiving UPnP responses with abnormally long values.
Mark Doliner <mark@kingant.net>
parents:
33560
diff
changeset
|
566 | g_strlcpy(dd->service_type, WAN_PPP_CONN_SERVICE, sizeof(dd->service_type)); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
567 | } |
|
11213
837e1970689d
[gaim-migrate @ 13344]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11204
diff
changeset
|
568 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
569 | sendMessage = g_strdup_printf(SEARCH_REQUEST_STRING, dd->service_type); |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
570 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
571 | totalSize = strlen(sendMessage); |
|
11213
837e1970689d
[gaim-migrate @ 13344]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11204
diff
changeset
|
572 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
573 | do { |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33770
diff
changeset
|
574 | gssize sent = sendto(dd->fd, sendMessage, totalSize, 0, |
|
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33770
diff
changeset
|
575 | (struct sockaddr*) &(dd->server), |
|
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33770
diff
changeset
|
576 | sizeof(struct sockaddr_in)); |
|
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33770
diff
changeset
|
577 | if (sent >= 0 && (gsize)sent == totalSize) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
578 | sentSuccess = TRUE; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
579 | break; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
580 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13097
diff
changeset
|
581 | } while (errno == EINTR || errno == EAGAIN); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
582 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
583 | g_free(sendMessage); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
584 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
585 | if(sentSuccess) { |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
586 | dd->tima = g_timeout_add(DISCOVERY_TIMEOUT, |
| 15884 | 587 | purple_upnp_discover_timeout, dd); |
| 588 | dd->inpa = purple_input_add(dd->fd, PURPLE_INPUT_READ, | |
| 589 | purple_upnp_discover_udp_read, dd); | |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
590 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
591 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
592 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
593 | } |
|
11213
837e1970689d
[gaim-migrate @ 13344]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11204
diff
changeset
|
594 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
595 | /* We have already done all our retries. Make sure that the callback |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
596 | * doesn't get called before the original function returns */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
597 | dd->tima = g_timeout_add(10, purple_upnp_discover_timeout, dd); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
598 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
599 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
600 | void |
| 15884 | 601 | purple_upnp_discover(PurpleUPnPCallback cb, gpointer cb_data) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
602 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
603 | /* Socket Setup Variables */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
604 | int sock; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
605 | struct hostent* hp; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
606 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
607 | /* UDP RECEIVE VARIABLES */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
608 | UPnPDiscoveryData *dd; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
609 | |
| 15884 | 610 | if (control_info.status == PURPLE_UPNP_STATUS_DISCOVERING) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
611 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
612 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
613 | discovery_callbacks, cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
614 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
615 | discovery_callbacks, cb_data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
616 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
617 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
618 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
619 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
620 | dd = g_new0(UPnPDiscoveryData, 1); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
621 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
622 | discovery_callbacks = g_slist_append(discovery_callbacks, cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
623 | discovery_callbacks = g_slist_append(discovery_callbacks, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
624 | cb_data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
625 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
626 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
627 | /* Set up the sockets */ |
|
31949
f141aee90086
Fix some closes on invalid fds, which can crash on Windows.
Florian Quèze <florian@instantbird.org>
parents:
31273
diff
changeset
|
628 | dd->fd = sock = socket(AF_INET, SOCK_DGRAM, 0); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
629 | if(sock == -1) { |
| 15884 | 630 | purple_debug_error("upnp", |
| 631 | "purple_upnp_discover(): Failed In sock creation\n"); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
632 | /* Short circuit the retry attempts */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
633 | dd->retry_count = NUM_UDP_ATTEMPTS; |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
634 | dd->tima = g_timeout_add(10, purple_upnp_discover_timeout, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
635 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
636 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
637 | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
638 | /* TODO: Non-blocking! */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
639 | if((hp = gethostbyname(HTTPMU_HOST_ADDRESS)) == NULL) { |
| 15884 | 640 | purple_debug_error("upnp", |
| 641 | "purple_upnp_discover(): Failed In gethostbyname\n"); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
642 | /* Short circuit the retry attempts */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
643 | dd->retry_count = NUM_UDP_ATTEMPTS; |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
644 | dd->tima = g_timeout_add(10, purple_upnp_discover_timeout, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
645 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
646 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
647 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
648 | memset(&(dd->server), 0, sizeof(struct sockaddr)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
649 | dd->server.sin_family = AF_INET; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
650 | memcpy(&(dd->server.sin_addr), hp->h_addr_list[0], hp->h_length); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
651 | dd->server.sin_port = htons(HTTPMU_HOST_PORT); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
652 | |
| 15884 | 653 | control_info.status = PURPLE_UPNP_STATUS_DISCOVERING; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
654 | |
| 15884 | 655 | purple_upnp_discover_send_broadcast(dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
656 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
657 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
658 | static SoupMessage * |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
659 | purple_upnp_generate_action_message_and_send(const gchar *actionName, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
660 | const gchar *actionParams, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
661 | SoupSessionCallback cb, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
662 | gpointer cb_data) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
663 | { |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
664 | SoupMessage *msg; |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
665 | gchar *action; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
666 | gchar* soapMessage; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
667 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
668 | /* set the soap message */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
669 | soapMessage = g_strdup_printf(SOAP_ACTION, actionName, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
670 | control_info.service_type, actionParams, actionName); |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
671 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
672 | msg = soup_message_new("POST", control_info.control_url); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
673 | // purple_http_request_set_max_len(msg, MAX_UPNP_DOWNLOAD); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
674 | action = g_strdup_printf("\"urn:schemas-upnp-org:service:%s#%s\"", |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
675 | control_info.service_type, actionName); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
676 | soup_message_headers_replace(msg->request_headers, "SOAPAction", action); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
677 | g_free(action); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
678 | soup_message_set_request(msg, "text/xml; charset=utf-8", SOUP_MEMORY_TAKE, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
679 | soapMessage, strlen(soapMessage)); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
680 | soup_session_queue_message(session, msg, cb, cb_data); |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
681 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
682 | return msg; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
683 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
684 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
685 | const gchar * |
| 15884 | 686 | purple_upnp_get_public_ip() |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
687 | { |
| 15884 | 688 | if (control_info.status == PURPLE_UPNP_STATUS_DISCOVERED |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32147
diff
changeset
|
689 | && *control_info.publicip) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
690 | return control_info.publicip; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
691 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
692 | /* Trigger another UPnP discovery if 5 minutes have elapsed since the |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
693 | * last one, and it wasn't successful */ |
| 15884 | 694 | if (control_info.status < PURPLE_UPNP_STATUS_DISCOVERING |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
695 | && (time(NULL) - control_info.lookup_time) > 300) |
| 15884 | 696 | purple_upnp_discover(NULL, NULL); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
697 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
698 | return NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
699 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
700 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
701 | static void |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
702 | looked_up_public_ip_cb(G_GNUC_UNUSED SoupSession *session, SoupMessage *msg, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
703 | gpointer user_data) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
704 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
705 | gchar* temp, *temp2; |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
706 | const gchar *got_data; |
|
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
707 | size_t got_len; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
708 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
709 | if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
710 | return; |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
711 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
712 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
713 | /* extract the ip, or see if there is an error */ |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
714 | got_data = msg->response_body->data; |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
715 | got_len = msg->response_body->length; |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
716 | if((temp = g_strstr_len(got_data, got_len, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
717 | "<NewExternalIPAddress")) == NULL) { |
| 15884 | 718 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
719 | "looked_up_public_ip_cb(): Failed Finding <NewExternalIPAddress\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
720 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
721 | } |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
722 | if(!(temp = g_strstr_len(temp, got_len - (temp - got_data), ">"))) { |
| 15884 | 723 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
724 | "looked_up_public_ip_cb(): Failed In Finding >\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
725 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
726 | } |
|
34239
59b2fc93f2c4
HTTP: migrate purple_util_fetch_url_request to new API for upnp
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
727 | if(!(temp2 = g_strstr_len(temp, got_len - (temp - got_data), "<"))) { |
| 15884 | 728 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
729 | "looked_up_public_ip_cb(): Failed In Finding <\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
730 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
731 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
732 | *temp2 = '\0'; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
733 | |
|
33746
ad7e7fb98db3
Fix a crash when receiving UPnP responses with abnormally long values.
Mark Doliner <mark@kingant.net>
parents:
33560
diff
changeset
|
734 | g_strlcpy(control_info.publicip, temp + 1, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
735 | sizeof(control_info.publicip)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
736 | |
| 15884 | 737 | purple_debug_info("upnp", "NAT Returned IP: %s\n", control_info.publicip); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
738 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
739 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
740 | static void |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
741 | lookup_public_ip() |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
742 | { |
| 15884 | 743 | purple_upnp_generate_action_message_and_send("GetExternalIPAddress", "", |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
744 | looked_up_public_ip_cb, NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
745 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
746 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
747 | /* TODO: This could be exported */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
748 | static const gchar * |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20636
diff
changeset
|
749 | purple_upnp_get_internal_ip(void) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
750 | { |
| 15884 | 751 | if (control_info.status == PURPLE_UPNP_STATUS_DISCOVERED |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32147
diff
changeset
|
752 | && *control_info.internalip) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
753 | return control_info.internalip; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
754 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
755 | /* Trigger another UPnP discovery if 5 minutes have elapsed since the |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
756 | * last one, and it wasn't successful */ |
| 15884 | 757 | if (control_info.status < PURPLE_UPNP_STATUS_DISCOVERING |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
758 | && (time(NULL) - control_info.lookup_time) > 300) |
| 15884 | 759 | purple_upnp_discover(NULL, NULL); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
760 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
761 | return NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
762 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
763 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
764 | static void |
|
14183
bdde840e984c
[gaim-migrate @ 16755]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
765 | looked_up_internal_ip_cb(gpointer data, gint source, const gchar *error_message) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
766 | { |
|
31949
f141aee90086
Fix some closes on invalid fds, which can crash on Windows.
Florian Quèze <florian@instantbird.org>
parents:
31273
diff
changeset
|
767 | if (source != -1) { |
|
33746
ad7e7fb98db3
Fix a crash when receiving UPnP responses with abnormally long values.
Mark Doliner <mark@kingant.net>
parents:
33560
diff
changeset
|
768 | g_strlcpy(control_info.internalip, |
| 15884 | 769 | purple_network_get_local_system_ip(source), |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
770 | sizeof(control_info.internalip)); |
| 15884 | 771 | purple_debug_info("upnp", "Local IP: %s\n", |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
772 | control_info.internalip); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
13793
diff
changeset
|
773 | close(source); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
774 | } else |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27000
diff
changeset
|
775 | purple_debug_error("upnp", "Unable to look up local IP\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
776 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
777 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
778 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
779 | static void |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
780 | lookup_internal_ip() |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
781 | { |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
782 | SoupURI *uri; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
783 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
784 | uri = soup_uri_new(control_info.control_url); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
785 | if (!uri) { |
| 15884 | 786 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
787 | "lookup_internal_ip(): Failed In Parse URL\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
788 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
789 | } |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33774
diff
changeset
|
790 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
791 | if (purple_proxy_connect(NULL, NULL, uri->host, uri->port, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
792 | looked_up_internal_ip_cb, NULL) == NULL) { |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
793 | purple_debug_error( |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
794 | "upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d", |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
795 | uri->host, uri->port); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
796 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
797 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
798 | soup_uri_free(uri); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
799 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
800 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
801 | static void |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
802 | done_port_mapping_cb(G_GNUC_UNUSED SoupSession *session, SoupMessage *msg, |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
803 | gpointer user_data) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
804 | { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
805 | PurpleUPnPMappingAddRemove *ar = user_data; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
806 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
807 | gboolean success = TRUE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
808 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
809 | /* determine if port mapping was a success */ |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
810 | if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) { |
| 15884 | 811 | purple_debug_error("upnp", |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
812 | "purple_upnp_set_port_mapping(): Failed HTTP_OK: %s", |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
813 | msg->reason_phrase); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
814 | success = FALSE; |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
815 | } else { |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
816 | purple_debug_info("upnp", |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
817 | "Successfully completed port mapping operation"); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
818 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
819 | |
|
31273
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
820 | ar->success = success; |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
821 | ar->tima = g_timeout_add(0, fire_ar_cb_async_and_free, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
822 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
823 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
824 | static void |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
825 | do_port_mapping_cb(gboolean has_control_mapping, gpointer data) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
826 | { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
827 | PurpleUPnPMappingAddRemove *ar = data; |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
828 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
829 | if (has_control_mapping) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
830 | gchar action_name[25]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
831 | gchar *action_params; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
832 | if(ar->add) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
833 | const gchar *internal_ip; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
834 | /* get the internal IP */ |
| 15884 | 835 | if(!(internal_ip = purple_upnp_get_internal_ip())) { |
| 836 | purple_debug_error("upnp", | |
| 837 | "purple_upnp_set_port_mapping(): couldn't get local ip\n"); | |
|
31273
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
838 | ar->success = FALSE; |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
839 | ar->tima = g_timeout_add(0, fire_ar_cb_async_and_free, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
840 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
841 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
842 | strncpy(action_name, "AddPortMapping", |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
843 | sizeof(action_name)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
844 | action_params = g_strdup_printf( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
845 | ADD_PORT_MAPPING_PARAMS, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
846 | ar->portmap, ar->protocol, ar->portmap, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
847 | internal_ip); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
848 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
849 | strncpy(action_name, "DeletePortMapping", sizeof(action_name)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
850 | action_params = g_strdup_printf( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
851 | DELETE_PORT_MAPPING_PARAMS, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
852 | ar->portmap, ar->protocol); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
853 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
854 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
855 | ar->msg = purple_upnp_generate_action_message_and_send( |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
856 | action_name, action_params, done_port_mapping_cb, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
857 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
858 | g_free(action_params); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
859 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
860 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
861 | |
|
31273
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
862 | ar->success = FALSE; |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
863 | ar->tima = g_timeout_add(0, fire_ar_cb_async_and_free, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
864 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
865 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
866 | static gboolean |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
867 | fire_port_mapping_failure_cb(gpointer data) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
868 | { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
869 | PurpleUPnPMappingAddRemove *ar = data; |
|
31273
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
870 | |
|
c221db041ca1
upnp: Asynch-ronize the callbacks from UPnP to calling code. Refs #12387
Paul Aurich <darkrain42@pidgin.im>
parents:
31190
diff
changeset
|
871 | ar->tima = 0; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
872 | do_port_mapping_cb(FALSE, data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
873 | return FALSE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
874 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
875 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
876 | void purple_upnp_cancel_port_mapping(PurpleUPnPMappingAddRemove *ar) |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
877 | { |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
878 | GSList *l; |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
879 | |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
880 | /* Remove ar from discovery_callbacks if present; it was inserted after a cb. |
|
30383
030f0d1491e1
Comment spellcheck.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29810
diff
changeset
|
881 | * The same cb may be in the list multiple times, so be careful to remove |
|
030f0d1491e1
Comment spellcheck.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29810
diff
changeset
|
882 | * the one associated with ar. */ |
|
30384
4b8995626b20
Fix a read-after-free from valgrind:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30383
diff
changeset
|
883 | l = discovery_callbacks; |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
884 | while (l) |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
885 | { |
|
30384
4b8995626b20
Fix a read-after-free from valgrind:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30383
diff
changeset
|
886 | GSList *next = l->next; |
|
4b8995626b20
Fix a read-after-free from valgrind:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30383
diff
changeset
|
887 | |
|
4b8995626b20
Fix a read-after-free from valgrind:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30383
diff
changeset
|
888 | if (next && (next->data == ar)) { |
|
4b8995626b20
Fix a read-after-free from valgrind:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30383
diff
changeset
|
889 | discovery_callbacks = g_slist_delete_link(discovery_callbacks, next); |
|
4b8995626b20
Fix a read-after-free from valgrind:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30383
diff
changeset
|
890 | next = l->next; |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
891 | discovery_callbacks = g_slist_delete_link(discovery_callbacks, l); |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
892 | } |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
893 | |
|
30384
4b8995626b20
Fix a read-after-free from valgrind:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30383
diff
changeset
|
894 | l = next; |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
895 | } |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
896 | |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
897 | if (ar->tima > 0) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
898 | g_source_remove(ar->tima); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
899 | |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
900 | soup_session_cancel_message(session, ar->msg, SOUP_STATUS_CANCELLED); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
901 | |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
902 | g_free(ar); |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
903 | } |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
904 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
905 | PurpleUPnPMappingAddRemove * |
| 15884 | 906 | purple_upnp_set_port_mapping(unsigned short portmap, const gchar* protocol, |
| 907 | PurpleUPnPCallback cb, gpointer cb_data) | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
908 | { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
909 | PurpleUPnPMappingAddRemove *ar; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
910 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
911 | ar = g_new0(PurpleUPnPMappingAddRemove, 1); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
912 | ar->cb = cb; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
913 | ar->cb_data = cb_data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
914 | ar->add = TRUE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
915 | ar->portmap = portmap; |
|
33746
ad7e7fb98db3
Fix a crash when receiving UPnP responses with abnormally long values.
Mark Doliner <mark@kingant.net>
parents:
33560
diff
changeset
|
916 | g_strlcpy(ar->protocol, protocol, sizeof(ar->protocol)); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
917 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
918 | /* If we're waiting for a discovery, add to the callbacks list */ |
| 15884 | 919 | if(control_info.status == PURPLE_UPNP_STATUS_DISCOVERING) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
920 | /* TODO: This will fail because when this cb is triggered, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
921 | * the internal IP lookup won't be complete */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
922 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
923 | discovery_callbacks, do_port_mapping_cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
924 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
925 | discovery_callbacks, ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
926 | return ar; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
927 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
928 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
929 | /* If we haven't had a successful UPnP discovery, check if 5 minutes has |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
930 | * elapsed since the last try, try again */ |
| 15884 | 931 | if(control_info.status == PURPLE_UPNP_STATUS_UNDISCOVERED || |
| 932 | (control_info.status == PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
933 | && (time(NULL) - control_info.lookup_time) > 300)) { |
| 15884 | 934 | purple_upnp_discover(do_port_mapping_cb, ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
935 | return ar; |
| 15884 | 936 | } else if(control_info.status == PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
937 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
938 | /* Asynchronously trigger a failed response */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
939 | ar->tima = g_timeout_add(10, fire_port_mapping_failure_cb, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
940 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
941 | /* No need to do anything if nobody expects a response*/ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
942 | g_free(ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
943 | ar = NULL; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
944 | } |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
945 | return ar; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
946 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
947 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
948 | do_port_mapping_cb(TRUE, ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
949 | return ar; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
950 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
951 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
952 | PurpleUPnPMappingAddRemove * |
| 15884 | 953 | purple_upnp_remove_port_mapping(unsigned short portmap, const char* protocol, |
| 954 | PurpleUPnPCallback cb, gpointer cb_data) | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
955 | { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
956 | PurpleUPnPMappingAddRemove *ar; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
957 | |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
958 | ar = g_new0(PurpleUPnPMappingAddRemove, 1); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
959 | ar->cb = cb; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
960 | ar->cb_data = cb_data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
961 | ar->add = FALSE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
962 | ar->portmap = portmap; |
|
33746
ad7e7fb98db3
Fix a crash when receiving UPnP responses with abnormally long values.
Mark Doliner <mark@kingant.net>
parents:
33560
diff
changeset
|
963 | g_strlcpy(ar->protocol, protocol, sizeof(ar->protocol)); |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
964 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
965 | /* If we're waiting for a discovery, add to the callbacks list */ |
| 15884 | 966 | if(control_info.status == PURPLE_UPNP_STATUS_DISCOVERING) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
967 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
968 | discovery_callbacks, do_port_mapping_cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
969 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
970 | discovery_callbacks, ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
971 | return ar; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
972 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
973 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
974 | /* If we haven't had a successful UPnP discovery, check if 5 minutes has |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
975 | * elapsed since the last try, try again */ |
| 15884 | 976 | if(control_info.status == PURPLE_UPNP_STATUS_UNDISCOVERED || |
| 977 | (control_info.status == PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
978 | && (time(NULL) - control_info.lookup_time) > 300)) { |
| 15884 | 979 | purple_upnp_discover(do_port_mapping_cb, ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
980 | return ar; |
| 15884 | 981 | } else if(control_info.status == PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
982 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
983 | /* Asynchronously trigger a failed response */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
984 | ar->tima = g_timeout_add(10, fire_port_mapping_failure_cb, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
985 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
986 | /* No need to do anything if nobody expects a response*/ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
987 | g_free(ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
988 | ar = NULL; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
989 | } |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
990 | return ar; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
991 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
992 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
993 | do_port_mapping_cb(TRUE, ar); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
994 | return ar; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
995 | } |
|
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:
15884
diff
changeset
|
996 | |
|
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:
15884
diff
changeset
|
997 | static void |
|
37489
cbf9ccc715ab
Move everything in libpurple that was using the network-changed signal to use the gio one
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
998 | purple_upnp_network_config_changed_cb(GNetworkMonitor *monitor, gboolean available, gpointer data) |
|
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:
15884
diff
changeset
|
999 | { |
|
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:
15884
diff
changeset
|
1000 | /* Reset the control_info to default values */ |
|
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:
15884
diff
changeset
|
1001 | control_info.status = PURPLE_UPNP_STATUS_UNDISCOVERED; |
|
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:
15884
diff
changeset
|
1002 | g_free(control_info.control_url); |
|
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:
15884
diff
changeset
|
1003 | control_info.control_url = NULL; |
|
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:
15884
diff
changeset
|
1004 | control_info.service_type[0] = '\0'; |
|
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:
15884
diff
changeset
|
1005 | control_info.publicip[0] = '\0'; |
|
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:
15884
diff
changeset
|
1006 | control_info.internalip[0] = '\0'; |
|
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:
15884
diff
changeset
|
1007 | control_info.lookup_time = 0; |
|
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:
15884
diff
changeset
|
1008 | } |
|
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:
15884
diff
changeset
|
1009 | |
|
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:
15884
diff
changeset
|
1010 | 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:
15884
diff
changeset
|
1011 | purple_upnp_init() |
|
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:
15884
diff
changeset
|
1012 | { |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1013 | session = soup_session_new(); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1014 | |
|
37489
cbf9ccc715ab
Move everything in libpurple that was using the network-changed signal to use the gio one
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
1015 | g_signal_connect(g_network_monitor_get_default(), |
|
cbf9ccc715ab
Move everything in libpurple that was using the network-changed signal to use the gio one
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
1016 | "network-changed", |
|
cbf9ccc715ab
Move everything in libpurple that was using the network-changed signal to use the gio one
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
1017 | G_CALLBACK(purple_upnp_network_config_changed_cb), |
|
cbf9ccc715ab
Move everything in libpurple that was using the network-changed signal to use the gio one
Gary Kramlich <grim@reaperworld.com>
parents:
36257
diff
changeset
|
1018 | NULL); |
|
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:
15884
diff
changeset
|
1019 | } |
|
40017
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1020 | |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1021 | void |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1022 | purple_upnp_uninit(void) |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1023 | { |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1024 | soup_session_abort(session); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1025 | g_clear_object(&session); |
|
258b6fab7e79
Convert UPnP mappings to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
1026 | } |