Calling a function without calling its parameters inside another function is a little bit confusing as follows:
ppp = pppos_create(&ppp_netif, output_cb, status_cb, 0);
Where output_cb
and status_cb
are functions that their parameters are not set and their definitions must be written in upper lines than the line they are called.
Function definitions:
static void status_cb(ppp_pcb *pcb, int err_code, void *ctx) {
struct netif *pppif = ppp_netif(pcb);
switch(err_code) {
case PPPERR_NONE: {
printf("status_cb: Connected\n");
printf(" our_ipaddr = %s\r\n", ipaddr_ntoa(&pppif->ip_addr));
printf(" his_ipaddr = %s\r\n", ipaddr_ntoa(&pppif->gw));
printf(" netmask = %s\r\n", ipaddr_ntoa(&pppif->
break;
}
case PPPERR_PARAM: {
printf("status_cb: Invalid parameter\r\n");
break;
}
}
}
static u32_t output_cb(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx)
{
return HAL_UART_Transmit_IT(&huart1, data, sizeof(data));
}
int main(void)
{
ppp = pppos_create(&ppp_netif, output_cb, status_cb, 0);
}
What does status_cb
print without giving an err_code
as a parameter? When or how will status_cb
and output_cb
be evaluated?
Where pppos_create
is defined as follows:
ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb)
{
pppos_pcb *pppos;
ppp_pcb *ppp;
pppos = (pppos_pcb *)LWIP_MEMPOOL_ALLOC(PPPOS_PCB);
if (pppos == NULL) {
return NULL;
}
ppp = ppp_new(pppif, &pppos_callbacks, pppos, link_status_cb, ctx_cb);
if (ppp == NULL) {
LWIP_MEMPOOL_FREE(PPPOS_PCB, pppos);
return NULL;
}
memset(pppos, 0, sizeof(pppos_pcb));
pppos->ppp = ppp;
pppos->output_cb = output_cb;
return ppp;
}
Kind Regards