- Timestamp:
- May 19, 2009 2:25:41 PM (16 years ago)
- Location:
- pjproject/branches/projects/sipit24/pjnath
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/sipit24/pjnath/include/pjnath/config.h
r2714 r2717 370 370 /** 371 371 * Minimum interval value to be used for sending STUN keep-alive on the ICE 372 * s tream transport, in seconds. This minimum interval, plus a random value373 * which maximum is PJ_ICE_S T_KEEP_ALIVE_MAX_RAND, specify the actual interval372 * session, in seconds. This minimum interval, plus a random value 373 * which maximum is PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND, specify the actual interval 374 374 * of the STUN keep-alive. 375 375 * 376 * Default: 20 seconds 377 * 378 * @see PJ_ICE_ST_KEEP_ALIVE_MAX_RAND 379 */ 380 #ifndef PJ_ICE_ST_KEEP_ALIVE_MIN 381 # define PJ_ICE_ST_KEEP_ALIVE_MIN 20 382 #endif 383 376 * Default: 15 seconds 377 * 378 * @see PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND 379 */ 380 #ifndef PJ_ICE_SESS_KEEP_ALIVE_MIN 381 # define PJ_ICE_SESS_KEEP_ALIVE_MIN 20 382 #endif 383 384 /* Warn about deprecated macro */ 385 #ifdef PJ_ICE_ST_KEEP_ALIVE_MIN 386 # error PJ_ICE_ST_KEEP_ALIVE_MIN is deprecated 387 #endif 384 388 385 389 /** 386 390 * To prevent STUN keep-alives to be sent simultaneously, application should 387 * add random interval to minimum interval (PJ_ICE_S T_KEEP_ALIVE_MIN). This391 * add random interval to minimum interval (PJ_ICE_SESS_KEEP_ALIVE_MIN). This 388 392 * setting specifies the maximum random value to be added to the minimum 389 393 * interval, in seconds. … … 391 395 * Default: 5 seconds 392 396 * 393 * @see PJ_ICE_ST_KEEP_ALIVE_MIN 394 */ 395 #ifndef PJ_ICE_ST_KEEP_ALIVE_MAX_RAND 396 # define PJ_ICE_ST_KEEP_ALIVE_MAX_RAND 5 397 * @see PJ_ICE_SESS_KEEP_ALIVE_MIN 398 */ 399 #ifndef PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND 400 # define PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND 5 401 #endif 402 403 /* Warn about deprecated macro */ 404 #ifdef PJ_ICE_ST_KEEP_ALIVE_MAX_RAND 405 # error PJ_ICE_ST_KEEP_ALIVE_MAX_RAND is deprecated 397 406 #endif 398 407 -
pjproject/branches/projects/sipit24/pjnath/include/pjnath/ice_session.h
r2705 r2717 637 637 unsigned comp_cnt; /**< # of components. */ 638 638 pj_ice_sess_comp comp[PJ_ICE_MAX_COMP]; /**< Component array */ 639 unsigned comp_ka; /**< Next comp for KA */ 639 640 640 641 /* Local candidates */ -
pjproject/branches/projects/sipit24/pjnath/include/pjnath/stun_msg.h
r2642 r2717 198 198 PJ_STUN_BINDING_ERROR_RESPONSE = 0x0111, 199 199 200 /** 201 * Binding Indication (ICE) 202 */ 203 PJ_STUN_BINDING_INDICATION = 0x0011, 200 204 201 205 /** -
pjproject/branches/projects/sipit24/pjnath/include/pjnath/stun_session.h
r2642 r2717 486 486 PJ_DECL(void) pj_stun_session_set_log(pj_stun_session *sess, 487 487 unsigned flags); 488 /** 489 * Configure whether the STUN session should utilize FINGERPRINT in 490 * outgoing messages. 491 * 492 * @param sess The STUN session instance. 493 * @param use Boolean for the setting. 494 * 495 * @return The previous configured value of FINGERPRINT 496 * utilization of the sessoin. 497 */ 498 PJ_DECL(pj_bool_t) pj_stun_session_use_fingerprint(pj_stun_session *sess, 499 pj_bool_t use); 488 500 489 501 /** -
pjproject/branches/projects/sipit24/pjnath/src/pjnath/ice_session.c
r2714 r2717 76 76 TIMER_START_NOMINATED_CHECK,/**< Controlling agent start connectivity 77 77 checks with USE-CANDIDATE flag. */ 78 78 TIMER_KEEP_ALIVE /**< ICE keep-alive timer. */ 79 79 80 80 }; … … 134 134 static void on_timer(pj_timer_heap_t *th, pj_timer_entry *te); 135 135 static void on_ice_complete(pj_ice_sess *ice, pj_status_t status); 136 static void ice_keep_alive(pj_ice_sess *ice, pj_bool_t send_now); 136 137 static void destroy_ice(pj_ice_sess *ice, 137 138 pj_status_t reason); … … 1112 1113 break; 1113 1114 case TIMER_COMPLETION_CALLBACK: 1115 /* Start keep-alive timer but don't send any packets yet. 1116 * Need to do it here just in case app destroy the session 1117 * in the callback. 1118 */ 1119 if (ice->ice_status == PJ_SUCCESS) 1120 ice_keep_alive(ice, PJ_FALSE); 1121 1122 /* Notify app about ICE completion*/ 1114 1123 if (ice->cb.on_ice_complete) 1115 1124 (*ice->cb.on_ice_complete)(ice, ice->ice_status); … … 1118 1127 start_nominated_check(ice); 1119 1128 break; 1129 case TIMER_KEEP_ALIVE: 1130 ice_keep_alive(ice, PJ_TRUE); 1131 break; 1132 } 1133 } 1134 1135 /* Send keep-alive */ 1136 static void ice_keep_alive(pj_ice_sess *ice, pj_bool_t send_now) 1137 { 1138 if (send_now) { 1139 /* Send Binding Indication for the component */ 1140 pj_ice_sess_comp *comp = &ice->comp[ice->comp_ka]; 1141 pj_stun_tx_data *tdata; 1142 pj_ice_sess_check *the_check; 1143 pj_ice_msg_data *msg_data; 1144 int addr_len; 1145 pj_bool_t saved; 1146 pj_status_t status; 1147 1148 /* Must have nominated check by now */ 1149 pj_assert(comp->nominated_check != NULL); 1150 the_check = comp->nominated_check; 1151 1152 /* Create the Binding Indication */ 1153 status = pj_stun_session_create_ind(comp->stun_sess, 1154 PJ_STUN_BINDING_INDICATION, 1155 &tdata); 1156 if (status != PJ_SUCCESS) 1157 goto done; 1158 1159 /* Need the transport_id */ 1160 msg_data = PJ_POOL_ZALLOC_T(tdata->pool, pj_ice_msg_data); 1161 msg_data->transport_id = the_check->lcand->transport_id; 1162 1163 /* Temporarily disable FINGERPRINT. The Binding Indication 1164 * SHOULD NOT contain any attributes. 1165 */ 1166 saved = pj_stun_session_use_fingerprint(comp->stun_sess, PJ_FALSE); 1167 1168 /* Send to session */ 1169 addr_len = pj_sockaddr_get_len(&the_check->rcand->addr); 1170 status = pj_stun_session_send_msg(comp->stun_sess, msg_data, 1171 PJ_FALSE, PJ_FALSE, 1172 &the_check->rcand->addr, 1173 addr_len, tdata); 1174 1175 /* Restore FINGERPRINT usage */ 1176 pj_stun_session_use_fingerprint(comp->stun_sess, saved); 1177 1178 done: 1179 ice->comp_ka = (ice->comp_ka + 1) % ice->comp_cnt; 1180 } 1181 1182 if (ice->timer.id == TIMER_NONE) { 1183 pj_time_val delay = { 0, 0 }; 1184 1185 delay.msec = (PJ_ICE_SESS_KEEP_ALIVE_MIN + 1186 (pj_rand() % PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND)) * 1000 / 1187 ice->comp_cnt; 1188 pj_time_val_normalize(&delay); 1189 1190 ice->timer.id = TIMER_KEEP_ALIVE; 1191 pj_timer_heap_schedule(ice->stun_cfg.timer_heap, &ice->timer, &delay); 1192 1193 } else { 1194 pj_assert(!"Not expected any timer active"); 1120 1195 } 1121 1196 } … … 2614 2689 unsigned src_addr_len) 2615 2690 { 2691 struct stun_data *sd; 2692 2616 2693 PJ_UNUSED_ARG(sess); 2617 2694 PJ_UNUSED_ARG(pkt); … … 2622 2699 PJ_UNUSED_ARG(src_addr_len); 2623 2700 2624 PJ_TODO(SUPPORT_RX_BIND_REQUEST_AS_INDICATION); 2625 2626 return PJ_ENOTSUP; 2701 sd = (struct stun_data*) pj_stun_session_get_user_data(sess); 2702 2703 if (msg->hdr.type == PJ_STUN_BINDING_INDICATION) { 2704 LOG5((sd->ice->obj_name, "Received Binding Indication keep-alive " 2705 "for component %d", sd->comp_id)); 2706 } else { 2707 LOG4((sd->ice->obj_name, "Received unexpected %s indication " 2708 "for component %d", pj_stun_get_method_name(msg->hdr.type), 2709 sd->comp_id)); 2710 } 2711 2712 return PJ_SUCCESS; 2627 2713 } 2628 2714 -
pjproject/branches/projects/sipit24/pjnath/src/pjnath/stun_session.c
r2712 r2717 636 636 } 637 637 638 PJ_DEF(pj_bool_t) pj_stun_session_use_fingerprint(pj_stun_session *sess, 639 pj_bool_t use) 640 { 641 pj_bool_t old_use; 642 643 PJ_ASSERT_RETURN(sess, PJ_FALSE); 644 645 old_use = sess->use_fingerprint; 646 sess->use_fingerprint = use; 647 return old_use; 648 } 649 638 650 static pj_status_t get_auth(pj_stun_session *sess, 639 651 pj_stun_tx_data *tdata)
Note: See TracChangeset
for help on using the changeset viewer.