Skip to content

Commit

Permalink
add a few checks
Browse files Browse the repository at this point in the history
  • Loading branch information
miniupnp committed Mar 29, 2016
1 parent 688b135 commit 0877a65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions miniupnpc-libevent/README
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ UPnP IGD control point (ie client) using libevent
http://libevent.org
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
13 changes: 9 additions & 4 deletions miniupnpc-libevent/miniupnpc-libevent.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* $Id: miniupnpc-libevent.c,v 1.27 2015/07/22 13:51:09 nanard Exp $ */
/* miniupnpc-libevent
* Copyright (c) 2008-2014, Thomas BERNARD <[email protected]>
* Copyright (c) 2008-2016, Thomas BERNARD <[email protected]>
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
*
* Permission to use, copy, modify, and/or distribute this software for any
Expand Down Expand Up @@ -240,14 +240,20 @@ static void upnpc_receive_and_parse_ssdp(evutil_socket_t s, short events, upnpc_
debug_printf("device already known\n");
} else {
device = malloc(sizeof(upnpc_device_t));
if(device == NULL) {
debug_printf("Memory allocation error\n");
return;
}
memset(device, 0, sizeof(upnpc_device_t));
device->parent = p;
device->next = p->devices;
p->devices = device;
if(upnpc_set_root_desc_location(device, location, locationsize) < 0) {
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
event_del(p->ev_ssdp_recv); /* stop receiving SSDP responses */
Expand Down Expand Up @@ -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, "Connection", "close");
/*evhttp_add_header(headers, "User-Agent", "***");*/
evhttp_make_request(d->desc_conn, req, EVHTTP_REQ_GET, path);
return 0;
return evhttp_make_request(d->desc_conn, req, EVHTTP_REQ_GET, path);
}

static char * build_url_string(const char * urlbase, const char * root_desc_url, const char * controlurl)
Expand Down

0 comments on commit 0877a65

Please sign in to comment.