diff --git a/mongoose.c b/mongoose.c index b094d25993f766e8d9499d189bc0ec9b68506b27..e2017d416b09f7b89b24bcdd31da41679eed89e1 100644 --- a/mongoose.c +++ b/mongoose.c @@ -9306,7 +9306,7 @@ void mg_sock_addr_to_str(const union socket_address *sa, char *buf, size_t len, if (inet_ntop(sa->sa.sa_family, addr, start, capacity) == NULL) { *buf = '\0'; } -#elif defined(_WIN32) || MG_LWIP || (MG_NET_IF == MG_NET_IF_PIC32_HARMONY) +#elif defined(_WIN32) || MG_LWIP || (MG_NET_IF == MG_NET_IF_PIC32) /* Only Windoze Vista (and newer) have inet_ntop() */ strncpy(buf, inet_ntoa(sa->sin.sin_addr), len); #else @@ -14706,15 +14706,15 @@ static void mg_gmt_time_string(char *buf, size_t buf_len, time_t *t) { #endif #ifdef MG_MODULE_LINES -#line 1 "common/platforms/pic32_harmony/pic32_harmony_net_if.h" +#line 1 "common/platforms/pic32/pic32_net_if.h" #endif /* * Copyright (c) 2014-2016 Cesanta Software Limited * All rights reserved */ -#ifndef CS_COMMON_PLATFORMS_PIC32_HARMONY_NET_IF_H_ -#define CS_COMMON_PLATFORMS_PIC32_HARMONY_NET_IF_H_ +#ifndef CS_COMMON_PLATFORMS_PIC32_NET_IF_H_ +#define CS_COMMON_PLATFORMS_PIC32_NET_IF_H_ /* Amalgamated: #include "mongoose/src/net_if.h" */ @@ -14722,55 +14722,55 @@ static void mg_gmt_time_string(char *buf, size_t buf_len, time_t *t) { extern "C" { #endif /* __cplusplus */ -#ifndef MG_ENABLE_NET_IF_PIC32_HARMONY -#define MG_ENABLE_NET_IF_PIC32_HARMONY MG_NET_IF == MG_NET_IF_PIC32_HARMONY +#ifndef MG_ENABLE_NET_IF_PIC32 +#define MG_ENABLE_NET_IF_PIC32 MG_NET_IF == MG_NET_IF_PIC32 #endif -extern struct mg_iface_vtable mg_pic32_harmony_iface_vtable; +extern struct mg_iface_vtable mg_pic32_iface_vtable; #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* CS_COMMON_PLATFORMS_PIC32_HARMONY_NET_IF_H_ */ +#endif /* CS_COMMON_PLATFORMS_PIC32_NET_IF_H_ */ #ifdef MG_MODULE_LINES -#line 1 "common/platforms/pic32_harmony/pic32_harmony_net_if.c" +#line 1 "common/platforms/pic32/pic32_net_if.c" #endif /* * Copyright (c) 2014-2016 Cesanta Software Limited * All rights reserved */ -#if MG_ENABLE_NET_IF_PIC32_HARMONY +#if MG_ENABLE_NET_IF_PIC32 -int mg_pic32_harmony_if_create_conn(struct mg_connection *nc) { +int mg_pic32_if_create_conn(struct mg_connection *nc) { (void) nc; return 1; } -void mg_pic32_harmony_if_recved(struct mg_connection *nc, size_t len) { +void mg_pic32_if_recved(struct mg_connection *nc, size_t len) { (void) nc; (void) len; } -void mg_pic32_harmony_if_add_conn(struct mg_connection *nc) { +void mg_pic32_if_add_conn(struct mg_connection *nc) { (void) nc; } -void mg_pic32_harmony_if_init(struct mg_iface *iface) { +void mg_pic32_if_init(struct mg_iface *iface) { (void) iface; (void) mg_get_errno(); /* Shutup compiler */ } -void mg_pic32_harmony_if_free(struct mg_iface *iface) { +void mg_pic32_if_free(struct mg_iface *iface) { (void) iface; } -void mg_pic32_harmony_if_remove_conn(struct mg_connection *nc) { +void mg_pic32_if_remove_conn(struct mg_connection *nc) { (void) nc; } -void mg_pic32_harmony_if_destroy_conn(struct mg_connection *nc) { +void mg_pic32_if_destroy_conn(struct mg_connection *nc) { if (nc->sock == INVALID_SOCKET) return; /* For UDP, only close outgoing sockets or listeners. */ if (!(nc->flags & MG_F_UDP)) { @@ -14784,8 +14784,7 @@ void mg_pic32_harmony_if_destroy_conn(struct mg_connection *nc) { nc->sock = INVALID_SOCKET; } -int mg_pic32_harmony_if_listen_udp(struct mg_connection *nc, - union socket_address *sa) { +int mg_pic32_if_listen_udp(struct mg_connection *nc, union socket_address *sa) { nc->sock = TCPIP_UDP_ServerOpen( sa->sin.sin_family == AF_INET ? IP_ADDRESS_TYPE_IPV4 : IP_ADDRESS_TYPE_IPV6, @@ -14797,18 +14796,17 @@ int mg_pic32_harmony_if_listen_udp(struct mg_connection *nc, return 0; } -void mg_pic32_harmony_if_udp_send(struct mg_connection *nc, const void *buf, - size_t len) { +void mg_pic32_if_udp_send(struct mg_connection *nc, const void *buf, + size_t len) { mbuf_append(&nc->send_mbuf, buf, len); } -void mg_pic32_harmony_if_tcp_send(struct mg_connection *nc, const void *buf, - size_t len) { +void mg_pic32_if_tcp_send(struct mg_connection *nc, const void *buf, + size_t len) { mbuf_append(&nc->send_mbuf, buf, len); } -int mg_pic32_harmony_if_listen_tcp(struct mg_connection *nc, - union socket_address *sa) { +int mg_pic32_if_listen_tcp(struct mg_connection *nc, union socket_address *sa) { nc->sock = TCPIP_TCP_ServerOpen( sa->sin.sin_family == AF_INET ? IP_ADDRESS_TYPE_IPV4 : IP_ADDRESS_TYPE_IPV6, @@ -14850,7 +14848,7 @@ static int mg_accept_conn(struct mg_connection *lc) { mg_if_accept_tcp_cb(nc, (union socket_address *) &sa, sizeof(sa)); - return mg_pic32_harmony_if_listen_tcp(lc, &lc->sa) >= 0; + return mg_pic32_if_listen_tcp(lc, &lc->sa) >= 0; } char *inet_ntoa(struct in_addr in) { @@ -14940,7 +14938,7 @@ static void mg_handle_recv(struct mg_connection *nc) { } } -time_t mg_pic32_harmony_if_poll(struct mg_iface *iface, int timeout_ms) { +time_t mg_pic32_if_poll(struct mg_iface *iface, int timeout_ms) { struct mg_mgr *mgr = iface->mgr; double now = mg_time(); struct mg_connection *nc, *tmp; @@ -14982,17 +14980,17 @@ time_t mg_pic32_harmony_if_poll(struct mg_iface *iface, int timeout_ms) { return now; } -void mg_pic32_harmony_if_sock_set(struct mg_connection *nc, sock_t sock) { +void mg_pic32_if_sock_set(struct mg_connection *nc, sock_t sock) { nc->sock = sock; } -void mg_pic32_harmony_if_get_conn_addr(struct mg_connection *nc, int remote, - union socket_address *sa) { +void mg_pic32_if_get_conn_addr(struct mg_connection *nc, int remote, + union socket_address *sa) { /* TODO(alaskin): not implemented yet */ } -void mg_pic32_harmony_if_connect_tcp(struct mg_connection *nc, - const union socket_address *sa) { +void mg_pic32_if_connect_tcp(struct mg_connection *nc, + const union socket_address *sa) { nc->sock = TCPIP_TCP_ClientOpen( sa->sin.sin_family == AF_INET ? IP_ADDRESS_TYPE_IPV4 : IP_ADDRESS_TYPE_IPV6, @@ -15000,37 +14998,36 @@ void mg_pic32_harmony_if_connect_tcp(struct mg_connection *nc, nc->err = (nc->sock == INVALID_SOCKET) ? -1 : 0; } -void mg_pic32_harmony_if_connect_udp(struct mg_connection *nc) { +void mg_pic32_if_connect_udp(struct mg_connection *nc) { nc->sock = TCPIP_UDP_ClientOpen(IP_ADDRESS_TYPE_ANY, 0, NULL); nc->err = (nc->sock == INVALID_SOCKET) ? -1 : 0; } /* clang-format off */ -#define MG_PIC32_HARMONY_IFACE_VTABLE \ - { \ - mg_pic32_harmony_if_init, \ - mg_pic32_harmony_if_free, \ - mg_pic32_harmony_if_add_conn, \ - mg_pic32_harmony_if_remove_conn, \ - mg_pic32_harmony_if_poll, \ - mg_pic32_harmony_if_listen_tcp, \ - mg_pic32_harmony_if_listen_udp, \ - mg_pic32_harmony_if_connect_tcp, \ - mg_pic32_harmony_if_connect_udp, \ - mg_pic32_harmony_if_tcp_send, \ - mg_pic32_harmony_if_udp_send, \ - mg_pic32_harmony_if_recved, \ - mg_pic32_harmony_if_create_conn, \ - mg_pic32_harmony_if_destroy_conn, \ - mg_pic32_harmony_if_sock_set, \ - mg_pic32_harmony_if_get_conn_addr, \ +#define MG_PIC32_IFACE_VTABLE \ + { \ + mg_pic32_if_init, \ + mg_pic32_if_free, \ + mg_pic32_if_add_conn, \ + mg_pic32_if_remove_conn, \ + mg_pic32_if_poll, \ + mg_pic32_if_listen_tcp, \ + mg_pic32_if_listen_udp, \ + mg_pic32_if_connect_tcp, \ + mg_pic32_if_connect_udp, \ + mg_pic32_if_tcp_send, \ + mg_pic32_if_udp_send, \ + mg_pic32_if_recved, \ + mg_pic32_if_create_conn, \ + mg_pic32_if_destroy_conn, \ + mg_pic32_if_sock_set, \ + mg_pic32_if_get_conn_addr, \ } /* clang-format on */ -struct mg_iface_vtable mg_pic32_harmony_iface_vtable = - MG_PIC32_HARMONY_IFACE_VTABLE; -#if MG_NET_IF == MG_NET_IF_PIC32_HARMONY -struct mg_iface_vtable mg_default_iface_vtable = MG_PIC32_HARMONY_IFACE_VTABLE; +struct mg_iface_vtable mg_pic32_iface_vtable = MG_PIC32_IFACE_VTABLE; +#if MG_NET_IF == MG_NET_IF_PIC32 +struct mg_iface_vtable mg_default_iface_vtable = MG_PIC32_IFACE_VTABLE; #endif -#endif /* MG_ENABLE_NET_IF_PIC32_HARMONY */ +#endif /* MG_ENABLE_NET_IF_PIC32 */ diff --git a/mongoose.h b/mongoose.h index 9924b691db8d809a7e9396ec1692186cc6939e81..76d6226bc7fa01589b45aef9efc14aa49547e3c8 100644 --- a/mongoose.h +++ b/mongoose.h @@ -55,7 +55,7 @@ #define CS_P_NXP_KINETIS 9 #define CS_P_NRF51 12 #define CS_P_NRF52 10 -#define CS_P_PIC32_HARMONY 11 +#define CS_P_PIC32 11 /* Next id: 15 */ /* If not specified explicitly, we guess platform by defines. */ @@ -78,7 +78,7 @@ #elif defined(FRDM_K64F) || defined(FREEDOM) #define CS_PLATFORM CS_P_NXP_KINETIS #elif defined(PIC32) -#define CS_PLATFORM CS_P_PIC32_HARMONY +#define CS_PLATFORM CS_P_PIC32 #elif defined(ICACHE_FLASH) #define CS_PLATFORM CS_P_ESP8266 #elif defined(TARGET_IS_TM4C129_RA0) || defined(TARGET_IS_TM4C129_RA1) || \ @@ -95,7 +95,7 @@ #define MG_NET_IF_SOCKET 1 #define MG_NET_IF_SIMPLELINK 2 #define MG_NET_IF_LWIP_LOW_LEVEL 3 -#define MG_NET_IF_PIC32_HARMONY 4 +#define MG_NET_IF_PIC32 4 #define MG_SSL_IF_OPENSSL 1 #define MG_SSL_IF_MBEDTLS 2 @@ -112,7 +112,7 @@ /* Amalgamated: #include "common/platforms/platform_wince.h" */ /* Amalgamated: #include "common/platforms/platform_nxp_lpc.h" */ /* Amalgamated: #include "common/platforms/platform_nxp_kinetis.h" */ -/* Amalgamated: #include "common/platforms/platform_pic32_harmony.h" */ +/* Amalgamated: #include "common/platforms/platform_pic32.h" */ /* Common stuff */ @@ -1424,19 +1424,19 @@ typedef struct stat cs_stat_t; #endif /* CS_PLATFORM == CS_P_NXP_KINETIS */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_NXP_KINETIS_H_ */ #ifdef MG_MODULE_LINES -#line 1 "common/platforms/platform_pic32_harmony.h" +#line 1 "common/platforms/platform_pic32.h" #endif /* * Copyright (c) 2014-2016 Cesanta Software Limited * All rights reserved */ -#ifndef CS_COMMON_PLATFORMS_PLATFORM_PIC32_HARMONY_H_ -#define CS_COMMON_PLATFORMS_PLATFORM_PIC32_HARMONY_H_ +#ifndef CS_COMMON_PLATFORMS_PLATFORM_PIC32_H_ +#define CS_COMMON_PLATFORMS_PLATFORM_PIC32_H_ -#if CS_PLATFORM == CS_P_PIC32_HARMONY +#if CS_PLATFORM == CS_P_PIC32 -#define MG_NET_IF MG_NET_IF_PIC32_HARMONY +#define MG_NET_IF MG_NET_IF_PIC32 #include <stdint.h> #include <time.h> @@ -1456,9 +1456,9 @@ typedef TCP_SOCKET sock_t; char* inet_ntoa(struct in_addr in); -#endif /* CS_PLATFORM == CS_P_PIC32_HARMONY */ +#endif /* CS_PLATFORM == CS_P_PIC32 */ -#endif /* CS_COMMON_PLATFORMS_PLATFORM_PIC32_HARMONY_H_ */ +#endif /* CS_COMMON_PLATFORMS_PLATFORM_PIC32_H_ */ #ifdef MG_MODULE_LINES #line 1 "common/platforms/lwip/mg_lwip.h" #endif