Beispiel #1
0
/************************************************************************
* NAME: fapp_netif_info_print
*
* DESCRIPTION: Print detailed address information about default
*              network interface.
************************************************************************/
void fapp_netif_info_print( fnet_shell_desc_t desc, fnet_netif_desc_t netif)
{
    fnet_char_t name[FNET_NETIF_NAMELEN];

    fnet_netif_get_name(netif, name, sizeof(name));
    fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_S, "Interface", name);
    
    fapp_netif_addr_print(desc, AF_SUPPORTED, netif, FNET_TRUE);
#if FNET_CFG_IP4
    {    
        fnet_ip4_addr_t ip_addr;
        fnet_char_t     ip_str[FNET_IP4_ADDR_STR_SIZE];
          
        ip_addr = fnet_netif_get_ip4_subnet_mask(netif);
        fnet_inet_ntoa(*(struct in_addr *)( &ip_addr), ip_str);
        fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_S, "IPv4 Subnet mask", ip_str);
        
        ip_addr = fnet_netif_get_ip4_gateway(netif);
        fnet_inet_ntoa(*(struct in_addr *)( &ip_addr), ip_str);
        fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_S, "IPv4 Gateway", ip_str);
      
    #if FNET_CFG_DNS
        ip_addr = fnet_netif_get_ip4_dns(netif);    
        fnet_inet_ntoa(*(struct in_addr *)( &ip_addr), ip_str);
        fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_S, "IPv4 DNS", ip_str);
    #endif
    }
#endif /* FNET_CFG_IP4 */
}
Beispiel #2
0
static int fapp_http_ssi_echo_handle(char * query, long *cookie)
{
    int result = FNET_OK;
    const struct fapp_http_echo_variable *  echo_var_ptr;
    fnet_netif_desc_t netif = fapp_default_netif;
    
    const char *ssi_buffer_ptr = 0;
    
    /* Find static echo value. */
	for(echo_var_ptr = fapp_http_echo_variables; echo_var_ptr->variable && echo_var_ptr->value; echo_var_ptr++)
	{
        if (!fnet_strcmp( query, echo_var_ptr->variable))                    
        {				 
            ssi_buffer_ptr = echo_var_ptr->value;
            break;
        }
    }
   
    /* Find run-time echo values. */
    if(ssi_buffer_ptr == 0)
    {
    #if FNET_CFG_IP4
        char ip_str[FNET_IP4_ADDR_STR_SIZE];
    #endif

        ssi_buffer_ptr = fapp_http_ssi_buffer; 
        if (!fnet_strcmp( query, "IP_ADDRESS"))
        {
        #if FNET_CFG_IP4
            fnet_ip4_addr_t ip_adr = fnet_netif_get_ip4_addr(netif);
            fnet_inet_ntoa(*(struct in_addr *)( &ip_adr), ip_str);
            fnet_snprintf(fapp_http_ssi_buffer, sizeof(fapp_http_ssi_buffer), "%s", ip_str);
        #else
            fnet_snprintf(fapp_http_ssi_buffer, sizeof(fapp_http_ssi_buffer), "...");            
        #endif /* FNET_CFG_IP4 */
        }
        else if (!fnet_strcmp( query, "SUBNET_MASK"))
        {
        #if FNET_CFG_IP4
            fnet_ip4_addr_t ip_adr = fnet_netif_get_ip4_subnet_mask(netif);
            fnet_inet_ntoa(*(struct in_addr *)( &ip_adr), ip_str);
            fnet_snprintf(fapp_http_ssi_buffer, sizeof(fapp_http_ssi_buffer), "%s", ip_str);
        #else
            fnet_snprintf(fapp_http_ssi_buffer, sizeof(fapp_http_ssi_buffer), "...");            
        #endif /* FNET_CFG_IP4 */            
        }
        else if (!fnet_strcmp( query, "GATEWAY"))
        {
        #if FNET_CFG_IP4
            fnet_ip4_addr_t ip_adr = fnet_netif_get_ip4_gateway(netif);
            fnet_inet_ntoa(*(struct in_addr *)( &ip_adr), ip_str);
            fnet_snprintf(fapp_http_ssi_buffer, sizeof(fapp_http_ssi_buffer), "%s", ip_str);
        #else
            fnet_snprintf(fapp_http_ssi_buffer, sizeof(fapp_http_ssi_buffer), "...");            
        #endif /* FNET_CFG_IP4 */            
        }
        else if (!fnet_strcmp( query, "MAC"))
        {
            fnet_mac_addr_t macaddr;
            char mac_str[FNET_MAC_ADDR_STR_SIZE];
            fnet_netif_get_hw_addr(netif, macaddr, sizeof(fnet_mac_addr_t));
            fnet_mac_to_str(macaddr, mac_str);
            fnet_snprintf(fapp_http_ssi_buffer, sizeof(fapp_http_ssi_buffer), "%s", mac_str);
        }
        else
        {
            result = FNET_ERR;
        }
    }
    
    *cookie = (long)ssi_buffer_ptr; /* Save ssi_buffer_ptr as cookie.*/
    
    return result;
}