It was compilable, but did not really work due to the changed pktif.c... Should work again now.

This commit is contained in:
goldsimon 2007-09-20 19:41:05 +00:00
parent 4b634d5d37
commit 7af5dcd9ee
3 changed files with 81 additions and 81 deletions

View File

@ -75,6 +75,7 @@
#include "lwip/stats.h"
#include "lwip/sys.h"
#include "lwip/ip.h"
#include "lwip/snmp.h"
#include "netif/etharp.h"
@ -86,7 +87,7 @@
#define IFNAME1 'k'
/* index of the network adapter to use for lwIP */
#define PACKET_LIB_ADAPTER_NR 1
#define PACKET_LIB_ADAPTER_NR 3
static struct eth_addr broadcastaddr = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
@ -95,7 +96,7 @@ static void ethernetif_input(struct netif *netif);
static struct netif *pktif_netif;
extern unsigned char ethaddr[6];
extern unsigned char ethaddr[ETHARP_HWADDR_LEN];
extern unsigned char *cur_packet;
extern int cur_length;
extern int init_adapter(int adapter_num, char* mac_addr);
@ -105,7 +106,7 @@ extern int packet_send(void *buffer, int len);
static void
low_level_init(struct netif *netif)
{
char mac_addr[6];
char mac_addr[ETHARP_HWADDR_LEN];
LWIP_DEBUGF(NETIF_DEBUG, ("pktif: eth_addr %02X%02X%02X%02X%02X%02X\n",netif->hwaddr[0],netif->hwaddr[1],netif->hwaddr[2],netif->hwaddr[3],netif->hwaddr[4],netif->hwaddr[5]));
@ -116,8 +117,8 @@ low_level_init(struct netif *netif)
}
/* Prepare MAC addr: increase the last octet so that lwIP netif has a similar but different MAC addr */
memcpy(&netif->hwaddr, mac_addr, 6);
netif->hwaddr[5]++;
memcpy(&netif->hwaddr, mac_addr, ETHARP_HWADDR_LEN);
netif->hwaddr[ETHARP_HWADDR_LEN - 1]++;
pktif_netif=netif;
}
@ -159,7 +160,7 @@ low_level_output(struct netif *ethernetif, struct pbuf *p)
return ERR_BUF;
}
#ifdef LINK_STATS
#if LINK_STATS
lwip_stats.link.xmit++;
#endif /* LINK_STATS */
return ERR_OK;
@ -188,7 +189,8 @@ low_level_input(struct netif *netif)
ethhdr = (struct eth_hdr*)cur_packet;
/* MAC filter: only let my MAC or broadcast through */
if ((memcmp(&ethhdr->dest, &netif->hwaddr, 6)) && (memcmp(&ethhdr->dest, &broadcastaddr, 6))) {
if ((memcmp(&ethhdr->dest, &netif->hwaddr, ETHARP_HWADDR_LEN)) &&
(memcmp(&ethhdr->dest, &broadcastaddr, ETHARP_HWADDR_LEN))) {
/* acknowledge that packet has been read(); */
cur_length=0;
return NULL;
@ -217,13 +219,13 @@ low_level_input(struct netif *netif)
}
/* acknowledge that packet has been read(); */
cur_length = 0;
#ifdef LINK_STATS
#if LINK_STATS
lwip_stats.link.recv++;
#endif /* LINK_STATS */
} else {
/* drop packet(); */
cur_length = 0;
#ifdef LINK_STATS
#if LINK_STATS
lwip_stats.link.memerr++;
lwip_stats.link.drop++;
#endif /* LINK_STATS */
@ -303,10 +305,10 @@ ethernetif_init(struct netif *netif)
netif->output = etharp_output;
netif->mtu = 1500;
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;;
netif->hwaddr_len = 6;
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
netif->hwaddr_len = ETHARP_HWADDR_LEN;
NETIF_INIT_SNMP(netif, 6, 100000000);
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100000000);
low_level_init(netif);

View File

@ -27,20 +27,10 @@
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
* Simon Goldschmidt
*
*/
/*
*********************************************************************************************************
* UCOS-II Port
*
* Target : Any processor
* Put together by : Michael Anburaj
* URL : http://geocities.com/michaelanburaj/ Email : michaelanburaj@hotmail.com
*
*********************************************************************************************************
*/
#include <stdlib.h>
#include <stdio.h> // sprintf() for task names
@ -84,6 +74,7 @@ u32_t sys_arch_protect()
}
void sys_arch_unprotect(u32_t pval)
{
LWIP_UNUSED_ARG(pval);
LeaveCriticalSection(&critSec);
}
void do_sleep(int ms)
@ -229,6 +220,10 @@ sys_thread_t sys_thread_new(char *name, void (* function)(void *arg), void *arg,
HANDLE h;
SYS_ARCH_DECL_PROTECT(lev);
LWIP_UNUSED_ARG(name);
LWIP_UNUSED_ARG(stacksize);
LWIP_UNUSED_ARG(prio);
new_thread = (struct threadlist*)malloc(sizeof(struct threadlist));
LWIP_ASSERT("new_thread != NULL", new_thread != NULL);
if(new_thread != NULL) {

View File

@ -52,14 +52,10 @@
#include "netif/loopif.h"
#include "arch/perf.h"
#include "httpd.h"
//#include "ftpd.h"
//#include "fs.h"
/* index of the network adapter to use for lwIP */
#define PACKET_LIB_ADAPTER_NR 4
#define PACKET_LIB_ADAPTER_NR 3
err_t ethernetif_init(struct netif *netif);
int init_adapter(int adapter_num, char *macaddr_out);
@ -116,36 +112,57 @@ void netio_init(void)
}
#endif /* LWIP_TCP */
#if LWIP_UDP && LWIP_IGMP
void mcast_init(void)
{
struct udp_pcb *pcb;
struct pbuf* p;
struct ip_addr remote_addr;
char data[1024]={0};
int size = sizeof(data);
err_t err;
pcb = udp_new();
udp_bind(pcb, IP_ADDR_ANY, 10000);
pcb->multicast_ip.addr = inet_addr("192.168.5.5");
p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF);
if (p == NULL) {
err = ERR_MEM;
} else {
p->payload = (void*)data;
p->len = p->tot_len = size;
remote_addr.addr = inet_addr("232.0.0.0");
LOCK_TCPIP_CORE();
err = udp_sendto(pcb, p, &remote_addr, ntohs(20000));
UNLOCK_TCPIP_CORE();
pbuf_free(p);
}
udp_remove(pcb);
}
#else
#define mcast_init()
#endif /* LWIP_UDP && LWIP_IGMP*/
struct netif netif;
struct netif loop_netif;
void main_loop()
void my_netif_init()
{
struct ip_addr ipaddr, netmask, gw;
#if LWIP_HAVE_LOOPIF
struct ip_addr loop_ipaddr, loop_netmask, loop_gw;
#endif
#if NO_SYS
int last_time;
int timer1;
int timer2;
#endif /* NO_SYS */
int done;
char mac_addr[6];
#endif /* LWIP_HAVE_LOOPIF */
IP4_ADDR(&gw, 192,168,1,1);
IP4_ADDR(&ipaddr, 192,168,1,200);
IP4_ADDR(&netmask, 255,255,255,0);
printf("Starting lwIP, local interface IP is %s\n", inet_ntoa(*(struct in_addr*)&ipaddr));
if (init_adapter(PACKET_LIB_ADAPTER_NR, mac_addr) != 0) {
printf("ERROR initializing network adapter %d!\n", PACKET_LIB_ADAPTER_NR);
return;
}
memcpy(&netif.hwaddr, mac_addr, 6);
/* increase the last octet so that lwIP netif has a similar but different MAC addr */
netif.hwaddr[5]++;
#if NO_SYS
netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, ip_input));
#else /* NO_SYS */
@ -157,27 +174,42 @@ void main_loop()
IP4_ADDR(&loop_gw, 127,0,0,1);
IP4_ADDR(&loop_ipaddr, 127,0,0,1);
IP4_ADDR(&loop_netmask, 255,0,0,0);
printf("Starting lwIP, loopback interface IP is %s\n", inet_ntoa(*(struct in_addr*)&loop_ipaddr));
#if NO_SYS
netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, loopif_init, ip_input);
#else /* NO_SYS */
netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, loopif_init, tcpip_input);
#endif /* NO_SYS */
netif_set_up(&loop_netif);
#endif
#endif /* LWIP_HAVE_LOOPIF */
}
void main_loop()
{
#if NO_SYS
int last_time;
int timer1;
int timer2;
#endif /* NO_SYS */
int done;
#if NO_SYS
tcp_init();
udp_init();
ip_init();
lwip_init();
#else /* NO_SYS */
tcpip_init(0,0);
my_netif_init();
#endif /* NO_SYS */
#if LWIP_UDP
mcast_init();
#endif /* LWIP_UDP */
#if LWIP_TCP
httpd_init();
netio_init();
#endif
//ftpd_init();
#endif /* LWIP_TCP */
#if NO_SYS
last_time=clock();
@ -217,40 +249,11 @@ void main_loop()
shutdown_adapter();
}
void bcopy(const void *src, void *dest, int len)
{
memcpy(dest,src,len);
}
void bzero(void *data, int n)
{
memset(data,0,n);
}
int main(void)
{
setvbuf(stdout,NULL,_IONBF,0);
#ifdef PERF
perf_init("/tmp/lwip.perf");
#endif /* PERF */
#ifdef STATS
stats_init();
#endif /* STATS */
sys_init();
mem_init();
memp_init();
pbuf_init();
etharp_init();
#if !NO_SYS
lwip_socket_init();
#endif /* !NO_SYS */
//tcpdump_init();
printf("System initialized.\n");
setvbuf(stdout, NULL,_IONBF, 0);
main_loop();
return 0;
}