/* * RTEMS status */ static void rtems_netstat (unsigned int level) { rtems_bsdnet_show_if_stats (); rtems_bsdnet_show_mbuf_stats (); if (level >= 1) { rtems_bsdnet_show_inet_routes (); } if (level >= 2) { rtems_bsdnet_show_ip_stats (); rtems_bsdnet_show_icmp_stats (); rtems_bsdnet_show_udp_stats (); rtems_bsdnet_show_tcp_stats (); } }
void system_init(void) { #ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_IO /* Register GR-RASTA-IO driver resources for the AMBA PnP bus available * on the GR-RASTA-IO board. */ system_init_rastaio(); #endif #if (defined(ENABLE_NETWORK_SMC_LEON2) && defined(LEON2)) || \ (defined(ENABLE_NETWORK_SMC_LEON3) && defined(LEON3)) /* Registering SMC driver first, this way the first entry in * interface_configs will reflect the SMC network settings. */ smcconfig.name = "smc1"; smcconfig.drv_ctrl = NULL; smcconfig.attach = (void *)RTEMS_BSP_NETWORK_DRIVER_ATTACH_SMC91111; network_interface_add(&smcconfig); #endif /* CPU/SYSTEM specific Init */ system_init2(); #ifndef RTEMS_DRVMGR_STARTUP /* Initializing Driver Manager if not alread performed by BSP */ printf("Initializing manager\n"); if ( rtems_drvmgr_init() ) { printf("Driver manager Failed to initialize\n"); exit(-1); } #endif /* Print Driver manager drivers and their assigned devices */ /*rtems_drvmgr_print_drvs(1);*/ #ifdef ENABLE_NETWORK /* Init network */ printf("Initializing network\n"); rtems_bsdnet_initialize_network (); printf("Initializing network DONE\n\n"); rtems_bsdnet_show_inet_routes(); printf("\n"); rtems_bsdnet_show_if_stats(); printf("\n\n"); #endif }
/* * RTEMS Startup Task */ rtems_task Init (rtems_task_argument ignored) { int mcast_main(int ac, char **av); rtems_status_code status; printf("Loading filesystem image\n"); status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size ); printk( "Initializing network\n" ); rtems_bsdnet_initialize_network (); // This appears to have no effect. // add_mcast_route( MULTI_ADDRESS, MULTI_NETMASK, MULTI_GATEWAY ); printk( "Network initialized\n" ); rtems_bsdnet_show_inet_routes (); printk( "Initiating mcast test\n" ); mcast_main ( 0, 0 ); exit (0); }
void mon_route(int argc, char *argv[], uint32_t command_arg, boolean verbose) { int cmd; struct sockaddr_in dst; struct sockaddr_in gw; struct sockaddr_in netmask; int f_host; int f_gw = 0; int cur_idx; int flags; int rc; memset(&dst, 0, sizeof(dst)); memset(&gw, 0, sizeof(gw)); memset(&netmask, 0, sizeof(netmask)); dst.sin_len = sizeof(dst); dst.sin_family = AF_INET; dst.sin_addr.s_addr = inet_addr("0.0.0.0"); gw.sin_len = sizeof(gw); gw.sin_family = AF_INET; gw.sin_addr.s_addr = inet_addr("0.0.0.0"); netmask.sin_len = sizeof(netmask); netmask.sin_family = AF_INET; netmask.sin_addr.s_addr = inet_addr("255.255.255.0"); if (argc < 2) { rtems_bsdnet_show_inet_routes(); return; } if (strcmp(argv[1], "add") == 0) { cmd = RTM_ADD; } else if (strcmp(argv[1], "del") == 0) { cmd = RTM_DELETE; } else { printf("invalid command: %s\n", argv[1]); printf("\tit should be 'add' or 'del'\n"); return; } if (argc < 3) { printf("not enough arguments\n"); return; } if (strcmp(argv[2], "-host") == 0) { f_host = 1; } else if (strcmp(argv[2], "-net") == 0) { f_host = 0; } else { printf("Invalid type: %s\n", argv[1]); printf("\tit should be '-host' or '-net'\n"); return; } if (argc < 4) { printf("not enough arguments\n"); return; } inet_pton(AF_INET, argv[3], &dst.sin_addr); cur_idx = 4; while(cur_idx < argc) { if (strcmp(argv[cur_idx], "gw") == 0) { if ((cur_idx +1) >= argc) { printf("no gateway address\n"); return; } f_gw = 1; inet_pton(AF_INET, argv[cur_idx + 1], &gw.sin_addr); cur_idx += 1; } else if(strcmp(argv[cur_idx], "netmask") == 0) { if ((cur_idx +1) >= argc) { printf("no netmask address\n"); return; } f_gw = 1; inet_pton(AF_INET, argv[cur_idx + 1], &netmask.sin_addr); cur_idx += 1; } else { printf("Unknown argument: %s\n", argv[cur_idx]); return; } cur_idx += 1; } flags = RTF_STATIC; if (f_gw != 0) { flags |= RTF_GATEWAY; } if (f_host != 0) { flags |= RTF_HOST; } rc = rtems_bsdnet_rtrequest(cmd, &dst, &gw, &netmask, flags, NULL); if (rc < 0) { printf("Error adding route\n"); } }
int rtems_shell_main_netstats( /* command */ int argc, char *argv[] ) { int option; int doAll = 0; int doInetRoutes = 0; int doMBUFStats = 0; int doIFStats = 0; int doIPStats = 0; int doICMPStats = 0; int doUDPStats = 0; int doTCPStats = 0; int verbose = 0; struct getopt_data getopt_reent; memset(&getopt_reent, 0, sizeof(getopt_data)); while ( (option = getopt_r( argc, argv, "Aimfpcutv", &getopt_reent)) != -1 ) { switch ((char)option) { case 'A': doAll = 1; break; case 'i': doInetRoutes = 1; break; case 'm': doMBUFStats = 1; break; case 'f': doIFStats = 1; break; case 'p': doIPStats = 1; break; case 'c': doICMPStats = 1; break; case 'u': doUDPStats = 1; break; case 't': doTCPStats = 1; break; case 'v': verbose = 1; break; case '?': default: netstats_usage(); return -1; } } if ( verbose ) { printf( "doAll=%d\n" "doInetRoutes=%d\n" "doMBUFStats=%d\n" "doIFStats=%d\n" "doIPStats=%d\n" "doICMPStats=%d\n" "doUDPStats=%d\n" "doTCPStats=%d\n", doAll, doInetRoutes, doMBUFStats, doIFStats, doIPStats, doICMPStats, doUDPStats, doTCPStats ); } if ( doInetRoutes == 1 || doAll == 1 ) { rtems_bsdnet_show_inet_routes(); } if ( doMBUFStats == 1 || doAll == 1 ) { rtems_bsdnet_show_mbuf_stats(); } if ( doIFStats == 1 || doAll == 1 ) { rtems_bsdnet_show_if_stats(); } if ( doIPStats == 1 || doAll == 1 ) { rtems_bsdnet_show_ip_stats(); } if ( doICMPStats == 1 || doAll == 1 ) { rtems_bsdnet_show_icmp_stats(); } if ( doUDPStats == 1 || doAll == 1 ) { rtems_bsdnet_show_udp_stats(); } if ( doTCPStats == 1 || doAll == 1 ) { rtems_bsdnet_show_tcp_stats(); } return 0; }
/*+++++++++++++++++++++++++++++++++++++++++++++*/ static int main_inet(int argc,char * argv[]) { rtems_bsdnet_show_inet_routes (); return 0; }