diff --git a/include/sipp.hpp b/include/sipp.hpp index 9a533cb6..9462a8c5 100644 --- a/include/sipp.hpp +++ b/include/sipp.hpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #ifdef __SUNOS #include @@ -296,7 +297,8 @@ MAYBE_EXTERN int currentRepartitionToDisplay DEFVAL(1); MAYBE_EXTERN unsigned int base_cseq DEFVAL(0); MAYBE_EXTERN char * auth_uri DEFVAL(0); MAYBE_EXTERN const char * call_id_string DEFVAL("%u-%p@%s"); -MAYBE_EXTERN char **generic[100]; +typedef std::unordered_map ParamMap; +MAYBE_EXTERN ParamMap generic; MAYBE_EXTERN bool rtp_echo_state DEFVAL(true); MAYBE_EXTERN bool callidSlash DEFVAL(false); diff --git a/src/message.cpp b/src/message.cpp index 535d0496..374b81fd 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -349,19 +349,12 @@ SendingMessage::SendingMessage(scenario* msg_scenario, const char* const_src, bo parseAuthenticationKeyword(msg_scenario, newcomp, keyword); } else { // scan for the generic parameters - must be last test - int i = 0; - while (generic[i]) { - char *msg1 = *generic[i]; - char *msg2 = *(generic[i] + 1); - if(!strcmp(keyword, msg1)) { - newcomp->type = E_Message_Literal; - newcomp->literal = strdup(msg2); - newcomp->literalLen = strlen(newcomp->literal); - break; - } - ++i; - } - if (!generic[i]) { + auto gen = generic.find(keyword); + if (gen != generic.end()) { + newcomp->type = E_Message_Literal; + newcomp->literal = strdup((*gen).second.c_str()); + newcomp->literalLen = strlen(newcomp->literal); + } else { ERROR("Unsupported keyword '%s' in xml scenario file", keyword); } diff --git a/src/sipp.cpp b/src/sipp.cpp index 69c0973a..ea1055a9 100644 --- a/src/sipp.cpp +++ b/src/sipp.cpp @@ -1318,7 +1318,6 @@ int main(int argc, char *argv[]) { int argi = 0; pthread_t pthread2_id = 0, pthread3_id = 0; - unsigned int generic_count = 0; bool slave_masterSet = false; int rtp_errors; int echo_errors; @@ -1326,8 +1325,6 @@ int main(int argc, char *argv[]) rtp_errors = 0; echo_errors = 0; - generic[0] = NULL; - /* At least one argument is needed */ if (argc < 2) { help(); @@ -1641,11 +1638,7 @@ int main(int argc, char *argv[]) REQUIRE_ARG(); CHECK_PASS(); - if (generic_count + 1 >= sizeof(generic)/sizeof(generic[0])) { - ERROR("Too many generic parameters %d",generic_count + 1); - } - generic[generic_count++] = &argv[argi - 1]; - generic[generic_count] = NULL; + generic[argv[argi - 1]] = argv[argi]; break; case SIPP_OPTION_VAR: REQUIRE_ARG();