📄 monitor.c
字号:
cyg_addrword_t loc;
cyg_addrword_t oloc;
for( oloc = loc = base; loc <= (base+size) ; loc++ )
{
if( ( loc % 16 ) == 0 )
{
if( loc != base )
{
html_table_data_begin( client, "" );
for( ; oloc < loc; oloc++ )
{
char c = *(char *)oloc;
if( !isprint(c) )
c = '.';
putc( c, client );
}
html_table_row_end( client );
}
if( loc == (base+size) )
break;
html_table_row_begin(client, "" );
html_table_data_begin( client, "" );
fprintf( client, "%08x:",loc);
}
html_table_data_begin( client, "" );
if( (loc % datasize) == 0 )
{
switch( datasize )
{
case 1: fprintf( client, "%02x", *(cyg_uint8 *)loc ); break;
case 2: fprintf( client, "%04x", *(cyg_uint16 *)loc ); break;
case 4: fprintf( client, "%08x", *(cyg_uint32 *)loc ); break;
}
}
}
}
html_table_end( client );
cyg_html_tag_end( client, "font" );
html_form_input(client, "submit", "next", "Next Page", "");
}
html_form_end( client );
draw_navbar(client);
}
html_body_end(client);
html_end(client);
return 1;
}
CYG_HTTPD_TABLE_ENTRY( cyg_monitor_memory_entry,
"/monitor/memory.htm*",
cyg_monitor_memory,
NULL );
/* ================================================================= */
/* Network Monitor
*
* This function generates a page containing information about the
* network interfaces and the protocols.
*/
static cyg_bool cyg_monitor_network( FILE * client, char *filename,
char *formdata, void *arg )
{
struct ifaddrs *iflist, *ifp;
getifaddrs(&iflist);
html_begin(client);
html_head(client,"eCos Network Monitor", "");
html_body_begin(client,"");
{
html_heading(client, 2, "Network Monitor" );
html_heading(client, 3, "Interfaces" );
html_table_begin( client, "border" );
{
char addr[64];
int i;
ifp = iflist;
html_table_header( client, "Interface", "" );
html_table_header( client, "Status", "" );
while( ifp != (struct ifaddrs *)NULL)
{
if (ifp->ifa_addr->sa_family != AF_LINK)
{
html_table_row_begin(client, "" );
{
html_table_data_begin( client, "" );
fprintf( client, "%s", ifp->ifa_name);
html_table_data_begin( client, "" );
html_table_begin( client, "" );
{
/* Get the interface's flags and display
* the interesting ones.
*/
html_table_row_begin(client, "" );
fprintf( client, "<td>Flags<td>\n" );
for( i = 0; i < 16; i++ )
{
switch( ifp->ifa_flags & (1<<i) )
{
default: break;
case IFF_UP: fputs( " UP", client ); break;
case IFF_BROADCAST: fputs( " BROADCAST", client ); break;
case IFF_DEBUG: fputs( " DEBUG", client ); break;
case IFF_LOOPBACK: fputs( " LOOPBACK", client ); break;
case IFF_PROMISC: fputs( " PROMISCUOUS", client ); break;
case IFF_RUNNING: fputs( " RUNNING", client ); break;
case IFF_SIMPLEX: fputs( " SIMPLEX", client ); break;
case IFF_MULTICAST: fputs( " MULTICAST", client ); break;
}
}
html_table_row_end( client );
html_table_row_begin(client, "" );
getnameinfo(ifp->ifa_addr, sizeof(*ifp->ifa_addr),
addr, sizeof(addr), NULL, 0, NI_NUMERICHOST);
fprintf( client, "<td>Address<td>%s\n", addr);
html_table_row_end( client );
if (ifp->ifa_netmask)
{
html_table_row_begin(client, "" );
getnameinfo(ifp->ifa_netmask, sizeof(*ifp->ifa_netmask),
addr, sizeof(addr), NULL, 0, NI_NUMERICHOST);
fprintf( client, "<td>Mask<td>%s\n", addr);
html_table_row_end( client );
}
if (ifp->ifa_broadaddr)
{
html_table_row_begin(client, "" );
getnameinfo(ifp->ifa_broadaddr, sizeof(*ifp->ifa_broadaddr),
addr, sizeof(addr), NULL, 0, NI_NUMERICHOST);
fprintf( client, "<td>Broadcast<td>%s\n", addr);
html_table_row_end( client );
}
}
html_table_end( client );
}
html_table_row_end( client );
}
ifp = ifp->ifa_next;
}
}
html_table_end( client );
/* Now the protocols. For each of the main protocols: IP,
* ICMP, UDP, TCP print a table of useful information derived
* from the in-kernel data structures. Note that this only
* works for the BSD stacks.
*/
html_para_begin( client, "" );
html_heading(client, 3, "Protocols" );
html_para_begin( client, "" );
html_table_begin( client, "border");
{
html_table_header( client, "IPv4", "" );
#ifdef CYGPKG_NET_INET6
html_table_header( client, "IPv6", "" );
#endif
html_table_header( client, "ICMPv4", "" );
#ifdef CYGPKG_NET_INET6
html_table_header( client, "ICMPv6", "" );
#endif
html_table_header( client, "UDP", "" );
html_table_header( client, "TCP", "" );
html_table_row_begin(client, "" );
{
html_table_data_begin( client, "valign=\"top\"" );
html_table_begin( client, "" );
{
fprintf( client, "<tr><td><b>%s:</b><td></tr>\n", "Received" );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Total",
ipstat.ips_total );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Bad",
ipstat.ips_badsum+
ipstat.ips_tooshort+
ipstat.ips_toosmall+
ipstat.ips_badhlen+
ipstat.ips_badlen+
ipstat.ips_noproto+
ipstat.ips_toolong
);
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Reassembled",
ipstat.ips_reassembled );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Delivered",
ipstat.ips_delivered );
fprintf( client, "<tr><td><b>%s:</b><td></tr>\n", "Sent" );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Total",
ipstat.ips_localout );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Raw",
ipstat.ips_rawout );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Fragmented",
ipstat.ips_fragmented );
}
html_table_end( client );
#ifdef CYGPKG_NET_INET6
html_table_data_begin( client, "valign=\"top\"" );
html_table_begin( client, "" );
{
fprintf( client, "<tr><td><b>%s:</b><td></tr>\n", "Received" );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "Total",
ip6stat.ip6s_total );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "Bad",
ip6stat.ip6s_tooshort+
ip6stat.ip6s_toosmall
);
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "Reassembled",
ip6stat.ip6s_reassembled );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "Delivered",
ip6stat.ip6s_delivered );
fprintf( client, "<tr><td><b>%s:</b><td></tr>\n", "Sent" );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "Total",
ip6stat.ip6s_localout );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "Raw",
ip6stat.ip6s_rawout );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "Fragmented",
ip6stat.ip6s_fragmented );
}
html_table_end( client );
#endif
html_table_data_begin( client, "valign=\"top\"" );
html_table_begin( client, "" );
{
fprintf( client, "<tr><td><b>%s:</b><td></tr>\n", "Received" );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "ECHO",
icmpstat.icps_inhist[ICMP_ECHO] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "ECHO REPLY",
icmpstat.icps_inhist[ICMP_ECHOREPLY] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "UNREACH",
icmpstat.icps_inhist[ICMP_UNREACH] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "REDIRECT",
icmpstat.icps_inhist[ICMP_REDIRECT] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Other",
icmpstat.icps_inhist[ICMP_SOURCEQUENCH]+
icmpstat.icps_inhist[ICMP_ROUTERADVERT]+
icmpstat.icps_inhist[ICMP_ROUTERSOLICIT]+
icmpstat.icps_inhist[ICMP_TIMXCEED]+
icmpstat.icps_inhist[ICMP_PARAMPROB]+
icmpstat.icps_inhist[ICMP_TSTAMP]+
icmpstat.icps_inhist[ICMP_TSTAMPREPLY]+
icmpstat.icps_inhist[ICMP_IREQ]+
icmpstat.icps_inhist[ICMP_IREQREPLY]+
icmpstat.icps_inhist[ICMP_MASKREQ]+
icmpstat.icps_inhist[ICMP_MASKREPLY]
);
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Bad",
icmpstat.icps_badcode+
icmpstat.icps_tooshort+
icmpstat.icps_checksum+
icmpstat.icps_badlen+
icmpstat.icps_bmcastecho
);
fprintf( client, "<tr><td><b>%s:</b><td></tr>\n", "Sent" );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "ECHO",
icmpstat.icps_outhist[ICMP_ECHO] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "ECHO REPLY",
icmpstat.icps_outhist[ICMP_ECHOREPLY] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "UNREACH",
icmpstat.icps_outhist[ICMP_UNREACH] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "REDIRECT",
icmpstat.icps_outhist[ICMP_REDIRECT] );
fprintf( client, "<tr><td>%s<td>%ld</tr>\n", "Other",
icmpstat.icps_inhist[ICMP_SOURCEQUENCH]+
icmpstat.icps_outhist[ICMP_ROUTERADVERT]+
icmpstat.icps_outhist[ICMP_ROUTERSOLICIT]+
icmpstat.icps_outhist[ICMP_TIMXCEED]+
icmpstat.icps_outhist[ICMP_PARAMPROB]+
icmpstat.icps_outhist[ICMP_TSTAMP]+
icmpstat.icps_outhist[ICMP_TSTAMPREPLY]+
icmpstat.icps_outhist[ICMP_IREQ]+
icmpstat.icps_outhist[ICMP_IREQREPLY]+
icmpstat.icps_outhist[ICMP_MASKREQ]+
icmpstat.icps_outhist[ICMP_MASKREPLY]
);
}
html_table_end( client );
#ifdef CYGPKG_NET_INET6
html_table_data_begin( client, "valign=\"top\"" );
html_table_begin( client, "" );
{
fprintf( client, "<tr><td><b>%s:</b><td></tr>\n", "Received" );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "ECHO",
icmp6stat.icp6s_inhist[ICMP_ECHO] );
fprintf( client, "<tr><td>%s<td>%lld</tr>\n", "ECHO REPLY",
icmp6stat.icp6s_inhist[ICMP_ECHOREPLY] );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -