Ignore:
Timestamp:
Jun 21, 2008 2:13:24 PM (16 years ago)
Author:
bennylp
Message:

Fixed bug in ICE: packet is not sent when ICE is not running (remote has no ice) and TURN is set as default candidate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r2031 r2043  
    122122    pj_stun_sock        *stun_sock;     /**< STUN transport.            */ 
    123123    pj_turn_sock        *turn_sock;     /**< TURN relay transport.      */ 
     124    pj_bool_t            turn_log_off;  /**< TURN loggin off?           */ 
    124125 
    125126    unsigned             cand_cnt;      /**< # of candidates/aliaes.    */ 
     
    663664                      "component %d", i+1)); 
    664665            pj_turn_sock_set_log(comp->turn_sock, 0xFFFF); 
     666            comp->turn_log_off = PJ_FALSE; 
    665667        } 
    666668 
     
    909911    pj_ssize_t pkt_size; 
    910912    pj_ice_strans_comp *comp; 
     913    unsigned def_cand; 
    911914    pj_status_t status; 
    912915 
     
    916919    comp = ice_st->comp[comp_id-1]; 
    917920 
    918     /* If ICE is available, send data with ICE */ 
     921    /* Check that default candidate for the component exists */ 
     922    def_cand = comp->default_cand; 
     923    if (def_cand >= comp->cand_cnt) 
     924        return PJ_EINVALIDOP; 
     925 
     926    /* If ICE is available, send data with ICE, otherwise send with the 
     927     * default candidate selected during initialization. 
     928     */ 
    919929    if (ice_st->ice) { 
    920930        if (comp->turn_sock) { 
     
    927937        return status; 
    928938 
    929     } else if (comp->stun_sock) { 
    930  
    931         pkt_size = data_len; 
    932         status = pj_stun_sock_sendto(comp->stun_sock, NULL, data, data_len, 
    933                                      0, dst_addr, dst_addr_len); 
    934         return (status==PJ_SUCCESS||status==PJ_EPENDING) ? PJ_SUCCESS : status; 
     939    } else if (comp->cand_list[def_cand].status == PJ_SUCCESS) { 
     940 
     941        if (comp->cand_list[def_cand].type == PJ_ICE_CAND_TYPE_RELAYED) { 
     942 
     943            enum { 
     944                msg_disable_ind = 0xFFFF & 
     945                                  ~(PJ_STUN_SESS_LOG_TX_IND| 
     946                                    PJ_STUN_SESS_LOG_RX_IND) 
     947            }; 
     948 
     949            if (!comp->turn_log_off) { 
     950                /* Disable logging for Send/Data indications */ 
     951                PJ_LOG(5,(ice_st->obj_name,  
     952                          "Disabling STUN Indication logging for " 
     953                          "component %d", comp->comp_id)); 
     954                pj_turn_sock_set_log(comp->turn_sock, msg_disable_ind); 
     955                comp->turn_log_off = PJ_TRUE; 
     956            } 
     957 
     958            status = pj_turn_sock_sendto(comp->turn_sock, data, data_len, 
     959                                         dst_addr, dst_addr_len); 
     960            return (status==PJ_SUCCESS||status==PJ_EPENDING) ?  
     961                    PJ_SUCCESS : status; 
     962        } else { 
     963            pkt_size = data_len; 
     964            status = pj_stun_sock_sendto(comp->stun_sock, NULL, data,  
     965                                         data_len, 0, dst_addr, dst_addr_len); 
     966            return (status==PJ_SUCCESS||status==PJ_EPENDING) ?  
     967                    PJ_SUCCESS : status; 
     968        } 
    935969 
    936970    } else 
     
    9931027                        pj_turn_sock_set_log(ice_st->comp[i]->turn_sock, 
    9941028                                             msg_disable_ind); 
     1029                        ice_st->comp[i]->turn_log_off = PJ_TRUE; 
    9951030                    } 
    9961031 
Note: See TracChangeset for help on using the changeset viewer.