A super trimmed down TLS stack, GPL licensed
Dependents: MiniTLS-HTTPS-Example
MiniTLS - A super trimmed down TLS/SSL Library for embedded devices Author: Donatien Garnier Copyright (C) 2013-2014 AppNearMe Ltd
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Diff: socket/socket_lwip.c
- Revision:
- 3:eb324ffffd2b
- Parent:
- 2:527a66d0a1a9
diff -r 527a66d0a1a9 -r eb324ffffd2b socket/socket_lwip.c --- a/socket/socket_lwip.c Mon Jun 09 14:57:54 2014 +0000 +++ b/socket/socket_lwip.c Tue Jun 10 14:22:36 2014 +0000 @@ -22,6 +22,11 @@ * \author Donatien Garnier */ +#define __DEBUG__ 4 +#ifndef __MODULE__ +#define __MODULE__ "socket_lwip.c" +#endif + #include "core/fwk.h" #include "socket.h" @@ -38,20 +43,22 @@ int socket_connect(int fd, const char* hostname, uint16_t port) { - /*struct hostent* hostent = gethostbyname(hostname); + struct hostent* hostent = lwip_gethostbyname(hostname); if(hostent == NULL) - { - return MINITLS_ERR_SOCKET_ERROR; - }*/ + { + WARN("Could not resolve %s\r\n", hostname); + return -1; + } struct sockaddr_in server; + memset(&server, 0, sizeof(struct sockaddr_in)); server.sin_family = AF_INET; - //memcpy(&server.sin_addr.s_addr, &hostent->h_addr_list[0], hostent->h_length); - server.sin_addr.s_addr = inet_addr(hostname); + memcpy(&server.sin_addr.s_addr, hostent->h_addr_list[0], hostent->h_length); + //server.sin_addr.s_addr = inet_addr(hostname); server.sin_port = htons(port); - DBG("Trying to connect to %s:%d", hostname, port); + DBG("Trying to connect to %s:%d", inet_ntoa(server.sin_addr.s_addr), port); - return lwip_connect(fd, (struct sockaddr*)&server, sizeof(struct sockaddr_in)); + return lwip_connect(fd, (const struct sockaddr*)&server, sizeof(struct sockaddr_in)); } int socket_wait_readable(int fd, int timeout_ms)