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

Submitted by:  Simon Goldschmidt <goldsimon>
Submitted on:  Fri 30 Oct 2009 09:28:32 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned 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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 14 Jan 2010 08:06:16 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1