Changeset 2054 for pjproject/trunk/pjnath/src/pjnath/ice_session.c
- Timestamp:
- Jun 25, 2008 9:16:46 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r2047 r2054 66 66 }; 67 67 68 /* Default ICE session preferences, according to draft-ice */68 /* Candidate type preference */ 69 69 static pj_uint8_t cand_type_prefs[4] = 70 70 { 71 #if PJ_ICE_CAND_TYPE_PREF_BITS < 8 72 /* Keep it to 2 bits */ 73 3, /**< PJ_ICE_HOST_PREF */ 74 1, /**< PJ_ICE_SRFLX_PREF. */ 75 2, /**< PJ_ICE_PRFLX_PREF */ 76 0 /**< PJ_ICE_RELAYED_PREF */ 77 #else 78 /* Default ICE session preferences, according to draft-ice */ 71 79 126, /**< PJ_ICE_HOST_PREF */ 72 80 100, /**< PJ_ICE_SRFLX_PREF. */ 73 81 110, /**< PJ_ICE_PRFLX_PREF */ 74 82 0 /**< PJ_ICE_RELAYED_PREF */ 83 #endif 75 84 }; 76 85 … … 216 225 const pj_sockaddr *base_addr) 217 226 { 227 #if 0 218 228 char buf[64]; 219 229 pj_uint32_t val; … … 228 238 get_type_prefix(type), val); 229 239 pj_strdup2(pool, foundation, buf); 240 #else 241 /* Much shorter version, valid for candidates added by 242 * pj_ice_strans. 243 */ 244 foundation->ptr = (char*) pj_pool_alloc(pool, 1); 245 *foundation->ptr = (char)get_type_prefix(type); 246 foundation->slen = 1; 247 248 PJ_UNUSED_ARG(base_addr); 249 #endif 230 250 } 231 251 … … 451 471 const pj_uint8_t prefs[4]) 452 472 { 473 unsigned i; 453 474 PJ_ASSERT_RETURN(ice && prefs, PJ_EINVAL); 454 475 ice->prefs = (pj_uint8_t*) pj_pool_calloc(ice->pool, PJ_ARRAY_SIZE(prefs), 455 476 sizeof(pj_uint8_t)); 456 pj_memcpy(ice->prefs, prefs, sizeof(prefs)); 477 for (i=0; i<4; ++i) { 478 pj_assert(prefs[i] < (2 << PJ_ICE_CAND_TYPE_PREF_BITS)); 479 ice->prefs[i] = prefs[i]; 480 } 457 481 return PJ_SUCCESS; 458 482 } … … 579 603 pj_uint32_t comp_id) 580 604 { 605 #if 0 581 606 return ((ice->prefs[type] & 0xFF) << 24) + 582 607 ((local_pref & 0xFFFF) << 8) + 583 608 (((256 - comp_id) & 0xFF) << 0); 609 #else 610 enum { 611 type_mask = ((2 << PJ_ICE_CAND_TYPE_PREF_BITS) - 1), 612 local_mask = ((2 << PJ_ICE_LOCAL_PREF_BITS) - 1), 613 comp_mask = ((2 << PJ_ICE_COMP_BITS) - 1), 614 615 comp_shift = 0, 616 local_shift = (PJ_ICE_COMP_BITS), 617 type_shift = (comp_shift + local_shift), 618 619 max_comp = (2<<PJ_ICE_COMP_BITS), 620 }; 621 622 return ((ice->prefs[type] & type_mask) << type_shift) + 623 ((local_pref & local_mask) << local_shift) + 624 (((max_comp - comp_id) & comp_mask) << comp_shift); 625 #endif 584 626 } 585 627 … … 1430 1472 1431 1473 /* Add PRIORITY */ 1432 prio = CALC_CAND_PRIO(ice, PJ_ICE_CAND_TYPE_PRFLX, 65535,1474 prio = CALC_CAND_PRIO(ice, PJ_ICE_CAND_TYPE_PRFLX, 0, 1433 1475 lcand->comp_id); 1434 1476 pj_stun_msg_add_uint_attr(check->tdata->pool, check->tdata->msg,
Note: See TracChangeset
for help on using the changeset viewer.