fixed warnings in unix port; use the same compiler settings in all 3 projects; use echo.c from apps and removed duplicate from unix/proj/minimal
This commit is contained in:
parent
8806c1e50e
commit
55d09ae777
|
@ -39,7 +39,11 @@ LWIPDIR=$(CONTRIBDIR)/../lwip/src
|
||||||
|
|
||||||
CCDEP=gcc
|
CCDEP=gcc
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-g -Wall -DIPv4 -DLWIP_DEBUG -fPIC
|
CFLAGS=-g -Wall -DIPv4 -DLWIP_DEBUG -fPIC -pedantic -Werror \
|
||||||
|
-Wparentheses -Wsequence-point -Wswitch-default \
|
||||||
|
-Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \
|
||||||
|
-Wc++-compat -Wwrite-strings -Wold-style-definition \
|
||||||
|
-Wredundant-decls -Wnested-externs -Wno-address
|
||||||
|
|
||||||
CFLAGS:=$(CFLAGS) \
|
CFLAGS:=$(CFLAGS) \
|
||||||
-I$(LWIPDIR)/include -I$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
|
-I$(LWIPDIR)/include -I$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
|
||||||
|
|
|
@ -61,7 +61,7 @@ tcpip_init_done(void *arg)
|
||||||
{
|
{
|
||||||
ip_addr_t ipaddr, netmask, gateway;
|
ip_addr_t ipaddr, netmask, gateway;
|
||||||
sys_sem_t *sem;
|
sys_sem_t *sem;
|
||||||
sem = arg;
|
sem = (sys_sem_t *)arg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CHANGE THESE to suit your own network configuration:
|
CHANGE THESE to suit your own network configuration:
|
||||||
|
|
|
@ -35,7 +35,11 @@ CC=gcc
|
||||||
#To compile for cygwin: make ARCH=cygwin
|
#To compile for cygwin: make ARCH=cygwin
|
||||||
#To compile for openbsd: make ARCH=openbsd
|
#To compile for openbsd: make ARCH=openbsd
|
||||||
ARCH=openbsd
|
ARCH=openbsd
|
||||||
CFLAGS=-g -Wall -pedantic -D$(ARCH) -DIPv4 -Os -fpack-struct -DLWIP_DEBUG
|
CFLAGS=-g -Wall -D$(ARCH) -DIPv4 -Os -DLWIP_DEBUG -pedantic -Werror \
|
||||||
|
-Wparentheses -Wsequence-point -Wswitch-default \
|
||||||
|
-Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \
|
||||||
|
-Wc++-compat -Wwrite-strings -Wold-style-definition \
|
||||||
|
-Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wno-address
|
||||||
ARFLAGS=rs
|
ARFLAGS=rs
|
||||||
|
|
||||||
CONTRIBDIR=../../../..
|
CONTRIBDIR=../../../..
|
||||||
|
@ -47,7 +51,8 @@ LWIPDIR=$(CONTRIBDIR)/../lwip/src
|
||||||
|
|
||||||
CFLAGS:=$(CFLAGS) \
|
CFLAGS:=$(CFLAGS) \
|
||||||
-I$(LWIPDIR)/include -I$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
|
-I$(LWIPDIR)/include -I$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
|
||||||
-I$(LWIPDIR)/include/ipv6 -I. -I$(CONTRIBDIR)/apps/snmp_private_mib
|
-I$(LWIPDIR)/include/ipv6 -I. -I$(CONTRIBDIR)/apps/snmp_private_mib \
|
||||||
|
-I$(CONTRIBDIR)/apps/tcpecho_raw
|
||||||
|
|
||||||
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
|
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
|
||||||
COREFILES=$(LWIPDIR)/core/def.c $(LWIPDIR)/core/dhcp.c $(LWIPDIR)/core/dns.c \
|
COREFILES=$(LWIPDIR)/core/def.c $(LWIPDIR)/core/dhcp.c $(LWIPDIR)/core/dns.c \
|
||||||
|
@ -82,7 +87,7 @@ LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||||
|
|
||||||
# APPFILES
|
# APPFILES
|
||||||
APPFILES=echo.c timer.c
|
APPFILES=../../../../apps/tcpecho_raw/echo.c timer.c
|
||||||
|
|
||||||
LWIPLIB=liblwip4.a
|
LWIPLIB=liblwip4.a
|
||||||
APPLIB=liblwipapps.a
|
APPLIB=liblwipapps.a
|
||||||
|
|
|
@ -1,349 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
||||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
||||||
* OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This file is part of and a contribution to the lwIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
* Credits go to Adam Dunkels (and the current maintainers) of this software.
|
|
||||||
*
|
|
||||||
* Christiaan Simons rewrote this file to get a more stable echo example.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* TCP echo server example using raw API.
|
|
||||||
*
|
|
||||||
* Echos all bytes sent by connecting client,
|
|
||||||
* and passively closes when client is done.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "lwip/debug.h"
|
|
||||||
#include "lwip/stats.h"
|
|
||||||
#include "lwip/tcp.h"
|
|
||||||
|
|
||||||
static struct tcp_pcb *echo_pcb;
|
|
||||||
|
|
||||||
enum echo_states
|
|
||||||
{
|
|
||||||
ES_NONE = 0,
|
|
||||||
ES_ACCEPTED,
|
|
||||||
ES_RECEIVED,
|
|
||||||
ES_CLOSING
|
|
||||||
};
|
|
||||||
|
|
||||||
struct echo_state
|
|
||||||
{
|
|
||||||
u8_t state;
|
|
||||||
u8_t retries;
|
|
||||||
struct tcp_pcb *pcb;
|
|
||||||
/* pbuf (chain) to recycle */
|
|
||||||
struct pbuf *p;
|
|
||||||
};
|
|
||||||
|
|
||||||
err_t echo_accept(void *arg, struct tcp_pcb *newpcb, err_t err);
|
|
||||||
err_t echo_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
|
|
||||||
void echo_error(void *arg, err_t err);
|
|
||||||
err_t echo_poll(void *arg, struct tcp_pcb *tpcb);
|
|
||||||
err_t echo_sent(void *arg, struct tcp_pcb *tpcb, u16_t len);
|
|
||||||
void echo_send(struct tcp_pcb *tpcb, struct echo_state *es);
|
|
||||||
void echo_close(struct tcp_pcb *tpcb, struct echo_state *es);
|
|
||||||
|
|
||||||
void
|
|
||||||
echo_init(void)
|
|
||||||
{
|
|
||||||
echo_pcb = tcp_new();
|
|
||||||
if (echo_pcb != NULL)
|
|
||||||
{
|
|
||||||
err_t err;
|
|
||||||
|
|
||||||
err = tcp_bind(echo_pcb, IP_ADDR_ANY, 7);
|
|
||||||
if (err == ERR_OK)
|
|
||||||
{
|
|
||||||
echo_pcb = tcp_listen(echo_pcb);
|
|
||||||
tcp_accept(echo_pcb, echo_accept);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* abort? output diagnostic? */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* abort? output diagnostic? */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
err_t
|
|
||||||
echo_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
|
|
||||||
{
|
|
||||||
err_t ret_err;
|
|
||||||
struct echo_state *es;
|
|
||||||
|
|
||||||
/* commonly observed practive to call tcp_setprio(), why? */
|
|
||||||
tcp_setprio(newpcb, TCP_PRIO_MIN);
|
|
||||||
|
|
||||||
es = mem_malloc(sizeof(struct echo_state));
|
|
||||||
if (es != NULL)
|
|
||||||
{
|
|
||||||
es->state = ES_ACCEPTED;
|
|
||||||
es->pcb = newpcb;
|
|
||||||
es->retries = 0;
|
|
||||||
es->p = NULL;
|
|
||||||
/* pass newly allocated es to our callbacks */
|
|
||||||
tcp_arg(newpcb, es);
|
|
||||||
tcp_recv(newpcb, echo_recv);
|
|
||||||
tcp_err(newpcb, echo_error);
|
|
||||||
tcp_poll(newpcb, echo_poll, 0);
|
|
||||||
ret_err = ERR_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret_err = ERR_MEM;
|
|
||||||
}
|
|
||||||
return ret_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err_t
|
|
||||||
echo_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
|
|
||||||
{
|
|
||||||
struct echo_state *es;
|
|
||||||
err_t ret_err;
|
|
||||||
|
|
||||||
LWIP_ASSERT("arg != NULL",arg != NULL);
|
|
||||||
es = arg;
|
|
||||||
if (p == NULL)
|
|
||||||
{
|
|
||||||
/* remote host closed connection */
|
|
||||||
es->state = ES_CLOSING;
|
|
||||||
if(es->p == NULL)
|
|
||||||
{
|
|
||||||
/* we're done sending, close it */
|
|
||||||
echo_close(tpcb, es);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* we're not done yet */
|
|
||||||
tcp_sent(tpcb, echo_sent);
|
|
||||||
echo_send(tpcb, es);
|
|
||||||
}
|
|
||||||
ret_err = ERR_OK;
|
|
||||||
}
|
|
||||||
else if(err != ERR_OK)
|
|
||||||
{
|
|
||||||
/* cleanup, for unkown reason */
|
|
||||||
if (p != NULL)
|
|
||||||
{
|
|
||||||
es->p = NULL;
|
|
||||||
pbuf_free(p);
|
|
||||||
}
|
|
||||||
ret_err = err;
|
|
||||||
}
|
|
||||||
else if(es->state == ES_ACCEPTED)
|
|
||||||
{
|
|
||||||
/* first data chunk in p->payload */
|
|
||||||
es->state = ES_RECEIVED;
|
|
||||||
/* store reference to incoming pbuf (chain) */
|
|
||||||
es->p = p;
|
|
||||||
/* install send completion notifier */
|
|
||||||
tcp_sent(tpcb, echo_sent);
|
|
||||||
echo_send(tpcb, es);
|
|
||||||
ret_err = ERR_OK;
|
|
||||||
}
|
|
||||||
else if (es->state == ES_RECEIVED)
|
|
||||||
{
|
|
||||||
/* read some more data */
|
|
||||||
if(es->p == NULL)
|
|
||||||
{
|
|
||||||
es->p = p;
|
|
||||||
tcp_sent(tpcb, echo_sent);
|
|
||||||
echo_send(tpcb, es);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct pbuf *ptr;
|
|
||||||
|
|
||||||
/* chain pbufs to the end of what we recv'ed previously */
|
|
||||||
ptr = es->p;
|
|
||||||
pbuf_chain(ptr,p);
|
|
||||||
}
|
|
||||||
ret_err = ERR_OK;
|
|
||||||
}
|
|
||||||
else if(es->state == ES_CLOSING)
|
|
||||||
{
|
|
||||||
/* odd case, remote side closing twice, trash data */
|
|
||||||
tcp_recved(tpcb, p->tot_len);
|
|
||||||
es->p = NULL;
|
|
||||||
pbuf_free(p);
|
|
||||||
ret_err = ERR_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* unkown es->state, trash data */
|
|
||||||
tcp_recved(tpcb, p->tot_len);
|
|
||||||
es->p = NULL;
|
|
||||||
pbuf_free(p);
|
|
||||||
ret_err = ERR_OK;
|
|
||||||
}
|
|
||||||
return ret_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
echo_error(void *arg, err_t err)
|
|
||||||
{
|
|
||||||
struct echo_state *es;
|
|
||||||
|
|
||||||
es = arg;
|
|
||||||
if (es != NULL)
|
|
||||||
{
|
|
||||||
mem_free(es);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err_t
|
|
||||||
echo_poll(void *arg, struct tcp_pcb *tpcb)
|
|
||||||
{
|
|
||||||
err_t ret_err;
|
|
||||||
struct echo_state *es;
|
|
||||||
|
|
||||||
es = arg;
|
|
||||||
if (es != NULL)
|
|
||||||
{
|
|
||||||
if (es->p != NULL)
|
|
||||||
{
|
|
||||||
/* there is a remaining pbuf (chain) */
|
|
||||||
tcp_sent(tpcb, echo_sent);
|
|
||||||
echo_send(tpcb, es);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* no remaining pbuf (chain) */
|
|
||||||
if(es->state == ES_CLOSING)
|
|
||||||
{
|
|
||||||
echo_close(tpcb, es);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret_err = ERR_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* nothing to be done */
|
|
||||||
tcp_abort(tpcb);
|
|
||||||
ret_err = ERR_ABRT;
|
|
||||||
}
|
|
||||||
return ret_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err_t
|
|
||||||
echo_sent(void *arg, struct tcp_pcb *tpcb, u16_t len)
|
|
||||||
{
|
|
||||||
struct echo_state *es;
|
|
||||||
|
|
||||||
es = arg;
|
|
||||||
es->retries = 0;
|
|
||||||
|
|
||||||
if(es->p != NULL)
|
|
||||||
{
|
|
||||||
/* still got pbufs to send */
|
|
||||||
tcp_sent(tpcb, echo_sent);
|
|
||||||
echo_send(tpcb, es);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* no more pbufs to send */
|
|
||||||
if(es->state == ES_CLOSING)
|
|
||||||
{
|
|
||||||
echo_close(tpcb, es);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ERR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
echo_send(struct tcp_pcb *tpcb, struct echo_state *es)
|
|
||||||
{
|
|
||||||
struct pbuf *ptr;
|
|
||||||
err_t wr_err = ERR_OK;
|
|
||||||
|
|
||||||
while ((wr_err == ERR_OK) &&
|
|
||||||
(es->p != NULL) &&
|
|
||||||
(es->p->len <= tcp_sndbuf(tpcb)))
|
|
||||||
{
|
|
||||||
ptr = es->p;
|
|
||||||
|
|
||||||
/* enqueue data for transmission */
|
|
||||||
wr_err = tcp_write(tpcb, ptr->payload, ptr->len, 1);
|
|
||||||
if (wr_err == ERR_OK)
|
|
||||||
{
|
|
||||||
u16_t plen;
|
|
||||||
u8_t freed;
|
|
||||||
|
|
||||||
plen = ptr->len;
|
|
||||||
/* continue with next pbuf in chain (if any) */
|
|
||||||
es->p = ptr->next;
|
|
||||||
if(es->p != NULL)
|
|
||||||
{
|
|
||||||
/* new reference! */
|
|
||||||
pbuf_ref(es->p);
|
|
||||||
}
|
|
||||||
/* chop first pbuf from chain */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
/* try hard to free pbuf */
|
|
||||||
freed = pbuf_free(ptr);
|
|
||||||
}
|
|
||||||
while(freed == 0);
|
|
||||||
/* we can read more data now */
|
|
||||||
tcp_recved(tpcb, plen);
|
|
||||||
}
|
|
||||||
else if(wr_err == ERR_MEM)
|
|
||||||
{
|
|
||||||
/* we are low on memory, try later / harder, defer to poll */
|
|
||||||
es->p = ptr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* other problem ?? */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
echo_close(struct tcp_pcb *tpcb, struct echo_state *es)
|
|
||||||
{
|
|
||||||
tcp_arg(tpcb, NULL);
|
|
||||||
tcp_sent(tpcb, NULL);
|
|
||||||
tcp_recv(tpcb, NULL);
|
|
||||||
tcp_err(tpcb, NULL);
|
|
||||||
tcp_poll(tpcb, NULL, 0);
|
|
||||||
|
|
||||||
if (es != NULL)
|
|
||||||
{
|
|
||||||
mem_free(es);
|
|
||||||
}
|
|
||||||
tcp_close(tpcb);
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
||||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
||||||
* OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This file is part of the lwIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef __ECHO_H__
|
|
||||||
#define __ECHO_H__
|
|
||||||
|
|
||||||
void echo_init(void);
|
|
||||||
|
|
||||||
#endif /* __MINIMAL_ECHO_H */
|
|
|
@ -94,7 +94,7 @@ static struct option longopts[] = {
|
||||||
};
|
};
|
||||||
#define NUM_OPTS ((sizeof(longopts) / sizeof(struct option)) - 1)
|
#define NUM_OPTS ((sizeof(longopts) / sizeof(struct option)) - 1)
|
||||||
|
|
||||||
void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
unsigned char i;
|
unsigned char i;
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,9 @@ low_level_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct mintapif *mintapif;
|
struct mintapif *mintapif;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
int ret;
|
||||||
|
|
||||||
mintapif = netif->state;
|
mintapif = (struct mintapif *)netif->state;
|
||||||
|
|
||||||
/* Obtain MAC address from network interface. */
|
/* Obtain MAC address from network interface. */
|
||||||
mintapif->ethaddr->addr[0] = 1;
|
mintapif->ethaddr->addr[0] = 1;
|
||||||
|
@ -127,7 +128,14 @@ low_level_init(struct netif *netif)
|
||||||
ip4_addr3(&(netif->gw)),
|
ip4_addr3(&(netif->gw)),
|
||||||
ip4_addr4(&(netif->gw)));
|
ip4_addr4(&(netif->gw)));
|
||||||
|
|
||||||
system(buf);
|
ret = system(buf);
|
||||||
|
if (ret < 0) {
|
||||||
|
perror("ifconfig failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("ifconfig returned %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
mintapif->lasttime = 0;
|
mintapif->lasttime = 0;
|
||||||
|
|
||||||
|
@ -152,7 +160,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
char *bufptr;
|
char *bufptr;
|
||||||
int written;
|
int written;
|
||||||
|
|
||||||
mintapif = netif->state;
|
mintapif = (struct mintapif *)netif->state;
|
||||||
|
|
||||||
/* initiate transfer(); */
|
/* initiate transfer(); */
|
||||||
|
|
||||||
|
@ -196,7 +204,7 @@ low_level_input(struct netif *netif)
|
||||||
char *bufptr;
|
char *bufptr;
|
||||||
struct mintapif *mintapif;
|
struct mintapif *mintapif;
|
||||||
|
|
||||||
mintapif = netif->state;
|
mintapif = (struct mintapif *)netif->state;
|
||||||
|
|
||||||
/* Obtain the size of the packet and put it into the "len"
|
/* Obtain the size of the packet and put it into the "len"
|
||||||
variable. */
|
variable. */
|
||||||
|
@ -272,7 +280,7 @@ mintapif_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct mintapif *mintapif;
|
struct mintapif *mintapif;
|
||||||
|
|
||||||
mintapif = mem_malloc(sizeof(struct mintapif));
|
mintapif = (struct mintapif *)mem_malloc(sizeof(struct mintapif));
|
||||||
if (mintapif == NULL)
|
if (mintapif == NULL)
|
||||||
{
|
{
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_init: out of memory for mintapif\n"));
|
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_init: out of memory for mintapif\n"));
|
||||||
|
@ -319,7 +327,7 @@ mintapif_wait(struct netif *netif, u16_t time)
|
||||||
int ret;
|
int ret;
|
||||||
struct mintapif *mintapif;
|
struct mintapif *mintapif;
|
||||||
|
|
||||||
mintapif = netif->state;
|
mintapif = (struct mintapif *)netif->state;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
|
@ -358,7 +366,7 @@ mintapif_select(struct netif *netif)
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct mintapif *mintapif;
|
struct mintapif *mintapif;
|
||||||
|
|
||||||
mintapif = netif->state;
|
mintapif = (struct mintapif *)netif->state;
|
||||||
|
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 0; /* usec_to; */
|
tv.tv_usec = 0; /* usec_to; */
|
||||||
|
|
|
@ -41,5 +41,6 @@ enum mintapif_signal {
|
||||||
|
|
||||||
err_t mintapif_init(struct netif *netif);
|
err_t mintapif_init(struct netif *netif);
|
||||||
int mintapif_select(struct netif *netif);
|
int mintapif_select(struct netif *netif);
|
||||||
|
enum mintapif_signal mintapif_wait(struct netif *netif, u16_t time);
|
||||||
|
|
||||||
#endif /* __MINTAPIF_H__ */
|
#endif /* __MINTAPIF_H__ */
|
||||||
|
|
|
@ -92,11 +92,11 @@ timer_init(void)
|
||||||
* @param interval when > 0 enables this timer, 0 disables.
|
* @param interval when > 0 enables this timer, 0 disables.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
timer_set_interval(unsigned char tmr, unsigned int interval)
|
timer_set_interval(unsigned char tmr_num, unsigned int interval)
|
||||||
{
|
{
|
||||||
if (tmr < TIMER_NUM)
|
if (tmr_num < TIMER_NUM)
|
||||||
{
|
{
|
||||||
timers[tmr].interval = interval;
|
timers[tmr_num].interval = interval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,14 +105,14 @@ timer_set_interval(unsigned char tmr, unsigned int interval)
|
||||||
* Returns timer event and restarts timer.
|
* Returns timer event and restarts timer.
|
||||||
*/
|
*/
|
||||||
unsigned char
|
unsigned char
|
||||||
timer_testclr_evt(unsigned char tmr)
|
timer_testclr_evt(unsigned char tmr_num)
|
||||||
{
|
{
|
||||||
if (tmr < TIMER_NUM)
|
if (tmr_num < TIMER_NUM)
|
||||||
{
|
{
|
||||||
unsigned char evt;
|
unsigned char evt;
|
||||||
struct itmr *tp;
|
struct itmr *tp;
|
||||||
|
|
||||||
tp = &timers[tmr];
|
tp = &timers[tmr_num];
|
||||||
|
|
||||||
evt = tp->event;
|
evt = tp->event;
|
||||||
if (tp->event != 0)
|
if (tp->event != 0)
|
||||||
|
@ -136,6 +136,7 @@ sigalarm_handler(int sig)
|
||||||
{
|
{
|
||||||
unsigned char i;
|
unsigned char i;
|
||||||
struct itmr *tp;
|
struct itmr *tp;
|
||||||
|
LWIP_UNUSED_ARG(sig);
|
||||||
|
|
||||||
snmp_inc_sysuptime();
|
snmp_inc_sysuptime();
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,13 @@ CFLAGS=-g -Wall -D$(ARCH) -DIPv4 -DLWIP_DEBUG -pedantic -Werror \
|
||||||
-Wparentheses -Wsequence-point -Wswitch-default \
|
-Wparentheses -Wsequence-point -Wswitch-default \
|
||||||
-Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \
|
-Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \
|
||||||
-Wc++-compat -Wwrite-strings -Wold-style-definition \
|
-Wc++-compat -Wwrite-strings -Wold-style-definition \
|
||||||
-Wmissing-prototypes -Wredundant-decls -Wnested-externs
|
-Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wno-address
|
||||||
# not used for now but interesting:
|
# not used for now but interesting:
|
||||||
# -Wpacked
|
# -Wpacked
|
||||||
# -Wunreachable-code
|
# -Wunreachable-code
|
||||||
# -ansi
|
# -ansi
|
||||||
# -std=c89
|
# -std=c89
|
||||||
LDFLAGS=-lpthread -lutil
|
LDFLAGS=-pthread -lutil
|
||||||
CONTRIBDIR=../../../..
|
CONTRIBDIR=../../../..
|
||||||
LWIPARCH=$(CONTRIBDIR)/ports/unix
|
LWIPARCH=$(CONTRIBDIR)/ports/unix
|
||||||
ARFLAGS=rs
|
ARFLAGS=rs
|
||||||
|
|
Loading…
Reference in New Issue