Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
Diff: sdk/mbed/types/Socket/internal/common.cpp
- Revision:
- 19:449a58827ddf
- Parent:
- 18:4962b4e95e32
- Child:
- 20:7b67c3f94de9
--- a/sdk/mbed/types/Socket/internal/common.cpp Sat Aug 23 05:48:49 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright 2014, ACKme Networks - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; - * the contents of this file may not be disclosed to third parties, copied - * or duplicated in any form, in whole or in part, without the prior - * written permission of ACKme Networks. - */ - - - -#include "types/Socket/Socket.h" -#include "common.h" - - -/*************************************************************************************************/ -int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) -{ - return -1; -} - -/*************************************************************************************************/ -struct hostent *gethostbyname(const char *name) -{ - static uint8_t buffer[sizeof(struct hostent) + sizeof(void*)*3 + 1*sizeof(uint32_t)]; - struct hostent *hostPtr = (struct hostent*)buffer; - char **ipPtrList = (char**)&buffer[sizeof(struct hostent)]; - char **aliasPtrList = (char**)&buffer[sizeof(struct hostent) + sizeof(void*)*2]; - uint32_t *ipPtr = (uint32_t*)&buffer[sizeof(struct hostent) + sizeof(void*)*3]; - - - hostPtr->h_addr_list = ipPtrList; - hostPtr->h_aliases = aliasPtrList; - hostPtr->h_addrtype = AF_INET; - hostPtr->h_length = sizeof(uint32_t); - hostPtr->h_name = (char*)name; - - aliasPtrList[0] = NULL; - ipPtrList[0] = (char*)ipPtr; - ipPtrList[1] = NULL; - - Wiconnect *wiconnect = Wiconnect::getInstance(); - if(wiconnect->lookup(name, ipPtr) != WICONNECT_SUCCESS) - { - ipPtrList[0] = NULL; - } - - return hostPtr; -} - -/*************************************************************************************************/ -u32_t ipaddr_addr(const char *cp) -{ - u32_t ip = 0; - - Wiconnect::strToIp(cp, &ip); - - return ip; -} - -/*************************************************************************************************/ -int ipaddr_aton(const char *cp, ip_addr_t *addr) -{ - return Wiconnect::strToIp(cp, &addr->addr) ? 0 : -1; -} - -/*************************************************************************************************/ -// returns ptr to static buffer; not reentrant! -char *ipaddr_ntoa(const ip_addr_t *addr) -{ - return (char*)Wiconnect::ipToStr(addr->addr); -} - -/*************************************************************************************************/ -char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen) -{ - return (char*)Wiconnect::ipToStr(addr->addr, buf); -}