Changeset 1434


Ignore:
Timestamp:
Sep 14, 2007 10:19:47 AM (17 years ago)
Author:
bennylp
Message:

Fixed ticket #372: Handle case where STUN mapped address has changed in ICE (thanks Ravin Suri)

Location:
pjproject/trunk/pjnath
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/include/pjnath/ice_strans.h

    r1242 r1434  
    163163                               pj_status_t status); 
    164164 
     165    /** 
     166     * This callback will be called when ICE transport has detected that 
     167     * the STUN mapped address of a candidate has changed. 
     168     * 
     169     * @param ice_st        The ICE stream transport. 
     170     * @param comp_id       Component ID. 
     171     * @param cand_id       Candidate ID. 
     172     */ 
     173    void    (*on_addr_change)(pj_ice_strans *ice_st,  
     174                              unsigned comp_id,  
     175                              unsigned cand_id); 
     176                               
    165177} pj_ice_strans_cb; 
    166178 
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r1433 r1434  
    583583 
    584584        /* tdata->user_data is NULL for keep-alive */ 
    585         tdata->user_data = NULL; 
     585        //tdata->user_data = NULL; 
     586 
     587        // We need this to support mapped address change 
     588        tdata->user_data = &comp->cand_list[j]; 
     589        ++comp->pending_cnt; 
     590 
    586591 
    587592        /* Send STUN binding request */ 
     
    590595                                          &ice_st->stun_srv,  
    591596                                          sizeof(pj_sockaddr_in), tdata); 
     597        if (status != PJ_SUCCESS) { 
     598            --comp->pending_cnt; 
     599        } 
    592600    } 
    593601 
     
    10861094    pj_stun_mapped_addr_attr *ma; 
    10871095    pj_sockaddr *mapped_addr; 
     1096    char ip[20]; 
    10881097 
    10891098    comp = (pj_ice_strans_comp*) pj_stun_session_get_user_data(sess); 
     
    11291138    } 
    11301139 
     1140    /* Ignore response if it reports the same address */ 
     1141    if (cand->addr.ipv4.sin_addr.s_addr == mapped_addr->ipv4.sin_addr.s_addr && 
     1142        cand->addr.ipv4.sin_port == mapped_addr->ipv4.sin_port) 
     1143    { 
     1144        return; 
     1145    } 
     1146 
     1147    pj_ansi_strcpy(ip, pj_inet_ntoa(comp->local_addr.ipv4.sin_addr)); 
     1148 
    11311149    PJ_LOG(4,(comp->ice_st->obj_name,  
    1132               "STUN mapped address: %s:%d", 
     1150              "STUN mapped address for %s:%d is %s:%d", 
     1151              ip, (int)pj_ntohs(comp->local_addr.ipv4.sin_port), 
    11331152              pj_inet_ntoa(mapped_addr->ipv4.sin_addr), 
    11341153              (int)pj_ntohs(mapped_addr->ipv4.sin_port))); 
     
    11421161    /* We have STUN, so we must start the keep-alive timer */ 
    11431162    start_ka_timer(comp->ice_st); 
    1144 } 
    1145  
     1163 
     1164    /* Notify app that STUN address has changed. */ 
     1165    if (comp->ice_st->cb.on_addr_change) 
     1166        (*comp->ice_st->cb.on_addr_change)(comp->ice_st, comp->comp_id,  
     1167                                           (cand - comp->cand_list)); 
     1168} 
     1169 
Note: See TracChangeset for help on using the changeset viewer.