⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipp.cpp

📁 sipp is sip protocal testing tool.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                for(int j=0; j<actions->getUsedAction(); j++)            {              action = actions->getAction(j);              if(action != NULL)                {                  printf("   --> action[%d] = ", j);                  action->afficheInfo();                  printf(SIPP_ENDL);                  found = true;                }            }        }    }  if(!found) printf("=> No action found on any messages"SIPP_ENDL);    printf(SIPP_ENDL);  printf("Setted Variable List:" SIPP_ENDL);  found = false;  j=0;  for(i=0; i<SCEN_VARIABLE_SIZE; i++) {    for (int j=0;j<SCEN_MAX_MESSAGES;j++)    {      variable = scenVariableTable[i][j];      if(variable != NULL)        {          printf("=> Variable[%d] : setted regExp[%s]" SIPP_ENDL,                 i,                 variable->getRegularExpression());          found = true;          j++;        }    }  }  if(!found) printf("=> No variable found for this scenario"SIPP_ENDL);  for(i=0; i<(scenario_len + 5 - j); i++) {    printf(SIPP_ENDL);  }  }/* Function to dump all available screens in a file */void print_screens(void){  int oldScreen = currentScreenToDisplay;  int oldRepartition = currentRepartitionToDisplay;  currentScreenToDisplay = DISPLAY_SCENARIO_SCREEN;    print_header_line(   screenf, 0);  print_stats_in_file( screenf, 0);  print_bottom_line(   screenf, 0);  currentScreenToDisplay = DISPLAY_STAT_SCREEN;    print_header_line(   screenf, 0);  CStat::instance()->displayStat(screenf);  print_bottom_line(   screenf, 0);  currentScreenToDisplay = DISPLAY_REPARTITION_SCREEN;  print_header_line(   screenf, 0);  CStat::instance()->displayRepartition(screenf);  print_bottom_line(   screenf, 0);  currentScreenToDisplay = DISPLAY_SECONDARY_REPARTITION_SCREEN;  for (int i = 1; i < MAX_RTD_INFO_LENGTH; i++) {    currentRepartitionToDisplay = i;    print_header_line(   screenf, 0);    CStat::instance()->displaySecondaryRepartition(screenf, i);    print_bottom_line(   screenf, 0);  }  currentScreenToDisplay = oldScreen;  currentRepartitionToDisplay = oldRepartition;}void print_statistics(int last){  static int first = 1;  if(backgroundMode == false) {    if(!last) {      screen_clear();    }    if(first) {      first = 0;      printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"             "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");    }    print_header_line(stdout,last);    switch(currentScreenToDisplay) {      case DISPLAY_STAT_SCREEN :        CStat::instance()->displayStat(stdout);        break;      case DISPLAY_REPARTITION_SCREEN :        CStat::instance()->displayRepartition(stdout);        break;      case DISPLAY_VARIABLE_SCREEN  :        print_variable_list();        break;      case DISPLAY_TDM_MAP_SCREEN  :        print_tdm_map();        break;      case DISPLAY_SECONDARY_REPARTITION_SCREEN :	CStat::instance()->displaySecondaryRepartition(stdout, currentRepartitionToDisplay);	break;      case DISPLAY_SCENARIO_SCREEN :      default:        print_stats_in_file(stdout, last);        break;    }    print_bottom_line(stdout,last);    if(last) { fprintf(stdout,"\n"); }  }}void set_rate(double new_rate){  double L_temp ;    if(toolMode == MODE_SERVER) {    rate = 0;    open_calls_allowed = 0;  }  rate = new_rate;  if(rate < 0) {    rate = 0;  }  last_rate_change_time = clock_tick;  calls_since_last_rate_change = 0;    if(!open_calls_user_setting) {        int call_duration_min =  scenario_duration;    if(duration > call_duration_min) call_duration_min = duration;    if(call_duration_min < 1000) call_duration_min = 1000;        L_temp = (3 * rate * call_duration_min) / rate_period_s / 1000 ;    open_calls_allowed = (unsigned int) L_temp ;    if(!open_calls_allowed) {      open_calls_allowed = 1;    }  }}void sipp_sigusr1(int /* not used */){  /* Smooth exit: do not place any new calls and exit */  quitting+=10;}void sipp_sigusr2(int /* not used */){  if (!signalDump) {     signalDump = true ;  }}bool process_key(int c) {    switch (c) {    case '1':      currentScreenToDisplay = DISPLAY_SCENARIO_SCREEN;      print_statistics(0);      break;    case '2':      currentScreenToDisplay = DISPLAY_STAT_SCREEN;      print_statistics(0);      break;    case '3':      currentScreenToDisplay = DISPLAY_REPARTITION_SCREEN;      print_statistics(0);      break;    case '4':      currentScreenToDisplay = DISPLAY_VARIABLE_SCREEN;      print_statistics(0);      break;    case '5':      if (use_tdmmap) {        currentScreenToDisplay = DISPLAY_TDM_MAP_SCREEN;        print_statistics(0);      }      break;    /* Screens 6, 7, 8, 9  are for the extra RTD repartitions. */    case '6':    case '7':    case '8':    case '9':      currentScreenToDisplay = DISPLAY_SECONDARY_REPARTITION_SCREEN;      currentRepartitionToDisplay = (c - '6') + 1;      print_statistics(0);      break;    case '+':      set_rate(rate + 1);      print_statistics(0);      break;    case '-':      set_rate(rate - 1);      print_statistics(0);      break;    case '*':      set_rate(rate + 10);      print_statistics(0);      break;    case '/':      set_rate(rate - 10);      print_statistics(0);      break;    case 'p':      if(paused) { 	paused = 0;	set_rate(rate);      } else {	paused = 1;      }      print_statistics(0);      break;    case 's':      if (screenf) {	print_screens();      }      break;    case 'q':      quitting+=10;      print_statistics(0);      return true;    case 'Q':      /* We are going to break, so we never have a chance to press q twice. */      quitting+=20;      print_statistics(0);      break;    }    return false;}/* User interface threads *//* Socket control thread */void ctrl_thread (void * param){  int soc,ret;  short prt;  int port, try_counter;  unsigned char bufrcv [20], c;   struct sockaddr_in sin;    port = DEFAULT_CTRL_SOCKET_PORT;  try_counter = 0;  /* Allow 10 control socket on the same system */  /* (several SIPp instances)                   */  while (try_counter < 10) {    prt = htons(port);    memset(&sin,0,sizeof(struct sockaddr_in));    soc = socket(AF_INET,SOCK_DGRAM,0);    sin.sin_port = prt;    sin.sin_family = AF_INET;    sin.sin_addr.s_addr = INADDR_ANY;    if (!bind(soc,(struct sockaddr *)&sin,sizeof(struct sockaddr_in))) {      /* Bind successful */      break;    }    try_counter++;    port++;  }  if (try_counter == 10) {    WARNING_P3("Unable to bind remote control socket (tried UDP ports %d-%d)",                   DEFAULT_CTRL_SOCKET_PORT,                   DEFAULT_CTRL_SOCKET_PORT+10,                   strerror(errno));    return;  }  while(!feof(stdin)){    ret = recv(soc,bufrcv,20,0);    if (process_key(bufrcv[0])) {	return;    }  }}/* KEYBOARD thread */void keyb_thread (void * param){  int c;  while(!feof(stdin)){    c = screen_readkey();    if (process_key(c)) {	return;    }  }}/*************************** Mini SIP parser ***************************/char * get_peer_tag(char *msg){  char        * to_hdr;  char        * ptr;   char        * end_ptr;  static char   tag[MAX_HEADER_LEN];  int           tag_i = 0;    to_hdr = strstr(msg, "\r\nTo:");  if(!to_hdr) to_hdr = strstr(msg, "\r\nto:");  if(!to_hdr) to_hdr = strstr(msg, "\r\nTO:");  if(!to_hdr) to_hdr = strstr(msg, "\r\nt:");  if(!to_hdr) {    ERROR("No valid To: header in reply");  }  // Remove CRLF  to_hdr += 2;  end_ptr = strchr(to_hdr,'\n');  ptr = strchr(to_hdr, '>');  if (!ptr) {    return NULL;  }    ptr = strchr(to_hdr, ';');     if(!ptr) {    return NULL;  }    to_hdr = ptr;  ptr = strstr(to_hdr, "tag");  if(!ptr) { ptr = strstr(to_hdr, "TAG"); }  if(!ptr) { ptr = strstr(to_hdr, "Tag"); }  if(!ptr) {    return NULL;  }  if (ptr>end_ptr) {    return NULL ;  }    ptr = strchr(ptr, '=');     if(!ptr) {    ERROR("Invalid tag param in To: header");  }  ptr ++;  while((*ptr)         &&         (*ptr != ' ')  &&         (*ptr != ';')  &&         (*ptr != '\t') &&         (*ptr != '\t') &&         (*ptr != '\r') &&          (*ptr != '\n') &&         (*ptr)) {    tag[tag_i++] = *(ptr++);  }  tag[tag_i] = 0;    return tag;}char * get_call_id(char *msg){  static char call_id[MAX_HEADER_LEN];  char * ptr1, * ptr2, * ptr3, backup;  bool short_form;  short_form = false;  ptr1 = strstr(msg, "Call-ID:");  if(!ptr1) { ptr1 = strstr(msg, "Call-Id:"); }  if(!ptr1) { ptr1 = strstr(msg, "Call-id:"); }  if(!ptr1) { ptr1 = strstr(msg, "call-Id:"); }  if(!ptr1) { ptr1 = strstr(msg, "call-id:"); }  if(!ptr1) { ptr1 = strstr(msg, "CALL-ID:"); }  // For short form, we need to make sure we start from beginning of line  // For others, no need to  if(!ptr1) { ptr1 = strstr(msg, "\r\ni:"); short_form = true;}  if(!ptr1) { ERROR_P1("(1) No valid Call-ID: header in reply '%s'", msg); }    if (short_form) {    ptr1 += 4;  } else {    ptr1 += 8;  }    while((*ptr1 == ' ') || (*ptr1 == '\t')) { ptr1++; }    if(!(*ptr1)) { ERROR("(2) No valid Call-ID: header in reply"); }    ptr2 = ptr1;  while((*ptr2) && 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -