From f69b1841e0860a5089387673f6f80f2143a64d8c Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sat, 5 Dec 2015 21:58:38 +0100 Subject: [PATCH] Fix compile when netconn api is disabled but socket api is enabled. Problem is that declaring functions as static in a public header will produce warnings in every file it is included because the static functions are not implemented. Solution: When socket api is enabled, netconn is simply available, too (Socket api uses netconn api internally) --- src/include/lwip/api.h | 44 ++++++++++++++------------------- src/include/lwip/netbuf.h | 28 +++++++++------------ src/include/lwip/priv/api_msg.h | 41 ++++++++++++++---------------- 3 files changed, 48 insertions(+), 65 deletions(-) diff --git a/src/include/lwip/api.h b/src/include/lwip/api.h index c619d2b8..8499edb2 100644 --- a/src/include/lwip/api.h +++ b/src/include/lwip/api.h @@ -35,13 +35,8 @@ #include "lwip/opt.h" #if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -/* don't export the netconn functions when socket API is enabled but netconn API is disabled */ -#if LWIP_NETCONN -#define LWIP_NETCONN_SCOPE -#else /* LWIP_NETCONN */ -#define LWIP_NETCONN_SCOPE static -#endif /* LWIP_NETCONN */ +/* Note: Netconn API is always available when sockets are enabled - + * sockets are implemented on top of them */ #include /* for size_t */ @@ -256,39 +251,38 @@ struct netconn { /* Network connection functions: */ #define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) #define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) -LWIP_NETCONN_SCOPE struct -netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, +struct netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_callback callback); -LWIP_NETCONN_SCOPE err_t netconn_delete(struct netconn *conn); +err_t netconn_delete(struct netconn *conn); /** Get the type of a netconn (as enum netconn_type). */ #define netconn_type(conn) (conn->type) -LWIP_NETCONN_SCOPE err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr, +err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local); #define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) #define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) -LWIP_NETCONN_SCOPE err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port); -LWIP_NETCONN_SCOPE err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port); -LWIP_NETCONN_SCOPE err_t netconn_disconnect (struct netconn *conn); -LWIP_NETCONN_SCOPE err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); +err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port); +err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port); +err_t netconn_disconnect (struct netconn *conn); +err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); #define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) -LWIP_NETCONN_SCOPE err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); -LWIP_NETCONN_SCOPE err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf); -LWIP_NETCONN_SCOPE err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); -LWIP_NETCONN_SCOPE void netconn_recved(struct netconn *conn, u32_t length); -LWIP_NETCONN_SCOPE err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, +err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); +err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf); +err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); +void netconn_recved(struct netconn *conn, u32_t length); +err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, const ip_addr_t *addr, u16_t port); -LWIP_NETCONN_SCOPE err_t netconn_send(struct netconn *conn, struct netbuf *buf); -LWIP_NETCONN_SCOPE err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, +err_t netconn_send(struct netconn *conn, struct netbuf *buf); +err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, u8_t apiflags, size_t *bytes_written); #define netconn_write(conn, dataptr, size, apiflags) \ netconn_write_partly(conn, dataptr, size, apiflags, NULL) -LWIP_NETCONN_SCOPE err_t netconn_close(struct netconn *conn); -LWIP_NETCONN_SCOPE err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); +err_t netconn_close(struct netconn *conn); +err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -LWIP_NETCONN_SCOPE err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr, +err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr, const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ #if LWIP_DNS diff --git a/src/include/lwip/netbuf.h b/src/include/lwip/netbuf.h index 0af5fdd0..8875e12d 100644 --- a/src/include/lwip/netbuf.h +++ b/src/include/lwip/netbuf.h @@ -35,13 +35,8 @@ #include "lwip/opt.h" #if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -/* don't export the netbuf functions when socket API is enabled but netconn API is disabled */ -#if LWIP_NETCONN -#define LWIP_NETCONN_SCOPE -#else /* LWIP_NETCONN */ -#define LWIP_NETCONN_SCOPE static -#endif /* LWIP_NETCONN */ +/* Note: Netconn API is always available when sockets are enabled - + * sockets are implemented on top of them */ #include "lwip/pbuf.h" #include "lwip/ip_addr.h" @@ -72,19 +67,18 @@ struct netbuf { }; /* Network buffer functions: */ -LWIP_NETCONN_SCOPE struct netbuf * netbuf_new (void); -LWIP_NETCONN_SCOPE void netbuf_delete (struct netbuf *buf); -LWIP_NETCONN_SCOPE void * netbuf_alloc (struct netbuf *buf, u16_t size); -LWIP_NETCONN_SCOPE void netbuf_free (struct netbuf *buf); -LWIP_NETCONN_SCOPE err_t netbuf_ref (struct netbuf *buf, +struct netbuf * netbuf_new (void); +void netbuf_delete (struct netbuf *buf); +void * netbuf_alloc (struct netbuf *buf, u16_t size); +void netbuf_free (struct netbuf *buf); +err_t netbuf_ref (struct netbuf *buf, const void *dataptr, u16_t size); -LWIP_NETCONN_SCOPE void netbuf_chain (struct netbuf *head, - struct netbuf *tail); +void netbuf_chain (struct netbuf *head, struct netbuf *tail); -LWIP_NETCONN_SCOPE err_t netbuf_data (struct netbuf *buf, +err_t netbuf_data (struct netbuf *buf, void **dataptr, u16_t *len); -LWIP_NETCONN_SCOPE s8_t netbuf_next (struct netbuf *buf); -LWIP_NETCONN_SCOPE void netbuf_first (struct netbuf *buf); +s8_t netbuf_next (struct netbuf *buf); +void netbuf_first (struct netbuf *buf); #define netbuf_copy_partial(buf, dataptr, len, offset) \ diff --git a/src/include/lwip/priv/api_msg.h b/src/include/lwip/priv/api_msg.h index 70371bfb..909a925d 100644 --- a/src/include/lwip/priv/api_msg.h +++ b/src/include/lwip/priv/api_msg.h @@ -35,13 +35,8 @@ #include "lwip/opt.h" #if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -/* don't export the netconn functions when socket API is enabled but netconn API is disabled */ -#if LWIP_NETCONN -#define LWIP_NETCONN_SCOPE -#else /* LWIP_NETCONN */ -#define LWIP_NETCONN_SCOPE static -#endif /* LWIP_NETCONN */ +/* Note: Netconn API is always available when sockets are enabled - + * sockets are implemented on top of them */ #include /* for size_t */ @@ -191,28 +186,28 @@ struct dns_api_msg { }; #endif /* LWIP_DNS */ -LWIP_NETCONN_SCOPE void lwip_netconn_do_newconn ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_delconn ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_bind ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_connect ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_disconnect ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_listen ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_send ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_recv ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_write ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_getaddr ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_close ( struct api_msg_msg *msg); -LWIP_NETCONN_SCOPE void lwip_netconn_do_shutdown ( struct api_msg_msg *msg); +void lwip_netconn_do_newconn ( struct api_msg_msg *msg); +void lwip_netconn_do_delconn ( struct api_msg_msg *msg); +void lwip_netconn_do_bind ( struct api_msg_msg *msg); +void lwip_netconn_do_connect ( struct api_msg_msg *msg); +void lwip_netconn_do_disconnect ( struct api_msg_msg *msg); +void lwip_netconn_do_listen ( struct api_msg_msg *msg); +void lwip_netconn_do_send ( struct api_msg_msg *msg); +void lwip_netconn_do_recv ( struct api_msg_msg *msg); +void lwip_netconn_do_write ( struct api_msg_msg *msg); +void lwip_netconn_do_getaddr ( struct api_msg_msg *msg); +void lwip_netconn_do_close ( struct api_msg_msg *msg); +void lwip_netconn_do_shutdown ( struct api_msg_msg *msg); #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -LWIP_NETCONN_SCOPE void lwip_netconn_do_join_leave_group( struct api_msg_msg *msg); +void lwip_netconn_do_join_leave_group( struct api_msg_msg *msg); #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ #if LWIP_DNS -LWIP_NETCONN_SCOPE void lwip_netconn_do_gethostbyname(void *arg); +void lwip_netconn_do_gethostbyname(void *arg); #endif /* LWIP_DNS */ -LWIP_NETCONN_SCOPE struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); -LWIP_NETCONN_SCOPE void netconn_free(struct netconn *conn); +struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); +void netconn_free(struct netconn *conn); #ifdef __cplusplus }