Skip to content

Commit

Permalink
tcp lwip: added sed scripts for converting orig c code to inet, reduc…
Browse files Browse the repository at this point in the history
…e differences between converted original files and the working code files
  • Loading branch information
ZoltanBojthe authored and avarga committed Sep 26, 2023
1 parent 42d2965 commit 5f135b2
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 26 deletions.
10 changes: 5 additions & 5 deletions src/inet/transportlayer/tcp_lwip/lwip/core/memp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/inet/transportlayer/tcp_lwip/lwip/core/pbuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/inet/transportlayer/tcp_lwip/lwip/core/replace_class.sed
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
17 changes: 7 additions & 10 deletions src/inet/transportlayer/tcp_lwip/lwip/core/tcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
));
Expand Down Expand Up @@ -823,7 +820,7 @@ tcp_slowtmr(void)
*/
void
LwipTcpLayer::
tcp_fasttmr(void)
tcp_fasttmr()
{
struct tcp_pcb *pcb;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1104,7 +1101,7 @@ tcp_alloc(u8_t prio)
*/
LwipTcpLayer::tcp_pcb *
LwipTcpLayer::
tcp_new(void)
tcp_new()
{
return tcp_alloc(TCP_PRIO_NORMAL);
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/inet/transportlayer/tcp_lwip/lwip/core/tcp_in.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 4 additions & 7 deletions src/inet/transportlayer/tcp_lwip/lwip/include/lwip/lwip_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand All @@ -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: */
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -555,15 +552,15 @@ 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);

/* 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);
Expand Down

0 comments on commit 5f135b2

Please sign in to comment.