[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AW: Re: [lwip-users] How to upgrade to LWIP 1.0
From: |
Craig Graham |
Subject: |
Re: AW: Re: [lwip-users] How to upgrade to LWIP 1.0 |
Date: |
Wed, 13 Oct 2004 17:47:57 +0100 |
User-agent: |
KMail/1.6 |
Basicly, with LWIP-0.7.2, you were responsible for dispatching output from the
ARP update at the driver level. In 1.0.0, you aren't - the ARP code handles
it for you, so the return values aren't needed anymore.
Here's a fragment from our ethernet driver - as it still compiles for both
0.7.2 and 1.0.0, you can see the difference between the two codebases...
ethhdr = p->payload;
q = NULL;
switch (htons(ethhdr->type))
{
#if _LWIP_VERSION_==_1_0_0_
case ETHTYPE_IP:
/* update ARP table */
etharp_ip_input(netif, p);
/* skip Ethernet header */
pbuf_header(p, -(int)sizeof(struct
eth_hdr));
/* pass to network layer */
netif->input(p, netif);
break;
case ETHTYPE_ARP:
etharp_arp_input(netif,
ethernetif->ethaddr, p);
p=NULL;
break;
#else
case ETHTYPE_IP:
/* update ARP table */
q=etharp_ip_input(netif, p);
/* skip Ethernet header */
pbuf_header(p, -14);
/* pass to network layer */
netif->input(p, netif);
break;
case ETHTYPE_ARP:
q=etharp_arp_input(netif,
ethernetif->ethaddr, p);
p=NULL;
break;
#endif
default:
pbuf_free(p);
p = NULL;
break;
}
if (q != NULL) // this bit only does stuff on lwip0.7.2
{
low_level_output(netif, q);
pbuf_free(q);
q = NULL;
}
On Wednesday 13 October 2004 14:37, schulz, marco wrote:
> Hello Christiaan,
>
> thanks for your reply.
>
> Now I think I can compile LWIP 1.0.0 very well. But due to some changes in
> etharp.c in the functions etharp_output() and etharp_arp_input() I run into
> some problems with the ethernet driver. The problems are located in the
> file eth.c (I think a modification of ethernetif.c) in the functions
> eth_output() and eth_input() where pointers to PBUFs are expected as return
> values but in the newer version of the above mentioned functions in
> etharp.c VOID will be returned. This file looks the following:
>
> **** BEGIN OF FILE: ETH.C
> **************************************************
>
> /*
> * Copyright (c) 2001, 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. 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 file is part of the lwIP TCP/IP stack.
> *
> * Author: Adam Dunkels <address@hidden>
> *
> * $Id: ethernetif.c,v 1.2 2003/09/11 11:39:09 kenw Exp $
> */
>
> /*
> * This file is a skeleton for developing Ethernet network interface
> * drivers for lwIP. Add code to the low_level functions and do a
> * search-and-replace for the word "ethernetif" to replace it with
> * something that better describes your network interface.
> */
>
> #include "lwip/debug.h"
>
> #include "lwip/opt.h"
> #include "lwip/def.h"
> #include "lwip/mem.h"
> #include "lwip/pbuf.h"
> #include "lwip/sys.h"
>
> #include "netif/etharp.h"
> #include "netif/eth.h"
>
>
> /* Forward declarations. */
> unsigned int eth_input(struct netif *netif);
> err_t eth_output(struct netif *netif, struct pbuf *p, struct ip_addr
> *ipaddr);
>
>
> /*-------------------------------------------------------------------------
>----------*/ /*
> * ethernetif_output():
> *
> * This function is called by the TCP/IP stack when an IP packet
> * should be sent. It calls the function called low_level_output() to
> * do the actuall transmission of the packet.
> *
> */
> /*-------------------------------------------------------------------------
>----------*/ err_t
> eth_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
> {
> struct ethernetif *ethernetif = netif->state;
> p = etharp_output(netif, ipaddr, p);
> /* network hardware address obtained? */
> if (p != NULL) {
> /* send out the packet */
> netif->linkoutput(netif, p);
> }
> return ERR_OK;
> }
>
> /*-------------------------------------------------------------------------
>----------*/ /*
> * eth_input():
> *
> * This function should be called when a packet is ready to be read
> * from the interface. It uses the function low_level_input() that
> * should handle the actual reception of bytes from the network
> * interface.
> *
> */
> /*-------------------------------------------------------------------------
>----------*/ unsigned int
> eth_input(struct netif *netif)
> {
> struct ethernetif *ethernetif;
> struct eth_hdr *ethhdr = NULL;
> struct pbuf *p = NULL, *q = NULL;
>
> ethernetif = netif->state;
> p = ethernetif->low_level_input(ethernetif);
> if(p != NULL) {
> ethhdr = p->payload;
>
> q = NULL;
> switch(htons(ethhdr->type)) {
>
> case ETHTYPE_IP:
> /* update ARP table, obtain first queued packet */
> q=etharp_ip_input(netif, p);
> pbuf_header(p, -14);
> netif->input(p, netif);
> break;
>
> case ETHTYPE_ARP:
> /* pass p to ARP module, get ARP reply or ARP queued packet */
> q = etharp_arp_input(netif, (struct eth_addr *)&netif->hwaddr[0],
> p);
> break;
>
> default:
> pbuf_free(p);
> p = NULL;
> break;
> }
>
> /* send out the ARP reply or ARP queued packet */
> if (q != NULL) {
> /* q pbuf has been succesfully sent? */
> if (netif->linkoutput(netif, q) == ERR_OK)
> {
> pbuf_free(q);
> q = NULL;
> }
> else
> {
> /* TODO: re-queue packet in the ARP cache here (?) */
> pbuf_free(q);
> q = NULL;
> }
> }
> }
> return 0;
> }
>
> /* the service task routine */
> static void eth_thread(void* pdata)
> {
> struct ethernetif *ethernetif=NULL;
> unsigned char err;
> sys_mbox_t mbox = (sys_mbox_t)pdata;
>
> /* now waiting and service devices */
> while (1) {
> sys_mbox_fetch(mbox, (void *)ðernetif);
> /* call the device service routine */
> if (ethernetif && ethernetif->service)
> ethernetif->service(ethernetif);
> }
> }
>
>
> /* the module init routine, called by application */
> static sys_mbox_t eth_mbox;
> void eth_interfaces_init(unsigned int pri)
> {
> unsigned int result;
>
> /* create message queue */
> eth_mbox = sys_mbox_new();
> /* create the net service task */
> sys_thread_new(eth_thread, eth_mbox, pri );
>
> /* init arp table */
> etharp_init();
> }
>
> /* to inform the service task that one service is neede
> * usually called from ISR by device drivers
> */
> void eth_service_notify(struct ethernetif *ethernetif)
> {
> sys_mbox_post(eth_mbox, (void *)ethernetif);
> }
>
> /*-------------------------------------------------------------------------
>----------*/
>
> **** END OF FILE: ETH.C **************************************************
>
> I have no real idea what I should do to overcome this problem. So it would
> be nice, if you could give me some further hints how I could change the
> eth.c to get the Ethernet driver back to work. Is it maybe also possible to
> give me some explanation about the (file)structure of LWIP - just for
> better understanding?
>
> Thanks, Marco.
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 12 Oct 2004 16:48:32 +0200
> From: address@hidden
> Subject: Re: [lwip-users] How to upgrade to LWIP 1.0
> To: Mailing list for lwIP users <address@hidden>
> Message-ID:
> <address@hidden>
> Content-Type: text/plain; charset=UTF-8
>
>
>
>
>
>
> address@hidden wrote on 12-10-2004
>
> 10:01:38:
> > So my question is: What do I have to do to upgrade from LWIP 0.72 to
> > LWIP 1.0?
>
> Read the CHANGLOG file carefully. Also have a look at the mail archives.
>
> > – What files have to be exchanged? What functions have to
> > be changed? Do I have to change some changes in the drivers and/or
> > the operating system layer?
>
> There are no new files in lwip. For finding small changes
> I would recommend using a good difference/merge editor.
>
> Maybe you're supplier should give you some support on this.
>
> Christiaan Simons
>
> Software Engineer
> Axon Digital Design
>
> +31 (0)13 511 66 66
> +31 (0)13 511 41 51
>
> address@hidden
> http://www.axon.tv
>
>
> The information contained in this communication is confidential and is
> intended solely for the use of the individual or entity to whom it is
> addressed. Axon Digital Design Group is neither liable for the proper nor
> for the complete transmission of the information contained in this
> communication nor for any delay in its receipt. Axon Digital Design Group
> does not guarantee that the integrity of this communication has been
> maintained nor that the communication is free of viruses, interceptions or
> interference. If you are not the intended recipient of this communication,
> you are hereby notified that reading, disseminating, distributing or
> copying this message is strictly prohibited. In that case please return the
> communication to the sender and delete and destroy all copies. In carrying
> out its engagements, Axon Digital Design Group applies general terms and
> conditions, which contain a clause that limits its liability. A copy of
> these terms and conditions is available on request free of charge.
>
> ------------------------------
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
> End of lwip-users Digest, Vol 14, Issue 12
> ******************************************
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users