mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-18 00:46:30 +00:00
add a few checks
This commit is contained in:
parent
688b13586c
commit
0877a65ed6
@ -5,3 +5,9 @@ UPnP IGD control point (ie client) using libevent
|
|||||||
http://libevent.org
|
http://libevent.org
|
||||||
https://github.com/libevent/libevent
|
https://github.com/libevent/libevent
|
||||||
|
|
||||||
|
The UPnP Event code needs SUBSCRIBE / UNSUBSCRIBE / NOTIFY HTTP methods.
|
||||||
|
Implementation is in progress in libevent HTTP code :
|
||||||
|
https://github.com/libevent/libevent/pull/327
|
||||||
|
|
||||||
|
|
||||||
|
TODO : improve error handling / reporting
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* $Id: miniupnpc-libevent.c,v 1.27 2015/07/22 13:51:09 nanard Exp $ */
|
/* $Id: miniupnpc-libevent.c,v 1.27 2015/07/22 13:51:09 nanard Exp $ */
|
||||||
/* miniupnpc-libevent
|
/* miniupnpc-libevent
|
||||||
* Copyright (c) 2008-2014, Thomas BERNARD <miniupnp@free.fr>
|
* Copyright (c) 2008-2016, Thomas BERNARD <miniupnp@free.fr>
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
@ -240,6 +240,10 @@ static void upnpc_receive_and_parse_ssdp(evutil_socket_t s, short events, upnpc_
|
|||||||
debug_printf("device already known\n");
|
debug_printf("device already known\n");
|
||||||
} else {
|
} else {
|
||||||
device = malloc(sizeof(upnpc_device_t));
|
device = malloc(sizeof(upnpc_device_t));
|
||||||
|
if(device == NULL) {
|
||||||
|
debug_printf("Memory allocation error\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
memset(device, 0, sizeof(upnpc_device_t));
|
memset(device, 0, sizeof(upnpc_device_t));
|
||||||
device->parent = p;
|
device->parent = p;
|
||||||
device->next = p->devices;
|
device->next = p->devices;
|
||||||
@ -247,7 +251,9 @@ static void upnpc_receive_and_parse_ssdp(evutil_socket_t s, short events, upnpc_
|
|||||||
if(upnpc_set_root_desc_location(device, location, locationsize) < 0) {
|
if(upnpc_set_root_desc_location(device, location, locationsize) < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
upnpc_get_desc(device, device->root_desc_location);
|
if(upnpc_get_desc(device, device->root_desc_location)) {
|
||||||
|
debug_printf("FAILED to request device root description\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
event_del(p->ev_ssdp_recv); /* stop receiving SSDP responses */
|
event_del(p->ev_ssdp_recv); /* stop receiving SSDP responses */
|
||||||
@ -523,8 +529,7 @@ static int upnpc_get_desc(upnpc_device_t * d, const char * url)
|
|||||||
evhttp_add_header(headers, "Host", hostname_port);
|
evhttp_add_header(headers, "Host", hostname_port);
|
||||||
evhttp_add_header(headers, "Connection", "close");
|
evhttp_add_header(headers, "Connection", "close");
|
||||||
/*evhttp_add_header(headers, "User-Agent", "***");*/
|
/*evhttp_add_header(headers, "User-Agent", "***");*/
|
||||||
evhttp_make_request(d->desc_conn, req, EVHTTP_REQ_GET, path);
|
return evhttp_make_request(d->desc_conn, req, EVHTTP_REQ_GET, path);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * build_url_string(const char * urlbase, const char * root_desc_url, const char * controlurl)
|
static char * build_url_string(const char * urlbase, const char * root_desc_url, const char * controlurl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user