static void server_task(INT stacd, VP exinf) { DEBUG_PRINT(("server task started\n")); ping(inet_addr(IP_T_ENGINE_ORG)); // t-engine.org traceroute(inet_addr(IP_T_ENGINE_ORG)); // t-engine.org //traceroute(inet_addr(IP_GOOGLE_CO_JP)); // google.co.jp test_tcp_server(); test_getaddrinfo(); test_getnameinfo(); test_http(); tk_sig_sem(semid, 1); tk_exd_tsk(); }
int main(int argc, char **argv) { int ret = EXIT_FAILURE; char *mesh_iface = mesh_dfl_iface; if ((argc > 1) && (strcmp(argv[1], "-m") == 0)) { if (argc < 3) { printf("Error - the option '-m' needs a parameter\n"); goto err; } mesh_iface = argv[2]; argv += 2; argc -= 2; } if (argc < 2) { printf("Error - no command specified\n"); goto err; } if (strcmp(argv[1], "-h") == 0) goto err; if (strcmp(argv[1], "-v") == 0) { printf("batctl %s [batman-adv: ", SOURCE_VERSION); ret = read_file("", module_ver_path, USE_READ_BUFF | SILENCE_ERRORS, 0, 0); if ((line_ptr) && (line_ptr[strlen(line_ptr) - 1] == '\n')) line_ptr[strlen(line_ptr) - 1] = '\0'; if (ret == EXIT_SUCCESS) printf("%s]\n", line_ptr); else printf("module not loaded]\n"); free(line_ptr); exit(EXIT_SUCCESS); } /* TODO: remove this generic check here and move it into the individual functions */ /* check if user is root */ if ((strcmp(argv[1], "bisect") != 0) && ((getuid()) || (getgid()))) { fprintf(stderr, "Error - you must be root to run '%s' !\n", argv[0]); exit(EXIT_FAILURE); } if ((strcmp(argv[1], "ping") == 0) || (strcmp(argv[1], "p") == 0)) { ret = ping(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "traceroute") == 0) || (strcmp(argv[1], "tr") == 0)) { ret = traceroute(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "tcpdump") == 0) || (strcmp(argv[1], "td") == 0)) { ret = tcpdump(argc - 1, argv + 1); } else if ((strcmp(argv[1], "interface") == 0) || (strcmp(argv[1], "if") == 0)) { ret = interface(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "originators") == 0) || (strcmp(argv[1], "o") == 0)) { ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, DEBUG_ORIGINATORS, originators_usage); } else if ((strcmp(argv[1], "translocal") == 0) || (strcmp(argv[1], "tl") == 0)) { ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, DEBUG_TRANSTABLE_LOCAL, trans_local_usage); } else if ((strcmp(argv[1], "transglobal") == 0) || (strcmp(argv[1], "tg") == 0)) { ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, DEBUG_TRANSTABLE_GLOBAL, trans_global_usage); } else if ((strcmp(argv[1], "softif_neigh") == 0) || (strcmp(argv[1], "sn") == 0)) { ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, DEBUG_SOFTIF_NEIGH, softif_neigh_usage); } else if ((strcmp(argv[1], "loglevel") == 0) || (strcmp(argv[1], "ll") == 0)) { ret = handle_loglevel(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "log") == 0) || (strcmp(argv[1], "l") == 0)) { ret = log_print(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "interval") == 0) || (strcmp(argv[1], "it") == 0)) { ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, SYS_ORIG_INTERVAL, orig_interval_usage, NULL); } else if ((strcmp(argv[1], "vis_mode") == 0) || (strcmp(argv[1], "vm") == 0)) { ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, SYS_VIS_MODE, vis_mode_usage, sysfs_param_server); } else if ((strcmp(argv[1], "vis_data") == 0) || (strcmp(argv[1], "vd") == 0)) { ret = vis_data(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "gw_mode") == 0) || (strcmp(argv[1], "gw") == 0)) { ret = handle_gw_setting(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "gateways") == 0) || (strcmp(argv[1], "gwl") == 0)) { ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, DEBUG_GATEWAYS, gateways_usage); } else if ((strcmp(argv[1], "aggregation") == 0) || (strcmp(argv[1], "ag") == 0)) { ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, SYS_AGGR, aggregation_usage, sysfs_param_enable); } else if ((strcmp(argv[1], "bonding") == 0) || (strcmp(argv[1], "b") == 0)) { ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, SYS_BONDING, bonding_usage, sysfs_param_enable); } else if ((strcmp(argv[1], "fragmentation") == 0) || (strcmp(argv[1], "f") == 0)) { ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, SYS_FRAG, fragmentation_usage, sysfs_param_enable); } else if ((strcmp(argv[1], "ap_isolation") == 0) || (strcmp(argv[1], "ap") == 0)) { ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, SYS_AP_ISOLA, ap_isolation_usage, sysfs_param_enable); } else if ((strcmp(argv[1], "bisect") == 0)) { ret = bisect(argc - 1, argv + 1); } else { printf("Error - no command specified\n"); print_usage(); } return ret; err: print_usage(); exit(EXIT_FAILURE); }