diff --git a/CHANGES.md b/CHANGES.md index daa9c352..6a1f6f66 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,13 @@ +BREAKING(!) changes in 3.6.0 +============================ + +* Automatic filenames (trace files, error files, etc..) are now created in + the current working directory instead of in the directory of the scenario + file. (Issue #399, reported by @sergey-safarov.) +* Only validates SSL certficate if CA-file is separately specified! + (PR #335, by Patrick Wildt @bluerise.) + + Bugs fixed in 3.6.0 =================== @@ -9,8 +19,6 @@ Bugs fixed in 3.6.0 Changes in 3.6.0 ================ -* BEWARE: Only validates SSL certficate if CA-file is separately specified! - (PR #335, by Patrick Wildt @bluerise.) * Added PAGER by default to the extremely large sipp help output. * Removed unused RTPStream code concerning video streams. Also consolidated the rtpstream audio port usage to reuse the global diff --git a/src/call.cpp b/src/call.cpp index 4b1b73b3..513259e0 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -45,13 +45,16 @@ #include #include #include + +#include +#include #include #include -#include #ifdef PCAPPLAY #include "send_packets.h" #endif + #include "sipp.hpp" #include "auth.hpp" #include "deadcall.hpp" @@ -1060,28 +1063,29 @@ char * call::send_scene(int index, int *send_status, int *len) void call::do_bookkeeping(message *curmsg) { /* If this message increments a counter, do it now. */ - if(int counter = curmsg -> counter) { - computeStat(CStat::E_ADD_GENERIC_COUNTER, 1, counter - 1); + if (curmsg -> counter) { + computeStat(CStat::E_ADD_GENERIC_COUNTER, 1, curmsg->counter - 1); } /* If this message can be used to compute RTD, do it now */ - if(int rtd = curmsg -> start_rtd) { - start_time_rtd[rtd - 1] = getmicroseconds(); + if (curmsg->start_rtd) { + start_time_rtd[curmsg->start_rtd - 1] = getmicroseconds(); } - if(int rtd = curmsg -> stop_rtd) { + if (curmsg->stop_rtd) { + int rtd = curmsg->stop_rtd; if (!rtd_done[rtd - 1]) { unsigned long long start = start_time_rtd[rtd - 1]; unsigned long long end = getmicroseconds(); - if(dumpInRtt) { + if (dumpInRtt) { call_scenario->stats->computeRtt(start, end, rtd); } computeStat(CStat::E_ADD_RESPONSE_TIME_DURATION, (end - start) / 1000, rtd - 1); - if (!curmsg -> repeat_rtd) { + if (!curmsg->repeat_rtd) { rtd_done[rtd - 1] = true; } } diff --git a/src/logger.cpp b/src/logger.cpp index 0515c9de..3a64f991 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -41,9 +41,8 @@ #include #include #include + #include "logger.hpp" -#include "screen.hpp" -#include "sipp.hpp" #define SIPP_ENDL "\r\n" diff --git a/src/screen.cpp b/src/screen.cpp index 30c2372e..24d76783 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -21,25 +21,21 @@ * Screen.cpp : Simple curses & logfile encapsulation */ -#include "stat.hpp" -#include "sipp.hpp" +#include #include #include #include #include #include -#include #include #include #include - -#ifdef __SUNOS -#include -#endif - #include +#include "screen.hpp" +#include "sipp.hpp" + /* Export these so others needn't include curses.h */ int key_backspace = KEY_BACKSPACE; int key_dc = KEY_DC; diff --git a/src/send_packets.c b/src/send_packets.c index 10864470..19051e2a 100644 --- a/src/send_packets.c +++ b/src/send_packets.c @@ -88,12 +88,12 @@ float2timer(float time, struct timeval *tvp) static char* find_file(const char* filename) { char *fullpath; - if (filename[0] == '/' || !scenario_path) { + if (filename[0] == '/' || !*scenario_path) { return strdup(filename); } fullpath = malloc(MAX_PATH); - snprintf(fullpath, MAX_PATH, "%s/%s", scenario_path, filename); + snprintf(fullpath, MAX_PATH, "%s%s", scenario_path, filename); if (access(fullpath, R_OK) < 0) { free(fullpath); diff --git a/src/sipp.cpp b/src/sipp.cpp index 44d378c8..5def5cd5 100644 --- a/src/sipp.cpp +++ b/src/sipp.cpp @@ -1149,18 +1149,20 @@ static void set_scenario(const char* name) free(scenario_file); free(scenario_path); - const char* ext = strrchr(name, '.'); - if (ext && strcmp(ext, ".xml") == 0) { - scenario_file = strndup(name, ext - name); + const char* sep = strrchr(name, '/'); + if (sep) { + ++sep; // include slash + scenario_path = strndup(name, sep - name); } else { - scenario_file = strdup(name); + scenario_path = strdup(""); + sep = name; } - const char* sep = strrchr(scenario_file, '/'); - if (sep) { - scenario_path = strndup(scenario_file, sep - scenario_file); + const char* ext = strrchr(sep, '.'); + if (ext && strcmp(ext, ".xml") == 0) { + scenario_file = strndup(sep, ext - sep); } else { - scenario_path = NULL; + scenario_file = strdup(sep); } } @@ -1636,7 +1638,9 @@ int main(int argc, char *argv[]) case SIPP_OPTION_SCENARIO: REQUIRE_ARG(); CHECK_PASS(); - if (!strcmp(argv[argi - 1], "-sf")) { + if (main_scenario) { + ERROR("Internal error, main_scenario already set"); + } else if (!strcmp(argv[argi - 1], "-sf")) { set_scenario(argv[argi]); if (useLogf == 1) { rotate_logfile(); @@ -1645,10 +1649,9 @@ int main(int argc, char *argv[]) main_scenario->stats->setFileName(scenario_file, ".csv"); } else if (!strcmp(argv[argi - 1], "-sn")) { int i = find_scenario(argv[argi]); - - main_scenario = new scenario(0, i); set_scenario(argv[argi]); - main_scenario->stats->setFileName(argv[argi], ".csv"); + main_scenario = new scenario(0, i); + main_scenario->stats->setFileName(scenario_file, ".csv"); } else if (!strcmp(argv[argi - 1], "-sd")) { int i = find_scenario(argv[argi]); fprintf(stdout, "%s", default_scenario[i]); @@ -1870,9 +1873,13 @@ int main(int argc, char *argv[]) lose_packets = 1; } - /* trace file setting */ + /* If no scenario was selected, choose the uac one */ if (scenario_file == NULL) { - set_scenario("sipp"); + assert(main_scenario == NULL); + int i = find_scenario("uac"); + set_scenario("uac"); + main_scenario = new scenario(0, i); + main_scenario->stats->setFileName(scenario_file, ".csv"); } #ifdef USE_TLS @@ -1929,7 +1936,7 @@ int main(int argc, char *argv[]) if (dumpInRtt == 1) { - main_scenario->stats->initRtt((char*)scenario_file, (char*)".csv", + main_scenario->stats->initRtt(scenario_file, ".csv", report_freq_dumpRtt); } @@ -1964,12 +1971,6 @@ int main(int argc, char *argv[]) } } - /* Load default scenario in case nothing was loaded */ - if (!main_scenario) { - main_scenario = new scenario(0, 0); - main_scenario->stats->setFileName("uac", ".csv"); - sprintf(scenario_file,"uac"); - } /* if (!ooc_scenario) { ooc_scenario = new scenario(0, find_scenario("ooc_default")); @@ -2122,5 +2123,6 @@ int main(int argc, char *argv[]) #endif free(scenario_file); + free(scenario_path); sipp_exit(EXIT_TEST_RES_UNKNOWN); }