/************************************************************************ * NAME: fapp_http_cgi_stdata_handle * * DESCRIPTION: *************************************************************************/ static int fapp_http_cgi_stdata_handle(char * query, long *cookie) { unsigned long time, t_hour, t_min, t_sec; struct fnet_netif_statistics statistics; FNET_COMP_UNUSED_ARG(query); /* Get Time. */ time = fnet_timer_ticks(); t_hour = time/FNET_TIMER_TICK_IN_HOUR; t_min = (time%FNET_TIMER_TICK_IN_HOUR)/FNET_TIMER_TICK_IN_MIN; t_sec = (time%FNET_TIMER_TICK_IN_MIN)/FNET_TIMER_TICK_IN_SEC; /* Get statistics. */ fnet_memset_zero( &statistics, sizeof(struct fnet_netif_statistics) ); fnet_netif_get_statistics(fapp_default_netif, &statistics); /* Write to the temprorary buffer. */ fnet_snprintf(fapp_http_cgi_buffer, sizeof(fapp_http_cgi_buffer), "({\"time\":\"%02d:%02d:%02d\",\"tx\":%d,\"rx\":%d})", t_hour, t_min, t_sec, statistics.tx_packet, statistics.rx_packet); *cookie = (long)fapp_http_cgi_buffer; /* Save fapp_http_cgi_buffer as cookie.*/ return FNET_OK; }
static void fapp_stat_cmd( fnet_shell_desc_t desc, fnet_index_t argc, fnet_char_t ** argv ) { struct fnet_netif_statistics statistics; fnet_netif_desc_t netif = fnet_netif_get_default(); FNET_COMP_UNUSED_ARG(argc); FNET_COMP_UNUSED_ARG(argv); /* Print Packet statistics. */ if(fnet_netif_get_statistics(netif, &statistics) == FNET_OK) { fnet_shell_println(desc, "\nPackets:"); fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_D, "TX Packets", statistics.tx_packet); fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_D, "RX Packets", statistics.rx_packet); } #if FNET_CFG_IP6 { fnet_index_t i; fnet_netif_ip6_prefix_t ip6_prefix; fnet_netif_ip6_neighbor_cache_t ip6_neighbor_cache; fnet_char_t numaddr[FNET_IP6_ADDR_STR_SIZE]; fnet_char_t mac_str[FNET_MAC_ADDR_STR_SIZE]; /* Print content of IPv6 Prefix List. */ fnet_shell_println(desc, "\nIPv6 Prefix List:"); for(i=0U; fnet_netif_get_ip6_prefix(netif, i, &ip6_prefix) == FNET_TRUE; i++) { fnet_shell_println(desc," [%d] %s/%d\n", i, fnet_inet_ntop(AF_INET6, &ip6_prefix.prefix, numaddr, sizeof(numaddr)), ip6_prefix.prefix_length); } /* Print content of IPv6 Neighbor Cache. */ for(i=0U; fnet_netif_get_ip6_neighbor_cache(netif, i, &ip6_neighbor_cache) == FNET_TRUE; i++) { if(i == 0U) { fnet_shell_println(desc, "\nIPv6 Neighbor Cache:"); } fnet_shell_println(desc," [%d] %s = %s (%s)\n", i, fnet_inet_ntop(AF_INET6, &ip6_neighbor_cache.ip_addr, numaddr, sizeof(numaddr)), fnet_mac_to_str(ip6_neighbor_cache.ll_addr, mac_str), (ip6_neighbor_cache.is_router == FNET_TRUE) ? "router" : "host"); } } #endif }