Ignore:
Timestamp:
Apr 3, 2007 6:01:27 PM (17 years ago)
Author:
bennylp
Message:

Fixed misc bugs with ICE: (1) moved STUN session from candidate to component since it causes STUN response to wrong session, and (2) keep-alive transaction timed-out when ICE is active

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c

    r1126 r1140  
    435435    pj_bool_t remote_is_lite = PJ_FALSE; 
    436436    pj_bool_t ice_mismatch = PJ_FALSE; 
     437    pjmedia_sdp_conn *conn = NULL; 
     438    pj_sockaddr conn_addr; 
     439    pj_bool_t conn_found_in_candidate = PJ_FALSE; 
    437440    const pj_str_t STR_CANDIDATE = {"candidate", 9}; 
    438441    const pj_str_t STR_ICE_LITE = {"ice-lite", 8}; 
     
    445448 
    446449    sdp_med = rem_sdp->media[media_index]; 
     450 
     451    /* Get the SDP connection for the media stream. 
     452     * We'll verify later if the SDP connection address is specified  
     453     * as one of the candidate. 
     454     */ 
     455    conn = sdp_med->conn; 
     456    if (conn == NULL) 
     457        conn = rem_sdp->conn; 
     458 
     459    if (conn == NULL) { 
     460        /* Unable to find SDP connection */ 
     461        return PJMEDIA_SDP_EMISSINGCONN; 
     462    } 
     463 
     464    pj_sockaddr_in_init(&conn_addr.ipv4, &conn->addr,  
     465                        (pj_uint16_t)sdp_med->desc.port); 
    447466 
    448467    /* Find ice-ufrag attribute in session descriptor */ 
     
    481500        attr = sdp_med->attr[i]; 
    482501 
     502        /* Detect if remote is ICE lite */ 
    483503        if (pj_strcmp(&attr->name, &STR_ICE_LITE)==0) { 
    484504            remote_is_lite = PJ_TRUE; 
     
    486506        } 
    487507 
     508        /* Detect if remote has reported ICE mismatch */ 
    488509        if (pj_strcmp(&attr->name, &STR_ICE_MISMATCH)==0) { 
    489510            ice_mismatch = PJ_TRUE; 
     
    494515            continue; 
    495516 
     517        /* Parse candidate */ 
    496518        status = parse_cand(pool, &attr->value, &cand[cand_cnt]); 
    497519        if (status != PJ_SUCCESS) 
    498520            return status; 
    499521 
     522        /* Check if this candidate is equal to the connection line */ 
     523        if (!conn_found_in_candidate && 
     524            pj_memcmp(&conn_addr.ipv4, &cand[cand_cnt].addr.ipv4, 
     525                      sizeof(pj_sockaddr_in))==0) 
     526        { 
     527            conn_found_in_candidate = PJ_TRUE; 
     528        } 
     529 
    500530        cand_cnt++; 
    501531    } 
     
    503533    /* Handle ice-mismatch case */ 
    504534    if (ice_mismatch) { 
    505         set_no_ice(tp_ice, "ice-mismatch detected"); 
     535        set_no_ice(tp_ice, "remote reported ice-mismatch"); 
     536        return PJ_SUCCESS; 
     537    } 
     538 
     539    /* Handle case where SDP connection address is not specified as 
     540     * one of the candidate. 
     541     */ 
     542    if (!conn_found_in_candidate) { 
     543        set_no_ice(tp_ice, "local reported ice-mismatch"); 
    506544        return PJ_SUCCESS; 
    507545    } 
     
    658696    char dst_addr[32]; 
    659697 
     698    pj_gettimeofday(&end_ice); 
     699    PJ_TIME_VAL_SUB(end_ice, tp_ice->start_ice); 
     700 
    660701    if (status != PJ_SUCCESS) { 
    661702        char errmsg[PJ_ERR_MSG_SIZE]; 
    662703        pj_strerror(status, errmsg, sizeof(errmsg)); 
    663         PJ_LOG(1,(ice_st->obj_name, "ICE negotiation failed: %s", errmsg)); 
     704        PJ_LOG(1,(ice_st->obj_name,  
     705                  "ICE negotiation failed after %d:%03ds: %s",  
     706                  (int)end_ice.sec, (int)end_ice.msec, 
     707                  errmsg)); 
    664708        return; 
    665709    } 
    666  
    667     pj_gettimeofday(&end_ice); 
    668     PJ_TIME_VAL_SUB(end_ice, tp_ice->start_ice); 
    669710 
    670711    check = &ice_st->ice->valid_list.checks[0]; 
Note: See TracChangeset for help on using the changeset viewer.