Sat, 31 Mar 2007 20:33:54 +0000
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.
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
1 | /** |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
2 | * @file upnp.c UPnP Implementation |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
3 | * @ingroup core |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
4 | * |
| 15884 | 5 | * purple |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
6 | * |
| 15884 | 7 | * 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
|
8 | * 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
|
9 | * source distribution. |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
10 | * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
11 | * 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
|
12 | * 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
|
13 | * the Free Software Foundation; either version 2 of the License, or |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
14 | * (at your option) any later version. |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
15 | * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
16 | * 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
|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
19 | * GNU General Public License for more details. |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
20 | * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
21 | * 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
|
22 | * along with this program; if not, write to the Free Software |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
24 | */ |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
25 | #include "internal.h" |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
26 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
27 | #include "upnp.h" |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
28 | |
|
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
|
29 | #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
|
30 | #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
|
31 | #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
|
32 | #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
|
33 | #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
|
34 | #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
|
35 | #include "xmlnode.h" |
|
11195
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 | /*************************************************************** |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
38 | ** General Defines * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
39 | ****************************************************************/ |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
40 | #define HTTP_OK "200 OK" |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
41 | #define DEFAULT_HTTP_PORT 80 |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
42 | #define DISCOVERY_TIMEOUT 1000 |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
43 | |
|
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 | ** Discovery/Description Defines * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
46 | ****************************************************************/ |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
47 | #define NUM_UDP_ATTEMPTS 2 |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
48 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
49 | /* Address and port of an SSDP request used for discovery */ |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
50 | #define HTTPMU_HOST_ADDRESS "239.255.255.250" |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
51 | #define HTTPMU_HOST_PORT 1900 |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
52 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
53 | #define SEARCH_REQUEST_DEVICE "urn:schemas-upnp-org:service:%s" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
54 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
55 | #define SEARCH_REQUEST_STRING \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
56 | "M-SEARCH * HTTP/1.1\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
57 | "MX: 2\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
58 | "HOST: 239.255.255.250:1900\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
59 | "MAN: \"ssdp:discover\"\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
60 | "ST: urn:schemas-upnp-org:service:%s\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
61 | "\r\n" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
62 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
63 | #define WAN_IP_CONN_SERVICE "WANIPConnection:1" |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
64 | #define WAN_PPP_CONN_SERVICE "WANPPPConnection:1" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
65 | |
|
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 | ** Action Defines * |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
68 | *******************************************************************/ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
69 | #define HTTP_HEADER_ACTION \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
70 | "POST /%s HTTP/1.1\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
71 | "HOST: %s:%d\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
72 | "SOAPACTION: \"urn:schemas-upnp-org:service:%s#%s\"\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
73 | "CONTENT-TYPE: text/xml ; charset=\"utf-8\"\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
74 | "CONTENT-LENGTH: %" G_GSIZE_FORMAT "\r\n\r\n" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
75 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
76 | #define SOAP_ACTION \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
77 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
78 | "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" " \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
79 | "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
80 | "<s:Body>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
81 | "<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
|
82 | "%s" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
83 | "</u:%s>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
84 | "</s:Body>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
85 | "</s:Envelope>" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
86 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
87 | #define PORT_MAPPING_LEASE_TIME "0" |
| 15884 | 88 | #define PORT_MAPPING_DESCRIPTION "PURPLE_UPNP_PORT_FORWARD" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
89 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
90 | #define ADD_PORT_MAPPING_PARAMS \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
91 | "<NewRemoteHost></NewRemoteHost>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
92 | "<NewExternalPort>%i</NewExternalPort>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
93 | "<NewProtocol>%s</NewProtocol>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
94 | "<NewInternalPort>%i</NewInternalPort>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
95 | "<NewInternalClient>%s</NewInternalClient>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
96 | "<NewEnabled>1</NewEnabled>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
97 | "<NewPortMappingDescription>" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
98 | PORT_MAPPING_DESCRIPTION \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
99 | "</NewPortMappingDescription>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
100 | "<NewLeaseDuration>" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
101 | PORT_MAPPING_LEASE_TIME \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
102 | "</NewLeaseDuration>\r\n" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
103 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
104 | #define DELETE_PORT_MAPPING_PARAMS \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
105 | "<NewRemoteHost></NewRemoteHost>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
106 | "<NewExternalPort>%i</NewExternalPort>\r\n" \ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
107 | "<NewProtocol>%s</NewProtocol>\r\n" |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
108 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
109 | typedef enum { |
| 15884 | 110 | PURPLE_UPNP_STATUS_UNDISCOVERED = -1, |
| 111 | PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER, | |
| 112 | PURPLE_UPNP_STATUS_DISCOVERING, | |
| 113 | PURPLE_UPNP_STATUS_DISCOVERED | |
| 114 | } PurpleUPnPStatus; | |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
115 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
116 | typedef struct { |
| 15884 | 117 | PurpleUPnPStatus status; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
118 | gchar* control_url; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
119 | gchar service_type[20]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
120 | char publicip[16]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
121 | char internalip[16]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
122 | time_t lookup_time; |
| 15884 | 123 | } PurpleUPnPControlInfo; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
124 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
125 | typedef struct { |
| 15884 | 126 | guint inpa; /* purple_input_add handle */ |
| 127 | guint tima; /* purple_timeout_add handle */ | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
128 | int fd; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
129 | struct sockaddr_in server; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
130 | gchar service_type[25]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
131 | int retry_count; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
132 | gchar *full_url; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
133 | } UPnPDiscoveryData; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
134 | |
|
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
|
135 | struct _UPnPMappingAddRemove |
|
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
|
136 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
137 | unsigned short portmap; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
138 | gchar protocol[4]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
139 | gboolean add; |
| 15884 | 140 | PurpleUPnPCallback cb; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
141 | gpointer cb_data; |
| 15884 | 142 | guint tima; /* purple_timeout_add handle */ |
| 143 | PurpleUtilFetchUrlData *gfud; | |
|
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
|
144 | }; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
145 | |
| 15884 | 146 | static PurpleUPnPControlInfo control_info = { |
| 147 | PURPLE_UPNP_STATUS_UNDISCOVERED, | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
148 | NULL, "\0", "\0", "\0", 0}; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
149 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
150 | static GSList *discovery_callbacks = NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
151 | |
| 15884 | 152 | static void purple_upnp_discover_send_broadcast(UPnPDiscoveryData *dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
153 | static void lookup_public_ip(void); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
154 | static void lookup_internal_ip(void); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
155 | |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
156 | static void |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
157 | fire_discovery_callbacks(gboolean success) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
158 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
159 | while(discovery_callbacks) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
160 | gpointer data; |
| 15884 | 161 | PurpleUPnPCallback cb = discovery_callbacks->data; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
162 | discovery_callbacks = g_slist_remove(discovery_callbacks, cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
163 | data = discovery_callbacks->data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
164 | discovery_callbacks = g_slist_remove(discovery_callbacks, data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
165 | cb(success, data); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
166 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
167 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
168 | |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
169 | static gboolean |
| 15884 | 170 | purple_upnp_compare_device(const xmlnode* device, const gchar* deviceType) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
171 | { |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
172 | xmlnode* deviceTypeNode = xmlnode_get_child(device, "deviceType"); |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
173 | char *tmp; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
174 | gboolean ret; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
175 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
176 | if(deviceTypeNode == NULL) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
177 | return FALSE; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
178 | } |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
179 | |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
180 | tmp = xmlnode_get_data(deviceTypeNode); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
181 | ret = !g_ascii_strcasecmp(tmp, deviceType); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
182 | g_free(tmp); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
183 | |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
184 | return ret; |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
185 | } |
|
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
186 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
187 | static gboolean |
| 15884 | 188 | purple_upnp_compare_service(const xmlnode* service, const gchar* serviceType) |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
189 | { |
| 13793 | 190 | xmlnode* serviceTypeNode; |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
191 | char *tmp; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
192 | gboolean ret; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
193 | |
| 13793 | 194 | if(service == NULL) { |
| 195 | return FALSE; | |
| 196 | } | |
| 197 | ||
| 198 | serviceTypeNode = xmlnode_get_child(service, "serviceType"); | |
| 199 | ||
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
200 | if(serviceTypeNode == NULL) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
201 | return FALSE; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
202 | } |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
203 | |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
204 | tmp = xmlnode_get_data(serviceTypeNode); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
205 | ret = !g_ascii_strcasecmp(tmp, serviceType); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
206 | g_free(tmp); |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
207 | |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
208 | return ret; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
209 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
210 | |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
211 | static gchar* |
| 15884 | 212 | purple_upnp_parse_description_response(const gchar* httpResponse, gsize len, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
213 | const gchar* httpURL, const gchar* serviceType) |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
214 | { |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
215 | gchar *xmlRoot, *baseURL, *controlURL, *service; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
216 | xmlnode *xmlRootNode, *serviceTypeNode, *controlURLNode, *baseURLNode; |
|
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
217 | char *tmp; |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
218 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
219 | /* make sure we have a valid http response */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
220 | if(g_strstr_len(httpResponse, len, HTTP_OK) == NULL) { |
| 15884 | 221 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
222 | "parse_description_response(): Failed In HTTP_OK\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
223 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
224 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
225 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
226 | /* find the root of the xml document */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
227 | if((xmlRoot = g_strstr_len(httpResponse, len, "<root")) == NULL) { |
| 15884 | 228 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
229 | "parse_description_response(): Failed finding root\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
230 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
231 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
232 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
233 | /* create the xml root node */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
234 | if((xmlRootNode = xmlnode_from_str(xmlRoot, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
235 | len - (xmlRoot - httpResponse))) == NULL) { |
| 15884 | 236 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
237 | "parse_description_response(): Could not parse xml root node\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
238 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
239 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
240 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
241 | /* get the baseURL of the device */ |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
242 | if((baseURLNode = xmlnode_get_child(xmlRootNode, "URLBase")) != NULL) { |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
243 | baseURL = xmlnode_get_data(baseURLNode); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
244 | } else { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
245 | baseURL = g_strdup(httpURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
246 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
247 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
248 | /* 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
|
249 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
250 | /* get urn:schemas-upnp-org:device:InternetGatewayDevice:1 and its devicelist */ |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
251 | serviceTypeNode = xmlnode_get_child(xmlRootNode, "device"); |
| 15884 | 252 | while(!purple_upnp_compare_device(serviceTypeNode, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
253 | "urn:schemas-upnp-org:device:InternetGatewayDevice:1") && |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
254 | serviceTypeNode != NULL) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
255 | serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
256 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
257 | if(serviceTypeNode == NULL) { |
| 15884 | 258 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
259 | "parse_description_response(): could not get serviceTypeNode 1\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
260 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
261 | xmlnode_free(xmlRootNode); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
262 | return NULL; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
263 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
264 | serviceTypeNode = xmlnode_get_child(serviceTypeNode, "deviceList"); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
265 | if(serviceTypeNode == NULL) { |
| 15884 | 266 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
267 | "parse_description_response(): could not get serviceTypeNode 2\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
268 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
269 | xmlnode_free(xmlRootNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
270 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
271 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
272 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
273 | /* get urn:schemas-upnp-org:device:WANDevice:1 and its devicelist */ |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
274 | serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device"); |
| 15884 | 275 | while(!purple_upnp_compare_device(serviceTypeNode, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
276 | "urn:schemas-upnp-org:device:WANDevice:1") && |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
277 | serviceTypeNode != NULL) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
278 | serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
279 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
280 | if(serviceTypeNode == NULL) { |
| 15884 | 281 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
282 | "parse_description_response(): could not get serviceTypeNode 3\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
283 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
284 | xmlnode_free(xmlRootNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
285 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
286 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
287 | serviceTypeNode = xmlnode_get_child(serviceTypeNode, "deviceList"); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
288 | if(serviceTypeNode == NULL) { |
| 15884 | 289 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
290 | "parse_description_response(): could not get serviceTypeNode 4\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
291 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
292 | xmlnode_free(xmlRootNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
293 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
294 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
295 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
296 | /* get urn:schemas-upnp-org:device:WANConnectionDevice:1 and its servicelist */ |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
297 | serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device"); |
| 15884 | 298 | while(serviceTypeNode && !purple_upnp_compare_device(serviceTypeNode, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
299 | "urn:schemas-upnp-org:device:WANConnectionDevice:1")) { |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
300 | serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
301 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
302 | if(serviceTypeNode == NULL) { |
| 15884 | 303 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
304 | "parse_description_response(): could not get serviceTypeNode 5\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
305 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
306 | xmlnode_free(xmlRootNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
307 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
308 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
309 | serviceTypeNode = xmlnode_get_child(serviceTypeNode, "serviceList"); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
310 | if(serviceTypeNode == NULL) { |
| 15884 | 311 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
312 | "parse_description_response(): could not get serviceTypeNode 6\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
313 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
314 | xmlnode_free(xmlRootNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
315 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
316 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
317 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
318 | /* get the serviceType variable passed to this function */ |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
319 | service = g_strdup_printf(SEARCH_REQUEST_DEVICE, serviceType); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
320 | serviceTypeNode = xmlnode_get_child(serviceTypeNode, "service"); |
| 15884 | 321 | while(!purple_upnp_compare_service(serviceTypeNode, service) && |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
322 | serviceTypeNode != NULL) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
323 | serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
324 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
325 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
326 | g_free(service); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
327 | if(serviceTypeNode == NULL) { |
| 15884 | 328 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
329 | "parse_description_response(): could not get serviceTypeNode 7\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
330 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
331 | xmlnode_free(xmlRootNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
332 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
333 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
334 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
335 | /* get the controlURL of the service */ |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
336 | if((controlURLNode = xmlnode_get_child(serviceTypeNode, |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
337 | "controlURL")) == NULL) { |
| 15884 | 338 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
339 | "parse_description_response(): Could not find controlURL\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
340 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
341 | xmlnode_free(xmlRootNode); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
342 | return NULL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
343 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
344 | |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
345 | tmp = xmlnode_get_data(controlURLNode); |
| 15884 | 346 | if(baseURL && !purple_str_has_prefix(tmp, "http://") && |
| 347 | !purple_str_has_prefix(tmp, "HTTP://")) { | |
| 15348 | 348 | /* Handle absolute paths in a relative URL. This probably |
| 349 | * belongs in util.c. */ | |
| 350 | if (tmp[0] == '/') { | |
| 351 | size_t length; | |
| 352 | const char *path, *start = strstr(baseURL, "://"); | |
| 353 | start = start ? start + 3 : baseURL; | |
| 354 | path = strchr(start, '/'); | |
| 355 | length = path ? path - baseURL : strlen(baseURL); | |
| 15683 | 356 | controlURL = g_strdup_printf("%.*s%s", (int)length, baseURL, tmp); |
| 15348 | 357 | } else { |
| 358 | controlURL = g_strdup_printf("%s%s", baseURL, tmp); | |
| 359 | } | |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
360 | g_free(tmp); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
361 | }else{ |
|
13622
9311eed487c7
[gaim-migrate @ 16007]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
362 | controlURL = tmp; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
363 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
364 | g_free(baseURL); |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
365 | xmlnode_free(xmlRootNode); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
366 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
367 | return controlURL; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
368 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
369 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
370 | static void |
| 15884 | 371 | upnp_parse_description_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
372 | const gchar *httpResponse, gsize len, const gchar *error_message) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
373 | { |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
374 | UPnPDiscoveryData *dd = user_data; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
375 | gchar *control_url = NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
376 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
377 | if (len > 0) |
| 15884 | 378 | control_url = purple_upnp_parse_description_response( |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
379 | httpResponse, len, dd->full_url, dd->service_type); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
380 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
381 | g_free(dd->full_url); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
382 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
383 | if(control_url == NULL) { |
| 15884 | 384 | purple_debug_error("upnp", |
| 385 | "purple_upnp_parse_description(): control URL is NULL\n"); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
386 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
387 | |
| 15884 | 388 | control_info.status = control_url ? PURPLE_UPNP_STATUS_DISCOVERED |
| 389 | : PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER; | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
390 | control_info.lookup_time = time(NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
391 | control_info.control_url = control_url; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
392 | strncpy(control_info.service_type, dd->service_type, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
393 | sizeof(control_info.service_type)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
394 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
395 | fire_discovery_callbacks(control_url != NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
396 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
397 | /* Look up the public and internal IPs */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
398 | if(control_url != NULL) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
399 | lookup_public_ip(); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
400 | lookup_internal_ip(); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
401 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
402 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
403 | g_free(dd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
404 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
405 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
406 | static void |
| 15884 | 407 | purple_upnp_parse_description(const gchar* descriptionURL, UPnPDiscoveryData *dd) |
|
12909
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 | gchar* httpRequest; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
410 | gchar* descriptionXMLAddress; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
411 | gchar* descriptionAddress; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
412 | int port = 0; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
413 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
414 | /* parse the 4 above variables out of the descriptionURL |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
415 | example description URL: http://192.168.1.1:5678/rootDesc.xml */ |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
416 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
417 | /* parse the url into address, port, path variables */ |
| 15884 | 418 | if(!purple_url_parse(descriptionURL, &descriptionAddress, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
419 | &port, &descriptionXMLAddress, NULL, NULL)) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
420 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
421 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
422 | if(port == 0 || port == -1) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
423 | port = DEFAULT_HTTP_PORT; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
424 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
425 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
426 | /* for example... |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
427 | GET /rootDesc.xml HTTP/1.1\r\nHost: 192.168.1.1:5678\r\n\r\n */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
428 | httpRequest = g_strdup_printf( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
429 | "GET /%s HTTP/1.1\r\n" |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
430 | "Connection: close\r\n" |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
431 | "Host: %s:%d\r\n\r\n", |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
432 | descriptionXMLAddress, descriptionAddress, port); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
433 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
434 | g_free(descriptionXMLAddress); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
435 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
436 | dd->full_url = g_strdup_printf("http://%s:%d", |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
437 | descriptionAddress, port); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13097
diff
changeset
|
438 | g_free(descriptionAddress); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
439 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
440 | /* Remove the timeout because everything it is waiting for has |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
441 | * successfully completed */ |
| 15884 | 442 | purple_timeout_remove(dd->tima); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
443 | dd->tima = 0; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
444 | |
| 15884 | 445 | purple_util_fetch_url_request(descriptionURL, TRUE, NULL, TRUE, httpRequest, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
446 | TRUE, upnp_parse_description_cb, dd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
447 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
448 | g_free(httpRequest); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
449 | |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
450 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
451 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
452 | static void |
| 15884 | 453 | 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
|
454 | UPnPDiscoveryData *dd) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
455 | { |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
456 | gchar* startDescURL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
457 | gchar* endDescURL; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
458 | gchar* descURL; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
459 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
460 | if(g_strstr_len(buf, buf_len, HTTP_OK) == NULL) { |
| 15884 | 461 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
462 | "parse_discover_response(): Failed In HTTP_OK\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
463 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
464 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
465 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
466 | if((startDescURL = g_strstr_len(buf, buf_len, "http://")) == NULL) { |
| 15884 | 467 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
468 | "parse_discover_response(): Failed In finding http://\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
469 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
470 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
471 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
472 | endDescURL = g_strstr_len(startDescURL, buf_len - (startDescURL - buf), |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
473 | "\r"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
474 | if(endDescURL == NULL) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
475 | endDescURL = g_strstr_len(startDescURL, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
476 | buf_len - (startDescURL - buf), "\n"); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
477 | if(endDescURL == NULL) { |
| 15884 | 478 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
479 | "parse_discover_response(): Failed In endDescURL\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
480 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
481 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
482 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
483 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
484 | /* XXX: I'm not sure how this could ever happen */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
485 | if(endDescURL == startDescURL) { |
| 15884 | 486 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
487 | "parse_discover_response(): endDescURL == startDescURL\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
488 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
489 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
490 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
491 | descURL = g_strndup(startDescURL, endDescURL - startDescURL); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
492 | |
| 15884 | 493 | purple_upnp_parse_description(descURL, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
494 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
495 | g_free(descURL); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
496 | |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
497 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
498 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
499 | static gboolean |
| 15884 | 500 | purple_upnp_discover_timeout(gpointer data) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
501 | { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
502 | UPnPDiscoveryData* dd = data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
503 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
504 | if (dd->inpa) |
| 15884 | 505 | purple_input_remove(dd->inpa); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
506 | dd->inpa = 0; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
507 | dd->tima = 0; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
508 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
509 | if (dd->retry_count < NUM_UDP_ATTEMPTS) { |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
510 | /* 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
|
511 | dd->retry_count++; |
| 15884 | 512 | purple_upnp_discover_send_broadcast(dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
513 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
514 | if (dd->fd) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
515 | close(dd->fd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
516 | |
| 15884 | 517 | control_info.status = PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
518 | control_info.lookup_time = time(NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
519 | control_info.service_type[0] = '\0'; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
520 | g_free(control_info.control_url); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
521 | control_info.control_url = NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
522 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
523 | fire_discovery_callbacks(FALSE); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
524 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
525 | g_free(dd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
526 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
527 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
528 | return FALSE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
529 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
530 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
531 | static void |
| 15884 | 532 | 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
|
533 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
534 | int len; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
535 | UPnPDiscoveryData *dd = data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
536 | gchar buf[65536]; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
537 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
538 | do { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
539 | len = recv(dd->fd, buf, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
540 | sizeof(buf) - 1, 0); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
541 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
542 | if(len > 0) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
543 | buf[len] = '\0'; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
544 | break; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
545 | } else if(errno != EINTR) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
546 | /* We'll either get called again, or time out */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
547 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
548 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
549 | } while (errno == EINTR); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
550 | |
| 15884 | 551 | purple_input_remove(dd->inpa); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
552 | dd->inpa = 0; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
553 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
554 | close(dd->fd); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
555 | dd->fd = 0; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
556 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
557 | /* parse the response, and see if it was a success */ |
| 15884 | 558 | purple_upnp_parse_discover_response(buf, len, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
559 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
560 | /* We'll either time out or continue successfully */ |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
561 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
562 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
563 | static void |
| 15884 | 564 | purple_upnp_discover_send_broadcast(UPnPDiscoveryData *dd) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
565 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
566 | gchar *sendMessage = NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
567 | gsize totalSize; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
568 | gboolean sentSuccess; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
569 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
570 | /* because we are sending over UDP, if there is a failure |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
571 | we should retry the send NUM_UDP_ATTEMPTS times. Also, |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
572 | try different requests for WANIPConnection and WANPPPConnection*/ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
573 | for(; dd->retry_count < NUM_UDP_ATTEMPTS; dd->retry_count++) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13097
diff
changeset
|
574 | sentSuccess = FALSE; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
575 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
576 | if((dd->retry_count % 2) == 0) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
577 | strncpy(dd->service_type, WAN_IP_CONN_SERVICE, sizeof(dd->service_type)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
578 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
579 | strncpy(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
|
580 | } |
|
11213
837e1970689d
[gaim-migrate @ 13344]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11204
diff
changeset
|
581 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
582 | 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
|
583 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
584 | totalSize = strlen(sendMessage); |
|
11213
837e1970689d
[gaim-migrate @ 13344]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11204
diff
changeset
|
585 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
586 | do { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
587 | if(sendto(dd->fd, sendMessage, totalSize, 0, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
588 | (struct sockaddr*) &(dd->server), |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
589 | sizeof(struct sockaddr_in) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
590 | ) == totalSize) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
591 | sentSuccess = TRUE; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
592 | break; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
593 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13097
diff
changeset
|
594 | } while (errno == EINTR || errno == EAGAIN); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
595 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
596 | g_free(sendMessage); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
597 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
598 | if(sentSuccess) { |
| 15884 | 599 | dd->tima = purple_timeout_add(DISCOVERY_TIMEOUT, |
| 600 | purple_upnp_discover_timeout, dd); | |
| 601 | dd->inpa = purple_input_add(dd->fd, PURPLE_INPUT_READ, | |
| 602 | purple_upnp_discover_udp_read, dd); | |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
603 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
604 | return; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
605 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
606 | } |
|
11213
837e1970689d
[gaim-migrate @ 13344]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11204
diff
changeset
|
607 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
608 | /* 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
|
609 | * doesn't get called before the original function returns */ |
| 15884 | 610 | purple_timeout_add(10, purple_upnp_discover_timeout, dd); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
611 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
612 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
613 | void |
| 15884 | 614 | purple_upnp_discover(PurpleUPnPCallback cb, gpointer cb_data) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
615 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
616 | /* Socket Setup Variables */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
617 | int sock; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
618 | struct hostent* hp; |
|
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 | /* UDP RECEIVE VARIABLES */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
621 | UPnPDiscoveryData *dd; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
622 | |
| 15884 | 623 | if (control_info.status == PURPLE_UPNP_STATUS_DISCOVERING) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
624 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
625 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
626 | discovery_callbacks, cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
627 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
628 | discovery_callbacks, cb_data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
629 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
630 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
631 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
632 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
633 | dd = g_new0(UPnPDiscoveryData, 1); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
634 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
635 | discovery_callbacks = g_slist_append(discovery_callbacks, cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
636 | discovery_callbacks = g_slist_append(discovery_callbacks, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
637 | cb_data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
638 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
639 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
640 | /* Set up the sockets */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
641 | sock = socket(AF_INET, SOCK_DGRAM, 0); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
642 | if(sock == -1) { |
| 15884 | 643 | purple_debug_error("upnp", |
| 644 | "purple_upnp_discover(): Failed In sock creation\n"); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
645 | /* Short circuit the retry attempts */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
646 | dd->retry_count = NUM_UDP_ATTEMPTS; |
| 15884 | 647 | purple_timeout_add(10, purple_upnp_discover_timeout, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
648 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
649 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
650 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
651 | dd->fd = sock; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
652 | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
653 | /* TODO: Non-blocking! */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
654 | if((hp = gethostbyname(HTTPMU_HOST_ADDRESS)) == NULL) { |
| 15884 | 655 | purple_debug_error("upnp", |
| 656 | "purple_upnp_discover(): Failed In gethostbyname\n"); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
657 | /* Short circuit the retry attempts */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
658 | dd->retry_count = NUM_UDP_ATTEMPTS; |
| 15884 | 659 | purple_timeout_add(10, purple_upnp_discover_timeout, dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
660 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
661 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
662 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
663 | memset(&(dd->server), 0, sizeof(struct sockaddr)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
664 | dd->server.sin_family = AF_INET; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
665 | 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
|
666 | dd->server.sin_port = htons(HTTPMU_HOST_PORT); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
667 | |
| 15884 | 668 | control_info.status = PURPLE_UPNP_STATUS_DISCOVERING; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
669 | |
| 15884 | 670 | purple_upnp_discover_send_broadcast(dd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
671 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
672 | |
| 15884 | 673 | static PurpleUtilFetchUrlData* |
| 674 | purple_upnp_generate_action_message_and_send(const gchar* actionName, | |
| 675 | const gchar* actionParams, PurpleUtilFetchUrlCallback cb, | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
676 | gpointer cb_data) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
677 | { |
| 15884 | 678 | PurpleUtilFetchUrlData* gfud; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
679 | gchar* soapMessage; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
680 | gchar* totalSendMessage; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
681 | gchar* pathOfControl; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
682 | gchar* addressOfControl; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
683 | int port = 0; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
684 | |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
685 | /* parse the url into address, port, path variables */ |
| 15884 | 686 | if(!purple_url_parse(control_info.control_url, &addressOfControl, |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
687 | &port, &pathOfControl, NULL, NULL)) { |
| 15884 | 688 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
689 | "generate_action_message_and_send(): Failed In Parse URL\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
690 | /* XXX: This should probably be async */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
691 | if(cb) |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
692 | cb(NULL, cb_data, NULL, 0, NULL); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
693 | } |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
694 | if(port == 0 || port == -1) { |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
695 | port = DEFAULT_HTTP_PORT; |
|
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
696 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
697 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
698 | /* set the soap message */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
699 | soapMessage = g_strdup_printf(SOAP_ACTION, actionName, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
700 | control_info.service_type, actionParams, actionName); |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
701 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
702 | /* set the HTTP Header, and append the body to it */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
703 | totalSendMessage = g_strdup_printf(HTTP_HEADER_ACTION "%s", |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
704 | pathOfControl, addressOfControl, port, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
705 | control_info.service_type, actionName, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
706 | strlen(soapMessage), soapMessage); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
707 | g_free(pathOfControl); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
708 | g_free(soapMessage); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
709 | |
| 15884 | 710 | gfud = purple_util_fetch_url_request(control_info.control_url, FALSE, NULL, TRUE, |
|
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
|
711 | totalSendMessage, TRUE, cb, cb_data); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
712 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
713 | g_free(totalSendMessage); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
714 | g_free(addressOfControl); |
|
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
|
715 | |
|
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
|
716 | return gfud; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
717 | } |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
718 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
719 | const gchar * |
| 15884 | 720 | purple_upnp_get_public_ip() |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
721 | { |
| 15884 | 722 | if (control_info.status == PURPLE_UPNP_STATUS_DISCOVERED |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
723 | && control_info.publicip |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
724 | && strlen(control_info.publicip) > 0) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
725 | return control_info.publicip; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
726 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
727 | /* Trigger another UPnP discovery if 5 minutes have elapsed since the |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
728 | * last one, and it wasn't successful */ |
| 15884 | 729 | if (control_info.status < PURPLE_UPNP_STATUS_DISCOVERING |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
730 | && (time(NULL) - control_info.lookup_time) > 300) |
| 15884 | 731 | purple_upnp_discover(NULL, NULL); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
732 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
733 | return NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
734 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
735 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
736 | static void |
| 15884 | 737 | looked_up_public_ip_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
738 | const gchar *httpResponse, gsize len, const gchar *error_message) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
739 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
740 | gchar* temp, *temp2; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
741 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
742 | if ((error_message != NULL) || (httpResponse == NULL)) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
743 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
744 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
745 | /* extract the ip, or see if there is an error */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
746 | if((temp = g_strstr_len(httpResponse, len, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
747 | "<NewExternalIPAddress")) == NULL) { |
| 15884 | 748 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
749 | "looked_up_public_ip_cb(): Failed Finding <NewExternalIPAddress\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
750 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
751 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
752 | if(!(temp = g_strstr_len(temp, len - (temp - httpResponse), ">"))) { |
| 15884 | 753 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
754 | "looked_up_public_ip_cb(): Failed In Finding >\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
755 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
756 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
757 | if(!(temp2 = g_strstr_len(temp, len - (temp - httpResponse), "<"))) { |
| 15884 | 758 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
759 | "looked_up_public_ip_cb(): Failed In Finding <\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
760 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
761 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
762 | *temp2 = '\0'; |
|
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 | strncpy(control_info.publicip, temp + 1, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
765 | sizeof(control_info.publicip)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
766 | |
| 15884 | 767 | 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
|
768 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
769 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
770 | static void |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
771 | lookup_public_ip() |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
772 | { |
| 15884 | 773 | purple_upnp_generate_action_message_and_send("GetExternalIPAddress", "", |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
774 | looked_up_public_ip_cb, NULL); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
775 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
776 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
777 | /* TODO: This could be exported */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
778 | static const gchar * |
| 15884 | 779 | purple_upnp_get_internal_ip() |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
780 | { |
| 15884 | 781 | if (control_info.status == PURPLE_UPNP_STATUS_DISCOVERED |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
782 | && control_info.internalip |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
783 | && strlen(control_info.internalip) > 0) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
784 | return control_info.internalip; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
785 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
786 | /* Trigger another UPnP discovery if 5 minutes have elapsed since the |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
787 | * last one, and it wasn't successful */ |
| 15884 | 788 | if (control_info.status < PURPLE_UPNP_STATUS_DISCOVERING |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
789 | && (time(NULL) - control_info.lookup_time) > 300) |
| 15884 | 790 | purple_upnp_discover(NULL, NULL); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
791 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
792 | return NULL; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
793 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
794 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
795 | static void |
|
14183
bdde840e984c
[gaim-migrate @ 16755]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
796 | 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
|
797 | { |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
13793
diff
changeset
|
798 | if (source) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
799 | strncpy(control_info.internalip, |
| 15884 | 800 | purple_network_get_local_system_ip(source), |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
801 | sizeof(control_info.internalip)); |
| 15884 | 802 | purple_debug_info("upnp", "Local IP: %s\n", |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
803 | control_info.internalip); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
13793
diff
changeset
|
804 | close(source); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
805 | } else |
| 15884 | 806 | purple_debug_info("upnp", "Unable to look up local IP\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
807 | |
|
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 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
810 | static void |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
811 | lookup_internal_ip() |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
812 | { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
813 | gchar* addressOfControl; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
814 | int port = 0; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
815 | |
| 15884 | 816 | if(!purple_url_parse(control_info.control_url, &addressOfControl, &port, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
817 | NULL, NULL, NULL)) { |
| 15884 | 818 | purple_debug_error("upnp", |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14552
diff
changeset
|
819 | "lookup_internal_ip(): Failed In Parse URL\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
820 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
821 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
822 | if(port == 0 || port == -1) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
823 | port = DEFAULT_HTTP_PORT; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
824 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
825 | |
| 15884 | 826 | if(purple_proxy_connect(NULL, NULL, addressOfControl, port, |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
827 | looked_up_internal_ip_cb, NULL) == NULL) |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
13793
diff
changeset
|
828 | { |
| 15884 | 829 | purple_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d\n", |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
830 | addressOfControl, port); |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
831 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
832 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
833 | g_free(addressOfControl); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
834 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
835 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
836 | static void |
| 15884 | 837 | done_port_mapping_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
838 | const gchar *httpResponse, gsize len, const gchar *error_message) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
839 | { |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
840 | UPnPMappingAddRemove *ar = user_data; |
|
12909
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 | gboolean success = TRUE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
843 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
844 | /* determine if port mapping was a success */ |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
845 | if ((error_message != NULL) || (httpResponse == NULL) || |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
846 | (g_strstr_len(httpResponse, len, HTTP_OK) == NULL)) |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
847 | { |
| 15884 | 848 | purple_debug_error("upnp", |
| 849 | "purple_upnp_set_port_mapping(): Failed HTTP_OK\n%s\n", | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
850 | httpResponse ? httpResponse : "(null)"); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
851 | success = FALSE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
852 | } else |
| 15884 | 853 | purple_debug_info("upnp", "Successfully completed port mapping operation\n"); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
854 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
855 | if (ar->cb) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
856 | ar->cb(success, ar->cb_data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
857 | g_free(ar); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
858 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
859 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
860 | static void |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
861 | do_port_mapping_cb(gboolean has_control_mapping, gpointer data) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
862 | { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
863 | UPnPMappingAddRemove *ar = data; |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
864 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
865 | if (has_control_mapping) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
866 | gchar action_name[25]; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
867 | gchar *action_params; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
868 | if(ar->add) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
869 | const gchar *internal_ip; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
870 | /* get the internal IP */ |
| 15884 | 871 | if(!(internal_ip = purple_upnp_get_internal_ip())) { |
| 872 | purple_debug_error("upnp", | |
| 873 | "purple_upnp_set_port_mapping(): couldn't get local ip\n"); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
874 | /* UGLY */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
875 | if (ar->cb) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
876 | ar->cb(FALSE, ar->cb_data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
877 | g_free(ar); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
878 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
879 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
880 | strncpy(action_name, "AddPortMapping", |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
881 | sizeof(action_name)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
882 | action_params = g_strdup_printf( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
883 | ADD_PORT_MAPPING_PARAMS, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
884 | ar->portmap, ar->protocol, ar->portmap, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
885 | internal_ip); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
886 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
887 | strncpy(action_name, "DeletePortMapping", sizeof(action_name)); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
888 | action_params = g_strdup_printf( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
889 | DELETE_PORT_MAPPING_PARAMS, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
890 | ar->portmap, ar->protocol); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
891 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
892 | |
| 15884 | 893 | ar->gfud = purple_upnp_generate_action_message_and_send(action_name, |
|
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
|
894 | action_params, done_port_mapping_cb, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
895 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
896 | g_free(action_params); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
897 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
898 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
899 | |
|
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
900 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
901 | if (ar->cb) |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
902 | ar->cb(FALSE, ar->cb_data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
903 | g_free(ar); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
904 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
905 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
906 | static gboolean |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
907 | fire_port_mapping_failure_cb(gpointer data) |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
908 | { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
909 | do_port_mapping_cb(FALSE, data); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
910 | return FALSE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
911 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
912 | |
| 15884 | 913 | void purple_upnp_cancel_port_mapping(UPnPMappingAddRemove *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
|
914 | { |
|
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
|
915 | 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
|
916 | |
|
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
|
917 | /* Remove ar from discovery_callbacks if present; it was inserted after a cb. |
|
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
|
918 | * The same cb may be in the list multple times, so be careful to remove the one assocaited with 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
|
919 | l = discovery_callbacks; |
|
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
|
920 | 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
|
921 | { |
|
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
|
922 | if (l->next && (l->next->data == 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
|
923 | discovery_callbacks = g_slist_delete_link(discovery_callbacks, l->next); |
|
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
|
924 | 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
|
925 | } |
|
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 | |
|
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
|
927 | l = l->next; |
|
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
|
928 | } |
|
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
|
929 | |
|
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
|
930 | if (ar->tima > 0) |
| 15884 | 931 | purple_timeout_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
|
932 | |
|
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
|
933 | if (ar->gfud) |
| 15884 | 934 | purple_util_fetch_url_cancel(ar->gfud); |
|
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 | |
|
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
|
936 | 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
|
937 | } |
|
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
|
938 | |
|
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
|
939 | UPnPMappingAddRemove * |
| 15884 | 940 | purple_upnp_set_port_mapping(unsigned short portmap, const gchar* protocol, |
| 941 | PurpleUPnPCallback cb, gpointer cb_data) | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
942 | { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
943 | UPnPMappingAddRemove *ar; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
944 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
945 | ar = g_new0(UPnPMappingAddRemove, 1); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
946 | ar->cb = cb; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
947 | ar->cb_data = cb_data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
948 | ar->add = TRUE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
949 | ar->portmap = portmap; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
950 | strncpy(ar->protocol, protocol, sizeof(ar->protocol)); |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
951 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
952 | /* If we're waiting for a discovery, add to the callbacks list */ |
| 15884 | 953 | if(control_info.status == PURPLE_UPNP_STATUS_DISCOVERING) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
954 | /* TODO: This will fail because when this cb is triggered, |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
955 | * the internal IP lookup won't be complete */ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
956 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
957 | discovery_callbacks, do_port_mapping_cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
958 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
959 | 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
|
960 | return ar; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
961 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
962 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
963 | /* 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
|
964 | * elapsed since the last try, try again */ |
| 15884 | 965 | if(control_info.status == PURPLE_UPNP_STATUS_UNDISCOVERED || |
| 966 | (control_info.status == PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
967 | && (time(NULL) - control_info.lookup_time) > 300)) { |
| 15884 | 968 | 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
|
969 | return ar; |
| 15884 | 970 | } 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
|
971 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
972 | /* Asynchronously trigger a failed response */ |
| 15884 | 973 | ar->tima = purple_timeout_add(10, fire_port_mapping_failure_cb, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
974 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
975 | /* No need to do anything if nobody expects a response*/ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
976 | 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
|
977 | ar = NULL; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
978 | } |
|
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
|
979 | return ar; |
|
12734
69569600b471
[gaim-migrate @ 15078]
Daniel Atallah <datallah@pidgin.im>
parents:
12207
diff
changeset
|
980 | } |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
981 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
982 | 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
|
983 | return ar; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
984 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
985 | |
|
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
|
986 | UPnPMappingAddRemove * |
| 15884 | 987 | purple_upnp_remove_port_mapping(unsigned short portmap, const char* protocol, |
| 988 | PurpleUPnPCallback cb, gpointer cb_data) | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
989 | { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
990 | UPnPMappingAddRemove *ar; |
|
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 | ar = g_new0(UPnPMappingAddRemove, 1); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
993 | ar->cb = cb; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
994 | ar->cb_data = cb_data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
995 | ar->add = FALSE; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
996 | ar->portmap = portmap; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
997 | strncpy(ar->protocol, protocol, sizeof(ar->protocol)); |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11213
diff
changeset
|
998 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
999 | /* If we're waiting for a discovery, add to the callbacks list */ |
| 15884 | 1000 | if(control_info.status == PURPLE_UPNP_STATUS_DISCOVERING) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1001 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1002 | discovery_callbacks, do_port_mapping_cb); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1003 | discovery_callbacks = g_slist_append( |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1004 | 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
|
1005 | return ar; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1006 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1007 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1008 | /* 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
|
1009 | * elapsed since the last try, try again */ |
| 15884 | 1010 | if(control_info.status == PURPLE_UPNP_STATUS_UNDISCOVERED || |
| 1011 | (control_info.status == PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1012 | && (time(NULL) - control_info.lookup_time) > 300)) { |
| 15884 | 1013 | 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
|
1014 | return ar; |
| 15884 | 1015 | } 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
|
1016 | if (cb) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1017 | /* Asynchronously trigger a failed response */ |
| 15884 | 1018 | ar->tima = purple_timeout_add(10, fire_port_mapping_failure_cb, ar); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1019 | } else { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1020 | /* No need to do anything if nobody expects a response*/ |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1021 | 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
|
1022 | ar = NULL; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1023 | } |
|
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
|
1024 | return ar; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1025 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1026 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12734
diff
changeset
|
1027 | 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
|
1028 | return ar; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
diff
changeset
|
1029 | } |
|
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
|
1030 | |
|
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
|
1031 | static 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
|
1032 | purple_upnp_network_config_changed_cb(void *data) |
|
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
|
1033 | { |
|
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
|
1034 | /* 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
|
1035 | 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
|
1036 | 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
|
1037 | 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
|
1038 | 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
|
1039 | 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
|
1040 | 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
|
1041 | 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
|
1042 | } |
|
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
|
1043 | |
|
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
|
1044 | static 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
|
1045 | purple_upnp_get_handle(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
|
1046 | { |
|
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
|
1047 | static int handle; |
|
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
|
1048 | |
|
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
|
1049 | return &handle; |
|
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
|
1050 | } |
|
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
|
1051 | |
|
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
|
1052 | 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
|
1053 | 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
|
1054 | { |
|
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
|
1055 | purple_signal_connect(purple_network_get_handle(), "network-configuration-changed", |
|
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
|
1056 | purple_upnp_get_handle(), PURPLE_CALLBACK(purple_upnp_network_config_changed_cb), |
|
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
|
1057 | GINT_TO_POINTER(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
|
1058 | } |