lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #27856] PPP: Set netif link- and status-callback


From: Iordan Neshev
Subject: [lwip-devel] [bug #27856] PPP: Set netif link- and status-callback
Date: Fri, 04 Dec 2009 09:54:20 +0000
User-agent: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.00

Follow-up Comment #2, bug #27856 (project lwip):

Oh, I forgot to mention they come from
the MSVC port - in file test.c there are:

void status_callback(struct netif *netif); and
void link_callback(struct netif *netif);


For my (PPP) code I defined those:
#if LWIP_NETIF_STATUS_CALLBACK
void pppnetif_status_callback(struct netif *netif);
#endif
#if LWIP_NETIF_LINK_CALLBACK
void pppnetif_link_callback(struct netif *netif);
#endif

They are set with netif_set_status_callback()
and netif_set_link_callback() respectively.


Here is how the callbacks look in my code:
#if LWIP_NETIF_STATUS_CALLBACK
// This function is called when the netif state is set to up or down
void pppnetif_status_callback(struct netif *netif)
{
        if (netif_is_up(netif)) {       // tests the NETIF_FLAG_UP flag;
                
//              printf("nDUMMY PPP status_callback==UP, local interface IP is 
%sn",
inet_ntoa(*(struct in_addr*)&(netif->ip_addr.addr)));
        } else {
//              printf("nDUMMY PPP status_callback==DOWNn");
        }
}
#endif  /* LWIP_NETIF_STATUS_CALLBACK */

#if LWIP_NETIF_LINK_CALLBACK


// This function is called when the netif link is set to up or down
void pppnetif_link_callback(struct netif *netif)
{
// note: NETIF_FLAG_LINK_UP - if set, the interface has an active link (set
by the network interface driver)
        if (netif_is_link_up(netif))    {       // tests the NETIF_FLAG_LINK_UP 
flag;  to do:
modify my driver to deal with this flag! 
//              printf("nDUMMY PPP Link callback==UP, local interface IP is 
%sn",
inet_ntoa(*(struct in_addr*)&(netif->ip_addr.addr)));
        } else {
//              printf("nDUMMY PPP Link callback==DOWNn");
        }
}
#endif /* LWIP_NETIF_LINK_CALLBACK */

As you see, they are dummy. This was just a minor step
towards a full lwip-compliant implementation of PPP netif.
Btw, I'd like to know if they really do what they are
supposed to.

Currently the PPP code has one single pppLinkStatusCallback(),
which is set with pppOpen():

pppOpen(ppp_sio_fd, pppLinkStatusCallback, NULL); // NULL is void
*linkStatusCtx, put into pc->linkStatusCtx; currently context is not used

We have 
void (*linkStatusCB)(void *ctx, int errCode, void *arg)
member in the PPPControl struct.

The callback is called like this:
  if(pc->linkStatusCB) {
    pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode :
PPPERR_PROTOCOL, NULL);
  }

I use this callback just to print the IP, Gateway and DNS addresses assigned
to my device after the link is established(errCode == PPPERR_NONE).

As a side note, later we need to review the errcodes that are passed. I think
there are places with misleading errcodes, but we have a lot of work till
then.


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27856>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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