/** * Process command line arguments passed to olsrd * */ static int olsr_process_arguments(int argc, char *argv[], struct olsrd_config *cnf, struct if_config_options *ifcnf) { while (argc > 1) { NEXT_ARG; #ifdef WIN32 /* *Interface list */ if (strcmp(*argv, "-int") == 0) { ListInterfaces(); exit(0); } #endif /* *Configfilename */ if (strcmp(*argv, "-f") == 0) { fprintf(stderr, "Configfilename must ALWAYS be first argument!\n\n"); olsr_exit(__func__, EXIT_FAILURE); } /* *Use IP version 6 */ if (strcmp(*argv, "-ipv6") == 0) { cnf->ip_version = AF_INET6; continue; } /* *Broadcast address */ if (strcmp(*argv, "-bcast") == 0) { struct in_addr in; NEXT_ARG; CHECK_ARGC; if (inet_aton(*argv, &in) == 0) { printf("Invalid broadcast address! %s\nSkipping it!\n", *argv); continue; } memcpy(&ifcnf->ipv4_multicast.v4, &in.s_addr, sizeof(ifcnf->ipv4_multicast.v4)); continue; } /* * Set LQ level */ if (strcmp(*argv, "-lql") == 0) { int tmp_lq_level; NEXT_ARG; CHECK_ARGC; /* Sanity checking is done later */ sscanf(*argv, "%d", &tmp_lq_level); olsr_cnf->lq_level = tmp_lq_level; continue; } /* * Set LQ winsize */ if (strcmp(*argv, "-lqa") == 0) { float tmp_lq_aging; NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%f", &tmp_lq_aging); if (tmp_lq_aging < MIN_LQ_AGING || tmp_lq_aging > MAX_LQ_AGING) { printf("LQ aging factor %f not allowed. Range [%f-%f]\n", tmp_lq_aging, MIN_LQ_AGING, MAX_LQ_AGING); olsr_exit(__func__, EXIT_FAILURE); } olsr_cnf->lq_aging = tmp_lq_aging; continue; } /* * Set NAT threshold */ if (strcmp(*argv, "-lqnt") == 0) { float tmp_lq_nat_thresh; NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%f", &tmp_lq_nat_thresh); if (tmp_lq_nat_thresh < 0.1 || tmp_lq_nat_thresh > 1.0) { printf("NAT threshold %f not allowed. Range [%f-%f]\n", tmp_lq_nat_thresh, 0.1, 1.0); olsr_exit(__func__, EXIT_FAILURE); } olsr_cnf->lq_nat_thresh = tmp_lq_nat_thresh; continue; } /* * Enable additional debugging information to be logged. */ if (strcmp(*argv, "-d") == 0) { NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%d", &cnf->debug_level); continue; } /* * Interfaces to be used by olsrd. */ if (strcmp(*argv, "-i") == 0) { NEXT_ARG; CHECK_ARGC; if (*argv[0] == '-') { fprintf(stderr, "You must provide an interface label!\n"); olsr_exit(__func__, EXIT_FAILURE); } printf("Queuing if %s\n", *argv); olsr_create_olsrif(*argv, false); while ((argc - 1) && (argv[1][0] != '-')) { NEXT_ARG; printf("Queuing if %s\n", *argv); olsr_create_olsrif(*argv, false); } continue; } /* * Set the hello interval to be used by olsrd. * */ if (strcmp(*argv, "-hint") == 0) { NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%f", &ifcnf->hello_params.emission_interval); ifcnf->hello_params.validity_time = ifcnf->hello_params.emission_interval * 3; continue; } /* * Set the HNA interval to be used by olsrd. * */ if (strcmp(*argv, "-hnaint") == 0) { NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%f", &ifcnf->hna_params.emission_interval); ifcnf->hna_params.validity_time = ifcnf->hna_params.emission_interval * 3; continue; } /* * Set the MID interval to be used by olsrd. * */ if (strcmp(*argv, "-midint") == 0) { NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%f", &ifcnf->mid_params.emission_interval); ifcnf->mid_params.validity_time = ifcnf->mid_params.emission_interval * 3; continue; } /* * Set the tc interval to be used by olsrd. * */ if (strcmp(*argv, "-tcint") == 0) { NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%f", &ifcnf->tc_params.emission_interval); ifcnf->tc_params.validity_time = ifcnf->tc_params.emission_interval * 3; continue; } /* * Set the polling interval to be used by olsrd. */ if (strcmp(*argv, "-T") == 0) { NEXT_ARG; CHECK_ARGC; sscanf(*argv, "%f", &cnf->pollrate); continue; } /* * Should we display the contents of packages beeing sent? */ if (strcmp(*argv, "-dispin") == 0) { parser_set_disp_pack_in(true); continue; } /* * Should we display the contents of incoming packages? */ if (strcmp(*argv, "-dispout") == 0) { net_set_disp_pack_out(true); continue; } /* * Should we set up and send on a IPC socket for the front-end? */ if (strcmp(*argv, "-ipc") == 0) { cnf->ipc_connections = 1; continue; } /* * IPv6 multicast addr */ if (strcmp(*argv, "-multi") == 0) { struct in6_addr in6; NEXT_ARG; CHECK_ARGC; if (inet_pton(AF_INET6, *argv, &in6) <= 0) { fprintf(stderr, "Failed converting IP address %s\n", *argv); exit(EXIT_FAILURE); } memcpy(&ifcnf->ipv6_multicast, &in6, sizeof(struct in6_addr)); continue; } /* * Host emulation */ if (strcmp(*argv, "-hemu") == 0) { struct in_addr in; struct olsr_if *ifa; NEXT_ARG; CHECK_ARGC; if (inet_pton(AF_INET, *argv, &in) <= 0) { fprintf(stderr, "Failed converting IP address %s\n", *argv); exit(EXIT_FAILURE); } /* Add hemu interface */ ifa = olsr_create_olsrif("hcif01", true); if (!ifa) continue; ifa->cnf = get_default_if_config(); ifa->host_emul = true; memcpy(&ifa->hemu_ip, &in, sizeof(union olsr_ip_addr)); cnf->host_emul = true; continue; } /* * Delete possible default GWs */ if (strcmp(*argv, "-delgw") == 0) { olsr_cnf->del_gws = true; continue; } if (strcmp(*argv, "-nofork") == 0) { cnf->no_fork = true; continue; } return -1; } return 0; }
TVerdict CTestIfioctls::doTestStepL() { int err; if(TestStepName() == KExampleL) { INFO_PRINTF1(_L("ExampleL():")); err = ExampleL(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KListInterfaces) { INFO_PRINTF1(_L("ListInterfaces():")); err = ListInterfaces(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KCreateManyActiveInterfaces) { INFO_PRINTF1(_L("CreateManyActiveInterfaces():")); err = CreateManyActiveInterfaces(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KChooseInterface) { INFO_PRINTF1(_L("ChooseInterface():")); err = ChooseInterface(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KChooseActiveInterface) { INFO_PRINTF1(_L("ChooseActiveInterface():")); err = ChooseActiveInterface(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestIfNameIndex) { INFO_PRINTF1(_L("TestIfNameIndex():")); err = TestIfNameIndex(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestIfIndexToName) { INFO_PRINTF1(_L("TestIfIndexToName():")); err = TestIfIndexToName(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestIfNameToIndex) { INFO_PRINTF1(_L("TestIfNameToIndex():")); err = TestIfNameToIndex(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestSiocGIfIndex) { INFO_PRINTF1(_L("TestSiocGIfIndex():")); err = TestSiocGIfIndex(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KConnectToIpUsingConnection) { INFO_PRINTF1(_L("ConnectToIpUsingConnection():")); err = ConnectToIpUsingConnection(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KSendtoIpUsingConnection ) { INFO_PRINTF1(_L("SendtoIpUsingConnection():")); err = SendtoIpUsingConnection(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KConnectToUrlUsingConnection ) { INFO_PRINTF1(_L("ConnectToUrlUsingConnection():")); err = ConnectToUrlUsingConnection(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == Kioctltest) { INFO_PRINTF1(_L("ioctltest():")); err = ioctltest(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == Kreadtest) { INFO_PRINTF1(_L("readtest():")); err = readtest(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestAddDelRoute) { INFO_PRINTF1(_L("TestAddDelRoute():")); err = TestAddDelRoute(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestAddDelRouteNegative1) { INFO_PRINTF1(_L("TestAddDelRouteNegative1():")); err = TestAddDelRouteNegative1(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestAddDelRouteNegative2) { INFO_PRINTF1(_L("TestAddDelRouteNegative2():")); err = TestAddDelRouteNegative2(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestMacAddress) { INFO_PRINTF1(_L("TestMacAddress():")); err = TestMacAddress(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestMacAddressNegative1) { INFO_PRINTF1(_L("TestMacAddressNegative1():")); err = TestMacAddressNegative1(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestioctlfile ) { INFO_PRINTF1(_L("Testioctlfile():")); err = Testioctlfile(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } else if(TestStepName() == KTestioctl1) { INFO_PRINTF1(_L("Testioctl1():")); err = Testioctl1(); SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass); } return TestStepResult(); }