More changes, still not working.

This commit is contained in:
proff_fs 2003-05-02 19:43:59 +00:00
parent b4eaa5a113
commit 9000dbe8d0
2 changed files with 57 additions and 52 deletions

View File

@ -1,11 +1,11 @@
/*
* Copyright (c) 2001,2002 Florian Schulze.
* 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
@ -14,7 +14,7 @@
* 3. Neither the name of the authors nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -34,31 +34,31 @@
* This file is derived from an example in lwIP with the following license:
*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
* 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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 SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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.
*
*/
@ -137,7 +137,7 @@ int init_adapter(void)
ULONG AdapterLength;
PPACKET_OID_DATA ppacket_oid_data;
// obtain the name of the adapters installed on this machine
AdapterLength=4096;
@ -159,16 +159,16 @@ int init_adapter(void)
temp1=AdapterName;
while ((*temp!='\0')||(*(temp-1)!='\0'))
{
if (*temp=='\0')
if (*temp=='\0')
{
memcpy(AdapterList[i],temp1,(temp-temp1)*2);
temp1=temp+1;
i++;
}
temp++;
}
AdapterNum=i;
}
@ -183,7 +183,7 @@ int init_adapter(void)
while ((*tempa!='\0')||(*(tempa-1)!='\0'))
{
if (*tempa=='\0')
if (*tempa=='\0')
{
memcpy(AdapterList[i],temp1a,tempa-temp1a);
temp1a=tempa+1;
@ -191,7 +191,7 @@ int init_adapter(void)
}
tempa++;
}
AdapterNum=i;
}
@ -224,7 +224,7 @@ void shutdown_adapter(void)
struct ethernetif *ethernetif;
ethernetif = pktif_netif->state;
PacketFreePacket(lpPacket);
PacketCloseAdapter(lpAdapter);
}
@ -241,14 +241,14 @@ low_level_init(struct netif *netif)
struct ethernetif *ethernetif;
ethernetif = netif->state;
open_adapter(ethernetif);
#ifdef NETIF_DEBUG
DEBUGF(NETIF_DEBUG, ("pktif: eth_addr %02X%02X%02X%02X%02X%02X\n",ethernetif->ethaddr->addr[0],ethernetif->ethaddr->addr[1],ethernetif->ethaddr->addr[2],ethernetif->ethaddr->addr[3],ethernetif->ethaddr->addr[4],ethernetif->ethaddr->addr[5]));
#endif /* NETIF_DEBUG */
/* Do whatever else is needed to initialize interface. */
/* Do whatever else is needed to initialize interface. */
pktif_netif=netif;
}
/*-----------------------------------------------------------------------------------*/
@ -290,14 +290,14 @@ low_level_output(struct netif *ethernetif, struct pbuf *p)
}
/* signal that packet should be sent(); */
if (!PacketSendPacket(lpAdapter,lpPacket,TRUE))
return ERR_BUF;
PacketFreePacket(lpPacket);
#ifdef LINK_STATS
lwip_stats.link.xmit++;
#endif /* LINK_STATS */
#endif /* LINK_STATS */
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
@ -349,17 +349,17 @@ low_level_input(struct netif *ethernetif)
cur_length=0;
#ifdef LINK_STATS
lwip_stats.link.recv++;
#endif /* LINK_STATS */
#endif /* LINK_STATS */
} else {
/* drop packet(); */
cur_length=0;
#ifdef LINK_STATS
lwip_stats.link.memerr++;
lwip_stats.link.drop++;
#endif /* LINK_STATS */
#endif /* LINK_STATS */
}
return p;
return p;
}
/*-----------------------------------------------------------------------------------*/
/*
@ -401,7 +401,7 @@ ethernetif_input(struct netif *netif)
ethernetif = netif->state;
p = low_level_input(netif);
if (p != NULL) {
@ -454,18 +454,22 @@ void
ethernetif_init(struct netif *netif)
{
struct ethernetif *ethernetif;
ethernetif = mem_malloc(sizeof(struct ethernetif));
netif->state = ethernetif;
netif->name[0] = IFNAME0;
netif->name[1] = IFNAME1;
netif->linkoutput = low_level_output;
netif->output = ethernetif_output;
netif->mtu = 1500;
netif->flags = 0;
netif->hwaddr_len = 6;
ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
low_level_init(netif);
etharp_init();
etharp_init();
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
}
/*-----------------------------------------------------------------------------------*/
@ -488,7 +492,7 @@ static void ProcessPackets(LPPACKET lpPacket)
struct ethernetif *ethernetif;
ethernetif = pktif_netif->state;
ulBytesReceived = lpPacket->ulBytesReceived;
buf = lpPacket->Buffer;
@ -513,7 +517,7 @@ static void ProcessPackets(LPPACKET lpPacket)
ethernetif_input(pktif_netif);
}
}
}
void update_adapter(void)
{

View File

@ -35,6 +35,7 @@
#include <stdarg.h>
#include <time.h>
#include <string.h>
#include <conio.h>
#include "lwip/debug.h"
#include "lwip/mem.h"
@ -116,8 +117,8 @@ void main_loop()
int timer2;
int done;
IP4_ADDR(&gw, 192,168,2,201);
IP4_ADDR(&ipaddr, 192,168,2,200);
IP4_ADDR(&gw, 192,168,0,1);
IP4_ADDR(&ipaddr, 192,168,0,200);
IP4_ADDR(&netmask, 255,255,255,0);
if (init_adapter() != 0)
@ -172,7 +173,7 @@ void main_loop()
{
tcp_slowtmr();
timer2=0;
done=kbhit();
done=_kbhit();
}
update_adapter();