标签:inf tcpip ESS read 发布 hardware open har mil
lwIP - A Lightweight TCP/IP stack
在上一篇中,我们了解到在OpenFastPath上如何移植原生态的Linux Socket应用程序,那么,对于另外一个老牌的小型TCPIP协议栈------LWIP,又是如何处理这个问题的。
1、lwip重新定义了函数符号
#define listen(s,backlog) lwip_listen(s,backlog) /** @ingroup socket */ #define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags) /** @ingroup socket */ #define recvmsg(s,message,flags) lwip_recvmsg(s,message,flags) /** @ingroup socket */ #define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen) /** @ingroup socket */ #define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags) /** @ingroup socket */ #define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags) /** @ingroup socket */ #define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen) /** @ingroup socket */ #define socket(domain,type,protocol) lwip_socket(domain,type,protocol) #if LWIP_SOCKET_SELECT /** @ingroup socket */ #define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout) #endif #if LWIP_SOCKET_POLL /** @ingroup socket */ #define poll(fds,nfds,timeout) lwip_poll(fds,nfds,timeout) #endif
2、lwip重新定义了socket结构体
#if LWIP_IPV4 /* members are in network byte order */ struct sockaddr_in { u8_t sin_len; sa_family_t sin_family; in_port_t sin_port; struct in_addr sin_addr; #define SIN_ZERO_LEN 8 char sin_zero[SIN_ZERO_LEN]; }; #endif /* LWIP_IPV4 */
3、lwip重新定义了socket宏
/* Socket protocol types (TCP/UDP/RAW) */ #define SOCK_STREAM 1 #define SOCK_DGRAM 2 #define SOCK_RAW 3 /* * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c) */ #define SO_REUSEADDR 0x0004 /* Allow local address reuse */ #define SO_KEEPALIVE 0x0008 /* keep connections alive */ #define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ /* * Additional options, not kept in so_options. */ #define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */ #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ #define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */ #define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */ #define SO_LINGER 0x0080 /* linger on close if data present */ #define SO_DONTLINGER ((int)(~SO_LINGER))
说句题外话:LWIP从2012年的1.4.1版本后基本没有更新了,近两年突然发布了很多新版本,功能(主要是apps)也大大增强,说明这个开源还是有一定市场基础的。
Lwip:原生态的Linux socket应用如何移植到Lwip上
标签:inf tcpip ESS read 发布 hardware open har mil
原文地址:https://www.cnblogs.com/shaoyangz/p/10346240.html