From 5f135b2e3f873e05ab3ae77a5cea336494ef7f34 Mon Sep 17 00:00:00 2001 From: Zoltan Bojthe Date: Mon, 25 Sep 2023 11:35:54 +0200 Subject: [PATCH] tcp lwip: added sed scripts for converting orig c code to inet, reduce differences between converted original files and the working code files --- .../transportlayer/tcp_lwip/lwip/core/memp.cc | 10 +++++----- .../transportlayer/tcp_lwip/lwip/core/pbuf.cc | 4 ++-- .../tcp_lwip/lwip/core/replace_class.sed | 11 +++++++++++ .../tcp_lwip/lwip/core/replace_noclass.sed | 5 +++++ .../transportlayer/tcp_lwip/lwip/core/tcp.cc | 17 +++++++---------- .../transportlayer/tcp_lwip/lwip/core/tcp_in.cc | 3 +-- .../tcp_lwip/lwip/include/lwip/lwip_tcp.h | 11 ++++------- 7 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 src/inet/transportlayer/tcp_lwip/lwip/core/replace_class.sed create mode 100644 src/inet/transportlayer/tcp_lwip/lwip/core/replace_noclass.sed diff --git a/src/inet/transportlayer/tcp_lwip/lwip/core/memp.cc b/src/inet/transportlayer/tcp_lwip/lwip/core/memp.cc index 5a1eb1b6942..7e7f6755e73 100644 --- a/src/inet/transportlayer/tcp_lwip/lwip/core/memp.cc +++ b/src/inet/transportlayer/tcp_lwip/lwip/core/memp.cc @@ -113,7 +113,7 @@ struct memp { /** This array holds the first free element of each pool. * Elements form a linked list. */ -OPP_THREAD_LOCAL static OPP_THREAD_LOCAL struct memp *memp_tab[MEMP_MAX]; +static OPP_THREAD_LOCAL struct memp *memp_tab[MEMP_MAX]; #else /* MEMP_MEM_MALLOC */ @@ -157,7 +157,7 @@ static OPP_THREAD_LOCAL u8_t memp_memory[MEM_ALIGNMENT - 1 * Check that memp-lists don't form a circle */ static int -memp_sanity(void) +memp_sanity() { s16_t i, c; struct memp *m, *n; @@ -212,7 +212,7 @@ memp_overflow_check_element(struct memp *p, u16_t memp_size) * @see memp_overflow_check_element for a description of the check */ static void -memp_overflow_check_all(void) +memp_overflow_check_all() { u16_t i, j; struct memp *p; @@ -231,7 +231,7 @@ memp_overflow_check_all(void) * Initialize the restricted areas of all memp elements in every pool. */ static void -memp_overflow_init(void) +memp_overflow_init() { u16_t i, j; struct memp *p; @@ -261,7 +261,7 @@ memp_overflow_init(void) * Carves out memp_memory into linked lists for each pool-type. */ void -memp_init(void) +memp_init() { struct memp *memp; u16_t i, j; diff --git a/src/inet/transportlayer/tcp_lwip/lwip/core/pbuf.cc b/src/inet/transportlayer/tcp_lwip/lwip/core/pbuf.cc index 90ebc98c0bf..09a61c49f26 100644 --- a/src/inet/transportlayer/tcp_lwip/lwip/core/pbuf.cc +++ b/src/inet/transportlayer/tcp_lwip/lwip/core/pbuf.cc @@ -111,7 +111,7 @@ namespace inet { namespace tcp { #define PBUF_POOL_IS_EMPTY() pbuf_pool_is_empty() -OPP_THREAD_LOCAL static OPP_THREAD_LOCAL u8_t pbuf_free_ooseq_queued; +static OPP_THREAD_LOCAL u8_t pbuf_free_ooseq_queued; /** * Attempt to reclaim some memory from queued out-of-sequence TCP segments * if we run out of pool pbufs. It's better to give priority to new packets @@ -144,7 +144,7 @@ pbuf_free_ooseq(void* arg) /** Queue a call to pbuf_free_ooseq if not already queued. */ static void -pbuf_pool_is_empty(void) +pbuf_pool_is_empty() { u8_t queued; SYS_ARCH_DECL_PROTECT(old_level); diff --git a/src/inet/transportlayer/tcp_lwip/lwip/core/replace_class.sed b/src/inet/transportlayer/tcp_lwip/lwip/core/replace_class.sed new file mode 100644 index 00000000000..83d6d16f033 --- /dev/null +++ b/src/inet/transportlayer/tcp_lwip/lwip/core/replace_class.sed @@ -0,0 +1,11 @@ +s/ +$//g; +s/\bNULL\b/nullptr/g; +s/^(\w+[(])/LwipTcpLayer::\n\1/g; +s/^static *//g; +s/^struct tcp_hdr\b/LwipTcpLayer::tcp_hdr/g; +s/^struct tcp_pcb\b/LwipTcpLayer::tcp_pcb/g; +s/^struct tcp_seg\b/LwipTcpLayer::tcp_seg/g; +s/\%([0-9]*\")([SUX]16_F)\"/%\1 \2 "/g; +s/\%([0-9]*\")([SUX]32_F)\"/%\1 \2 "/g; +s/\(void\)/()/g; +s/\bip_output\(/ip_output(pcb, /g; \ No newline at end of file diff --git a/src/inet/transportlayer/tcp_lwip/lwip/core/replace_noclass.sed b/src/inet/transportlayer/tcp_lwip/lwip/core/replace_noclass.sed new file mode 100644 index 00000000000..109891d38a0 --- /dev/null +++ b/src/inet/transportlayer/tcp_lwip/lwip/core/replace_noclass.sed @@ -0,0 +1,5 @@ +s/ +$//g; +s/\bNULL\b/nullptr/g; +s/\%(\d*")([SUX]16_F)"/%\1 \2 "/g; +s/\%(\d*")([SUX]32_F)"/%\1 \2 "/g; +s/\(void\)/()/g; diff --git a/src/inet/transportlayer/tcp_lwip/lwip/core/tcp.cc b/src/inet/transportlayer/tcp_lwip/lwip/core/tcp.cc index 2c1a3823eb4..02a1a7f6437 100644 --- a/src/inet/transportlayer/tcp_lwip/lwip/core/tcp.cc +++ b/src/inet/transportlayer/tcp_lwip/lwip/core/tcp.cc @@ -95,7 +95,7 @@ const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 }; */ void LwipTcpLayer:: -tcp_tmr(void) +tcp_tmr() { /* Call tcp_fasttmr() every 250 ms */ tcp_fasttmr(); @@ -474,7 +474,7 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len) */ u16_t LwipTcpLayer:: -tcp_new_port(void) +tcp_new_port() { struct tcp_pcb *pcb; @@ -579,7 +579,7 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port, */ void LwipTcpLayer:: -tcp_slowtmr(void) +tcp_slowtmr() { struct tcp_pcb *pcb, *pcb2, *prev; u16_t eff_wnd; @@ -684,9 +684,6 @@ tcp_slowtmr(void) (pcb->keep_idle + TCP_MAXIDLE) / TCP_SLOW_INTERVAL) #endif /* LWIP_TCP_KEEPALIVE */ { -// LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %" U16_F ".%" U16_F ".%" U16_F ".%" U16_F ".\n", -// ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), -// ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip))); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %s\n", pcb->remote_ip.addr.str().c_str() )); @@ -823,7 +820,7 @@ tcp_slowtmr(void) */ void LwipTcpLayer:: -tcp_fasttmr(void) +tcp_fasttmr() { struct tcp_pcb *pcb; @@ -990,7 +987,7 @@ tcp_kill_prio(u8_t prio) */ void LwipTcpLayer:: -tcp_kill_timewait(void) +tcp_kill_timewait() { struct tcp_pcb *pcb, *inactive; u32_t inactivity; @@ -1104,7 +1101,7 @@ tcp_alloc(u8_t prio) */ LwipTcpLayer::tcp_pcb * LwipTcpLayer:: -tcp_new(void) +tcp_new() { return tcp_alloc(TCP_PRIO_NORMAL); } @@ -1313,7 +1310,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb) */ u32_t LwipTcpLayer:: -tcp_next_iss(void) +tcp_next_iss() { iss += tcp_ticks; /* TODO */ return iss; diff --git a/src/inet/transportlayer/tcp_lwip/lwip/core/tcp_in.cc b/src/inet/transportlayer/tcp_lwip/lwip/core/tcp_in.cc index b9e141b91af..225669b15ea 100644 --- a/src/inet/transportlayer/tcp_lwip/lwip/core/tcp_in.cc +++ b/src/inet/transportlayer/tcp_lwip/lwip/core/tcp_in.cc @@ -286,7 +286,6 @@ tcp_input(struct pbuf *p, struct netif *inp) return; } } - tcp_input_pcb = pcb; err = tcp_process(pcb); /* A return value of ERR_ABRT means that tcp_abort() was called @@ -1448,7 +1447,7 @@ tcp_parseopt(struct tcp_pcb *pcb) /* Parse the TCP MSS option, if present. */ if(TCPH_HDRLEN(tcphdr) > 0x5) { max_c = (TCPH_HDRLEN(tcphdr) - 5) << 2; - for (c = 0; c < max_c;) { + for (c = 0; c < max_c; ) { opt = opts[c]; switch (opt) { case 0x00: diff --git a/src/inet/transportlayer/tcp_lwip/lwip/include/lwip/lwip_tcp.h b/src/inet/transportlayer/tcp_lwip/lwip/include/lwip/lwip_tcp.h index d2a6ca8c576..c924cf9bd9d 100644 --- a/src/inet/transportlayer/tcp_lwip/lwip/include/lwip/lwip_tcp.h +++ b/src/inet/transportlayer/tcp_lwip/lwip/include/lwip/lwip_tcp.h @@ -225,7 +225,6 @@ class INET_API LwipTcpLayer /* Functions for interfacing with TCP: */ - /* Lower layer interface to TCP: */ #define tcp_init() /* Compatibility define, not init needed. */ void tcp_tmr (void); /* Must be called every @@ -272,13 +271,10 @@ err_t tcp_connect (struct tcp_pcb *pcb, struct ip_addr *ipaddr, err_t err)); struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog); - #define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) void tcp_abandon (struct tcp_pcb *pcb, int reset); - #define tcp_abort(pcb) tcp_abandon((pcb), 1) - err_t tcp_close (struct tcp_pcb *pcb); /* Flags for "apiflags" parameter in tcp_write and tcp_enqueue */ @@ -299,6 +295,7 @@ void tcp_setprio (struct tcp_pcb *pcb, u8_t prio); void tcp_slowtmr (void); void tcp_fasttmr (void); + /* Only used by IP to pass a TCP segment to TCP: */ void tcp_input (struct pbuf *p, struct netif *inp); /* Used within the TCP code only: */ @@ -444,7 +441,7 @@ enum tcp_state { /* Function to call when a listener has been connected. * @param arg user-supplied argument (tcp_pcb.callback_arg) * @param pcb a new tcp_pcb that now is connected - * @param err an error argument (TODO that is current always ERR_OK?) + * @param err an error argument (TODO: that is current always ERR_OK?) * @return ERR_OK: accept the new connection, * any other err_t abortsthe new connection */ @@ -555,7 +552,7 @@ struct tcp_pcb { * @param arg user-supplied argument (tcp_pcb.callback_arg) * @param pcb the tcp_pcb for which data has arrived * @param p the packet buffer which arrived - * @param err an error argument (TODO that is current always ERR_OK?) + * @param err an error argument (TODO: that is current always ERR_OK?) * @return ERR_OK: try to send some data by calling tcp_output */ err_t (* recv)(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); @@ -563,7 +560,7 @@ struct tcp_pcb { /* Function to be called when a connection has been set up. * @param arg user-supplied argument (tcp_pcb.callback_arg) * @param pcb the tcp_pcb that now is connected - * @param err an error argument (TODO that is current always ERR_OK?) + * @param err an error argument (TODO: that is current always ERR_OK?) * @return value is currently ignored */ err_t (* connected)(void *arg, struct tcp_pcb *pcb, err_t err);