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.
|