Exemplo n.º 1
0
/************************************************************************
* NAME: fapp_dhcp_handler_discover
*
* DESCRIPTION: Event handler on new IP from DHCP client.
************************************************************************/
static void fapp_dhcp_handler_discover( fnet_netif_desc_t netif,void *shl_desc )
{
    fnet_shell_desc_t desc = (fnet_shell_desc_t) shl_desc;
    FNET_COMP_UNUSED_ARG(netif);

    if(fapp_dhcp_discover_counter-- == 0)
    {
        fnet_shell_unblock((fnet_shell_desc_t)shl_desc);
        fapp_dhcp_on_ctrlc((fnet_shell_desc_t)shl_desc); /* Cancel DHCP.*/
    }
    else
        fnet_shell_println(desc, FAPP_DHCP_DISCOVER_STR);
}
Exemplo n.º 2
0
/************************************************************************
* NAME: fapp_dhcp_handler_updated
*
* DESCRIPTION: Event handler on new IP from DHCP client. 
************************************************************************/
static void fapp_dhcp_handler_updated(fnet_dhcp_desc_t dhcp_desc, fnet_netif_desc_t netif, void *shl_desc )
{
    fnet_shell_desc_t desc = (fnet_shell_desc_t) shl_desc;

    fapp_dhcp_discover_counter = -1; /* Infinite for future. */
    
    /* Optionally, unregister DHCP event handlers, just to do not 
     * disturb a user. */
    fnet_dhcp_handler_updated_set(dhcp_desc, 0, 0);
    fnet_dhcp_handler_discover_set(dhcp_desc, 0, 0);
    
    fnet_shell_unblock((fnet_shell_desc_t)shl_desc); /* Unblock the shell. */
   
    /* Print updated parameters info. */
    fnet_shell_println( desc, "\n%s", FAPP_DELIMITER_STR);
    fnet_shell_println( desc, FAPP_DHCP_NEWIP_STR);
    fnet_shell_println( desc, FAPP_DELIMITER_STR);

    fapp_netif_info_print( desc, netif );   
}
Exemplo n.º 3
0
/************************************************************************
* NAME: fapp_ping_handler
*
* DESCRIPTION:
************************************************************************/
static void fapp_ping_handler (fnet_error_t result, fnet_size_t packet_count, struct sockaddr *target_addr, fnet_uint32_t cookie)
{
    fnet_char_t                ip_str[FNET_IP_ADDR_STR_SIZE];
    fnet_shell_desc_t   desc = (fnet_shell_desc_t)cookie;
    
    if(result == FNET_ERR_OK)
    {
        fnet_shell_println(desc, FAPP_PING_STR_REPLY, fnet_inet_ntop(target_addr->sa_family, target_addr->sa_data, ip_str, sizeof(ip_str)));
    }    
    else if(result == FNET_ERR_TIMEDOUT)
    {
        fnet_shell_println(desc, FAPP_PING_STR_TIMEOUT);
    }
    else
    {
        fnet_shell_println(desc, "Error = %d", result);
    }   
         
    if(packet_count == 0U)
    {
        fnet_shell_unblock(desc); /* Unblock the shell. */    
    } 
}
Exemplo n.º 4
0
/************************************************************************
* NAME: fapp_dhcp_callback_discover
*
* DESCRIPTION: Event handler callback on new IP from DHCP client.
************************************************************************/
static void fapp_dhcp_callback_discover(fnet_dhcp_desc_t dhcp_desc, fnet_netif_desc_t netif, void *shl_desc )
{
    fnet_shell_desc_t desc = (fnet_shell_desc_t) shl_desc;

    FNET_COMP_UNUSED_ARG(netif);
    FNET_COMP_UNUSED_ARG(dhcp_desc);

    if(fapp_dhcp_discover_counter == 0)
    {
        fnet_shell_unblock((fnet_shell_desc_t)shl_desc);
        fapp_dhcp_on_ctrlc((fnet_shell_desc_t)shl_desc); /* Cancel DHCP.*/
        
        if(fapp_dhcp_autoip == FNET_TRUE)
        {
            fnet_shell_script(desc, "autoip");
        }
    }
    else
    {
        fapp_dhcp_discover_counter--;
        fnet_shell_println(desc, FAPP_DHCP_DISCOVER_STR);
    }
}