1 Star 0 Fork 48

yinbin6/lwip

forked from src-openEuler/lwip 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0153-cleancode-move-options-from-opt.h-to-lwipopts.h.patch 11.44 KB
一键复制 编辑 原始数据 按行查看 历史
From a5bcc8b1e84406b7980621d1eb97865d50f58c5c Mon Sep 17 00:00:00 2001
From: Lemmy Huang <huangliming5@huawei.com>
Date: Thu, 11 Jul 2024 17:30:25 +0800
Subject: [PATCH] cleancode: move options from opt.h to lwipopts.h
Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
---
src/core/stats.c | 11 ------
src/include/lwip/def.h | 2 +
src/include/lwip/opt.h | 73 +++----------------------------------
src/include/lwip/prot/ip4.h | 2 +
src/include/lwip/sockets.h | 64 +++++++++-----------------------
src/include/lwip/stats.h | 2 -
src/include/lwipopts.h | 9 +++++
7 files changed, 37 insertions(+), 126 deletions(-)
diff --git a/src/core/stats.c b/src/core/stats.c
index ce6a929..a90ad94 100644
--- a/src/core/stats.c
+++ b/src/core/stats.c
@@ -59,17 +59,6 @@ stats_init(void)
#endif /* LWIP_DEBUG */
}
-int get_mib2_stats(char *buf)
-{
- int len = 0;
-#if MIB2_STATS
- len = (long)&((struct stats_mib2 *)0)->udpindatagrams;
- /* we just need the ip&tcp, others not needed. */
- memcpy(buf, &lwip_stats.mib2, len);
-#endif
- return len;
-}
-
#if LWIP_STATS_DISPLAY
void
stats_display_proto(struct stats_proto *proto, const char *name)
diff --git a/src/include/lwip/def.h b/src/include/lwip/def.h
index cfc59e2..9950bdb 100644
--- a/src/include/lwip/def.h
+++ b/src/include/lwip/def.h
@@ -117,6 +117,7 @@ u32_t lwip_htonl(u32_t x);
/* Provide usual function names as macros for users, but this can be turned off */
#ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
+#if GAZELLE_ENABLE
/* avoid conflicts with netinet/in.h */
#ifdef htons
#undef htons
@@ -130,6 +131,7 @@ u32_t lwip_htonl(u32_t x);
#ifdef ntohl
#undef ntohl
#endif
+#endif /* GAZELLE_ENABLE */
#define htons(x) lwip_htons(x)
#define ntohs(x) lwip_ntohs(x)
diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h
index 9a1a32d..b19ecd0 100644
--- a/src/include/lwip/opt.h
+++ b/src/include/lwip/opt.h
@@ -133,7 +133,6 @@
* MEMCPY: override this if you have a faster implementation at hand than the
* one included in your C library
*/
-//#include <rte_memcpy.h>
#if !defined MEMCPY || defined __DOXYGEN__
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
#endif
@@ -526,22 +525,6 @@
#define MEMP_NUM_NETCONN 4
#endif
-/**
- * MEMP_NUM_SYS_SEM: the number of struct sys_sems.
- * (only needed if you use the sequential API, like api_lib.c)
- */
-#if !defined MEMP_NUM_SYS_SEM || defined __DOXYGEN__
-#define MEMP_NUM_SYS_SEM 128
-#endif
-
-/**
- * MEMP_NUM_SYS_MBOX: the number of struct sys_sems.
- * (only needed if you use the sequential API, like api_lib.c)
- */
-#if !defined MEMP_NUM_SYS_MBOX || defined __DOXYGEN__
-#define MEMP_NUM_SYS_MBOX 128
-#endif
-
/**
* MEMP_NUM_SELECT_CB: the number of struct lwip_select_cb.
* (Only needed if you have LWIP_MPU_COMPATIBLE==1 and use the socket API.
@@ -1124,7 +1107,7 @@
* LWIP_IGMP==1: Turn on IGMP module.
*/
#if !defined LWIP_IGMP || defined __DOXYGEN__
-#define LWIP_IGMP 1
+#define LWIP_IGMP 0
#endif
#if !LWIP_IPV4
@@ -1327,7 +1310,7 @@
* LWIP_TCP_SACK_OUT==1: TCP will support sending selective acknowledgements (SACKs).
*/
#if !defined LWIP_TCP_SACK_OUT || defined __DOXYGEN__
-#define LWIP_TCP_SACK_OUT 1
+#define LWIP_TCP_SACK_OUT 0
#endif
/**
@@ -1537,8 +1520,8 @@
* send window while having a small receive window only.
*/
#if !defined LWIP_WND_SCALE || defined __DOXYGEN__
-#define LWIP_WND_SCALE 1
-#define TCP_RCV_SCALE 6
+#define LWIP_WND_SCALE 0
+#define TCP_RCV_SCALE 0
#endif
/**
@@ -2096,7 +2079,7 @@
* LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
*/
#if !defined LWIP_SO_RCVBUF || defined __DOXYGEN__
-#define LWIP_SO_RCVBUF 1
+#define LWIP_SO_RCVBUF 0
#endif
/**
@@ -2314,7 +2297,7 @@
* MIB2_STATS==1: Stats for SNMP MIB2.
*/
#if !defined MIB2_STATS || defined __DOXYGEN__
-#define MIB2_STATS 1
+#define MIB2_STATS 0
#endif
#else
@@ -3504,10 +3487,6 @@
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#endif
-#ifndef PERF_OUTPUT_DEBUG
- #define PERF_OUTPUT_DEBUG LWIP_DBG_OFF
-#endif
-
/**
* TCP_RST_DEBUG: Enable debugging for TCP with the RST message.
*/
@@ -3603,46 +3582,6 @@
#define LWIP_TESTMODE 0
#endif
-/**
- * EPOLL_DEBUG: Enable debugging in epoll.c.
- */
-#if !defined EPOLL_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
-#define EPOLL_DEBUG LWIP_DBG_OFF
-#endif
-/**
- * @}
- */
-
-/**
- * ETHDEV_DEBUG: Enable debugging in ethdev.c.
- */
-#if !defined ETHDEV_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
-#define ETHDEV_DEBUG LWIP_DBG_OFF
-#endif
-/**
- * @}
- */
-
-/**
- * ETHDEV_DEBUG: Enable debugging in ethdev.c.
- */
-#if !defined SYSCALL_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
-#define SYSCALL_DEBUG LWIP_DBG_OFF
-#endif
-/**
- * @}
- */
-
-/**
- * CONTROL_DEBUG: Enable debugging in control_plane.c.
- */
-#if !defined CONTROL_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
-#define CONTROL_DEBUG LWIP_DBG_ON
-#endif
-/**
- * @}
- */
-
/*
--------------------------------------------------
---------- Performance tracking options ----------
diff --git a/src/include/lwip/prot/ip4.h b/src/include/lwip/prot/ip4.h
index c9ad89c..5f863a2 100644
--- a/src/include/lwip/prot/ip4.h
+++ b/src/include/lwip/prot/ip4.h
@@ -82,6 +82,7 @@ struct ip_hdr {
/* fragment offset field */
PACK_STRUCT_FIELD(u16_t _offset);
+#if GAZELLE_ENABLE
/* avoid conflicts with netinet/ip.h */
#ifdef IP_RF
#undef IP_RF
@@ -95,6 +96,7 @@ struct ip_hdr {
#ifdef IP_OFFMASK
#undef IP_OFFMASK
#endif
+#endif /* GAZELLE_ENABLE */
#define IP_RF 0x8000U /* reserved fragment flag */
#define IP_DF 0x4000U /* don't fragment flag */
diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h
index 9f5bc81..2b2d1ef 100644
--- a/src/include/lwip/sockets.h
+++ b/src/include/lwip/sockets.h
@@ -67,7 +67,7 @@ extern "C" {
to prevent this code from redefining it. */
#if GAZELLE_ENABLE
#define SA_FAMILY_T_DEFINED
- typedef u16_t sa_family_t;
+typedef u16_t sa_family_t;
#endif
#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
@@ -235,8 +235,22 @@ struct ifreq {
#define SOCK_RAW 3
#if GAZELLE_ENABLE
+#ifndef FIONBIO
+#define FIONBIO 0x5421 /* same as define in asm-generic/ioctls.h */
+#endif
+#ifndef O_NONBLOCK
+#define O_NONBLOCK 04000 /* same as define in bits/fcntl-linux.h */
+#endif
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 02000000 /* same as define in bits/fcntl-linux.h */
+#endif
+
+#define SOCK_NONBLOCK O_NONBLOCK
+#define SOCK_CLOEXEC O_CLOEXEC
+#define SOCK_TYPE_MASK 0xf
+
#include <asm/socket.h>
-#else
+#else /* GAZELLE_ENABLE */
/*
* Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
*/
@@ -345,6 +359,7 @@ struct linger {
#define TCP_KEEPINTVL 0x05 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
#define TCP_KEEPCNT 0x06 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
#else /* GAZELLE_ENABLE */
+
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
@@ -468,28 +483,6 @@ typedef struct ipv6_mreq {
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
-#if GAZELLE_ENABLE
-#ifndef SOCK_TYPE_MASK
-#define SOCK_TYPE_MASK 0xf
-#endif
-
-#ifndef FIONBIO
-#define FIONBIO 0x5421 /* same as define in asm-generic/ioctls.h */
-#endif
-#ifndef O_NONBLOCK
-#define O_NONBLOCK 04000 /* same as define in bits/fcntl-linux.h */
-#endif
-#ifndef O_CLOEXEC
-#define O_CLOEXEC 02000000 /* same as define in bits/fcntl-linux.h */
-#endif
-
-#ifndef SOCK_NONBLOCK
-#define SOCK_NONBLOCK O_NONBLOCK
-#endif
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC O_CLOEXEC
-#endif
-#endif /* GAZELLE_ENABLE */
/*
* Commands for ioctlsocket(), taken from the BSD file fcntl.h.
@@ -591,24 +584,7 @@ typedef struct fd_set
#define LWIP_SELECT_MAXNFDS FD_SETSIZE
#endif /* FD_SET */
-#if GAZELLE_ENABLE
-#if !defined(POLLIN) && !defined(POLLOUT)
-/* come from bits/poll.h */
-#define POLLIN 0x001
-#define POLLOUT 0x004
-#define POLLERR 0x008
-#define POLLNVAL 0x020
-/* Below values are unimplemented */
-#define POLLRDNORM 0x040
-#define POLLRDBAND 0x080
-#define POLLPRI 0x002
-#define POLLWRNORM 0x100
-#define POLLWRBAND 0x200
-#define POLLHUP 0x010
-#endif
-#endif /* GAZELLE_ENABLE */
-
-#if LWIP_SOCKET_POLL
+#if LWIP_SOCKET_POLL && !GAZELLE_ENABLE
/* poll-related defines and types */
/* @todo: find a better way to guard the definition of these defines and types if already defined */
#if !defined(POLLIN) && !defined(POLLOUT)
@@ -663,7 +639,6 @@ void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destro
#if LWIP_COMPAT_SOCKETS == 2
/* This helps code parsers/code completion by not having the COMPAT functions as defines */
#define lwip_accept accept
-#define lwip_accept4 accept4
#define lwip_bind bind
#define lwip_shutdown shutdown
#define lwip_getpeername getpeername
@@ -729,7 +704,6 @@ ssize_t lwip_sendto(int s, const void *dataptr, size_t size, int flags,
int lwip_socket(int domain, int type, int protocol);
ssize_t lwip_write(int s, const void *dataptr, size_t size);
ssize_t lwip_writev(int s, const struct iovec *iov, int iovcnt);
-
#if LWIP_SOCKET_SELECT
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
struct timeval *timeout);
@@ -863,8 +837,6 @@ int lwip_inet_pton(int af, const char *src, void *dst);
/** @ingroup socket */
#define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen)
/** @ingroup socket */
-#define accept4(s,addr,addrlen,flags) lwip_accept4(s,addr,addrlen,flags)
-/** @ingroup socket */
#define bind(s,name,namelen) lwip_bind(s,name,namelen)
/** @ingroup socket */
#define shutdown(s,how) lwip_shutdown(s,how)
diff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h
index 984e11d..6b3f18e 100644
--- a/src/include/lwip/stats.h
+++ b/src/include/lwip/stats.h
@@ -483,8 +483,6 @@ void stats_init(void);
#define MIB2_STATS_INC(x)
#endif
-int get_mib2_stats(char *buf);
-
/* Display of statistics */
#if LWIP_STATS_DISPLAY
void stats_display(void);
diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h
index 31856ce..5994390 100644
--- a/src/include/lwipopts.h
+++ b/src/include/lwipopts.h
@@ -104,6 +104,8 @@
#define LWIP_STATS_DISPLAY 1
+#define MIB2_STATS 1
+
#define LWIP_TIMERS 1
#define LWIP_TIMEVAL_PRIVATE 0
@@ -229,6 +231,10 @@
#define LWIP_TCP_KEEPALIVE 1
+#define LWIP_TCP_SACK_OUT 1
+#define LWIP_WND_SCALE 1
+#define TCP_RCV_SCALE 6
+
#define GAZELLE_TCP_MAX_CONN_PER_THREAD 65535
#define GAZELLE_TCP_REUSE_IPPORT 1
@@ -245,6 +251,8 @@
#define LWIP_SO_LINGER 0
+#define LWIP_SO_RCVBUF 1
+
#define SO_REUSE 1
#define SIOCSHIWAT 1
@@ -285,6 +293,7 @@
* LWIP_IGMP_V3==1: Turn on IGMPv3 module.
*/
#define LWIP_IGMP_V3 1
+#define LWIP_IGMP 1
/**
* LWIP_IPV6_MLD_V2==1: Enable multicast listener discovery protocol v2.
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yinbin6/lwip.git
git@gitee.com:yinbin6/lwip.git
yinbin6
lwip
lwip
master

搜索帮助