Remove more implicit casts in upnp part
Remove more "implicit integer or enum conversions" as well as memset before snprintf.
This commit is contained in:
parent
db532afb9b
commit
2eb3e069ba
@ -2,6 +2,13 @@
|
||||
Version 1.6.16
|
||||
*******************************************************************************
|
||||
|
||||
2012-03-11 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||
|
||||
Remove more implicit casts in upnp part
|
||||
|
||||
Remove more "implicit integer or enum conversions" as well as memset
|
||||
before snprintf.
|
||||
|
||||
2012-03-11 Yoichi NAKAYAMA <yoichi.nakayama(at)gmail.com>
|
||||
|
||||
Avoid out of range access in CheckOtherHTTPHeaders.
|
||||
|
@ -1280,9 +1280,9 @@ int UpnpUnRegisterRootDeviceLowPower(UpnpDevice_Handle Hnd, int PowerState,
|
||||
if (HInfo->aliasInstalled)
|
||||
web_server_set_alias(NULL, NULL, 0, 0);
|
||||
#endif /* INTERNAL_WEB_SERVER */
|
||||
if (HInfo->DeviceAf == AF_INET)
|
||||
if (HInfo->DeviceAf == (unsigned short)AF_INET)
|
||||
UpnpSdkDeviceRegisteredV4 = 0;
|
||||
else if (HInfo->DeviceAf == AF_INET6)
|
||||
else if (HInfo->DeviceAf == (unsigned short)AF_INET6)
|
||||
UpnpSdkDeviceregisteredV6 = 0;
|
||||
FreeHandle(Hnd);
|
||||
HandleUnlock();
|
||||
|
@ -76,8 +76,8 @@
|
||||
const int CHUNK_HEADER_SIZE = 10;
|
||||
const int CHUNK_TAIL_SIZE = 10;
|
||||
*/
|
||||
#define CHUNK_HEADER_SIZE 10
|
||||
#define CHUNK_TAIL_SIZE 10
|
||||
#define CHUNK_HEADER_SIZE (size_t)10
|
||||
#define CHUNK_TAIL_SIZE (size_t)10
|
||||
|
||||
#ifndef UPNP_ENABLE_BLOCKING_TCP_CONNECTIONS
|
||||
|
||||
@ -277,7 +277,7 @@ int http_RecvMessage(
|
||||
int ok_on_close = FALSE;
|
||||
char buf[2 * 1024];
|
||||
|
||||
if (request_method == HTTPMETHOD_UNKNOWN) {
|
||||
if (request_method == (http_method_t)HTTPMETHOD_UNKNOWN) {
|
||||
parser_request_init(parser);
|
||||
} else {
|
||||
parser_response_init(parser, request_method);
|
||||
@ -288,12 +288,13 @@ int http_RecvMessage(
|
||||
if (num_read > 0) {
|
||||
/* got data */
|
||||
status = parser_append(parser, buf, (size_t)num_read);
|
||||
if (status == PARSE_SUCCESS) {
|
||||
switch (status) {
|
||||
case PARSE_SUCCESS:
|
||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||
parser->msg.msg.buf );
|
||||
print_http_headers( &parser->msg );
|
||||
if (g_maxContentLength > 0 && parser->content_length > (unsigned int)g_maxContentLength) {
|
||||
if (g_maxContentLength > (size_t)0 && parser->content_length > (unsigned int)g_maxContentLength) {
|
||||
*http_error_code = HTTP_REQ_ENTITY_TOO_LARGE;
|
||||
line = __LINE__;
|
||||
ret = UPNP_E_OUTOF_BOUNDS;
|
||||
@ -302,19 +303,21 @@ int http_RecvMessage(
|
||||
line = __LINE__;
|
||||
ret = 0;
|
||||
goto ExitFunction;
|
||||
} else if (status == PARSE_FAILURE) {
|
||||
case PARSE_FAILURE:
|
||||
*http_error_code = parser->http_error_code;
|
||||
line = __LINE__;
|
||||
ret = UPNP_E_BAD_HTTPMSG;
|
||||
goto ExitFunction;
|
||||
} else if (status == PARSE_INCOMPLETE_ENTITY) {
|
||||
case PARSE_INCOMPLETE_ENTITY:
|
||||
/* read until close */
|
||||
ok_on_close = TRUE;
|
||||
} else if (status == PARSE_CONTINUE_1) {
|
||||
case PARSE_CONTINUE_1:
|
||||
/* Web post request. */
|
||||
line = __LINE__;
|
||||
ret = PARSE_SUCCESS;
|
||||
goto ExitFunction;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (num_read == 0) {
|
||||
if (ok_on_close) {
|
||||
@ -367,7 +370,7 @@ int http_SendMessage(SOCKINFO *info, int *TimeOut, const char *fmt, ...)
|
||||
size_t buf_length;
|
||||
size_t num_read;
|
||||
size_t num_written;
|
||||
size_t amount_to_be_read = 0;
|
||||
size_t amount_to_be_read = (size_t)0;
|
||||
/* 10 byte allocated for chunk header. */
|
||||
size_t Data_Buf_Size = WEB_SERVER_BUF_SIZE;
|
||||
|
||||
@ -422,7 +425,7 @@ int http_SendMessage(SOCKINFO *info, int *TimeOut, const char *fmt, ...)
|
||||
nr = virtualDirCallback.read(Fp, file_buf, n);
|
||||
num_read = (size_t)nr;
|
||||
} else {
|
||||
num_read = fread(file_buf, 1, n, Fp);
|
||||
num_read = fread(file_buf, (size_t)1, n, Fp);
|
||||
}
|
||||
amount_to_be_read -= num_read;
|
||||
if (Instr->ReadSendSize < 0) {
|
||||
@ -430,9 +433,9 @@ int http_SendMessage(SOCKINFO *info, int *TimeOut, const char *fmt, ...)
|
||||
amount_to_be_read = Data_Buf_Size;
|
||||
}
|
||||
} else {
|
||||
num_read = fread(file_buf, 1, Data_Buf_Size, Fp);
|
||||
num_read = fread(file_buf, (size_t)1, Data_Buf_Size, Fp);
|
||||
}
|
||||
if (num_read == 0) {
|
||||
if (num_read == (size_t)0) {
|
||||
/* EOF so no more to send. */
|
||||
if (Instr && Instr->IsChunkActive) {
|
||||
const char *str = "0\r\n\r\n";
|
||||
@ -469,10 +472,10 @@ int http_SendMessage(SOCKINFO *info, int *TimeOut, const char *fmt, ...)
|
||||
/*printf("Sending %s\n",file_buf-strlen(Chunk_Header)); */
|
||||
nw = sock_write(info,
|
||||
file_buf - strlen(Chunk_Header),
|
||||
num_read + strlen(Chunk_Header) + 2,
|
||||
num_read + strlen(Chunk_Header) + (size_t)2,
|
||||
TimeOut);
|
||||
num_written = (size_t)nw;
|
||||
if (nw <= 0 || num_written != num_read + strlen(Chunk_Header) + 2)
|
||||
if (nw <= 0 || num_written != num_read + strlen(Chunk_Header) + (size_t)2)
|
||||
/* Send error nothing we can do. */
|
||||
goto Cleanup_File;
|
||||
} else {
|
||||
@ -499,7 +502,7 @@ Cleanup_File:
|
||||
/* memory buffer */
|
||||
buf = va_arg(argp, char *);
|
||||
buf_length = va_arg(argp, size_t);
|
||||
if (buf_length > 0) {
|
||||
if (buf_length > (size_t)0) {
|
||||
nw = sock_write(info, buf, buf_length, TimeOut);
|
||||
num_written = (size_t)nw;
|
||||
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
@ -559,7 +562,7 @@ int http_RequestAndResponse(
|
||||
SOCKINFO info;
|
||||
|
||||
tcp_connection = socket(
|
||||
destination->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||
(int)destination->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||
if (tcp_connection == INVALID_SOCKET) {
|
||||
parser_response_init(response, req_method);
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
@ -849,18 +852,18 @@ int http_WriteHttpPost( IN void *Handle,
|
||||
{
|
||||
http_post_handle_t *handle = (http_post_handle_t *)Handle;
|
||||
char *tempbuf = NULL;
|
||||
size_t tempbufSize = 0;
|
||||
size_t tempbufSize = (size_t)0;
|
||||
int freeTempbuf = 0;
|
||||
int numWritten = 0;
|
||||
|
||||
if (!handle || !size || !buf) {
|
||||
if (size)
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
return UPNP_E_INVALID_PARAM;
|
||||
}
|
||||
if (handle->contentLength == UPNP_USING_CHUNKED) {
|
||||
if (*size) {
|
||||
size_t tempSize = 0;
|
||||
size_t tempSize = (size_t)0;
|
||||
tempbuf = malloc(*size +
|
||||
CHUNK_HEADER_SIZE + CHUNK_TAIL_SIZE);
|
||||
if (!tempbuf)
|
||||
@ -871,7 +874,7 @@ int http_WriteHttpPost( IN void *Handle,
|
||||
memcpy(tempbuf + tempSize, buf, *size);
|
||||
memcpy(tempbuf + tempSize + *size, "\r\n", 2);
|
||||
/* end of chunk */
|
||||
tempbufSize = tempSize + *size + 2;
|
||||
tempbufSize = tempSize + *size + (size_t)2;
|
||||
freeTempbuf = 1;
|
||||
}
|
||||
} else {
|
||||
@ -883,7 +886,7 @@ int http_WriteHttpPost( IN void *Handle,
|
||||
if (freeTempbuf)
|
||||
free(tempbuf);
|
||||
if (numWritten < 0) {
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
return numWritten;
|
||||
} else {
|
||||
*size = (size_t)numWritten;
|
||||
@ -983,7 +986,7 @@ int http_OpenHttpPost(
|
||||
if (!handle)
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
handle->contentLength = contentLength;
|
||||
tcp_connection = socket(url.hostport.IPaddress.ss_family,
|
||||
tcp_connection = socket((int)url.hostport.IPaddress.ss_family,
|
||||
SOCK_STREAM, 0);
|
||||
if (tcp_connection == INVALID_SOCKET) {
|
||||
ret_code = UPNP_E_SOCKET_ERROR;
|
||||
@ -1238,31 +1241,35 @@ int http_ReadHttpGet(
|
||||
char tempbuf[2 * 1024];
|
||||
int ret_code = 0;
|
||||
|
||||
if (!handle || !size || (*size > 0 && !buf)) {
|
||||
if (!handle || !size || (*size > (size_t)0 && !buf)) {
|
||||
if (size)
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
return UPNP_E_INVALID_PARAM;
|
||||
}
|
||||
/* first parse what has already been gotten */
|
||||
if (handle->response.position != POS_COMPLETE)
|
||||
if (handle->response.position != (parser_pos_t)POS_COMPLETE)
|
||||
status = parser_parse_entity(&handle->response);
|
||||
else
|
||||
status = PARSE_SUCCESS;
|
||||
if (status == PARSE_INCOMPLETE_ENTITY)
|
||||
switch (status) {
|
||||
case PARSE_INCOMPLETE_ENTITY:
|
||||
/* read until close */
|
||||
ok_on_close = TRUE;
|
||||
else if ((status != PARSE_SUCCESS)
|
||||
&& (status != PARSE_CONTINUE_1)
|
||||
&& (status != PARSE_INCOMPLETE)) {
|
||||
break;
|
||||
case PARSE_SUCCESS:
|
||||
case PARSE_CONTINUE_1:
|
||||
case PARSE_INCOMPLETE:
|
||||
break;
|
||||
default:
|
||||
/*error */
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
return UPNP_E_BAD_RESPONSE;
|
||||
}
|
||||
/* read more if necessary entity */
|
||||
while (handle->response.msg.amount_discarded + *size >
|
||||
handle->response.msg.entity.length &&
|
||||
!handle->cancel &&
|
||||
handle->response.position != POS_COMPLETE) {
|
||||
handle->response.position != (parser_pos_t)POS_COMPLETE) {
|
||||
num_read = sock_read(&handle->sock_info, tempbuf,
|
||||
sizeof(tempbuf), &timeout);
|
||||
if (num_read > 0) {
|
||||
@ -1273,18 +1280,22 @@ int http_ReadHttpGet(
|
||||
/* set failure status */
|
||||
handle->response.http_error_code =
|
||||
HTTP_INTERNAL_SERVER_ERROR;
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
return PARSE_FAILURE;
|
||||
}
|
||||
status = parser_parse_entity(&handle->response);
|
||||
if (status == PARSE_INCOMPLETE_ENTITY) {
|
||||
switch (status) {
|
||||
case PARSE_INCOMPLETE_ENTITY:
|
||||
/* read until close */
|
||||
ok_on_close = TRUE;
|
||||
} else if ((status != PARSE_SUCCESS)
|
||||
&& (status != PARSE_CONTINUE_1)
|
||||
&& (status != PARSE_INCOMPLETE)) {
|
||||
break;
|
||||
case PARSE_SUCCESS:
|
||||
case PARSE_CONTINUE_1:
|
||||
case PARSE_INCOMPLETE:
|
||||
break;
|
||||
default:
|
||||
/*error */
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
return UPNP_E_BAD_RESPONSE;
|
||||
}
|
||||
} else if (num_read == 0) {
|
||||
@ -1295,12 +1306,12 @@ int http_ReadHttpGet(
|
||||
handle->response.position = POS_COMPLETE;
|
||||
} else {
|
||||
/* partial msg */
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
handle->response.http_error_code = HTTP_BAD_REQUEST; /* or response */
|
||||
return UPNP_E_BAD_HTTPMSG;
|
||||
}
|
||||
} else {
|
||||
*size = 0;
|
||||
*size = (size_t)0;
|
||||
return num_read;
|
||||
}
|
||||
}
|
||||
@ -1313,7 +1324,7 @@ int http_ReadHttpGet(
|
||||
*size = handle->response.msg.entity.length -
|
||||
handle->response.msg.amount_discarded;
|
||||
/* copy data to user buffer. delete copied data */
|
||||
if (*size > 0) {
|
||||
if (*size > (size_t)0) {
|
||||
memcpy(buf, &handle->response.msg.msg.buf[handle->response.entity_start_position],
|
||||
*size);
|
||||
membuffer_delete(&handle->response.msg.msg,
|
||||
@ -1497,8 +1508,11 @@ int http_OpenHttpGetProxy(const char *url_str, const char *proxy_str,
|
||||
goto errorHandler;
|
||||
}
|
||||
status = parser_get_entity_read_method(&handle->response);
|
||||
if (status != (parse_status_t)PARSE_CONTINUE_1 &&
|
||||
status != (parse_status_t)PARSE_SUCCESS) {
|
||||
switch (status) {
|
||||
case PARSE_CONTINUE_1:
|
||||
case PARSE_SUCCESS:
|
||||
break;
|
||||
default:
|
||||
ret_code = UPNP_E_BAD_RESPONSE;
|
||||
goto errorHandler;
|
||||
}
|
||||
@ -1509,7 +1523,7 @@ int http_OpenHttpGetProxy(const char *url_str, const char *proxy_str,
|
||||
*contentType = NULL;
|
||||
else
|
||||
*contentType = ctype.buf;
|
||||
if (handle->response.position == POS_COMPLETE)
|
||||
if (handle->response.position == (parser_pos_t)POS_COMPLETE)
|
||||
*contentLength = 0;
|
||||
else if (handle->response.ent_position == ENTREAD_USING_CHUNKED)
|
||||
*contentLength = UPNP_USING_CHUNKED;
|
||||
@ -1557,7 +1571,7 @@ int http_SendStatusResponse(IN SOCKINFO *info, IN int http_status_code,
|
||||
http_CalcResponseVersion(request_major_version, request_minor_version,
|
||||
&response_major, &response_minor);
|
||||
membuffer_init(&membuf);
|
||||
membuf.size_inc = 70;
|
||||
membuf.size_inc = (size_t)70;
|
||||
/* response start line */
|
||||
ret = http_MakeMessage(&membuf, response_major, response_minor, "RSCB",
|
||||
http_status_code, http_status_code);
|
||||
|
@ -129,7 +129,7 @@ init_table( IN const char *encoded_str,
|
||||
|
||||
for( i = 0; i < tbl_size; i++ ) {
|
||||
table[i] = s;
|
||||
s += strlen( s ) + 1; /* next entry */
|
||||
s += strlen( s ) + (size_t)1; /* next entry */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2012 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -112,7 +113,7 @@ static int sock_read_write(
|
||||
/*! [out] Buffer to get data to or send data from. */
|
||||
char *buffer,
|
||||
/*! [in] Size of the buffer. */
|
||||
int bufsize,
|
||||
size_t bufsize,
|
||||
/*! [in] timeout value. */
|
||||
int *timeoutSecs,
|
||||
/*! [in] Boolean value specifying read or write option. */
|
||||
@ -166,7 +167,7 @@ static int sock_read_write(
|
||||
#endif
|
||||
if (bRead) {
|
||||
/* read data. */
|
||||
numBytes = (long)recv(sockfd, buffer, (size_t)bufsize, MSG_NOSIGNAL);
|
||||
numBytes = (long)recv(sockfd, buffer, bufsize, MSG_NOSIGNAL);
|
||||
} else {
|
||||
byte_left = bufsize;
|
||||
bytes_sent = 0;
|
||||
@ -200,12 +201,12 @@ static int sock_read_write(
|
||||
return (int)numBytes;
|
||||
}
|
||||
|
||||
int sock_read(SOCKINFO *info, char *buffer, int bufsize, int *timeoutSecs)
|
||||
int sock_read(SOCKINFO *info, char *buffer, size_t bufsize, int *timeoutSecs)
|
||||
{
|
||||
return sock_read_write(info, buffer, bufsize, timeoutSecs, TRUE);
|
||||
}
|
||||
|
||||
int sock_write(SOCKINFO *info, const char *buffer, int bufsize, int *timeoutSecs)
|
||||
int sock_write(SOCKINFO *info, const char *buffer, size_t bufsize, int *timeoutSecs)
|
||||
{
|
||||
/* Consciently removing constness. */
|
||||
return sock_read_write(info, (char *)buffer, bufsize, timeoutSecs, FALSE);
|
||||
|
@ -69,7 +69,7 @@ static int is_reserved(
|
||||
/*! [in] Char to be matched for RESERVED characters. */
|
||||
char in)
|
||||
{
|
||||
if (strchr(RESERVED, in)) {
|
||||
if (strchr(RESERVED, (int)in)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -87,7 +87,7 @@ int is_mark(
|
||||
/*! [in] Char to be matched for MARKED characters. */
|
||||
char in)
|
||||
{
|
||||
if (strchr(MARK, in)) {
|
||||
if (strchr(MARK, (int)in)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -213,12 +213,12 @@ static void copy_token(
|
||||
|
||||
int copy_URL_list(URL_list *in, URL_list *out)
|
||||
{
|
||||
size_t len = strlen(in->URLs) + 1;
|
||||
size_t i = 0;
|
||||
size_t len = strlen(in->URLs) + (size_t)1;
|
||||
size_t i = (size_t)0;
|
||||
|
||||
out->URLs = NULL;
|
||||
out->parsedURLs = NULL;
|
||||
out->size = 0;
|
||||
out->size = (size_t)0;
|
||||
|
||||
out->URLs = malloc(len);
|
||||
out->parsedURLs = malloc(sizeof(uri_type) * in->size);
|
||||
@ -226,7 +226,7 @@ int copy_URL_list(URL_list *in, URL_list *out)
|
||||
if ( !out->URLs || !out->parsedURLs)
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
memcpy(out->URLs, in->URLs, len);
|
||||
for( i = 0; i < in->size; i++ ) {
|
||||
for( i = (size_t)0; i < in->size; i++ ) {
|
||||
/*copy the parsed uri */
|
||||
out->parsedURLs[i].type = in->parsedURLs[i].type;
|
||||
copy_token( &in->parsedURLs[i].scheme, in->URLs,
|
||||
@ -257,7 +257,7 @@ void free_URL_list(URL_list *list)
|
||||
if (list->parsedURLs) {
|
||||
free(list->parsedURLs);
|
||||
}
|
||||
list->size = 0;
|
||||
list->size = (size_t)0;
|
||||
}
|
||||
|
||||
|
||||
@ -326,7 +326,7 @@ int parse_hostport(
|
||||
char *srvport = NULL;
|
||||
char *last_dot = NULL;
|
||||
unsigned short int port;
|
||||
int af = AF_UNSPEC;
|
||||
unsigned short af = AF_UNSPEC;
|
||||
size_t hostport_size;
|
||||
int has_port = 0;
|
||||
int ret;
|
||||
@ -409,24 +409,24 @@ int parse_hostport(
|
||||
return UPNP_E_INVALID_URL;
|
||||
} else
|
||||
/* Port was not specified, use default port. */
|
||||
port = 80;
|
||||
port = 80u;
|
||||
/* The length of the host and port string can be calculated by */
|
||||
/* subtracting pointers. */
|
||||
hostport_size = (size_t)c - (size_t)workbuf;
|
||||
/* Fill in the 'out' information. */
|
||||
if (af == AF_INET) {
|
||||
sai4->sin_family = (unsigned short)AF_INET;
|
||||
if (af == (unsigned short)AF_INET) {
|
||||
sai4->sin_family = af;
|
||||
sai4->sin_port = htons(port);
|
||||
ret = inet_pton(AF_INET, srvname, &sai4->sin_addr);
|
||||
} else if (af == AF_INET6) {
|
||||
sai6->sin6_family = (unsigned short)AF_INET6;
|
||||
} else if (af == (unsigned short)AF_INET6) {
|
||||
sai6->sin6_family = af;
|
||||
sai6->sin6_port = htons(port);
|
||||
sai6->sin6_scope_id = gIF_INDEX;
|
||||
ret = inet_pton(AF_INET6, srvname, &sai6->sin6_addr);
|
||||
} else {
|
||||
/* IP address was set by the hostname (getaddrinfo). */
|
||||
/* Override port: */
|
||||
if (out->IPaddress.ss_family == AF_INET)
|
||||
if (out->IPaddress.ss_family == (unsigned short)AF_INET)
|
||||
sai4->sin_port = htons(port);
|
||||
else
|
||||
sai6->sin6_port = htons(port);
|
||||
|
@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2012 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -189,7 +190,7 @@
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define WEB_SERVER_BUF_SIZE (1024*1024)
|
||||
#define WEB_SERVER_BUF_SIZE (size_t)(1024*1024)
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
|
@ -5,6 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2012 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -143,7 +144,7 @@ int sock_read(
|
||||
/*! [out] Buffer to get data to. */
|
||||
char* buffer,
|
||||
/*! [in] Size of the buffer. */
|
||||
int bufsize,
|
||||
size_t bufsize,
|
||||
/*! [in,out] timeout value. */
|
||||
int *timeoutSecs);
|
||||
|
||||
@ -161,7 +162,7 @@ int sock_write(
|
||||
/*! [in] Buffer to send data from. */
|
||||
const char *buffer,
|
||||
/*! [in] Size of the buffer. */
|
||||
int bufsize,
|
||||
size_t bufsize,
|
||||
/*! [in,out] timeout value. */
|
||||
int *timeoutSecs);
|
||||
|
||||
|
@ -354,7 +354,7 @@ int DeviceAdvertisement(
|
||||
/* [in] Service duration in sec. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily,
|
||||
unsigned short AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
@ -432,7 +432,7 @@ int ServiceAdvertisement(
|
||||
/* [in] Life time of this device. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily,
|
||||
unsigned short AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
@ -480,7 +480,7 @@ int ServiceShutdown(
|
||||
/* [in] Service duration in sec. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily,
|
||||
unsigned short AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
@ -508,7 +508,7 @@ int DeviceShutdown(
|
||||
/* [in] Device duration in sec. */
|
||||
int Duration,
|
||||
/* [in] Device address family. */
|
||||
int AddressFamily,
|
||||
unsigned short AddressFamily,
|
||||
/* [in] PowerState as defined by UPnP Low Power. */
|
||||
int PowerState,
|
||||
/* [in] SleepPeriod as defined by UPnP Low Power. */
|
||||
|
@ -107,7 +107,7 @@ struct Handle_Info
|
||||
/*! . */
|
||||
int MaxSubscriptionTimeOut;
|
||||
/*! Address family: AF_INET or AF_INET6. */
|
||||
int DeviceAf;
|
||||
unsigned short DeviceAf;
|
||||
#endif
|
||||
|
||||
/* Client only */
|
||||
|
@ -380,7 +380,7 @@ static void CreateServicePacket(
|
||||
nts = "ssdp:byebye";
|
||||
/* NOTE: The CACHE-CONTROL and LOCATION headers are not present in
|
||||
* a shutdown msg, but are present here for MS WinMe interop. */
|
||||
if (AddressFamily == AF_INET)
|
||||
if (AddressFamily == (unsigned short)AF_INET)
|
||||
host = SSDP_IP;
|
||||
else {
|
||||
if (isUrlV6UlaGua(location))
|
||||
@ -430,7 +430,7 @@ static void CreateServicePacket(
|
||||
}
|
||||
|
||||
int DeviceAdvertisement(char *DevType, int RootDev, char *Udn, char *Location,
|
||||
int Duration, int AddressFamily, int PowerState,
|
||||
int Duration, unsigned short AddressFamily, int PowerState,
|
||||
int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
struct sockaddr_storage __ss;
|
||||
@ -445,12 +445,11 @@ int DeviceAdvertisement(char *DevType, int RootDev, char *Udn, char *Location,
|
||||
UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"In function DeviceAdvertisement\n");
|
||||
memset(&__ss, 0, sizeof(__ss));
|
||||
memset(Mil_Usn, 0, sizeof(Mil_Usn));
|
||||
if (AddressFamily == AF_INET) {
|
||||
if (AddressFamily == (unsigned short)AF_INET) {
|
||||
DestAddr4->sin_family = (unsigned short)AF_INET;
|
||||
inet_pton(AF_INET, SSDP_IP, &DestAddr4->sin_addr);
|
||||
DestAddr4->sin_port = htons(SSDP_PORT);
|
||||
} else if (AddressFamily == AF_INET6) {
|
||||
} else if (AddressFamily == (unsigned short)AF_INET6) {
|
||||
DestAddr6->sin6_family = (unsigned short)AF_INET6;
|
||||
inet_pton(AF_INET6,
|
||||
(isUrlV6UlaGua(Location)) ? SSDP_IPV6_SITELOCAL :
|
||||
@ -524,7 +523,6 @@ int SendReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
|
||||
msgs[0] = NULL;
|
||||
msgs[1] = NULL;
|
||||
memset(Mil_Usn, 0, sizeof(Mil_Usn));
|
||||
if (RootDev) {
|
||||
/* one msg for root device */
|
||||
num_msgs = 1;
|
||||
@ -587,11 +585,10 @@ int DeviceReply(struct sockaddr *DestAddr, char *DevType, int RootDev,
|
||||
szReq[0] = NULL;
|
||||
szReq[1] = NULL;
|
||||
szReq[2] = NULL;
|
||||
memset(Mil_Nt, 0, sizeof(Mil_Nt));
|
||||
memset(Mil_Usn, 0, sizeof(Mil_Usn));
|
||||
/* create 2 or 3 msgs */
|
||||
if (RootDev) {
|
||||
/* 3 replies for root device */
|
||||
memset(Mil_Nt, 0, sizeof(Mil_Nt));
|
||||
strncpy(Mil_Nt, "upnp:rootdevice", sizeof(Mil_Nt) - 1);
|
||||
rc = snprintf(Mil_Usn, sizeof(Mil_Usn), "%s::upnp:rootdevice", Udn);
|
||||
if (rc < 0 || (unsigned int) rc >= sizeof(Mil_Usn))
|
||||
@ -641,8 +638,8 @@ error_handler:
|
||||
}
|
||||
|
||||
int ServiceAdvertisement(char *Udn, char *ServType, char *Location,
|
||||
int Duration, int AddressFamily, int PowerState,
|
||||
int SleepPeriod, int RegistrationState)
|
||||
int Duration, unsigned short AddressFamily,
|
||||
int PowerState, int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
char Mil_Usn[LINE_SIZE];
|
||||
char *szReq[1];
|
||||
@ -653,14 +650,13 @@ int ServiceAdvertisement(char *Udn, char *ServType, char *Location,
|
||||
int rc = 0;
|
||||
|
||||
memset(&__ss, 0, sizeof(__ss));
|
||||
memset(Mil_Usn, 0, sizeof(Mil_Usn));
|
||||
szReq[0] = NULL;
|
||||
if (AddressFamily == AF_INET) {
|
||||
DestAddr4->sin_family = (unsigned short)AF_INET;
|
||||
if (AddressFamily == (unsigned short)AF_INET) {
|
||||
DestAddr4->sin_family = AddressFamily;
|
||||
inet_pton(AF_INET, SSDP_IP, &DestAddr4->sin_addr);
|
||||
DestAddr4->sin_port = htons(SSDP_PORT);
|
||||
} else if (AddressFamily == AF_INET6) {
|
||||
DestAddr6->sin6_family = (unsigned short)AF_INET6;
|
||||
} else if (AddressFamily == (unsigned short)AF_INET6) {
|
||||
DestAddr6->sin6_family = AddressFamily;
|
||||
inet_pton(AF_INET6,
|
||||
(isUrlV6UlaGua(Location)) ? SSDP_IPV6_SITELOCAL :
|
||||
SSDP_IPV6_LINKLOCAL, &DestAddr6->sin6_addr);
|
||||
@ -698,7 +694,6 @@ int ServiceReply(struct sockaddr *DestAddr, char *ServType, char *Udn,
|
||||
int RetVal = UPNP_E_OUTOF_MEMORY;
|
||||
int rc = 0;
|
||||
|
||||
memset(Mil_Usn, 0, sizeof(Mil_Usn));
|
||||
szReq[0] = NULL;
|
||||
rc = snprintf(Mil_Usn, sizeof(Mil_Usn), "%s::%s", Udn, ServType);
|
||||
if (rc < 0 || (unsigned int) rc >= sizeof(Mil_Usn))
|
||||
@ -717,8 +712,8 @@ error_handler:
|
||||
}
|
||||
|
||||
int ServiceShutdown(char *Udn, char *ServType, char *Location, int Duration,
|
||||
int AddressFamily, int PowerState, int SleepPeriod,
|
||||
int RegistrationState)
|
||||
unsigned short AddressFamily, int PowerState,
|
||||
int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
char Mil_Usn[LINE_SIZE];
|
||||
char *szReq[1];
|
||||
@ -729,14 +724,13 @@ int ServiceShutdown(char *Udn, char *ServType, char *Location, int Duration,
|
||||
int rc = 0;
|
||||
|
||||
memset(&__ss, 0, sizeof(__ss));
|
||||
memset(Mil_Usn, 0, sizeof(Mil_Usn));
|
||||
szReq[0] = NULL;
|
||||
if (AddressFamily == AF_INET) {
|
||||
DestAddr4->sin_family = AF_INET;
|
||||
if (AddressFamily == (unsigned short)AF_INET) {
|
||||
DestAddr4->sin_family = AddressFamily;
|
||||
inet_pton(AF_INET, SSDP_IP, &DestAddr4->sin_addr);
|
||||
DestAddr4->sin_port = htons(SSDP_PORT);
|
||||
} else if (AddressFamily == AF_INET6) {
|
||||
DestAddr6->sin6_family = AF_INET6;
|
||||
} else if (AddressFamily == (unsigned short)AF_INET6) {
|
||||
DestAddr6->sin6_family = AddressFamily;
|
||||
inet_pton(AF_INET6,
|
||||
(isUrlV6UlaGua(Location)) ? SSDP_IPV6_SITELOCAL :
|
||||
SSDP_IPV6_LINKLOCAL, &DestAddr6->sin6_addr);
|
||||
@ -766,7 +760,7 @@ error_handler:
|
||||
}
|
||||
|
||||
int DeviceShutdown(char *DevType, int RootDev, char *Udn, char *_Server,
|
||||
char *Location, int Duration, int AddressFamily,
|
||||
char *Location, int Duration, unsigned short AddressFamily,
|
||||
int PowerState, int SleepPeriod, int RegistrationState)
|
||||
{
|
||||
struct sockaddr_storage __ss;
|
||||
@ -781,13 +775,12 @@ int DeviceShutdown(char *DevType, int RootDev, char *Udn, char *_Server,
|
||||
msgs[1] = NULL;
|
||||
msgs[2] = NULL;
|
||||
memset(&__ss, 0, sizeof(__ss));
|
||||
memset(Mil_Usn, 0, sizeof(Mil_Usn));
|
||||
if (AddressFamily == AF_INET) {
|
||||
DestAddr4->sin_family = (unsigned short)AF_INET;
|
||||
if (AddressFamily == (unsigned short)AF_INET) {
|
||||
DestAddr4->sin_family = AddressFamily;
|
||||
inet_pton(AF_INET, SSDP_IP, &DestAddr4->sin_addr);
|
||||
DestAddr4->sin_port = htons(SSDP_PORT);
|
||||
} else if (AddressFamily == AF_INET6) {
|
||||
DestAddr6->sin6_family = (unsigned short)AF_INET6;
|
||||
} else if (AddressFamily == (unsigned short)AF_INET6) {
|
||||
DestAddr6->sin6_family = AddressFamily;
|
||||
inet_pton(AF_INET6,
|
||||
(isUrlV6UlaGua(Location)) ? SSDP_IPV6_SITELOCAL :
|
||||
SSDP_IPV6_LINKLOCAL, &DestAddr6->sin6_addr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user