Text   |  XML   |  ReML   |   Visible Warnings:

Redundant Condition  at voip_calls.c:2381

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

MGCPcalls_packet

(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/voip_calls.c)expand/collapse
Show more  
 2317  MGCPcalls_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *MGCPinfo)
 2318  {
 2319          voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
 2320   
 2321          voip_calls_info_t *tmp_listinfo;
 2322          voip_calls_info_t *callsinfo = NULL;
 2323          mgcp_calls_info_t *tmp_mgcpinfo = NULL;
 2324          GList *list;
 2325          GList *listGraph;
 2326          gchar *frame_label = NULL;
 2327          gchar *comment = NULL;
 2328          graph_analysis_item_t *gai;
 2329          gboolean new = FALSE;
 2330          gboolean fromEndpoint = FALSE; /* true for calls originated in Endpoints, false for calls from MGC */
 2331          gdouble diff_time;
 2332   
 2333          const mgcp_info_t *pi = MGCPinfo;
 2334   
 2335   
 2336          if ((pi->mgcp_type == MGCP_REQUEST) && !pi->is_duplicate ){
 2337                  /* check whether we already have a call with this Endpoint and it is active*/
 2338                  list = g_list_first(tapinfo->callsinfo_list);
 2339                  while (list)
 2340                  {
 2341                          tmp_listinfo=list->data;
 2342                          if ((tmp_listinfo->protocol == VOIP_MGCP) && (tmp_listinfo->call_active_state == VOIP_ACTIVE)){
 2343                                  tmp_mgcpinfo = tmp_listinfo->prot_info;
 2344                                  if (pi->endpointId != NULL){
 2345                                          if (g_ascii_strcasecmp(tmp_mgcpinfo->endpointId,pi->endpointId) == 0){
 2346                                                  /*
 2347                                                     check first if it is an ended call. We can still match packets to this Endpoint 2 seconds
 2348                                                     after the call has been released 
 2349                                                  */
 2350                                                  diff_time = nstime_to_sec(&pinfo->fd->rel_ts) - tmp_listinfo->stop_sec - (double)tmp_listinfo->stop_usec/1000000;
 2351                                                  if ( ((tmp_listinfo->call_state == VOIP_CANCELLED) ||
 2352                                                       (tmp_listinfo->call_state == VOIP_COMPLETED)  ||
 2353                                                       (tmp_listinfo->call_state == VOIP_REJECTED)) &&
 2354                                                         (diff_time > 2) )
 2355                                                  {
 2356                                                          tmp_listinfo->call_active_state = VOIP_INACTIVE;
 2357                                                  } else {
 2358                                                          callsinfo = (voip_calls_info_t*)(list->data);
 2359                                                          break;
 2360                                                  }
 2361                                          }
 2362                                  }
 2363                          }
 2364                          list = g_list_next (list);
 2365                  }
 2366   
 2367                  /* there is no call with this Endpoint, lets see if this a new call or not */
 2368                  if (callsinfo == NULL){
 2369                          if ( (strcmp(pi->code, "NTFY") == 0) && isSignal("hd", pi->observedEvents) ){ /* off hook transition */
 2370                                  /* this is a new call from the Endpoint */
 2371                                  fromEndpoint = TRUE;
 2372                                  new = TRUE;
 2373                          } else if (strcmp(pi->code, "CRCX") == 0){
 2374                                  /* this is a new call from the MGC */
 2375                                  fromEndpoint = FALSE;
 2376                                  new = TRUE;
 2377                          }
 2378                          if (!new) return 0;
 2379                  }
 2380          } else if ( ((pi->mgcp_type == MGCP_RESPONSE) && pi->request_available) ||
 2381                          ((pi->mgcp_type == MGCP_REQUEST) && pi->is_duplicate) ) {
 2382                  /* if it is a response OR if it is a duplicated Request, lets look in the Graph to see 
 2383                     if there is a request that matches */
 2384                  listGraph = g_list_first(tapinfo->graph_analysis->list);
 2385                  while (listGraph)
 2386                  {
 2387                          gai = listGraph->data;
 2388                          if (gai->frame_num == pi->req_num){
 2389                                  /* there is a request that match, so look the associated call with this call_num */
 2390                                  list = g_list_first(tapinfo->callsinfo_list);
 2391                                  while (list)
 2392                                  {
 2393                                          tmp_listinfo=list->data;
 2394                                          if (tmp_listinfo->protocol == VOIP_MGCP){
 2395                                                  if (tmp_listinfo->call_num == gai->conv_num){
 2396                                                          tmp_mgcpinfo = tmp_listinfo->prot_info;
 2397                                                          callsinfo = (voip_calls_info_t*)(list->data);
 2398                                                          break;
 2399                                                  }
 2400                                          }
 2401                                          list = g_list_next (list);
 2402                                  }
 2403                                  if (callsinfo != NULL) break;
 2404                          }
 2405                          listGraph = g_list_next(listGraph);
 2406                  }
 2407                  /* if there is not a matching request, just return */
 2408                  if (callsinfo == NULL) return 0;
 2409          } else return 0;
 2410   
 2411          /* not in the list? then create a new entry */
 2412          if (callsinfo==NULL){
 2413                  callsinfo = g_malloc0(sizeof(voip_calls_info_t));
 2414                  callsinfo->call_active_state = VOIP_ACTIVE;
 2415                  callsinfo->call_state = VOIP_CALL_SETUP;
 2416                  if (fromEndpoint) {
 2417                          callsinfo->from_identity=g_strdup(pi->endpointId);
 2418                          callsinfo->to_identity=g_strdup("");
 2419                  } else {
 2420                          callsinfo->from_identity=g_strdup("");
 2421                          callsinfo->to_identity=g_strdup(pi->endpointId);
 2422                  }
 2423                  COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
 2424                  callsinfo->first_frame_num=pinfo->fd->num;
 2425                  callsinfo->selected=FALSE;
 2426                  callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs);
 2427                  callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
 2428                  callsinfo->protocol=VOIP_MGCP;
 2429                  callsinfo->prot_info=g_malloc(sizeof(mgcp_calls_info_t));
 2430                  callsinfo->free_prot_info = g_free;
 2431                  tmp_mgcpinfo=callsinfo->prot_info;
 2432                  tmp_mgcpinfo->endpointId = g_strdup(pi->endpointId);
 2433                  tmp_mgcpinfo->fromEndpoint = fromEndpoint;
 2434                  callsinfo->npackets = 0;
 2435                  callsinfo->call_num = tapinfo->ncalls++;
 2436                  tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo);
 2437          }
 2438   
 2439          g_assert(tmp_mgcpinfo != NULL);
 2440   
 2441          /* change call state and add to graph */
 2442          switch (pi->mgcp_type)
 2443          {
 2444          case MGCP_REQUEST:
 2445                  if ( (strcmp(pi->code, "NTFY") == 0) && (pi->observedEvents != NULL) ){
 2446                          frame_label = g_strdup_printf("%s ObsEvt:%s",pi->code, pi->observedEvents);
 2447   
 2448                          if (tmp_mgcpinfo->fromEndpoint){
 2449                                  /* use the Dialed digits to fill the "To" for the call, but use the first NTFY */
 2450                                  if (callsinfo->to_identity[0] == '\0') mgcpDialedDigits(pi->observedEvents, &(callsinfo->to_identity));
 2451   
 2452                          /* from MGC and the user picked up, the call is connected */
 2453                          } else if (isSignal("hd", pi->observedEvents))
 2454                                  callsinfo->call_state=VOIP_IN_CALL;
 2455   
 2456                          /* hung up signal */
 2457                          if (isSignal("hu", pi->observedEvents)) {
 2458                                  if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)){
 2459                                          callsinfo->call_state = VOIP_CANCELLED;
 2460                                  } else {
 2461                                          callsinfo->call_state = VOIP_COMPLETED;
 2462                                  }
 2463                          }
 2464   
 2465                  } else if (strcmp(pi->code, "RQNT") == 0) {
 2466                          /* for calls from Endpoint: if there is a "no signal" RQNT and the call was RINGING, we assume this is the CONNECT */
 2467                          if ( tmp_mgcpinfo->fromEndpoint && isSignal("", pi->signalReq) && (callsinfo->call_state == VOIP_RINGING) ) {
 2468                                          callsinfo->call_state = VOIP_IN_CALL;
 2469                          }
 2470   
 2471                          /* if there is ringback or ring tone, change state to ringing */
 2472                          if ( isSignal("rg", pi->signalReq) || isSignal("rt", pi->signalReq) ) {
 2473                                          callsinfo->call_state = VOIP_RINGING;
 2474                          }
 2475   
 2476                          /* if there is a Busy or ReorderTone, and the call was Ringing or Setup the call is Rejected */
 2477                          if ( (isSignal("ro", pi->signalReq) || isSignal("bz", pi->signalReq)) && ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state = VOIP_RINGING)) ) {
 2478                                          callsinfo->call_state = VOIP_REJECTED;
 2479                          }
 2480   
 2481                          if (pi->signalReq != NULL)
 2482                                  frame_label = g_strdup_printf("%s%sSigReq:%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"", pi->signalReq);
 2483                          else 
 2484                                  frame_label = g_strdup_printf("%s%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"");
 2485   
 2486                          /* use the CallerID info to fill the "From" for the call */
 2487                          if (!tmp_mgcpinfo->fromEndpoint) mgcpCallerID(pi->signalReq, &(callsinfo->from_identity));
 2488   
 2489                  } else if (strcmp(pi->code, "DLCX") == 0) {
 2490                          /*
 2491                            if there is a DLCX in a call To an Endpoint and the call was not connected, we use
 2492                            the DLCX as the end of the call
 2493                          */
 2494                          if (!tmp_mgcpinfo->fromEndpoint){
 2495                                  if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)){
 2496                                          callsinfo->call_state = VOIP_CANCELLED;
 2497                                  }
 2498                          }
 2499                  }
 2500   
 2501                  if (frame_label == NULL) frame_label = g_strdup(pi->code);
 2502                  break;
 2503          case MGCP_RESPONSE:
 2504                  frame_label = g_strdup_printf("%u (%s)",pi->rspcode, pi->code);
 2505                  break;
 2506          case MGCP_OTHERS:
 2507                  /* XXX what to do? */
 2508                  break;
 2509          }
 2510   
 2511   
 2512          comment = g_strdup_printf("MGCP %s %s%s", tmp_mgcpinfo->endpointId, (pi->mgcp_type == MGCP_REQUEST)?"Request":"Response", pi->is_duplicate?" Duplicate":"");
 2513   
 2514          callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs);
 2515          callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000;
 2516          callsinfo->last_frame_num=pinfo->fd->num;
 2517          ++(callsinfo->npackets);
 2518          /* increment the packets counter of all calls */
 2519          ++(tapinfo->npackets);
 2520   
 2521          /* add to the graph */
 2522          add_to_graph(tapinfo, pinfo, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
 2523          g_free(comment);
 2524          g_free(frame_label);
 2525   
 2526          /* add SDP info if apply */
 2527          if ( (sdp_summary != NULL) && (sdp_frame_num == pinfo->fd->num) ){
 2528                          append_to_frame_graph(tapinfo, pinfo->fd->num, sdp_summary, NULL);
 2529                          g_free(sdp_summary);
 2530                          sdp_summary = NULL;
 2531          }
 2532   
 2533          tapinfo->redraw = TRUE;
 2534   
 2535          return 1;  /* refresh output */
 2536  }
Show more  




Change Warning 4311.30057 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: