annotate src/upnp.c @ 12823:292a846fdeea

[gaim-migrate @ 15171] It seems like saved status sorting should be UTF-8 aware. I haven't tested this, but it seems right and compiles. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 11 Jan 2006 05:45:48 +0000
parents 0f499f27b29a
children 8e3b85fe4a55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
1 /**
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
2 * @file upnp.c UPnP Implementation
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
3 * @ingroup core
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
4 *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
5 * gaim
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
6 *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
9 * source distribution.
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
10 *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
14 * (at your option) any later version.
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
15 *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
19 * GNU General Public License for more details.
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
20 *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
24 */
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
25 #include "internal.h"
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
26 #include "gaim.h"
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
27
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
28 #include "debug.h"
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
29 #include "util.h"
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
30 #include "proxy.h"
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
31 #include "xmlnode.h"
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
32 #include "network.h"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
33 #include "eventloop.h"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
34 #include "upnp.h"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
35
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
36
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
37 /**
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
38 * Information on the httpResponse callback
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
39 */
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
40 typedef struct
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
41 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
42 guint inpa; /* gaim_input_add handle */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
43 guint tima; /* gaim_timout_add handle */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
44 gchar* sendBuffer; /* send data */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
45 gchar* recvBuffer; /* response data */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
46 guint totalSizeRecv;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
47 gboolean done;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
48
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
49 } NetResponseData;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
50
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
51
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
52 /***************************************************************
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
53 ** General Defines *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
54 ****************************************************************/
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
55 #define HTTP_OK "200 OK"
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
56 #define DEFAULT_HTTP_PORT 80
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
57 #define MAX_PORT_SIZE 6
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
58 #define SIZEOF_HTTP 7 /* size of "http://" string */
11492
18c6a6659770 [gaim-migrate @ 13735]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11443
diff changeset
59 #define RECEIVE_TIMEOUT 10000
18c6a6659770 [gaim-migrate @ 13735]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11443
diff changeset
60 #define CONSECUTIVE_RECEIVE_TIMEOUT 500
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
61 #define DISCOVERY_TIMEOUT 1000
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
62
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
63
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
64 /***************************************************************
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
65 ** Discovery/Description Defines *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
66 ****************************************************************/
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
67 #define NUM_UDP_ATTEMPTS 2
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
68
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
69 /* Address and port of an SSDP request used for discovery */
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
70 #define HTTPMU_HOST_ADDRESS "239.255.255.250"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
71 #define HTTPMU_HOST_PORT 1900
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
72
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
73 #define SEARCH_REQUEST_DEVICE "urn:schemas-upnp-org:service:" \
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
74 "%s"
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
75
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
76 #define SEARCH_REQUEST_STRING "M-SEARCH * HTTP/1.1\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
77 "MX: 2\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
78 "HOST: 239.255.255.250:1900\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
79 "MAN: \"ssdp:discover\"\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
80 "ST: urn:schemas-upnp-org:service:" \
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
81 "%s\r\n" \
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
82 "\r\n"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
83
11492
18c6a6659770 [gaim-migrate @ 13735]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11443
diff changeset
84 #define MAX_DISCOVERY_RECEIVE_SIZE 400
18c6a6659770 [gaim-migrate @ 13735]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11443
diff changeset
85 #define MAX_DESCRIPTION_RECEIVE_SIZE 7000
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
86 #define MAX_DESCRIPTION_HTTP_HEADER_SIZE 100
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
87
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
88
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
89 /******************************************************************
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
90 ** Action Defines *
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
91 *******************************************************************/
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
92 #define HTTP_HEADER_ACTION "POST /%s HTTP/1.1\r\n" \
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
93 "HOST: %s\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
94 "SOAPACTION: " \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
95 "\"urn:schemas-upnp-org:" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
96 "service:%s#%s\"\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
97 "CONTENT-TYPE: text/xml ; charset=\"utf-8\"\r\n"\
11656
f9c5480ad0ce [gaim-migrate @ 13940]
Richard Laager <rlaager@wiktel.com>
parents: 11586
diff changeset
98 "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n"
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
99
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
100 #define SOAP_ACTION "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
101 "<s:Envelope xmlns:s=" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
102 "\"http://schemas.xmlsoap.org/soap/envelope/\" " \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
103 "s:encodingStyle=" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
104 "\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
105 "<s:Body>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
106 "<u:%s xmlns:u=" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
107 "\"urn:schemas-upnp-org:service:%s\">\r\n%s" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
108 "</u:%s>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
109 "</s:Body>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
110 "</s:Envelope>\r\n"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
111
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
112 #define PORT_MAPPING_LEASE_TIME "0"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
113 #define PORT_MAPPING_DESCRIPTION "GAIM_UPNP_PORT_FORWARD"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
114
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
115 #define ADD_PORT_MAPPING_PARAMS "<NewRemoteHost></NewRemoteHost>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
116 "<NewExternalPort>%i</NewExternalPort>\r\n"\
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
117 "<NewProtocol>%s</NewProtocol>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
118 "<NewInternalPort>%i</NewInternalPort>\r\n"\
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
119 "<NewInternalClient>%s" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
120 "</NewInternalClient>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
121 "<NewEnabled>1</NewEnabled>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
122 "<NewPortMappingDescription>" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
123 PORT_MAPPING_DESCRIPTION \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
124 "</NewPortMappingDescription>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
125 "<NewLeaseDuration>" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
126 PORT_MAPPING_LEASE_TIME \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
127 "</NewLeaseDuration>\r\n"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
128
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
129 #define DELETE_PORT_MAPPING_PARAMS "<NewRemoteHost></NewRemoteHost>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
130 "<NewExternalPort>%i" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
131 "</NewExternalPort>\r\n" \
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
132 "<NewProtocol>%s</NewProtocol>\r\n"
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
133
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
134
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
135 static void
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
136 gaim_upnp_timeout(gpointer data, gint source, GaimInputCondition cond)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
137 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
138 NetResponseData* nrd = data;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
139
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
140 gaim_input_remove(nrd->inpa);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
141 gaim_timeout_remove(nrd->tima);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
142
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
143 if(nrd->totalSizeRecv == 0 && nrd->recvBuffer != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
144 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
145 nrd->recvBuffer = NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
146 } else if(nrd->recvBuffer != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
147 nrd->recvBuffer[nrd->totalSizeRecv] = '\0';
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
148 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
149
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
150 nrd->done = TRUE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
151 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
152
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
153
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
154 static void
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
155 gaim_upnp_http_read(gpointer data, gint sock, GaimInputCondition cond)
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
156 {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
157 int sizeRecv;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
158 NetResponseData* nrd = data;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
159
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
160 sizeRecv = recv(sock, &(nrd->recvBuffer[nrd->totalSizeRecv]),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
161 MAX_DESCRIPTION_RECEIVE_SIZE-nrd->totalSizeRecv, 0);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
162 if(sizeRecv < 0 && errno != EINTR) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
163 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
164 "gaim_upnp_http_read(): recv < 0: %i!\n\n", errno);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
165 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
166 nrd->recvBuffer = NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
167 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
168 gaim_input_remove(nrd->inpa);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
169 nrd->done = TRUE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
170 return;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
171 }else if(errno == EINTR) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
172 sizeRecv = 0;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
173 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
174 nrd->totalSizeRecv += sizeRecv;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
175
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
176 if(sizeRecv == 0) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
177 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
178 gaim_input_remove(nrd->inpa);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
179 if(nrd->totalSizeRecv == 0) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
180 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
181 "gaim_upnp_http_read(): totalSizeRecv == 0\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
182 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
183 nrd->recvBuffer = NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
184 } else {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
185 nrd->recvBuffer[nrd->totalSizeRecv] = '\0';
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
186 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
187 nrd->done = TRUE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
188 } else {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
189 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
190 gaim_input_remove(nrd->inpa);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
191 nrd->tima = gaim_timeout_add(CONSECUTIVE_RECEIVE_TIMEOUT,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
192 (GSourceFunc)gaim_upnp_timeout, nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
193 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
194 gaim_upnp_http_read, nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
195 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
196 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
197
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
198
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
199 static void
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
200 gaim_upnp_http_send(gpointer data, gint sock, GaimInputCondition cond)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
201 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
202 gsize sizeSent, totalSizeSent = 0;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
203 NetResponseData* nrd = data;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
204
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
205 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
206 while(totalSizeSent < strlen(nrd->sendBuffer)) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
207 sizeSent = send(sock,(gchar*)(nrd->sendBuffer+totalSizeSent),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
208 strlen(nrd->sendBuffer)-totalSizeSent,0);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
209 if(sizeSent <= 0 && errno != EINTR) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
210 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
211 "gaim_upnp_http_request(): Failed In send\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
212 nrd->done = TRUE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
213 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
214 nrd->recvBuffer = NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
215 close(sock);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
216 return;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
217 }else if(errno == EINTR) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
218 sizeSent = 0;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
219 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
220 totalSizeSent += sizeSent;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
221 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
222
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
223 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
224 (GSourceFunc)gaim_upnp_timeout, nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
225 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
226 gaim_upnp_http_read, nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
227 while (!nrd->done) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
228 g_main_context_iteration(NULL, TRUE);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
229 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
230 close(sock);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
231 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
232
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
233
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
234 static gchar*
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
235 gaim_upnp_http_request(const gchar* address, int port, gchar* httpRequest)
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
236 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
237 gchar* recvBuffer;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
238 NetResponseData* nrd = (NetResponseData*)g_malloc0(sizeof(NetResponseData));
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
239 nrd->sendBuffer = httpRequest;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
240 nrd->recvBuffer = (gchar*)g_malloc(MAX_DESCRIPTION_RECEIVE_SIZE);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
241
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
242 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
243 (GSourceFunc)gaim_upnp_timeout, nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
244
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
245 if(gaim_proxy_connect(NULL, address, port, gaim_upnp_http_send, nrd)) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
246
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
247 gaim_debug_error("upnp", "Connect Failed: Address: %s @@@ Port %d @@@ Request %s\n\n",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
248 address, port, nrd->sendBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
249
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
250 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
251 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
252 nrd->recvBuffer = NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
253 } else {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
254 while (!nrd->done) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
255 g_main_context_iteration(NULL, TRUE);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
256 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
257 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
258
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
259 recvBuffer = nrd->recvBuffer;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
260 g_free(nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
261
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
262 return recvBuffer;
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
263 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
264
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
265
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
266 static gboolean
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
267 gaim_upnp_compare_device(const xmlnode* device, const gchar* deviceType)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
268 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
269 xmlnode* deviceTypeNode = xmlnode_get_child(device, "deviceType");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
270 if(deviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
271 return FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
272 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
273 return !g_ascii_strcasecmp(xmlnode_get_data(deviceTypeNode), deviceType);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
274 }
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
275
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
276
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
277 static gboolean
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
278 gaim_upnp_compare_service(const xmlnode* service, const gchar* serviceType)
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
279 {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
280 xmlnode* serviceTypeNode = xmlnode_get_child(service, "serviceType");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
281 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
282 return FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
283 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
284 return !g_ascii_strcasecmp(xmlnode_get_data(serviceTypeNode),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
285 serviceType);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
286 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
287
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
288
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
289 static gchar*
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
290 gaim_upnp_parse_description_response(const gchar* httpResponse,
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
291 const gchar* httpURL, const gchar* serviceType)
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
292 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
293 gchar* xmlRoot;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
294 gchar* baseURL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
295 gchar* controlURL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
296 gchar* service;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
297 xmlnode* xmlRootNode;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
298 xmlnode* serviceTypeNode;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
299 xmlnode* controlURLNode;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
300 xmlnode* baseURLNode;
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
301
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
302 /* make sure we have a valid http response */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
303 if(g_strstr_len(httpResponse, strlen(httpResponse), HTTP_OK) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
304 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
305 "parse_description_response(): Failed In HTTP_OK\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
306 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
307 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
308
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
309 /* find the root of the xml document */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
310 if((xmlRoot = g_strstr_len(httpResponse, strlen(httpResponse),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
311 "<root")) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
312 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
313 "parse_description_response(): Failed finding root\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
314 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
315 }
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
316
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
317 /* create the xml root node */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
318 if((xmlRootNode = xmlnode_from_str(xmlRoot, -1)) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
319 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
320 "parse_description_response(): Could not parse xml root node\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
321 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
322 }
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
323
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
324 /* get the baseURL of the device */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
325 if((baseURLNode = xmlnode_get_child(xmlRootNode, "URLBase")) != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
326 baseURL = g_strdup(xmlnode_get_data(baseURLNode));
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
327 } else {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
328 baseURL = g_strdup(httpURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
329 }
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
330
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
331 /* get the serviceType child that has the service type as its data */
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
332
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
333 /* get urn:schemas-upnp-org:device:InternetGatewayDevice:1 and its devicelist */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
334 serviceTypeNode = xmlnode_get_child(xmlRootNode, "device");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
335 while(!gaim_upnp_compare_device(serviceTypeNode,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
336 "urn:schemas-upnp-org:device:InternetGatewayDevice:1") &&
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
337 serviceTypeNode != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
338 serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
339 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
340 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
341 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
342 "parse_description_response(): could not get serviceTypeNode 1\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
343 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
344 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
345 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
346 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
347 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "deviceList");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
348 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
349 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
350 "parse_description_response(): could not get serviceTypeNode 2\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
351 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
352 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
353 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
354 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
355
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
356 /* get urn:schemas-upnp-org:device:WANDevice:1 and its devicelist */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
357 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
358 while(!gaim_upnp_compare_device(serviceTypeNode,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
359 "urn:schemas-upnp-org:device:WANDevice:1") &&
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
360 serviceTypeNode != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
361 serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
362 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
363 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
364 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
365 "parse_description_response(): could not get serviceTypeNode 3\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
366 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
367 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
368 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
369 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
370 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "deviceList");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
371 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
372 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
373 "parse_description_response(): could not get serviceTypeNode 4\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
374 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
375 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
376 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
377 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
378
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
379 /* get urn:schemas-upnp-org:device:WANConnectionDevice:1 and its servicelist */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
380 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
381 while(!gaim_upnp_compare_device(serviceTypeNode,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
382 "urn:schemas-upnp-org:device:WANConnectionDevice:1") &&
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
383 serviceTypeNode != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
384 serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
385 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
386 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
387 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
388 "parse_description_response(): could not get serviceTypeNode 5\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
389 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
390 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
391 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
392 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
393 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "serviceList");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
394 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
395 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
396 "parse_description_response(): could not get serviceTypeNode 6\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
397 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
398 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
399 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
400 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
401
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
402 /* get the serviceType variable passed to this function */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
403 service = g_strdup_printf(SEARCH_REQUEST_DEVICE, serviceType);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
404 serviceTypeNode = xmlnode_get_child(serviceTypeNode, "service");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
405 while(!gaim_upnp_compare_service(serviceTypeNode, service) &&
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
406 serviceTypeNode != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
407 serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
408 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
409
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
410 g_free(service);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
411 if(serviceTypeNode == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
412 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
413 "parse_description_response(): could not get serviceTypeNode 7\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
414 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
415 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
416 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
417 }
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
418
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
419 /* get the controlURL of the service */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
420 if((controlURLNode = xmlnode_get_child(serviceTypeNode,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
421 "controlURL")) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
422 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
423 "parse_description_response(): Could not find controlURL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
424 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
425 xmlnode_free(xmlRootNode);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
426 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
427 }
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
428
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
429 if(g_strstr_len(xmlnode_get_data(controlURLNode),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
430 SIZEOF_HTTP, "http://") == NULL &&
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
431 g_strstr_len(xmlnode_get_data(controlURLNode),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
432 SIZEOF_HTTP, "HTTP://") == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
433 controlURL = g_strdup_printf("%s%s", baseURL,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
434 xmlnode_get_data(controlURLNode));
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
435 }else{
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
436 controlURL = g_strdup(xmlnode_get_data(controlURLNode));
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
437 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
438 g_free(baseURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
439 xmlnode_free(xmlRootNode);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
440
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
441 return controlURL;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
442 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
443
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
444
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
445 static gchar*
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
446 gaim_upnp_parse_description(const gchar* descriptionURL, const gchar* serviceType)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
447 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
448 gchar* fullURL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
449 gchar* controlURL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
450 gchar* httpResponse;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
451 gchar* httpRequest;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
452
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
453 gchar* descriptionXMLAddress;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
454 gchar* descriptionAddressPort;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
455 gchar* descriptionAddress;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
456 gchar descriptionPort[MAX_PORT_SIZE];
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
457 int port = 0;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
458
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
459 /* parse the 4 above variables out of the descriptionURL
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
460 example description URL: http://192.168.1.1:5678/rootDesc.xml */
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
461
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
462 /* parse the url into address, port, path variables */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
463 if(!gaim_url_parse(descriptionURL, &descriptionAddress,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
464 &port, &descriptionXMLAddress, NULL, NULL)) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
465 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
466 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
467 if(port == 0 || port == -1) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
468 port = DEFAULT_HTTP_PORT;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
469 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
470 g_ascii_dtostr(descriptionPort, MAX_PORT_SIZE, port);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
471 descriptionAddressPort = g_strdup_printf("%s:%s", descriptionAddress,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
472 descriptionPort);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
473
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
474 fullURL = g_strdup_printf("http://%s", descriptionAddressPort);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
475
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
476 /* for example...
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
477 GET /rootDesc.xml HTTP/1.1\r\nHost: 192.168.1.1:5678\r\n\r\n */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
478 httpRequest = g_strdup_printf("GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
479 descriptionXMLAddress, descriptionAddressPort);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
480
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
481 httpResponse = gaim_upnp_http_request(descriptionAddress,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
482 port, httpRequest);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
483 if(httpResponse == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
484 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
485 "gaim_upnp_parse_description(): httpResponse is NULL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
486 g_free(descriptionXMLAddress);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
487 g_free(descriptionAddress);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
488 g_free(descriptionAddressPort);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
489 g_free(httpRequest);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
490 g_free(fullURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
491 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
492 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
493
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
494 controlURL = gaim_upnp_parse_description_response(httpResponse,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
495 fullURL, serviceType);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
496
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
497 g_free(descriptionXMLAddress);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
498 g_free(descriptionAddress);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
499 g_free(descriptionAddressPort);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
500 g_free(fullURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
501 g_free(httpRequest);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
502 g_free(httpResponse);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
503
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
504 if(controlURL == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
505 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
506 "gaim_upnp_parse_description(): controlURL is NULL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
507 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
508
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
509 return controlURL;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
510 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
511
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
512
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
513 static gchar*
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
514 gaim_upnp_parse_discover_response(const gchar* buf, unsigned int bufSize,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
515 const gchar* serviceType)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
516 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
517 gchar* startDescURL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
518 gchar* endDescURL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
519 gchar* descURL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
520 gchar* retVal;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
521
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
522 if(g_strstr_len(buf, strlen(buf), HTTP_OK) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
523 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
524 "parse_discover_response(): Failed In HTTP_OK\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
525 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
526 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
527
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
528 if((startDescURL = g_strstr_len(buf, strlen(buf), "http://")) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
529 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
530 "parse_discover_response(): Failed In finding http://\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
531 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
532 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
533
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
534 endDescURL = g_strstr_len(startDescURL, strlen(startDescURL), "\r");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
535 if(endDescURL == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
536 endDescURL = g_strstr_len(startDescURL, strlen(startDescURL), "\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
537 if(endDescURL == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
538 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
539 "parse_discover_response(): Failed In endDescURL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
540 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
541 }else if(endDescURL == startDescURL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
542 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
543 "parse_discover_response(): endDescURL == startDescURL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
544 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
545 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
546 }else if(endDescURL == startDescURL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
547 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
548 "parse_discover_response(): 2nd endDescURL == startDescURL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
549 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
550 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
551 descURL = g_strndup(startDescURL, endDescURL-startDescURL);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
552
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
553 retVal = gaim_upnp_parse_description(descURL, serviceType);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
554 g_free(descURL);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
555 return retVal;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
556 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
557
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
558
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
559 static void
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
560 gaim_upnp_discover_udp_read(gpointer data, gint sock, GaimInputCondition cond)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
561 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
562 unsigned int length;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
563 struct sockaddr_in from;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
564 int sizeRecv;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
565 NetResponseData* nrd = data;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
566
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
567 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
568 length = sizeof(struct sockaddr_in);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
569
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
570 do {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
571 sizeRecv = recvfrom(sock, nrd->recvBuffer,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
572 MAX_DISCOVERY_RECEIVE_SIZE, 0,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
573 (struct sockaddr*)&from, &length);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
574
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
575 if(sizeRecv > 0) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
576 nrd->recvBuffer[sizeRecv] = '\0';
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
577 }else if(errno != EINTR) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
578 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
579 nrd->recvBuffer = NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
580 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
581 }while(errno == EINTR);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
582
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
583 gaim_input_remove(nrd->inpa);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
584 nrd->done = TRUE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
585 return;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
586 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
587
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
588
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
589 GaimUPnPControlInfo*
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
590 gaim_upnp_discover(void)
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
591 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
592 /* Socket Setup Variables */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
593 int sock, i;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
594 struct sockaddr_in server;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
595 struct hostent* hp;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
596
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
597 /* UDP SEND VARIABLES */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
598 gboolean sentSuccess, recvSuccess;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
599 ssize_t sizeSent;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
600 ssize_t totalSizeSent;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
601 gchar wanIP[] = "WANIPConnection:1";
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
602 gchar wanPPP[] = "WANPPPConnection:1";
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
603 gchar* serviceToUse;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
604 gchar* sendMessage = NULL;
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
605
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
606 /* UDP RECEIVE VARIABLES */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
607 GaimUPnPControlInfo* controlInfo = g_malloc(sizeof(GaimUPnPControlInfo));
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
608 NetResponseData* nrd = g_malloc(sizeof(NetResponseData));
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
609
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
610 /* Set up the sockets */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
611 sock = socket(AF_INET, SOCK_DGRAM, 0);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
612 if (sock == -1) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
613 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
614 "gaim_upnp_discover(): Failed In sock creation\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
615 g_free(nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
616 g_free(controlInfo);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
617 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
618 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
619 memset(&server, 0, sizeof(struct sockaddr));
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
620 server.sin_family = AF_INET;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
621 if((hp = gethostbyname(HTTPMU_HOST_ADDRESS)) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
622 close(sock);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
623 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
624 "gaim_upnp_discover(): Failed In gethostbyname\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
625 g_free(nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
626 g_free(controlInfo);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
627 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
628 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
629 memcpy(&server.sin_addr,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
630 hp->h_addr_list[0],
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
631 hp->h_length);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
632 server.sin_port = htons(HTTPMU_HOST_PORT);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
633
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
634 /* because we are sending over UDP, if there is a failure
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
635 we should retry the send NUM_UDP_ATTEMPTS times. Also,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
636 try different requests for WANIPConnection and WANPPPConnection*/
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
637 for(i = 0; i < NUM_UDP_ATTEMPTS; i++) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
638 sentSuccess = TRUE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
639 recvSuccess = TRUE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
640 totalSizeSent = 0;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
641
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
642 nrd->recvBuffer = NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
643 nrd->totalSizeRecv = 0;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
644 nrd->done = FALSE;
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
645
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
646 if(sendMessage != NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
647 g_free(sendMessage);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
648 }
11213
ff728e84d59a [gaim-migrate @ 13344]
Thomas Butter <tbutter>
parents: 11204
diff changeset
649
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
650 if(i%2 == 0) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
651 serviceToUse = wanIP;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
652 } else {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
653 serviceToUse = wanPPP;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
654 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
655 sendMessage = g_strdup_printf(SEARCH_REQUEST_STRING, serviceToUse);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
656
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
657 nrd->recvBuffer = (char*)g_malloc(MAX_DISCOVERY_RECEIVE_SIZE);
11213
ff728e84d59a [gaim-migrate @ 13344]
Thomas Butter <tbutter>
parents: 11204
diff changeset
658
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
659 while(totalSizeSent < (ssize_t)strlen(sendMessage)) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
660 sizeSent = sendto(sock,(void*)&sendMessage[totalSizeSent],
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
661 strlen(&sendMessage[totalSizeSent]),0,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
662 (struct sockaddr*)&server,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
663 sizeof(struct sockaddr_in));
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
664 if(sizeSent <= 0 && errno != EINTR) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
665 sentSuccess = FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
666 break;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
667 }else if(errno == EINTR) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
668 sizeSent = 0;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
669 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
670 totalSizeSent += sizeSent;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
671 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
672
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
673 if(sentSuccess) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
674 nrd->tima = gaim_timeout_add(DISCOVERY_TIMEOUT,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
675 (GSourceFunc)gaim_upnp_timeout, nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
676 nrd->inpa = gaim_input_add(sock, GAIM_INPUT_READ,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
677 gaim_upnp_discover_udp_read, nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
678 while (!nrd->done) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
679 g_main_context_iteration(NULL, TRUE);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
680 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
681 if(nrd->recvBuffer == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
682 recvSuccess = FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
683 } else {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
684 /* parse the response, and see if it was a success */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
685 close(sock);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
686 if((controlInfo->controlURL=
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
687 gaim_upnp_parse_discover_response(nrd->recvBuffer,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
688 strlen(nrd->recvBuffer),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
689 serviceToUse))==NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
690 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
691 "gaim_upnp_discover(): Failed In parse response\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
692 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
693 g_free(nrd);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
694 g_free(controlInfo);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
695 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
696 }
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
697
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
698 controlInfo->serviceType = g_strdup(serviceToUse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
699 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
700 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
701
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
702 /* if sent success and recv successful, then break */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
703 if(sentSuccess && recvSuccess) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
704 i = NUM_UDP_ATTEMPTS;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
705 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
706 }
11213
ff728e84d59a [gaim-migrate @ 13344]
Thomas Butter <tbutter>
parents: 11204
diff changeset
707
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
708 g_free(nrd->recvBuffer);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
709 g_free(sendMessage);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
710 g_free(nrd);
11213
ff728e84d59a [gaim-migrate @ 13344]
Thomas Butter <tbutter>
parents: 11204
diff changeset
711
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
712 if(!sentSuccess || !recvSuccess) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
713 close(sock);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
714 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
715 "gaim_upnp_discover(): Failed In sent/recv success\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
716 g_free(controlInfo);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
717 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
718 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
719
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
720 return controlInfo;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
721 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
722
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
723
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
724 static char*
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
725 gaim_upnp_generate_action_message_and_send(const GaimUPnPControlInfo* controlInfo,
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
726 const gchar* actionName, const gchar* actionParams)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
727 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
728 gchar* actionMessage;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
729 gchar* soapMessage;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
730 gchar* totalSendMessage;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
731 gchar* httpResponse;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
732
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
733 gchar* pathOfControl;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
734 gchar* addressOfControl;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
735 gchar* addressPortOfControl;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
736 gchar portOfControl[MAX_PORT_SIZE];
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
737 int port=0;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
738
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
739 /* set the soap message */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
740 soapMessage = g_strdup_printf(SOAP_ACTION, actionName,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
741 controlInfo->serviceType, actionParams, actionName);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
742
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
743 /* parse the url into address, port, path variables */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
744 if(!gaim_url_parse(controlInfo->controlURL, &addressOfControl,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
745 &port, &pathOfControl, NULL, NULL)) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
746 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
747 "generate_action_message_and_send(): Failed In Parse URL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
748 g_free(soapMessage);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
749 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
750 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
751 if(port == 0 || port == -1) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
752 port = DEFAULT_HTTP_PORT;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
753 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
754 g_ascii_dtostr(portOfControl, MAX_PORT_SIZE, port);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
755
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
756 /* set the addressPortOfControl variable which should have a
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
757 form like the following: 192.168.1.1:8000 */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
758 addressPortOfControl = g_strdup_printf("%s:%s",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
759 addressOfControl, portOfControl);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
760
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
761 /* set the HTTP Header */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
762 actionMessage = g_strdup_printf(HTTP_HEADER_ACTION,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
763 pathOfControl, addressPortOfControl,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
764 controlInfo->serviceType, actionName,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
765 strlen(soapMessage));
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
766
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
767 /* append to the header the body */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
768 totalSendMessage = g_strdup_printf("%s%s", actionMessage, soapMessage);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
769
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
770 /* get the return of the http response */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
771 httpResponse = gaim_upnp_http_request(addressOfControl,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
772 port, totalSendMessage);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
773 if(httpResponse == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
774 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
775 "generate_action_message_and_send(): Failed In httpResponse\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
776 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
777
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
778 g_free(actionMessage);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
779 g_free(soapMessage);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
780 g_free(totalSendMessage);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
781 g_free(pathOfControl);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
782 g_free(addressOfControl);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
783 g_free(addressPortOfControl);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
784
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
785 return httpResponse;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
786 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
787
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
788
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
789 gchar*
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
790 gaim_upnp_get_public_ip(const GaimUPnPControlInfo* controlInfo)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
791 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
792 gchar* extIPAddress;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
793 gchar* httpResponse;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
794 gchar actionName[] = "GetExternalIPAddress";
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
795 gchar actionParams[] = "";
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
796 gchar* temp, *temp2;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
797
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
798 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
799 actionName, actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
800 if(httpResponse == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
801 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
802 "gaim_upnp_get_public_ip(): Failed In httpResponse\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
803 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
804 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
805
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
806 /* extract the ip, or see if there is an error */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
807 if((temp = g_strstr_len(httpResponse, strlen(httpResponse),
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
808 "<NewExternalIPAddress")) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
809 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
810 "gaim_upnp_get_public_ip(): Failed Finding <NewExternalIPAddress\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
811 g_free(httpResponse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
812 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
813 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
814 if((temp = g_strstr_len(temp, strlen(temp), ">")) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
815 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
816 "gaim_upnp_get_public_ip(): Failed In Finding >\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
817 g_free(httpResponse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
818 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
819 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
820 if((temp2 = g_strstr_len(temp, strlen(temp), "<")) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
821 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
822 "gaim_upnp_get_public_ip(): Failed In Finding <\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
823 g_free(httpResponse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
824 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
825 }
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
826
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
827 extIPAddress = g_strndup(&temp[1], (temp2-1)-temp);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
828
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
829 g_free(httpResponse);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
830
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
831 gaim_debug_info("upnp", "NAT Returned IP: %s\n", extIPAddress);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
832 return extIPAddress;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
833 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
834
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
835
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
836 static void
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
837 gaim_upnp_get_local_system_ip(gpointer data, gint sock, GaimInputCondition cond)
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
838 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
839 NetResponseData* nrd = data;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
840 nrd->recvBuffer = g_strdup(gaim_network_get_local_system_ip(sock));
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
841
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
842 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
843 nrd->done = TRUE;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
844
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
845 close(sock);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
846 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
847
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
848
11492
18c6a6659770 [gaim-migrate @ 13735]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11443
diff changeset
849 static gchar*
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
850 gaim_upnp_get_local_ip_address(const gchar* address)
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
851 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
852 gchar* ip;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
853 gchar* pathOfControl;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
854 gchar* addressOfControl;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
855 int port = 0;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
856 NetResponseData* nrd = (NetResponseData*)g_malloc0(sizeof(NetResponseData));
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
857
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
858 if(!gaim_url_parse(address, &addressOfControl, &port, &pathOfControl,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
859 NULL, NULL)) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
860 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
861 "get_local_ip_address(): Failed In Parse URL\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
862 return NULL;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
863 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
864 if(port == 0 || port == -1) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
865 port = DEFAULT_HTTP_PORT;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
866 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
867
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
868 nrd->tima = gaim_timeout_add(RECEIVE_TIMEOUT,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
869 (GSourceFunc)gaim_upnp_timeout, nrd);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
870
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
871 if(gaim_proxy_connect(NULL, addressOfControl, port,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
872 gaim_upnp_get_local_system_ip, nrd)) {
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
873
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
874 gaim_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d @@@ Request %s\n\n",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
875 address, port, nrd->sendBuffer);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
876
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
877 gaim_timeout_remove(nrd->tima);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
878 } else {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
879 while (!nrd->done) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
880 g_main_context_iteration(NULL, TRUE);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
881 }
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
882 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
883
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
884 ip = nrd->recvBuffer;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
885 g_free(nrd);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
886
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
887 gaim_debug_info("upnp", "local ip: %s\n", ip);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
888
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
889 return ip;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
890 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
891
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
892
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
893 gboolean
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
894 gaim_upnp_set_port_mapping(const GaimUPnPControlInfo* controlInfo,
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
895 unsigned short portMap, const gchar* protocol)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
896 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
897 gchar* httpResponse;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
898 gchar actionName[] = "AddPortMapping";
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
899 gchar* actionParams;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
900 gchar* internalIP;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
901
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
902 /* get the internal IP */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
903 if((internalIP = gaim_upnp_get_local_ip_address(controlInfo->controlURL)) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
904 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
905 "gaim_upnp_set_port_mapping(): couldn't get local ip\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
906 return FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
907 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
908
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
909 /* make the portMappingParams variable */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
910 actionParams = g_strdup_printf(ADD_PORT_MAPPING_PARAMS, portMap,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
911 protocol, portMap, internalIP);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
912
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
913 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
914 actionName, actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
915 if(httpResponse == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
916 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
917 "gaim_upnp_set_port_mapping(): Failed In httpResponse\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
918 g_free(actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
919 g_free(internalIP);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
920 return FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
921 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
922
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
923 /* determine if port mapping was a success */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
924 if(strstr(httpResponse, HTTP_OK) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
925 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
926 "gaim_upnp_set_port_mapping(): Failed HTTP_OK\n\n%s\n\n", httpResponse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
927 g_free(actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
928 g_free(httpResponse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
929 g_free(internalIP);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
930 return FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
931 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
932
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
933 g_free(actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
934 g_free(httpResponse);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
935
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
936 gaim_debug_info("upnp", "NAT Added Port Forward On Port: %d: To IP: %s\n",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
937 portMap, internalIP);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
938 g_free(internalIP);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
939 return TRUE;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
940 }
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
941
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
942
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
943 gboolean
11566
7897207b522d [gaim-migrate @ 13832]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11492
diff changeset
944 gaim_upnp_remove_port_mapping(const GaimUPnPControlInfo* controlInfo,
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
945 unsigned short portMap, const char* protocol)
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
946 {
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
947 gchar* httpResponse;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
948 gchar actionName[] = "DeletePortMapping";
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
949 gchar* actionParams;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
950
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
951 /* make the portMappingParams variable */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
952 actionParams = g_strdup_printf(DELETE_PORT_MAPPING_PARAMS, portMap,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
953 protocol);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
954
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
955 httpResponse = gaim_upnp_generate_action_message_and_send(controlInfo,
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
956 actionName, actionParams);
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
957
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
958 if(httpResponse == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
959 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
960 "gaim_upnp_remove_port_mapping(): Failed In httpResponse\n\n");
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
961 g_free(actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
962 return FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
963 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
964
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
965 /* determine if port mapping was a success */
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
966 if(strstr(httpResponse, HTTP_OK) == NULL) {
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
967 gaim_debug_error("upnp",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
968 "gaim_upnp_set_port_mapping(): Failed HTTP_OK\n\n%s\n\n",
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
969 httpResponse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
970 g_free(actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
971 g_free(httpResponse);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
972 return FALSE;
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
973 }
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
974
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
975 g_free(actionParams);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
976 g_free(httpResponse);
11391
d3755a7ddd82 [gaim-migrate @ 13620]
Adam Warrington <awarring>
parents: 11213
diff changeset
977
12734
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
978 gaim_debug_info("upnp", "NAT Removed Port Forward On Port: %d\n", portMap);
0f499f27b29a [gaim-migrate @ 15078]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12207
diff changeset
979 return TRUE;
11195
3aeb85cc9cda [gaim-migrate @ 13319]
Adam Warrington <awarring>
parents:
diff changeset
980 }