Ignore:
Timestamp:
Jun 6, 2008 2:47:10 PM (14 years ago)
Author:
bennylp
Message:

Major major modifications related to ticket #485 (support for TURN-07):

  • Added STUN socket transport pj_stun_sock
  • Integration of TURN-07 to ICE
  • Major refactoring in ICE stream transport to make it simpler
  • Major modification (i.e. API change) in almost everywhere else
  • Much more elaborate STUN, TURN, and ICE tests in pjnath-test
File:
1 edited

Legend:

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

    r1410 r1988  
    3232{ 
    3333    char                 obj_name[PJ_MAX_OBJ_NAME]; 
    34     pj_stun_config      *cfg; 
    3534    pj_stun_tsx_cb       cb; 
    3635    void                *user_data; 
     
    3938 
    4039    pj_bool_t            require_retransmit; 
     40    unsigned             rto_msec; 
    4141    pj_timer_entry       retransmit_timer; 
    4242    unsigned             transmit_count; 
    4343    pj_time_val          retransmit_time; 
     44    pj_timer_heap_t     *timer_heap; 
    4445 
    4546    pj_timer_entry       destroy_timer; 
     
    7172 
    7273    tsx = PJ_POOL_ZALLOC_T(pool, pj_stun_client_tsx); 
    73     tsx->cfg = cfg; 
     74    tsx->rto_msec = cfg->rto_msec; 
     75    tsx->timer_heap = cfg->timer_heap; 
    7476    pj_memcpy(&tsx->cb, cb, sizeof(*cb)); 
    7577 
     
    100102    /* Cancel previously registered timer */ 
    101103    if (tsx->destroy_timer.id != 0) { 
    102         pj_timer_heap_cancel(tsx->cfg->timer_heap, &tsx->destroy_timer); 
     104        pj_timer_heap_cancel(tsx->timer_heap, &tsx->destroy_timer); 
    103105        tsx->destroy_timer.id = 0; 
    104106    } 
     
    106108    /* Stop retransmission, just in case */ 
    107109    if (tsx->retransmit_timer.id != 0) { 
    108         pj_timer_heap_cancel(tsx->cfg->timer_heap, &tsx->retransmit_timer); 
    109         tsx->retransmit_timer.id = 0; 
    110     } 
    111  
    112     status = pj_timer_heap_schedule(tsx->cfg->timer_heap, 
     110        pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 
     111        tsx->retransmit_timer.id = 0; 
     112    } 
     113 
     114    status = pj_timer_heap_schedule(tsx->timer_heap, 
    113115                                    &tsx->destroy_timer, delay); 
    114116    if (status != PJ_SUCCESS) 
     
    116118 
    117119    tsx->destroy_timer.id = TIMER_ACTIVE; 
     120    tsx->cb.on_complete = NULL; 
    118121 
    119122    return PJ_SUCCESS; 
     
    129132 
    130133    if (tsx->retransmit_timer.id != 0) { 
    131         pj_timer_heap_cancel(tsx->cfg->timer_heap, &tsx->retransmit_timer); 
     134        pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 
    132135        tsx->retransmit_timer.id = 0; 
    133136    } 
    134137    if (tsx->destroy_timer.id != 0) { 
    135         pj_timer_heap_cancel(tsx->cfg->timer_heap, &tsx->destroy_timer); 
     138        pj_timer_heap_cancel(tsx->timer_heap, &tsx->destroy_timer); 
    136139        tsx->destroy_timer.id = 0; 
    137140    } 
     
    187190        if (tsx->transmit_count == 0) { 
    188191            tsx->retransmit_time.sec = 0; 
    189             tsx->retransmit_time.msec = tsx->cfg->rto_msec; 
     192            tsx->retransmit_time.msec = tsx->rto_msec; 
    190193 
    191194        } else if (tsx->transmit_count < PJ_STUN_MAX_TRANSMIT_COUNT-1) { 
     
    206209         * cancel transmission). 
    207210         */; 
    208         status = pj_timer_heap_schedule(tsx->cfg->timer_heap,  
     211        status = pj_timer_heap_schedule(tsx->timer_heap,  
    209212                                        &tsx->retransmit_timer, 
    210213                                        &tsx->retransmit_time); 
     
    224227    /* Send message */ 
    225228    status = tsx->cb.on_send_msg(tsx, tsx->last_pkt, tsx->last_pkt_size); 
    226     if (status != PJ_SUCCESS) { 
     229 
     230    if (status == PJNATH_ESTUNDESTROYED) { 
     231        /* We've been destroyed, don't access the object. */ 
     232    } else if (status != PJ_SUCCESS) { 
    227233        if (tsx->retransmit_timer.id != 0) { 
    228             pj_timer_heap_cancel(tsx->cfg->timer_heap,  
     234            pj_timer_heap_cancel(tsx->timer_heap,  
    229235                                 &tsx->retransmit_timer); 
    230236            tsx->retransmit_timer.id = 0; 
     
    280286            } 
    281287        } 
     288        /* We might have been destroyed, don't try to access the object */ 
    282289        return; 
    283290    } 
     
    285292    tsx->retransmit_timer.id = 0; 
    286293    status = tsx_transmit_msg(tsx); 
    287     if (status != PJ_SUCCESS) { 
     294    if (status == PJNATH_ESTUNDESTROYED) { 
     295        /* We've been destroyed, don't try to access the object */ 
     296    } else if (status != PJ_SUCCESS) { 
    288297        tsx->retransmit_timer.id = 0; 
    289298        if (!tsx->complete) { 
     
    293302            } 
    294303        } 
     304        /* We might have been destroyed, don't try to access the object */ 
    295305    } 
    296306} 
     
    306316 
    307317    if (tsx->retransmit_timer.id != 0) { 
    308         pj_timer_heap_cancel(tsx->cfg->timer_heap, &tsx->retransmit_timer); 
     318        pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 
    309319        tsx->retransmit_timer.id = 0; 
    310320    } 
     
    352362     */ 
    353363    if (tsx->retransmit_timer.id) { 
    354         pj_timer_heap_cancel(tsx->cfg->timer_heap, &tsx->retransmit_timer); 
     364        pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 
    355365        tsx->retransmit_timer.id = 0; 
    356366    } 
     
    385395            tsx->cb.on_complete(tsx, status, msg, src_addr, src_addr_len); 
    386396        } 
     397        /* We might have been destroyed, don't try to access the object */ 
    387398    } 
    388399 
Note: See TracChangeset for help on using the changeset viewer.