upnp_igd_utils.c 17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*******************************************************************************
 *
 * Copyright (c) 2000-2003 Intel Corporation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 * - Neither name of Intel Corporation nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 ******************************************************************************/

#include "upnp_igd_utils.h"
#include "upnp_igd_private.h"
#include <upnptools.h>
35
#include <string.h>
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#include <stdlib.h>

void upnp_igd_print(upnp_igd_context *uIGD, upnp_igd_print_level level, const char *fmt, ...) {
	va_list ap;

	/* Protect both the display and the static buffer with the mutex */
	ithread_mutex_lock(&uIGD->print_mutex);

	va_start(ap, fmt);
	if (uIGD->print_fct) {
		uIGD->print_fct(uIGD->cookie, level, fmt, ap);
	}
	va_end(ap);

	ithread_mutex_unlock(&uIGD->print_mutex);
}

void upnp_igd_print_event_type(upnp_igd_context *uIGD, upnp_igd_print_level level, Upnp_EventType S) {
	switch (S) {
	/* Discovery */
	case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
57
		upnp_igd_print(uIGD, level, "UPNP_DISCOVERY_ADVERTISEMENT_ALIVE");
58 59
		break;
	case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
60
		upnp_igd_print(uIGD, level, "UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE");
61 62
		break;
	case UPNP_DISCOVERY_SEARCH_RESULT:
63
		upnp_igd_print(uIGD, level,  "UPNP_DISCOVERY_SEARCH_RESULT");
64 65
		break;
	case UPNP_DISCOVERY_SEARCH_TIMEOUT:
66
		upnp_igd_print(uIGD, level,  "UPNP_DISCOVERY_SEARCH_TIMEOUT");
67 68 69
		break;
	/* SOAP */
	case UPNP_CONTROL_ACTION_REQUEST:
70
		upnp_igd_print(uIGD, level, "UPNP_CONTROL_ACTION_REQUEST");
71 72
		break;
	case UPNP_CONTROL_ACTION_COMPLETE:
73
		upnp_igd_print(uIGD, level, "UPNP_CONTROL_ACTION_COMPLETE");
74 75
		break;
	case UPNP_CONTROL_GET_VAR_REQUEST:
76
		upnp_igd_print(uIGD, level, "UPNP_CONTROL_GET_VAR_REQUEST");
77 78
		break;
	case UPNP_CONTROL_GET_VAR_COMPLETE:
79
		upnp_igd_print(uIGD, level, "UPNP_CONTROL_GET_VAR_COMPLETE");
80 81 82
		break;
	/* GENA */
	case UPNP_EVENT_SUBSCRIPTION_REQUEST:
83
		upnp_igd_print(uIGD, level, "UPNP_EVENT_SUBSCRIPTION_REQUEST");
84 85
		break;
	case UPNP_EVENT_RECEIVED:
86
		upnp_igd_print(uIGD, level, "UPNP_EVENT_RECEIVED");
87 88
		break;
	case UPNP_EVENT_RENEWAL_COMPLETE:
89
		upnp_igd_print(uIGD, level, "UPNP_EVENT_RENEWAL_COMPLETE");
90 91
		break;
	case UPNP_EVENT_SUBSCRIBE_COMPLETE:
92
		upnp_igd_print(uIGD, level, "UPNP_EVENT_SUBSCRIBE_COMPLETE");
93 94
		break;
	case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
95
		upnp_igd_print(uIGD, level, "UPNP_EVENT_UNSUBSCRIBE_COMPLETE");
96 97
		break;
	case UPNP_EVENT_AUTORENEWAL_FAILED:
98
		upnp_igd_print(uIGD, level, "UPNP_EVENT_AUTORENEWAL_FAILED");
99 100
		break;
	case UPNP_EVENT_SUBSCRIPTION_EXPIRED:
101
		upnp_igd_print(uIGD, level, "UPNP_EVENT_SUBSCRIPTION_EXPIRED");
102 103 104 105 106 107 108
		break;
	}
}

void upnp_igd_print_event(upnp_igd_context *uIGD, upnp_igd_print_level level, Upnp_EventType EventType, void *Event) {
	ithread_mutex_lock(&uIGD->print_mutex);

109
	upnp_igd_print(uIGD, level, "======================================================================");
110 111 112 113 114 115 116 117
	upnp_igd_print_event_type(uIGD, level, EventType);
	switch (EventType) {
	/* SSDP */
	case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
	case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
	case UPNP_DISCOVERY_SEARCH_RESULT: {
		struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;

118
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
119
			UpnpGetErrorMessage(d_event->ErrCode), d_event->ErrCode);
120 121 122 123 124 125 126 127
		upnp_igd_print(uIGD, level, "Expires     =  %d",  d_event->Expires);
		upnp_igd_print(uIGD, level, "DeviceId    =  %s",  d_event->DeviceId);
		upnp_igd_print(uIGD, level, "DeviceType  =  %s",  d_event->DeviceType);
		upnp_igd_print(uIGD, level, "ServiceType =  %s",  d_event->ServiceType);
		upnp_igd_print(uIGD, level, "ServiceVer  =  %s",  d_event->ServiceVer);
		upnp_igd_print(uIGD, level, "Location    =  %s",  d_event->Location);
		upnp_igd_print(uIGD, level, "OS          =  %s",  d_event->Os);
		upnp_igd_print(uIGD, level, "Ext         =  %s",  d_event->Ext);
128 129 130 131 132 133 134 135 136 137 138
		break;
	}
	case UPNP_DISCOVERY_SEARCH_TIMEOUT:
		/* Nothing to print out here */
		break;
	/* SOAP */
	case UPNP_CONTROL_ACTION_REQUEST: {
		struct Upnp_Action_Request *a_event =
			(struct Upnp_Action_Request *)Event;
		char *xmlbuff = NULL;

139
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
140
			UpnpGetErrorMessage(a_event->ErrCode), a_event->ErrCode);
141 142 143 144
		upnp_igd_print(uIGD, level, "ErrStr      =  %s", a_event->ErrStr);
		upnp_igd_print(uIGD, level, "ActionName  =  %s", a_event->ActionName);
		upnp_igd_print(uIGD, level, "UDN         =  %s", a_event->DevUDN);
		upnp_igd_print(uIGD, level, "ServiceID   =  %s", a_event->ServiceID);
145 146 147
		if (a_event->ActionRequest) {
			xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionRequest);
			if (xmlbuff) {
148
				upnp_igd_print(uIGD, level, "ActRequest  =  %s", xmlbuff);
149 150 151 152
				ixmlFreeDOMString(xmlbuff);
			}
			xmlbuff = NULL;
		} else {
153
			upnp_igd_print(uIGD, level, "ActRequest  =  (null)");
154 155 156 157
		}
		if (a_event->ActionResult) {
			xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionResult);
			if (xmlbuff) {
158
				upnp_igd_print(uIGD, level, "ActResult   =  %s", xmlbuff);
159 160 161 162
				ixmlFreeDOMString(xmlbuff);
			}
			xmlbuff = NULL;
		} else {
163
			upnp_igd_print(uIGD, level, "ActResult   =  (null)");
164 165 166 167 168 169 170 171
		}
		break;
	}
	case UPNP_CONTROL_ACTION_COMPLETE: {
		struct Upnp_Action_Complete *a_event =
			(struct Upnp_Action_Complete *)Event;
		char *xmlbuff = NULL;

172
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
173
			UpnpGetErrorMessage(a_event->ErrCode), a_event->ErrCode);
174
		upnp_igd_print(uIGD, level, "CtrlUrl     =  %s", a_event->CtrlUrl);
175 176 177
		if (a_event->ActionRequest) {
			xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionRequest);
			if (xmlbuff) {
178
				upnp_igd_print(uIGD, level, "ActRequest  =  %s", xmlbuff);
179 180 181 182
				ixmlFreeDOMString(xmlbuff);
			}
			xmlbuff = NULL;
		} else {
183
			upnp_igd_print(uIGD, level, "ActRequest  =  (null)");
184 185 186 187
		}
		if (a_event->ActionResult) {
			xmlbuff = ixmlPrintNode((IXML_Node *)a_event->ActionResult);
			if (xmlbuff) {
188
				upnp_igd_print(uIGD, level, "ActResult   =  %s", xmlbuff);
189 190 191 192
				ixmlFreeDOMString(xmlbuff);
			}
			xmlbuff = NULL;
		} else {
193
			upnp_igd_print(uIGD, level, "ActResult   =  (null)");
194 195 196 197 198 199 200
		}
		break;
	}
	case UPNP_CONTROL_GET_VAR_REQUEST: {
		struct Upnp_State_Var_Request *sv_event =
			(struct Upnp_State_Var_Request *)Event;

201
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
202
			UpnpGetErrorMessage(sv_event->ErrCode), sv_event->ErrCode);
203 204 205 206 207
		upnp_igd_print(uIGD, level, "ErrStr      =  %s", sv_event->ErrStr);
		upnp_igd_print(uIGD, level, "UDN         =  %s", sv_event->DevUDN);
		upnp_igd_print(uIGD, level, "ServiceID   =  %s", sv_event->ServiceID);
		upnp_igd_print(uIGD, level, "StateVarName=  %s", sv_event->StateVarName);
		upnp_igd_print(uIGD, level, "CurrentVal  =  %s", sv_event->CurrentVal);
208 209 210 211 212 213
		break;
	}
	case UPNP_CONTROL_GET_VAR_COMPLETE: {
		struct Upnp_State_Var_Complete *sv_event =
			(struct Upnp_State_Var_Complete *)Event;

214
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
215
			UpnpGetErrorMessage(sv_event->ErrCode), sv_event->ErrCode);
216 217 218
		upnp_igd_print(uIGD, level, "CtrlUrl     =  %s", sv_event->CtrlUrl);
		upnp_igd_print(uIGD, level, "StateVarName=  %s", sv_event->StateVarName);
		upnp_igd_print(uIGD, level, "CurrentVal  =  %s", sv_event->CurrentVal);
219 220 221 222 223 224 225
		break;
	}
	/* GENA */
	case UPNP_EVENT_SUBSCRIPTION_REQUEST: {
		struct Upnp_Subscription_Request *sr_event =
			(struct Upnp_Subscription_Request *)Event;

226 227 228
		upnp_igd_print(uIGD, level, "ServiceID   =  %s", sr_event->ServiceId);
		upnp_igd_print(uIGD, level, "UDN         =  %s", sr_event->UDN);
		upnp_igd_print(uIGD, level, "SID         =  %s", sr_event->Sid);
229 230 231 232 233 234
		break;
	}
	case UPNP_EVENT_RECEIVED: {
		struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
		char *xmlbuff = NULL;

235 236
		upnp_igd_print(uIGD, level, "SID         =  %s", e_event->Sid);
		upnp_igd_print(uIGD, level, "EventKey    =  %d",	e_event->EventKey);
237
		xmlbuff = ixmlPrintNode((IXML_Node *)e_event->ChangedVariables);
238
		upnp_igd_print(uIGD, level, "ChangedVars =  %s", xmlbuff);
239 240 241 242 243 244 245 246
		ixmlFreeDOMString(xmlbuff);
		xmlbuff = NULL;
		break;
	}
	case UPNP_EVENT_RENEWAL_COMPLETE: {
		struct Upnp_Event_Subscribe *es_event =
			(struct Upnp_Event_Subscribe *)Event;

247 248
		upnp_igd_print(uIGD, level, "SID         =  %s", es_event->Sid);
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
249
			UpnpGetErrorMessage(es_event->ErrCode), es_event->ErrCode);
250
		upnp_igd_print(uIGD, level, "TimeOut     =  %d", es_event->TimeOut);
251 252 253 254 255 256 257
		break;
	}
	case UPNP_EVENT_SUBSCRIBE_COMPLETE:
	case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: {
		struct Upnp_Event_Subscribe *es_event =
			(struct Upnp_Event_Subscribe *)Event;

258 259
		upnp_igd_print(uIGD, level, "SID         =  %s", es_event->Sid);
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
260
			UpnpGetErrorMessage(es_event->ErrCode), es_event->ErrCode);
261 262
		upnp_igd_print(uIGD, level, "PublisherURL=  %s", es_event->PublisherUrl);
		upnp_igd_print(uIGD, level, "TimeOut     =  %d", es_event->TimeOut);
263 264 265 266 267 268 269
		break;
	}
	case UPNP_EVENT_AUTORENEWAL_FAILED:
	case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
		struct Upnp_Event_Subscribe *es_event =
			(struct Upnp_Event_Subscribe *)Event;

270 271
		upnp_igd_print(uIGD, level, "SID         =  %s", es_event->Sid);
		upnp_igd_print(uIGD, level, "ErrCode     =  %s(%d)",
272
			UpnpGetErrorMessage(es_event->ErrCode), es_event->ErrCode);
273 274
		upnp_igd_print(uIGD, level, "PublisherURL=  %s", es_event->PublisherUrl);
		upnp_igd_print(uIGD, level, "TimeOut     =  %d", es_event->TimeOut);
275 276 277
		break;
	}
	}
278
	upnp_igd_print(uIGD, level,"======================================================================");
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295

	ithread_mutex_unlock(&uIGD->print_mutex);
}


char *upnp_igd_get_first_document_item(upnp_igd_context *uIGD, IXML_Document *doc, const char *item) {
	IXML_NodeList *nodeList = NULL;
	IXML_Node *textNode = NULL;
	IXML_Node *tmpNode = NULL;
	char *ret = NULL;

	nodeList = ixmlDocument_getElementsByTagName(doc, (char *)item);
	if (nodeList) {
		tmpNode = ixmlNodeList_item(nodeList, 0);
		if (tmpNode) {
			textNode = ixmlNode_getFirstChild(tmpNode);
			if (!textNode) {
296
				upnp_igd_print(uIGD, UPNP_IGD_WARNING, "%s(%d): (BUG) ixmlNode_getFirstChild(tmpNode) returned NULL",
297 298 299 300 301 302
					__FILE__, __LINE__);
				ret = strdup("");
				goto epilogue;
			}
			ret = strdup(ixmlNode_getNodeValue(textNode));
			if (!ret) {
303
				upnp_igd_print(uIGD, UPNP_IGD_WARNING, "%s(%d): ixmlNode_getNodeValue returned NULL",
304 305 306 307
					__FILE__, __LINE__);
				ret = strdup("");
			}
		} else
308
			upnp_igd_print(uIGD, UPNP_IGD_WARNING, "%s(%d): ixmlNodeList_item(nodeList, 0) returned NULL",
309 310
				__FILE__, __LINE__);
	} else
311
		upnp_igd_print(uIGD, UPNP_IGD_ERROR, "%s(%d): Error finding %s in XML Node",
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
			__FILE__, __LINE__, item);

epilogue:
	if (nodeList)
		ixmlNodeList_free(nodeList);

	return ret;
}

char *upnp_igd_get_element_value(upnp_igd_context *uIGD, IXML_Element *element)
{
	IXML_Node *child = ixmlNode_getFirstChild((IXML_Node *)element);
	char *temp = NULL;

	if (child != 0 && ixmlNode_getNodeType(child) == eTEXT_NODE)
		temp = strdup(ixmlNode_getNodeValue(child));

	return temp;
}


char *upnp_igd_get_first_element_item(upnp_igd_context *uIGD,IXML_Element *element, const char *item)
{
	IXML_NodeList *nodeList = NULL;
	IXML_Node *textNode = NULL;
	IXML_Node *tmpNode = NULL;
	char *ret = NULL;

	nodeList = ixmlElement_getElementsByTagName(element, (char *)item);
	if (nodeList == NULL) {
342
		upnp_igd_print(uIGD, UPNP_IGD_ERROR, "%s(%d): Error finding %s in XML Node",
343 344 345 346 347
			__FILE__, __LINE__, item);
		return NULL;
	}
	tmpNode = ixmlNodeList_item(nodeList, 0);
	if (!tmpNode) {
348
		upnp_igd_print(uIGD, UPNP_IGD_ERROR, "%s(%d): Error finding %s value in XML Node",
349 350 351 352 353 354 355
			__FILE__, __LINE__, item);
		ixmlNodeList_free(nodeList);
		return NULL;
	}
	textNode = ixmlNode_getFirstChild(tmpNode);
	ret = strdup(ixmlNode_getNodeValue(textNode));
	if (!ret) {
356
		upnp_igd_print(uIGD, UPNP_IGD_ERROR, "%s(%d): Error allocating memory for %s in XML Node",
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
			__FILE__, __LINE__, item);
		ixmlNodeList_free(nodeList);
		return NULL;
	}
	ixmlNodeList_free(nodeList);

	return ret;
}


IXML_NodeList *upnp_igd_get_nth_service_list(upnp_igd_context *uIGD,
	/*! [in] . */
	IXML_Document *doc,
	/*! [in] . */
	unsigned int n) {
	IXML_NodeList *ServiceList = NULL;
	IXML_NodeList *servlistnodelist = NULL;
	IXML_Node *servlistnode = NULL;

	/*  ixmlDocument_getElementsByTagName()
	 *  Returns a NodeList of all Elements that match the given
	 *  tag name in the order in which they were encountered in a preorder
	 *  traversal of the Document tree.
	 *
	 *  return (NodeList*) A pointer to a NodeList containing the
	 *                      matching items or NULL on an error. 	 */
	servlistnodelist = ixmlDocument_getElementsByTagName(doc, "serviceList");
	if (servlistnodelist && ixmlNodeList_length(servlistnodelist) && n < ixmlNodeList_length(servlistnodelist)) {
		/* For the first service list (from the root device),
		 * we pass 0 */
		/*servlistnode = ixmlNodeList_item( servlistnodelist, 0 );*/

		/* Retrieves a Node from a NodeList} specified by a
		 *  numerical index.
		 *
		 *  return (Node*) A pointer to a Node or NULL if there was an
		 *                  error. */
		servlistnode = ixmlNodeList_item(servlistnodelist, n);
		if (servlistnode) {
			/* create as list of DOM nodes */
			ServiceList = ixmlElement_getElementsByTagName((IXML_Element *)servlistnode, "service");
		} else {
399
			upnp_igd_print(uIGD, UPNP_IGD_WARNING, "%s(%d): ixmlNodeList_item(nodeList, n) returned NULL", __FILE__, __LINE__);
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
		}
	}
	if (servlistnodelist) {
		ixmlNodeList_free(servlistnodelist);
	}

	return ServiceList;
}

int upnp_igd_get_find_and_parse_service(upnp_igd_context *uIGD, IXML_Document *DescDoc, const char *location,
		const char *serviceType, char **serviceId, char **eventURL, char **controlURL) {
	unsigned int i;
	unsigned long length;
	int found = 0;
	int ret;
	unsigned int sindex = 0;
	char *tempServiceType = NULL;
	char *baseURL = NULL;
	const char *base = NULL;
	char *relcontrolURL = NULL;
	char *releventURL = NULL;
	IXML_NodeList *serviceList = NULL;
	IXML_Element *service = NULL;
	baseURL = upnp_igd_get_first_document_item(uIGD, DescDoc, "URLBase");
	if (baseURL)
		base = baseURL;
	else
		base = location;
	for (sindex = 0;
	     (serviceList = upnp_igd_get_nth_service_list(uIGD, DescDoc , sindex)) != NULL;
	     sindex++) {
		tempServiceType = NULL;
		relcontrolURL = NULL;
		releventURL = NULL;
		service = NULL;
		length = ixmlNodeList_length(serviceList);
		for (i = 0; i < length; i++) {
			service = (IXML_Element *)ixmlNodeList_item(serviceList, i);
			tempServiceType = upnp_igd_get_first_element_item(uIGD,
				(IXML_Element *)service, "serviceType");
			if (tempServiceType && strcmp(tempServiceType, serviceType) == 0) {
441
				upnp_igd_print(uIGD, UPNP_IGD_DEBUG, "Found service: %s", serviceType);
442
				*serviceId = upnp_igd_get_first_element_item(uIGD, service, "serviceId");
443
				upnp_igd_print(uIGD, UPNP_IGD_DEBUG, "serviceId: %s", *serviceId);
444 445 446 447 448 449
				relcontrolURL = upnp_igd_get_first_element_item(uIGD, service, "controlURL");
				releventURL = upnp_igd_get_first_element_item(uIGD, service, "eventSubURL");
				*controlURL = malloc(strlen(base) + strlen(relcontrolURL) + 1);
				if (*controlURL) {
					ret = UpnpResolveURL(base, relcontrolURL, *controlURL);
					if (ret != UPNP_E_SUCCESS)
450
						upnp_igd_print(uIGD, UPNP_IGD_ERROR, "Error generating controlURL from %s + %s",
451 452 453 454 455 456
							base, relcontrolURL);
				}
				*eventURL = malloc(strlen(base) + strlen(releventURL) + 1);
				if (*eventURL) {
					ret = UpnpResolveURL(base, releventURL, *eventURL);
					if (ret != UPNP_E_SUCCESS)
457
						upnp_igd_print(uIGD, UPNP_IGD_ERROR, "Error generating eventURL from %s + %s",
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
							base, releventURL);
				}
				free(relcontrolURL);
				free(releventURL);
				relcontrolURL = NULL;
				releventURL = NULL;
				found = 1;
				break;
			}
			free(tempServiceType);
			tempServiceType = NULL;
		}
		free(tempServiceType);
		tempServiceType = NULL;
		if (serviceList)
			ixmlNodeList_free(serviceList);
		serviceList = NULL;
	}
	free(baseURL);

	return found;
}