buglwIP - A Lightweight TCP/IP stack - Bugs: bug #27856, PPP: Set netif link- and...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #27856: PPP: Set netif link- and status-callback

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Fri 30 Oct 2009 09:28:32 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.3.1

Thu 14 Jan 2010 08:06:16 PM UTC, comment #3: 

Fixed by adding ppp_set_netif_statuscallback()/ppp_set_netif_linkcallback().

This has the advantage that every ppp session can get its own callback instead of configuring one callback for all sessions at compile time (plus it better resembles the netif api).

Simon Goldschmidt <goldsimon>
Group administrator
Fri 04 Dec 2009 09:54:19 AM UTC, comment #2: 

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 %s\n", inet_ntoa((struct in_addr)&(netif->ip_addr.addr)));
} else {
// printf("\nDUMMY PPP status_callback==DOWN\n");
}
}
#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 %s\n", inet_ntoa((struct in_addr)&(netif->ip_addr.addr)));
} else {
// printf("\nDUMMY PPP Link callback==DOWN\n");
}
}
#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.

Iordan Neshev <iordan_neshev>
Thu 03 Dec 2009 08:01:56 PM UTC, comment #1: 

I know I submitted this, but I only copied it from patch #6901, so forgive me for asking this:

Where do the functions "pppnetif_status_callback" and "pppnetif_link_callback" come from, I don't see them in my lwIP sources!

And if you added them, what do they do?

Simon Goldschmidt <goldsimon>
Group administrator
Fri 30 Oct 2009 09:28:32 AM UTC, original submission:  

Suggestion from patch #6901:

static err_t
pppifNetifInit(struct netif *netif)
{
netif->name[0] = 'p';
netif->name[1] = 'p';
netif->output = pppifOutput;
netif->mtu = pppMTU((int)netif->state);

// --> this is missing
#if LWIP_NETIF_STATUS_CALLBACK
netif_set_status_callback(netif, pppnetif_status_callback);
#endif
#if LWIP_NETIF_LINK_CALLBACK
netif_set_link_callback(netif, pppnetif_link_callback);
#endif
// <--
return ERR_OK;
}

Simon Goldschmidt <goldsimon>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by iordan_neshev (Posted a comment)
  • -email is unavailable- added by goldsimon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-01-14 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code