miniupnpc-async: rename enum values to avoid collisions
This commit is contained in:
parent
73223d8e20
commit
810ae45e9d
|
@ -147,13 +147,13 @@ static int upnpc_send_ssdp_msearch(upnpc_t * p, const char * device, unsigned in
|
||||||
int err = SOCKET_ERROR;
|
int err = SOCKET_ERROR;
|
||||||
if(err == EINTR || WOULDBLOCK(err)) {
|
if(err == EINTR || WOULDBLOCK(err)) {
|
||||||
debug_printf("upnpc_send_ssdp_msearch: should try again");
|
debug_printf("upnpc_send_ssdp_msearch: should try again");
|
||||||
p->state = ESendSSDP;
|
p->state = EUPnPSendSSDP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRINT_SOCKET_ERROR("sendto");
|
PRINT_SOCKET_ERROR("sendto");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p->state = EReceiveSSDP;
|
p->state = EUPnPReceiveSSDP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,21 +201,21 @@ static int upnpc_receive_and_parse_ssdp(upnpc_t * p)
|
||||||
}
|
}
|
||||||
dev = calloc(1, sizeof(upnpc_device_t));
|
dev = calloc(1, sizeof(upnpc_device_t));
|
||||||
if(dev == NULL) {
|
if(dev == NULL) {
|
||||||
p->state = EError;
|
p->state = EUPnPError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(upnpc_set_root_desc_location(dev, location, locationsize) < 0) {
|
if(upnpc_set_root_desc_location(dev, location, locationsize) < 0) {
|
||||||
free(dev);
|
free(dev);
|
||||||
p->state = EError;
|
p->state = EUPnPError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
dev->next = p->device_list;
|
dev->next = p->device_list;
|
||||||
p->device_list = dev;
|
p->device_list = dev;
|
||||||
dev->state = EGetDescConnect;
|
dev->state = EDevGetDescConnect;
|
||||||
upnpc_connect(dev, dev->root_desc_location);
|
upnpc_connect(dev, dev->root_desc_location);
|
||||||
} else {
|
} else {
|
||||||
/* or do nothing ? */
|
/* or do nothing ? */
|
||||||
p->state = EError;
|
p->state = EUPnPError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -332,13 +332,13 @@ static int upnpc_connect(upnpc_device_t * p, const char * url)
|
||||||
}*/
|
}*/
|
||||||
if(!parseURL(url/*p->root_desc_location*/, hostname, &port,
|
if(!parseURL(url/*p->root_desc_location*/, hostname, &port,
|
||||||
&path, &scope_id)) {
|
&path, &scope_id)) {
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p->http_socket = socket(PF_INET, SOCK_STREAM, 0);
|
p->http_socket = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
if(p->http_socket < 0) {
|
if(p->http_socket < 0) {
|
||||||
PRINT_SOCKET_ERROR("socket");
|
PRINT_SOCKET_ERROR("socket");
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(!set_non_blocking(p->http_socket)) {
|
if(!set_non_blocking(p->http_socket)) {
|
||||||
|
@ -357,15 +357,15 @@ static int upnpc_connect(upnpc_device_t * p, const char * url)
|
||||||
return 0;
|
return 0;
|
||||||
} else if(errno != EINTR) {
|
} else if(errno != EINTR) {
|
||||||
PRINT_SOCKET_ERROR("connect");
|
PRINT_SOCKET_ERROR("connect");
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(r < 0 && errno == EINTR);
|
} while(r < 0 && errno == EINTR);
|
||||||
if(p->state == EGetDescConnect) {
|
if(p->state == EDevGetDescConnect) {
|
||||||
p->state = EGetDescRequest;
|
p->state = EDevGetDescRequest;
|
||||||
} else {
|
} else {
|
||||||
p->state = ESoapRequest;
|
p->state = EDevSoapRequest;
|
||||||
}
|
}
|
||||||
upnpc_send_request(p);
|
upnpc_send_request(p);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -378,18 +378,18 @@ static int upnpc_complete_connect(upnpc_device_t * p)
|
||||||
len = sizeof(err);
|
len = sizeof(err);
|
||||||
if(getsockopt(p->http_socket, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
|
if(getsockopt(p->http_socket, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
|
||||||
PRINT_SOCKET_ERROR("getsockopt");
|
PRINT_SOCKET_ERROR("getsockopt");
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(err != 0) {
|
if(err != 0) {
|
||||||
debug_printf("connect failed %d\n", err);
|
debug_printf("connect failed %d\n", err);
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(p->state == EGetDescConnect)
|
if(p->state == EDevGetDescConnect)
|
||||||
p->state = EGetDescRequest;
|
p->state = EDevGetDescRequest;
|
||||||
else
|
else
|
||||||
p->state = ESoapRequest;
|
p->state = EDevSoapRequest;
|
||||||
upnpc_send_request(p);
|
upnpc_send_request(p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -417,13 +417,13 @@ static int upnpc_send_request(upnpc_device_t * p)
|
||||||
int len;
|
int len;
|
||||||
if(!parseURL(p->root_desc_location, hostname, &port,
|
if(!parseURL(p->root_desc_location, hostname, &port,
|
||||||
&path, &scope_id)) {
|
&path, &scope_id)) {
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len = snprintf(NULL, 0, reqfmt, path, hostname, port);
|
len = snprintf(NULL, 0, reqfmt, path, hostname, port);
|
||||||
p->http_request = malloc(len + 1);
|
p->http_request = malloc(len + 1);
|
||||||
if(p->http_request == NULL) {
|
if(p->http_request == NULL) {
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p->http_request_len = snprintf(p->http_request, len + 1,
|
p->http_request_len = snprintf(p->http_request, len + 1,
|
||||||
|
@ -434,7 +434,7 @@ static int upnpc_send_request(upnpc_device_t * p)
|
||||||
p->http_request_len - p->http_request_sent, 0/* flags */);
|
p->http_request_len - p->http_request_sent, 0/* flags */);
|
||||||
if(n < 0) {
|
if(n < 0) {
|
||||||
PRINT_SOCKET_ERROR("send");
|
PRINT_SOCKET_ERROR("send");
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
debug_printf("sent %d bytes\n", (int)n);
|
debug_printf("sent %d bytes\n", (int)n);
|
||||||
|
@ -451,10 +451,10 @@ static int upnpc_send_request(upnpc_device_t * p)
|
||||||
free(p->http_request);
|
free(p->http_request);
|
||||||
p->http_request = NULL;
|
p->http_request = NULL;
|
||||||
p->http_request_len = 0;
|
p->http_request_len = 0;
|
||||||
if(p->state == EGetDescRequest)
|
if(p->state == EDevGetDescRequest)
|
||||||
p->state = EGetDescResponse;
|
p->state = EDevGetDescResponse;
|
||||||
else
|
else
|
||||||
p->state = ESoapResponse;
|
p->state = EDevSoapResponse;
|
||||||
free(p->http_response);
|
free(p->http_response);
|
||||||
p->http_response = NULL;
|
p->http_response = NULL;
|
||||||
p->http_response_received = 0;
|
p->http_response_received = 0;
|
||||||
|
@ -591,7 +591,7 @@ static int upnpc_get_response(upnpc_device_t * p)
|
||||||
if(errno == EINTR || WOULDBLOCK(errno))
|
if(errno == EINTR || WOULDBLOCK(errno))
|
||||||
return 0; /* try again later */
|
return 0; /* try again later */
|
||||||
PRINT_SOCKET_ERROR("read");
|
PRINT_SOCKET_ERROR("read");
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
} else if(n == 0) {
|
} else if(n == 0) {
|
||||||
/* receiving finished */
|
/* receiving finished */
|
||||||
|
@ -604,7 +604,7 @@ static int upnpc_get_response(upnpc_device_t * p)
|
||||||
}
|
}
|
||||||
/* TODO : decode chunked transfer-encoding */
|
/* TODO : decode chunked transfer-encoding */
|
||||||
/* parse xml */
|
/* parse xml */
|
||||||
if(p->state == EGetDescResponse) {
|
if(p->state == EDevGetDescResponse) {
|
||||||
struct IGDdatas igd;
|
struct IGDdatas igd;
|
||||||
struct xmlparser parser;
|
struct xmlparser parser;
|
||||||
memset(&igd, 0, sizeof(struct IGDdatas));
|
memset(&igd, 0, sizeof(struct IGDdatas));
|
||||||
|
@ -633,7 +633,7 @@ static int upnpc_get_response(upnpc_device_t * p)
|
||||||
p->http_response = NULL;
|
p->http_response = NULL;
|
||||||
p->http_response_received = 0;
|
p->http_response_received = 0;
|
||||||
p->http_response_end_of_headers = 0;
|
p->http_response_end_of_headers = 0;
|
||||||
p->state = EReady;
|
p->state = EDevReady;
|
||||||
} else {
|
} else {
|
||||||
/* receiving in progress */
|
/* receiving in progress */
|
||||||
debug_printf("received %d bytes:\n%.*s\n", (int)n, (int)n, buffer);
|
debug_printf("received %d bytes:\n%.*s\n", (int)n, (int)n, buffer);
|
||||||
|
@ -641,7 +641,7 @@ static int upnpc_get_response(upnpc_device_t * p)
|
||||||
p->http_response = malloc(n);
|
p->http_response = malloc(n);
|
||||||
if(p->http_response == NULL) {
|
if(p->http_response == NULL) {
|
||||||
debug_printf("failed to malloc %d bytes\n", (int)n);
|
debug_printf("failed to malloc %d bytes\n", (int)n);
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p->http_response_received = n;
|
p->http_response_received = n;
|
||||||
|
@ -650,7 +650,7 @@ static int upnpc_get_response(upnpc_device_t * p)
|
||||||
char * tmp = realloc(p->http_response, p->http_response_received + n);
|
char * tmp = realloc(p->http_response, p->http_response_received + n);
|
||||||
if(tmp == NULL) {
|
if(tmp == NULL) {
|
||||||
debug_printf("failed to realloc %d bytes\n", (int)(p->http_response_received + n));
|
debug_printf("failed to realloc %d bytes\n", (int)(p->http_response_received + n));
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p->http_response = tmp;
|
p->http_response = tmp;
|
||||||
|
@ -714,7 +714,7 @@ static int upnpc_build_soap_request(upnpc_device_t * p, const char * url,
|
||||||
}
|
}
|
||||||
args_xml = malloc(++l);
|
args_xml = malloc(++l);
|
||||||
if(args_xml == NULL) {
|
if(args_xml == NULL) {
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for(i = 0, n = 0; i < arg_count && n < l; i++) {
|
for(i = 0, n = 0; i < arg_count && n < l; i++) {
|
||||||
|
@ -727,7 +727,7 @@ static int upnpc_build_soap_request(upnpc_device_t * p, const char * url,
|
||||||
body_len = snprintf(NULL, 0, fmt_soap, action, service, args_xml?args_xml:"", action);
|
body_len = snprintf(NULL, 0, fmt_soap, action, service, args_xml?args_xml:"", action);
|
||||||
body = malloc(body_len + 1);
|
body = malloc(body_len + 1);
|
||||||
if(body == NULL) {
|
if(body == NULL) {
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
free(args_xml);
|
free(args_xml);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +737,7 @@ static int upnpc_build_soap_request(upnpc_device_t * p, const char * url,
|
||||||
free(args_xml);
|
free(args_xml);
|
||||||
args_xml = NULL;
|
args_xml = NULL;
|
||||||
if(!parseURL(url, hostname, &port, &path, &scope_id)) {
|
if(!parseURL(url, hostname, &port, &path, &scope_id)) {
|
||||||
p->state = EError;
|
p->state = EDevError;
|
||||||
free(body);
|
free(body);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -766,7 +766,7 @@ int upnpc_init(upnpc_t * p, const char * multicastif)
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
if(!p)
|
if(!p)
|
||||||
return UPNPC_ERR_INVALID_ARGS;
|
return UPNPC_ERR_INVALID_ARGS;
|
||||||
p->state = EError;
|
p->state = EUPnPError;
|
||||||
memset(p, 0, sizeof(upnpc_t)); /* clean everything */
|
memset(p, 0, sizeof(upnpc_t)); /* clean everything */
|
||||||
/* open the socket for SSDP */
|
/* open the socket for SSDP */
|
||||||
p->ssdp_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
p->ssdp_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
@ -807,7 +807,7 @@ int upnpc_init(upnpc_t * p, const char * multicastif)
|
||||||
return UPNPC_ERR_BIND_FAILED;
|
return UPNPC_ERR_BIND_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->state = EInit;
|
p->state = EUPnPInit;
|
||||||
return UPNPC_OK;
|
return UPNPC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,7 +838,7 @@ int upnpc_finalize(upnpc_t * p)
|
||||||
free(p->device_list);
|
free(p->device_list);
|
||||||
p->device_list = next;
|
p->device_list = next;
|
||||||
}
|
}
|
||||||
p->state = EFinalized;
|
p->state = EUPnPFinalized;
|
||||||
return UPNPC_OK;
|
return UPNPC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ int upnpc_get_external_ip_address(upnpc_device_t * p)
|
||||||
upnpc_build_soap_request(p, p->control_conn_url,
|
upnpc_build_soap_request(p, p->control_conn_url,
|
||||||
"urn:schemas-upnp-org:service:WANIPConnection:1",
|
"urn:schemas-upnp-org:service:WANIPConnection:1",
|
||||||
"GetExternalIPAddress", NULL, 0);
|
"GetExternalIPAddress", NULL, 0);
|
||||||
p->state = ESoapConnect;
|
p->state = EDevSoapConnect;
|
||||||
upnpc_connect(p, p->control_conn_url);
|
upnpc_connect(p, p->control_conn_url);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -857,7 +857,7 @@ int upnpc_get_link_layer_max_rate(upnpc_device_t * p)
|
||||||
upnpc_build_soap_request(p, p->control_cif_url,
|
upnpc_build_soap_request(p, p->control_cif_url,
|
||||||
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
|
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
|
||||||
"GetCommonLinkProperties", NULL, 0);
|
"GetCommonLinkProperties", NULL, 0);
|
||||||
p->state = ESoapConnect;
|
p->state = EDevSoapConnect;
|
||||||
upnpc_connect(p, p->control_conn_url);
|
upnpc_connect(p, p->control_conn_url);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -898,7 +898,7 @@ int upnpc_add_port_mapping(upnpc_device_t * p,
|
||||||
"urn:schemas-upnp-org:service:WANIPConnection:1",
|
"urn:schemas-upnp-org:service:WANIPConnection:1",
|
||||||
"AddPortMapping",
|
"AddPortMapping",
|
||||||
args, 8);
|
args, 8);
|
||||||
p->state = ESoapConnect;
|
p->state = EDevSoapConnect;
|
||||||
upnpc_connect(p, p->control_conn_url);
|
upnpc_connect(p, p->control_conn_url);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -911,17 +911,17 @@ int upnpc_select_fds(upnpc_t * p, int * nfds, fd_set * readfds, fd_set * writefd
|
||||||
if(!p) return UPNPC_ERR_INVALID_ARGS;
|
if(!p) return UPNPC_ERR_INVALID_ARGS;
|
||||||
for(d = p->device_list; d != NULL; d = d->next) {
|
for(d = p->device_list; d != NULL; d = d->next) {
|
||||||
switch(d->state) {
|
switch(d->state) {
|
||||||
case EGetDescConnect:
|
case EDevGetDescConnect:
|
||||||
case EGetDescRequest:
|
case EDevGetDescRequest:
|
||||||
case ESoapConnect:
|
case EDevSoapConnect:
|
||||||
case ESoapRequest:
|
case EDevSoapRequest:
|
||||||
FD_SET(d->http_socket, writefds);
|
FD_SET(d->http_socket, writefds);
|
||||||
if(*nfds < d->http_socket)
|
if(*nfds < d->http_socket)
|
||||||
*nfds = d->http_socket;
|
*nfds = d->http_socket;
|
||||||
n++;
|
n++;
|
||||||
break;
|
break;
|
||||||
case EGetDescResponse:
|
case EDevGetDescResponse:
|
||||||
case ESoapResponse:
|
case EDevSoapResponse:
|
||||||
FD_SET(d->http_socket, readfds);
|
FD_SET(d->http_socket, readfds);
|
||||||
if(*nfds < d->http_socket)
|
if(*nfds < d->http_socket)
|
||||||
*nfds = d->http_socket;
|
*nfds = d->http_socket;
|
||||||
|
@ -933,13 +933,13 @@ int upnpc_select_fds(upnpc_t * p, int * nfds, fd_set * readfds, fd_set * writefd
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(p->state) {
|
switch(p->state) {
|
||||||
case ESendSSDP:
|
case EUPnPSendSSDP:
|
||||||
FD_SET(p->ssdp_socket, writefds);
|
FD_SET(p->ssdp_socket, writefds);
|
||||||
if(*nfds < p->ssdp_socket)
|
if(*nfds < p->ssdp_socket)
|
||||||
*nfds = p->ssdp_socket;
|
*nfds = p->ssdp_socket;
|
||||||
n++;
|
n++;
|
||||||
break;
|
break;
|
||||||
case EReceiveSSDP:
|
case EUPnPReceiveSSDP:
|
||||||
default:
|
default:
|
||||||
/* still receive SSDP responses when processing Description, etc. */
|
/* still receive SSDP responses when processing Description, etc. */
|
||||||
FD_SET(p->ssdp_socket, readfds);
|
FD_SET(p->ssdp_socket, readfds);
|
||||||
|
@ -993,16 +993,16 @@ int upnpc_process(upnpc_t * p)
|
||||||
|
|
||||||
for(d = p->device_list; d != NULL; d = d->next) {
|
for(d = p->device_list; d != NULL; d = d->next) {
|
||||||
switch(d->state) {
|
switch(d->state) {
|
||||||
case EGetDescConnect:
|
case EDevGetDescConnect:
|
||||||
case ESoapConnect:
|
case EDevSoapConnect:
|
||||||
upnpc_complete_connect(d);
|
upnpc_complete_connect(d);
|
||||||
break;
|
break;
|
||||||
case EGetDescRequest:
|
case EDevGetDescRequest:
|
||||||
case ESoapRequest:
|
case EDevSoapRequest:
|
||||||
upnpc_send_request(d);
|
upnpc_send_request(d);
|
||||||
break;
|
break;
|
||||||
case EGetDescResponse:
|
case EDevGetDescResponse:
|
||||||
case ESoapResponse:
|
case EDevSoapResponse:
|
||||||
upnpc_get_response(d);
|
upnpc_get_response(d);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1012,28 +1012,28 @@ int upnpc_process(upnpc_t * p)
|
||||||
/* all devices ready => ready */
|
/* all devices ready => ready */
|
||||||
if(p->device_list != NULL) {
|
if(p->device_list != NULL) {
|
||||||
d = p->device_list;
|
d = p->device_list;
|
||||||
while(d && d->state == EReady) d = d->next;
|
while(d && d->state == EDevReady) d = d->next;
|
||||||
p->state = (d == NULL) ? EReady : EProcessing;
|
p->state = (d == NULL) ? EUPnPReady : EUPnPProcessing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p->socket_flags & UPNPC_SSDP_READABLE) {
|
if(p->socket_flags & UPNPC_SSDP_READABLE) {
|
||||||
upnpc_receive_and_parse_ssdp(p);
|
upnpc_receive_and_parse_ssdp(p);
|
||||||
}
|
}
|
||||||
switch(p->state) {
|
switch(p->state) {
|
||||||
case EInit:
|
case EUPnPInit:
|
||||||
upnpc_send_ssdp_msearch(p, devices_to_search[0], 2);
|
upnpc_send_ssdp_msearch(p, devices_to_search[0], 2);
|
||||||
break;
|
break;
|
||||||
case ESendSSDP:
|
case EUPnPSendSSDP:
|
||||||
upnpc_send_ssdp_msearch(p, devices_to_search[0], 2);
|
upnpc_send_ssdp_msearch(p, devices_to_search[0], 2);
|
||||||
break;
|
break;
|
||||||
case EReceiveSSDP:
|
case EUPnPReceiveSSDP:
|
||||||
/*upnpc_receive_and_parse_ssdp(p);*/
|
/*upnpc_receive_and_parse_ssdp(p);*/
|
||||||
break;
|
break;
|
||||||
/*case EGetDesc:
|
/*case EGetDesc:
|
||||||
upnpc_connect(p);
|
upnpc_connect(p);
|
||||||
break;*/
|
break;*/
|
||||||
case EReady:
|
case EUPnPReady:
|
||||||
case EProcessing:
|
case EUPnPProcessing:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return UPNPC_ERR_UNKNOWN_STATE;
|
return UPNPC_ERR_UNKNOWN_STATE;
|
||||||
|
|
|
@ -41,16 +41,16 @@ extern "C" {
|
||||||
typedef struct upnpc_device {
|
typedef struct upnpc_device {
|
||||||
struct upnpc_device * next;
|
struct upnpc_device * next;
|
||||||
enum {
|
enum {
|
||||||
EInit = 1,
|
EDevInit = 1,
|
||||||
EGetDescConnect,
|
EDevGetDescConnect,
|
||||||
EGetDescRequest,
|
EDevGetDescRequest,
|
||||||
EGetDescResponse,
|
EDevGetDescResponse,
|
||||||
EReady,
|
EDevReady,
|
||||||
ESoapConnect,
|
EDevSoapConnect,
|
||||||
ESoapRequest,
|
EDevSoapRequest,
|
||||||
ESoapResponse,
|
EDevSoapResponse,
|
||||||
EFinalized = 99,
|
EDevFinalized = 99,
|
||||||
EError = 1000
|
EDevError = 1000
|
||||||
} state;
|
} state;
|
||||||
char * root_desc_location;
|
char * root_desc_location;
|
||||||
char * control_cif_url;
|
char * control_cif_url;
|
||||||
|
@ -73,14 +73,14 @@ typedef struct upnpc_device {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
enum {
|
enum {
|
||||||
EInit = 1,
|
EUPnPInit = 1,
|
||||||
ESendSSDP,
|
EUPnPSendSSDP,
|
||||||
EReceiveSSDP,
|
EUPnPReceiveSSDP,
|
||||||
EGetDesc,
|
EUPnPGetDesc,
|
||||||
EReady,
|
EUPnPReady,
|
||||||
EProcessing,
|
EUPnPProcessing,
|
||||||
EFinalized = 99,
|
EUPnPFinalized = 99,
|
||||||
EError = 1000
|
EUPnPError = 1000
|
||||||
} state;
|
} state;
|
||||||
int socket_flags; /* see UPNPC_*_READABLE, etc. */
|
int socket_flags; /* see UPNPC_*_READABLE, etc. */
|
||||||
int ssdp_socket;
|
int ssdp_socket;
|
||||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
r = upnpc_process(&upnp);
|
r = upnpc_process(&upnp);
|
||||||
printf("upnpc_process returned %d\n", r);
|
printf("upnpc_process returned %d\n", r);
|
||||||
while(upnp.state != EError) {
|
while(upnp.state != EUPnPError) {
|
||||||
int nfds;
|
int nfds;
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
fd_set writefds;
|
fd_set writefds;
|
||||||
|
@ -81,7 +81,7 @@ int main(int argc, char * * argv)
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
if(r < 0)
|
if(r < 0)
|
||||||
break;
|
break;
|
||||||
if(upnp.state == EReady) {
|
if(upnp.state == EUPnPReady) {
|
||||||
char * p;
|
char * p;
|
||||||
if(device == NULL) {
|
if(device == NULL) {
|
||||||
/* select one device */
|
/* select one device */
|
||||||
|
|
Loading…
Reference in New Issue