Changeset 1141 for pjproject/trunk/pjnath/src/pjnath/ice_session.c
- Timestamp:
- Apr 3, 2007 7:15:10 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r1140 r1141 116 116 pj_status_t status, 117 117 pj_stun_tx_data *tdata, 118 const pj_stun_msg *response); 118 const pj_stun_msg *response, 119 const pj_sockaddr_t *src_addr, 120 unsigned src_addr_len); 119 121 static pj_status_t on_stun_rx_indication(pj_stun_session *sess, 120 122 const pj_uint8_t *pkt, … … 1207 1209 PJ_STUN_ATTR_PRIORITY, prio); 1208 1210 1209 /* Add USE-CANDIDATE and set this check to nominated */ 1211 /* Add USE-CANDIDATE and set this check to nominated. 1212 * Also add ICE-CONTROLLING or ICE-CONTROLLED 1213 */ 1210 1214 if (ice->role == PJ_ICE_SESS_ROLE_CONTROLLING) { 1211 1215 pj_stun_msg_add_empty_attr(check->tdata->pool, check->tdata->msg, 1212 1216 PJ_STUN_ATTR_USE_CANDIDATE); 1213 1217 check->nominated = PJ_TRUE; 1214 } 1218 1219 pj_stun_msg_add_uint64_attr(check->tdata->pool, check->tdata->msg, 1220 PJ_STUN_ATTR_ICE_CONTROLLING, 1221 &ice->tie_breaker); 1222 1223 } else { 1224 pj_stun_msg_add_uint64_attr(check->tdata->pool, check->tdata->msg, 1225 PJ_STUN_ATTR_ICE_CONTROLLED, 1226 &ice->tie_breaker); 1227 } 1228 1215 1229 1216 1230 /* Note that USERNAME and MESSAGE-INTEGRITY will be added by the … … 1429 1443 pj_status_t status, 1430 1444 pj_stun_tx_data *tdata, 1431 const pj_stun_msg *response) 1445 const pj_stun_msg *response, 1446 const pj_sockaddr_t *src_addr, 1447 unsigned src_addr_len) 1432 1448 { 1433 1449 struct req_data *rd = (struct req_data*) tdata->user_data; … … 1441 1457 1442 1458 PJ_UNUSED_ARG(stun_sess); 1459 PJ_UNUSED_ARG(src_addr_len); 1443 1460 1444 1461 ice = rd->ice; … … 1457 1474 lcand = NULL; 1458 1475 1459 LOG4((ice->obj_name,1460 "Check %s%s: connectivity check %s",1461 dump_check(buffer, sizeof(buffer), &ice->clist, check),1462 (check->nominated ? " (nominated)" : " (not nominated)"),1463 (status==PJ_SUCCESS ? "SUCCESS" : "FAILED")));1464 1465 1476 if (status != PJ_SUCCESS) { 1477 char errmsg[PJ_ERR_MSG_SIZE]; 1478 1479 if (status==PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_ROLE_CONFLICT)) { 1480 /* Role conclict response. 1481 * 7.1.2.1. Failure Cases: 1482 * If the request had contained the ICE-CONTROLLED attribute, 1483 * the agent MUST switch to the controlling role if it has not 1484 * already done so. If the request had contained the 1485 * ICE-CONTROLLING attribute, the agent MUST switch to the 1486 * controlled role if it has not already done so. Once it has 1487 * switched, the agent MUST immediately retry the request with 1488 * the ICE-CONTROLLING or ICE-CONTROLLED attribute reflecting 1489 * its new role. 1490 */ 1491 pj_ice_sess_role new_role = PJ_ICE_SESS_ROLE_UNKNOWN; 1492 pj_stun_msg *req = tdata->msg; 1493 1494 if (pj_stun_msg_find_attr(req, PJ_STUN_ATTR_ICE_CONTROLLING, 0)) { 1495 new_role = PJ_ICE_SESS_ROLE_CONTROLLED; 1496 } else if (pj_stun_msg_find_attr(req, PJ_STUN_ATTR_ICE_CONTROLLED, 1497 0)) { 1498 new_role = PJ_ICE_SESS_ROLE_CONTROLLING; 1499 } else { 1500 pj_assert(!"We should have put CONTROLLING/CONTROLLED attr!"); 1501 new_role = PJ_ICE_SESS_ROLE_CONTROLLED; 1502 } 1503 1504 if (new_role != ice->role) { 1505 LOG4((ice->obj_name, 1506 "Changing role because of role conflict")); 1507 pj_ice_sess_change_role(ice, new_role); 1508 } 1509 1510 /* Resend request */ 1511 LOG4((ice->obj_name, "Resending check because of role conflict")); 1512 check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_WAITING, 0); 1513 perform_check(ice, clist, rd->ckid); 1514 pj_mutex_unlock(ice->mutex); 1515 return; 1516 } 1517 1518 pj_strerror(status, errmsg, sizeof(errmsg)); 1519 LOG4((ice->obj_name, 1520 "Check %s%s: connectivity check FAILED: %s", 1521 dump_check(buffer, sizeof(buffer), &ice->clist, check), 1522 (check->nominated ? " (nominated)" : " (not nominated)"), 1523 errmsg)); 1524 1466 1525 check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED, status); 1467 1526 on_check_complete(ice, check); … … 1469 1528 return; 1470 1529 } 1530 1471 1531 1472 1532 /* The agent MUST check that the source IP address and port of the … … 1476 1536 * Request was sent from. 1477 1537 */ 1478 PJ_TODO(ICE_CHECK_RESPONSE_SOURCE_ADDRESS); 1538 if (sockaddr_cmp(&check->rcand->addr, src_addr) != 0) { 1539 status = PJNATH_EICEINSRCADDR; 1540 LOG4((ice->obj_name, 1541 "Check %s%s: connectivity check FAILED: source address mismatch", 1542 dump_check(buffer, sizeof(buffer), &ice->clist, check), 1543 (check->nominated ? " (nominated)" : " (not nominated)"))); 1544 check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED, status); 1545 on_check_complete(ice, check); 1546 pj_mutex_unlock(ice->mutex); 1547 return; 1548 } 1549 1550 LOG4((ice->obj_name, 1551 "Check %s%s: connectivity check SUCCESS", 1552 dump_check(buffer, sizeof(buffer), &ice->clist, check), 1553 (check->nominated ? " (nominated)" : " (not nominated)"))); 1479 1554 1480 1555 /* Get the STUN XOR-MAPPED-ADDRESS attribute. */
Note: See TracChangeset
for help on using the changeset viewer.