lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: [lwip] dhcp_fine_tmr()


From: Scott Robinson
Subject: [lwip-users] Re: [lwip] dhcp_fine_tmr()
Date: Thu, 09 Jan 2003 00:34:02 -0000

--jy6Sn24JjFx/iggw
Content-Type: multipart/mixed; boundary="LyciRD1jyfeSSjG0"
Content-Disposition: inline


--LyciRD1jyfeSSjG0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I suppose to supply further information, attached is the current version of
my net.c module.

I might simply be using DHCP wrong? There isn't much of an example in
simhost.c...

Scott.

--=20
http://quadhome.com/           - Personal webpage
tranzoa.net                    - Firewall

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT dpu s: a--- C++ UL+++ P++ L+++ E- W++ N++ o+ K++ w++=20
O M V(-) PS+ PE Y+ PGP+++ t@ 5 X- R- tv(-) b++++ DI++++ D+=20
G e* h! r* y=20
------END GEEK CODE BLOCK------

--LyciRD1jyfeSSjG0
Content-Type: text/x-csrc; charset=us-ascii
Content-Disposition: attachment; filename="net.c"
Content-Transfer-Encoding: quoted-printable

/*  net.c

    $Id: net.c,v 1.3 2002/11/12 18:15:41 quad Exp $

DESCRIPTION

    Network interface layer between the common library and lwIP

TODO

    Implement TCP.

    Add support for LAN Adapter.

    Add support for modem via SLIP.

*/

#include <vars.h>
#include <anim.h>
#include <util.h>
#include <timer.h>

#include "lwip/debug.h"

#include "lwip/mem.h"
#include "lwip/memp.h"
#include "lwip/sys.h"

#include "lwip/stats.h"

#include "lwip/ip.h"
#include "lwip/udp.h"
#include "lwip/tcp.h"
#include "lwip/dhcp.h"

#include "bbaif.h"

#include "net.h"

#include <assert.h>

static anim_render_chain_f  old_anim_chain;

#ifdef DO_DHCP
static struct dhcp_state   *client;
#endif

static void net_etharp_timer (void)
{
    static uint32   last_tick =3D 0;

    if (last_tick && ((time () - last_tick) >=3D (ARP_TMR_INTERVAL / 1000)))
    {
        etharp_tmr ();

        last_tick =3D time ();
    }
    else
        last_tick =3D time ();
}

#ifdef DO_DHCP
static void net_dhcp_coarse_timer (void)
{
    static uint32   last_tick =3D 0;

    if (last_tick && ((time () - last_tick) >=3D DHCP_COARSE_TIMER_SECS))
    {
        dhcp_coarse_tmr ();

        last_tick =3D time ();
    }
    else
        last_tick =3D time ();
}

static void net_dhcp_fine_timer (void)
{
    static uint32   last_tick =3D 0;

    if (last_tick && (timer_gen_micro(timer_gen_count() - last_tick) >=3D (=
DHCP_FINE_TIMER_MSECS * 1000)))
    {
        dhcp_fine_tmr ();

        last_tick =3D timer_gen_count ();
    }
    else
        last_tick =3D timer_gen_count ();
}
#endif

static void my_anim_chain (uint16 anim_code_a, uint16 anim_code_b)
{
    net_etharp_timer ();

#ifdef DO_DHCP
    net_dhcp_coarse_timer ();
    net_dhcp_fine_timer ();
#endif

    //net_tcp_timer ();

    if (old_anim_chain)
        return old_anim_chain (anim_code_a, anim_code_b);
}

void net_handle_tx (void *owner)
{
    struct netif   *netif;

    netif =3D (struct netif *) owner;

    /* NOTE: Dummy function, for the moment. */
}

void net_handle_rx (void *owner)
{
    struct netif   *netif;

    netif =3D (struct netif *) owner;

    /* NOTE: Dummy function, simply calls bbaif_input. */

    bbaif_input (netif);
}

void net_init (void)
{
    struct ip_addr  ipaddr;
    struct ip_addr  netmask;
    struct ip_addr  gw;
    struct netif   *netif;

    /* STAGE: Initialize the various timers. */

    timer_init ();
    anim_init ();

    anim_add_render_chain (my_anim_chain, &old_anim_chain);

    /* STAGE: Initialize lwIP. */

    mem_init ();
    memp_init ();
    pbuf_init ();=20
    netif_init ();
    ip_init ();
    udp_init ();
    //tcp_init();

    /* STAGE: Intial IP configuration. */

#ifdef DO_DHCP
    IP4_ADDR(&gw, 0,0,0,0);
    IP4_ADDR(&ipaddr, 0,0,0,0);
    IP4_ADDR(&netmask, 0,0,0,0);
#else
    IP4_ADDR(&gw, 10,1,1,254);
    IP4_ADDR(&ipaddr, 10,1,1,70);
    IP4_ADDR(&netmask, 255,0,0,0);
#endif

    /* STAGE: Enable the BBA network interface. */

    netif =3D netif_add (&ipaddr, &netmask, &gw, bbaif_init, ip_input);
 =20
    netif_set_default (netif);

#ifdef DO_DHCP
    /* STAGE: Enable address resolution via DHCP. */

    dhcp_init ();
    client =3D dhcp_start (netif);
#endif
}

--LyciRD1jyfeSSjG0--

--jy6Sn24JjFx/iggw
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iEYEARECAAYFAj3RTp8ACgkQ+1+mlYgeODc1SgCghffwZbgNMOglCSlpkR6ptJTX
t3UAnRw2Xj0wJouve6XB16+uJxqy9XmE
=tVaM
-----END PGP SIGNATURE-----

--jy6Sn24JjFx/iggw--
[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]