1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

net: socket: fix for e93d030058

The former fix for socket initialization was broken. This fixes the
"fix" by using the right exit condition for the loops.
This commit is contained in:
Oleg Hahm 2014-11-16 20:05:23 +01:00
parent 78b6b74a63
commit a2b21fb019

View File

@ -184,7 +184,7 @@ int socket_base_exists_socket(int socket)
if (socket<1) {
return false;
}
if (socket_base_sockets[socket - 1].socket_id == 0) {
if ((socket > MAX_SOCKETS) || (socket_base_sockets[socket - 1].socket_id == 0)) {
return false;
}
else {
@ -248,7 +248,7 @@ uint16_t socket_base_get_free_source_port(uint8_t protocol)
int socket_base_socket(int domain, int type, int protocol)
{
int i = 0;
int i = 1;
while (socket_base_get_socket(i) != NULL) {
i++;
@ -257,17 +257,16 @@ int socket_base_socket(int domain, int type, int protocol)
if (i > MAX_SOCKETS) {
return -1;
}
else {
socket_t *current_socket = &socket_base_sockets[i].socket_values;
socket_base_sockets[i].socket_id = i + 1;
current_socket->domain = domain;
current_socket->type = type;
current_socket->protocol = protocol;
socket_t *current_socket = &socket_base_sockets[i - 1].socket_values;
socket_base_sockets[i - 1].socket_id = i;
current_socket->domain = domain;
current_socket->type = type;
current_socket->protocol = protocol;
#ifdef MODULE_TCP
current_socket->tcp_control.state = 0;
current_socket->tcp_control.state = 0;
#endif
return socket_base_sockets[i].socket_id;
}
return socket_base_sockets[i - 1].socket_id;
}
int socket_base_connect(int socket, sockaddr6_t *addr, uint32_t addrlen)