Some build fixes for OpenBSD.

This commit is contained in:
christiaans 2005-10-10 07:25:35 +00:00
parent e2e13d3e30
commit ca90f6fce9
10 changed files with 55 additions and 23 deletions

View File

@ -20,6 +20,7 @@
#undef NTOHS
#include <stdlib.h>
#include <util.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
@ -28,7 +29,7 @@
#include <sys/signal.h>
#include <sys/types.h>
#if PPP_SUPPORT
#if PPP_SUPPORT && defined(linux)
#include <pty.h>
#endif
@ -295,7 +296,7 @@ sio_status_t * sio_open( int devnum )
fifoInit( &siostate->myfifo );
#endif /* ! PPP_SUPPORT */
sprintf( dev, "/dev/ttyS%d", devnum );
snprintf( dev, sizeof(dev), "/dev/ttyS%d", devnum );
if ( (devnum == 1) || (devnum == 0) )
{

View File

@ -267,9 +267,14 @@ tunif_input(struct netif *netif)
return;
}
#if 0
/* CS: ip_lookup() was removed */
if (ip_lookup(p->payload, netif)) {
#endif
netif->input(p, netif);
#if 0
}
#endif
}
/*-----------------------------------------------------------------------------------*/
/*

View File

@ -89,7 +89,7 @@ unix_socket_client(char *name)
/* fill socket address structure w/our address */
memset(&unix_addr, 0, sizeof(unix_addr));
unix_addr.sun_family = AF_UNIX;
sprintf(unix_addr.sun_path, "%s%05d", "/var/tmp/", getpid());
snprintf(unix_addr.sun_path, sizeof(unix_addr.sun_path), "%s%05d", "/var/tmp/", getpid());
#if !defined(linux) && !defined(cygwin)
len = sizeof(unix_addr.sun_len) + sizeof(unix_addr.sun_family) +
strlen(unix_addr.sun_path) + 1;

View File

@ -33,6 +33,7 @@ CCDEP=gcc
CC=gcc
#To compile for linux: make ARCH=linux
#To compile for cygwin: make ARCH=cygwin
#To compile for openbsd: make ARCH=openbsd
ARCH=unix
CFLAGS=-g -Wall -D$(ARCH) -DIPv4 -Os -fpack-struct
ARFLAGS=rs

View File

@ -46,6 +46,7 @@ echo_err(void *arg, err_t err)
struct echo_state *es = arg;
if (arg != NULL) {
LWIP_ASSERT("es->p != NULL", es->p != NULL);
pbuf_free(es->p);
mem_free(arg);
}
@ -60,7 +61,9 @@ close_conn(struct tcp_pcb *pcb, struct echo_state *es)
tcp_recv(pcb, NULL);
#endif /* 0 */
if (es != NULL) {
if (es->p != NULL) {
pbuf_free(es->p);
}
mem_free(es);
}
tcp_close(pcb);
@ -80,6 +83,7 @@ send_buf(struct tcp_pcb *pcb, struct echo_state *es)
return;
}
tcp_recved(pcb, q->len);
LWIP_ASSERT("q != NULL", q != NULL);
pbuf_free(q);
} while (es->p != NULL);
}

View File

@ -43,12 +43,12 @@
/* MEM_SIZE: the size of the heap memory. If the application will send
a lot of data that needs to be copied, this should be set high. */
#define MEM_SIZE 1000
#define MEM_SIZE 3000
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
sends a lot of data out of ROM (or other static memory), this
should be set high. */
#define MEMP_NUM_PBUF 8
#define MEMP_NUM_PBUF 30
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
per active UDP "connection". */
#define MEMP_NUM_UDP_PCB 4
@ -60,7 +60,7 @@ a lot of data that needs to be copied, this should be set high. */
#define MEMP_NUM_TCP_PCB_LISTEN 8
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
segments. */
#define MEMP_NUM_TCP_SEG 8
#define MEMP_NUM_TCP_SEG 16
/* The following four are used only with the sequential API and can be
set to 0 if the application only will use the raw API. */

View File

@ -77,6 +77,8 @@ main(int argc, char **argv)
netif_set_default(&netif);
netif_set_up(&netif);
echo_init();
printf("Applications started.\n");
@ -84,8 +86,17 @@ main(int argc, char **argv)
while (1) {
if (mintapif_wait(&netif, TCP_TMR_INTERVAL) == MINTAPIF_TIMEOUT) {
tcp_tmr();
if (mintapif_wait(&netif, TCP_FAST_INTERVAL) == MINTAPIF_TIMEOUT) {
static u8_t slow_timer = 0;
tcp_fasttmr();
if (slow_timer == 4) {
slow_timer = 0;
tcp_slowtmr();
} else {
slow_timer++;
}
}
}

View File

@ -43,14 +43,21 @@
#include <sys/uio.h>
#include <sys/socket.h>
#ifdef linux
#if defined(linux)
#include <sys/ioctl.h>
#include <linux/if.h>
#include <linux/if_tun.h>
#define DEVTAP "/dev/net/tun"
#else /* linux */
#define IFCONFIG_ARGS "tap0 inet %d.%d.%d.%d"
#elif defined(openbsd)
#define DEVTAP "/dev/tun0"
#define IFCONFIG_ARGS "tun0 inet %d.%d.%d.%d link0"
#else /* freebsd, cygwin? */
#define DEVTAP "/dev/tap0"
#endif /* linux */
#define IFCONFIG_ARGS "tap0 inet %d.%d.%d.%d"
#endif
#include "lwip/stats.h"
#include "lwip/mem.h"
@ -113,7 +120,7 @@ low_level_init(struct netif *netif)
}
#endif /* Linux */
snprintf(buf, sizeof(buf), "ifconfig tap0 inet %d.%d.%d.%d",
snprintf(buf, sizeof(buf), "/sbin/ifconfig " IFCONFIG_ARGS,
ip4_addr1(&(netif->gw)),
ip4_addr2(&(netif->gw)),
ip4_addr3(&(netif->gw)),
@ -263,14 +270,15 @@ mintapif_input(struct netif *netif)
switch (htons(ethhdr->type)) {
case ETHTYPE_IP:
q = etharp_ip_input(netif, p);
etharp_ip_input(netif, p);
pbuf_header(p, -14);
netif->input(p, netif);
break;
case ETHTYPE_ARP:
q = etharp_arp_input(netif, mintapif->ethaddr, p);
etharp_arp_input(netif, mintapif->ethaddr, p);
break;
default:
LWIP_ASSERT("p != NULL", p != NULL);
pbuf_free(p);
break;
}
@ -302,6 +310,8 @@ mintapif_init(struct netif *netif)
mintapif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
low_level_init(netif);
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
enum mintapif_signal

View File

@ -76,7 +76,7 @@ NETIFFILES+=$(LWIPDIR)/netif/ppp/auth.c $(LWIPDIR)/netif/ppp/chap.c \
$(LWIPARCH)/netif/sio.c
# ARCHFILES: Architecture specific files.
ARCHFILES=$(wildcard $(LWIPARCH)/*.c $(LWIPARCH)/netif/tapif.c $(LWIPARCH)/netif/unixif.c $(LWIPARCH)/netif/list.c $(LWIPARCH)/netif/tcpdump.c)
ARCHFILES=$(wildcard $(LWIPARCH)/*.c $(LWIPARCH)/netif/tapif.c $(LWIPARCH)/netif/tunif.c $(LWIPARCH)/netif/unixif.c $(LWIPARCH)/netif/list.c $(LWIPARCH)/netif/tcpdump.c)
# APPFILES: Applications.
APPFILES=apps/fs.c apps/httpd.c \

View File

@ -275,7 +275,7 @@ com_open(struct command *com)
}
sendstr("Opened connection, connection identifier is ", com->conn);
sprintf((char *)buffer, "%d\n", i);
snprintf((char *)buffer, sizeof(buffer), "%d\n", i);
netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY);
return ESUCCESS;
@ -337,7 +337,7 @@ com_lstn(struct command *com)
}
sendstr("Opened connection, connection identifier is ", com->conn);
sprintf((char *)buffer, "%d\n", i);
snprintf((char *)buffer, sizeof(buffer), "%d\n", i);
netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY);
return ESUCCESS;
@ -417,7 +417,7 @@ com_acpt(struct command *com)
}
sendstr("Accepted connection, connection identifier for new connection is ", com->conn);
sprintf((char *)buffer, "%d\n", j);
snprintf((char *)buffer, sizeof(buffer), "%d\n", j);
netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY);
return ESUCCESS;
@ -432,7 +432,7 @@ com_stat(struct command *com)
u16_t len;
for(i = 0; i < sizeof(struct stats_) / 2; i++) {
len = sprintf(buf, "%d", ((u16_t *)&lwip_stats)[i]);
len = snprintf(buf, sizeof(buffer), "%d", ((u16_t *)&lwip_stats)[i]);
sendstr(stat_msgs[i], com->conn);
netconn_write(com->conn, buf, len, NETCONN_COPY);
sendstr("\n", com->conn);
@ -594,7 +594,7 @@ com_udpc(struct command *com)
}
sendstr("Connection set up, connection identifier is ", com->conn);
sprintf((char *)buffer, "%d\n", i);
snprintf((char *)buffer, sizeof(buffer), "%d\n", i);
netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY);
return ESUCCESS;
@ -666,7 +666,7 @@ com_udpl(struct command *com)
}
sendstr("Connection set up, connection identifier is ", com->conn);
sprintf((char *)buffer, "%d\n", i);
snprintf((char *)buffer, sizeof(buffer), "%d\n", i);
netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY);
return ESUCCESS;
@ -738,7 +738,7 @@ com_udpn(struct command *com)
}
sendstr("Connection set up, connection identifier is ", com->conn);
sprintf((char *)buffer, "%d\n", i);
snprintf((char *)buffer, sizeof(buffer), "%d\n", i);
netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY);
return ESUCCESS;
@ -810,7 +810,7 @@ com_udpb(struct command *com)
}
sendstr("Connection set up, connection identifier is ", com->conn);
sprintf((char *)buffer, "%d\n", i);
snprintf((char *)buffer, sizeof(buffer), "%d\n", i);
netconn_write(com->conn, buffer, strlen((const char *)buffer), NETCONN_COPY);
return ESUCCESS;