Changeset 2719
- Timestamp:
- May 20, 2009 5:26:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/sipit24/pjnath/src/pjnath/ice_session.c
r2717 r2719 66 66 }; 67 67 68 typedefenum timer_type68 enum timer_type 69 69 { 70 70 TIMER_NONE, /**< Timer not active */ … … 1099 1099 { 1100 1100 pj_ice_sess *ice = (pj_ice_sess*) te->user_data; 1101 enum timer_t ime type = (enum timer_type)te->id;1101 enum timer_type type = (enum timer_type)te->id; 1102 1102 1103 1103 PJ_UNUSED_ARG(th); … … 1130 1130 ice_keep_alive(ice, PJ_TRUE); 1131 1131 break; 1132 case TIMER_NONE: 1133 /* Nothing to do, just to get rid of gcc warning */ 1134 break; 1132 1135 } 1133 1136 } … … 1226 1229 } 1227 1230 1231 /* Update valid check and nominated check for the candidate */ 1232 static void update_comp_check(pj_ice_sess *ice, unsigned comp_id, 1233 pj_ice_sess_check *check) 1234 { 1235 pj_ice_sess_comp *comp; 1236 1237 comp = find_comp(ice, comp_id); 1238 if (comp->valid_check == NULL) { 1239 comp->valid_check = check; 1240 } else { 1241 if (CMP_CHECK_PRIO(comp->valid_check, check) < 0) 1242 comp->valid_check = check; 1243 } 1244 1245 if (check->nominated) { 1246 /* Update the nominated check for the component */ 1247 if (comp->nominated_check == NULL) { 1248 comp->nominated_check = check; 1249 } else { 1250 if (CMP_CHECK_PRIO(comp->nominated_check, check) < 0) 1251 comp->nominated_check = check; 1252 } 1253 } 1254 } 1228 1255 1229 1256 /* This function is called when one check completes */ … … 1259 1286 check_set_state(ice, c, PJ_ICE_SESS_CHECK_STATE_WAITING, 0); 1260 1287 } 1261 }1262 1263 /* Update valid check */1264 if (comp->valid_check == NULL) {1265 comp->valid_check = check;1266 } else {1267 if (CMP_CHECK_PRIO(comp->valid_check, check) < 0)1268 comp->valid_check = check;1269 1288 } 1270 1289 … … 1334 1353 } 1335 1354 } 1336 1337 /* Update the nominated check for the component */1338 if (comp->nominated_check == NULL) {1339 comp->nominated_check = check;1340 } else {1341 if (CMP_CHECK_PRIO(comp->nominated_check, check) < 0)1342 comp->nominated_check = check;1343 }1344 1355 } 1345 1356 … … 1864 1875 */ 1865 1876 for (i=0; i<ice->comp_cnt; ++i) { 1877 unsigned j; 1878 const pj_ice_sess_check *vc = ice->comp[i].valid_check; 1879 1866 1880 pj_assert(ice->comp[i].nominated_check == NULL); 1867 pj_assert(ice->comp[i].valid_check->err_code == PJ_SUCCESS); 1868 1869 ice->comp[i].valid_check->state = PJ_ICE_SESS_CHECK_STATE_FROZEN; 1870 check_set_state(ice, ice->comp[i].valid_check, 1871 PJ_ICE_SESS_CHECK_STATE_WAITING, PJ_SUCCESS); 1881 pj_assert(vc->err_code == PJ_SUCCESS); 1882 1883 for (j=0; j<ice->clist.count; ++j) { 1884 pj_ice_sess_check *c = &ice->clist.checks[j]; 1885 if (c->lcand->transport_id == vc->lcand->transport_id && 1886 c->rcand == vc->rcand) 1887 { 1888 pj_assert(c->err_code == PJ_SUCCESS); 1889 c->state = PJ_ICE_SESS_CHECK_STATE_FROZEN; 1890 check_set_state(ice, c, PJ_ICE_SESS_CHECK_STATE_WAITING, 1891 PJ_SUCCESS); 1892 break; 1893 } 1894 } 1872 1895 } 1873 1896 1874 1897 /* And (re)start the periodic check */ 1875 1898 if (!ice->clist.timer.id) { 1876 ice->clist.timer.id = PJ_TRUE; 1877 delay.sec = delay.msec = 0; 1878 status = pj_timer_heap_schedule(ice->stun_cfg.timer_heap, 1879 &ice->clist.timer, &delay); 1880 if (status != PJ_SUCCESS) { 1881 ice->clist.timer.id = PJ_FALSE; 1882 } 1899 pj_timer_heap_cancel(ice->stun_cfg.timer_heap, &ice->clist.timer); 1900 ice->clist.timer.id = PJ_FALSE; 1901 } 1902 1903 ice->clist.timer.id = PJ_TRUE; 1904 delay.sec = delay.msec = 0; 1905 status = pj_timer_heap_schedule(ice->stun_cfg.timer_heap, 1906 &ice->clist.timer, &delay); 1907 if (status != PJ_SUCCESS) { 1908 ice->clist.timer.id = PJ_FALSE; 1909 } else { 1910 LOG5((ice->obj_name, "Periodic timer rescheduled..")); 1883 1911 } 1884 1912 … … 2254 2282 */ 2255 2283 2256 /* Add pair to valid list */ 2257 pj_assert(ice->valid_list.count < PJ_ICE_MAX_CHECKS); 2258 new_check = &ice->valid_list.checks[ice->valid_list.count++]; 2259 new_check->lcand = lcand; 2260 new_check->rcand = check->rcand; 2261 new_check->prio = CALC_CHECK_PRIO(ice, lcand, check->rcand); 2262 new_check->state = PJ_ICE_SESS_CHECK_STATE_SUCCEEDED; 2263 new_check->nominated = check->nominated; 2264 new_check->err_code = PJ_SUCCESS; 2284 /* Add pair to valid list, if it's not there, otherwise just update 2285 * nominated flag 2286 */ 2287 for (i=0; i<ice->valid_list.count; ++i) { 2288 if (ice->valid_list.checks[i].lcand == lcand && 2289 ice->valid_list.checks[i].rcand == check->rcand) 2290 break; 2291 } 2292 2293 if (i==ice->valid_list.count) { 2294 pj_assert(ice->valid_list.count < PJ_ICE_MAX_CHECKS); 2295 new_check = &ice->valid_list.checks[ice->valid_list.count++]; 2296 new_check->lcand = lcand; 2297 new_check->rcand = check->rcand; 2298 new_check->prio = CALC_CHECK_PRIO(ice, lcand, check->rcand); 2299 new_check->state = PJ_ICE_SESS_CHECK_STATE_SUCCEEDED; 2300 new_check->nominated = check->nominated; 2301 new_check->err_code = PJ_SUCCESS; 2302 } else { 2303 new_check = &ice->valid_list.checks[i]; 2304 ice->valid_list.checks[i].nominated = check->nominated; 2305 } 2265 2306 2266 2307 /* Sort valid_list */ 2267 2308 sort_checklist(&ice->valid_list); 2268 2309 2310 /* Update valid check and nominated check for the component */ 2311 update_comp_check(ice, new_check->lcand->comp_id, new_check); 2269 2312 2270 2313 /* 7.1.2.2.2. Updating Pair States … … 2634 2677 for (j=0; j<ice->valid_list.count; ++j) { 2635 2678 pj_ice_sess_check *vc = &ice->valid_list.checks[j]; 2636 if (vc->lcand == c->lcand && vc->rcand == c->rcand) { 2679 if (vc->lcand->transport_id == c->lcand->transport_id && 2680 vc->rcand == c->rcand) 2681 { 2682 /* Set nominated flag */ 2637 2683 vc->nominated = PJ_TRUE; 2684 2685 /* Update valid check and nominated check for the component */ 2686 update_comp_check(ice, vc->lcand->comp_id, vc); 2687 2688 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), &ice->valid_list, vc); 2689 LOG5((ice->obj_name, "Valid check %s is nominated", ice->tmp.txt)); 2638 2690 } 2639 2691 }
Note: See TracChangeset
for help on using the changeset viewer.