OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 return; | 1158 return; |
1159 } | 1159 } |
1160 // Notify the port the allocate succeeded, and schedule a refresh request. | 1160 // Notify the port the allocate succeeded, and schedule a refresh request. |
1161 port_->OnAllocateSuccess(relayed_attr->GetAddress(), | 1161 port_->OnAllocateSuccess(relayed_attr->GetAddress(), |
1162 mapped_attr->GetAddress()); | 1162 mapped_attr->GetAddress()); |
1163 port_->ScheduleRefresh(lifetime_attr->value()); | 1163 port_->ScheduleRefresh(lifetime_attr->value()); |
1164 } | 1164 } |
1165 | 1165 |
1166 void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { | 1166 void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { |
1167 // Process error response according to RFC5766, Section 6.4. | 1167 // Process error response according to RFC5766, Section 6.4. |
1168 const StunErrorCodeAttribute* error_code = response->GetErrorCode(); | 1168 int error_code = response->GetErrorCodeValue(); |
1169 | 1169 |
1170 LOG_J(LS_INFO, port_) << "Received TURN allocate error response" | 1170 LOG_J(LS_INFO, port_) << "Received TURN allocate error response" |
1171 << ", id=" << rtc::hex_encode(id()) | 1171 << ", id=" << rtc::hex_encode(id()) |
1172 << ", code=" << error_code->code() | 1172 << ", code=" << error_code << ", rtt=" << Elapsed(); |
1173 << ", rtt=" << Elapsed(); | |
1174 | 1173 |
1175 switch (error_code->code()) { | 1174 switch (error_code) { |
1176 case STUN_ERROR_UNAUTHORIZED: // Unauthrorized. | 1175 case STUN_ERROR_UNAUTHORIZED: // Unauthrorized. |
1177 OnAuthChallenge(response, error_code->code()); | 1176 OnAuthChallenge(response, error_code); |
1178 break; | 1177 break; |
1179 case STUN_ERROR_TRY_ALTERNATE: | 1178 case STUN_ERROR_TRY_ALTERNATE: |
1180 OnTryAlternate(response, error_code->code()); | 1179 OnTryAlternate(response, error_code); |
1181 break; | 1180 break; |
1182 case STUN_ERROR_ALLOCATION_MISMATCH: | 1181 case STUN_ERROR_ALLOCATION_MISMATCH: |
1183 // We must handle this error async because trying to delete the socket in | 1182 // We must handle this error async because trying to delete the socket in |
1184 // OnErrorResponse will cause a deadlock on the socket. | 1183 // OnErrorResponse will cause a deadlock on the socket. |
1185 port_->thread()->Post(RTC_FROM_HERE, port_, | 1184 port_->thread()->Post(RTC_FROM_HERE, port_, |
1186 TurnPort::MSG_ALLOCATE_MISMATCH); | 1185 TurnPort::MSG_ALLOCATE_MISMATCH); |
1187 break; | 1186 break; |
1188 default: | 1187 default: |
1189 LOG_J(LS_WARNING, port_) << "Received TURN allocate error response" | 1188 LOG_J(LS_WARNING, port_) |
1190 << ", id=" << rtc::hex_encode(id()) | 1189 << "Received TURN allocate error response" |
1191 << ", code=" << error_code->code() | 1190 << ", id=" << rtc::hex_encode(id()) << ", code=" << error_code |
1192 << ", rtt=" << Elapsed(); | 1191 << ", rtt=" << Elapsed(); |
1193 port_->OnAllocateError(); | 1192 port_->OnAllocateError(); |
1194 } | 1193 } |
1195 } | 1194 } |
1196 | 1195 |
1197 void TurnAllocateRequest::OnTimeout() { | 1196 void TurnAllocateRequest::OnTimeout() { |
1198 LOG_J(LS_WARNING, port_) << "TURN allocate request " | 1197 LOG_J(LS_WARNING, port_) << "TURN allocate request " |
1199 << rtc::hex_encode(id()) << " timeout"; | 1198 << rtc::hex_encode(id()) << " timeout"; |
1200 port_->OnAllocateRequestTimeout(); | 1199 port_->OnAllocateRequestTimeout(); |
1201 } | 1200 } |
1202 | 1201 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 << "refresh success response."; | 1313 << "refresh success response."; |
1315 return; | 1314 return; |
1316 } | 1315 } |
1317 | 1316 |
1318 // Schedule a refresh based on the returned lifetime value. | 1317 // Schedule a refresh based on the returned lifetime value. |
1319 port_->ScheduleRefresh(lifetime_attr->value()); | 1318 port_->ScheduleRefresh(lifetime_attr->value()); |
1320 port_->SignalTurnRefreshResult(port_, TURN_SUCCESS_RESULT_CODE); | 1319 port_->SignalTurnRefreshResult(port_, TURN_SUCCESS_RESULT_CODE); |
1321 } | 1320 } |
1322 | 1321 |
1323 void TurnRefreshRequest::OnErrorResponse(StunMessage* response) { | 1322 void TurnRefreshRequest::OnErrorResponse(StunMessage* response) { |
1324 const StunErrorCodeAttribute* error_code = response->GetErrorCode(); | 1323 int error_code = response->GetErrorCodeValue(); |
1325 | 1324 |
1326 if (error_code->code() == STUN_ERROR_STALE_NONCE) { | 1325 if (error_code == STUN_ERROR_STALE_NONCE) { |
1327 if (port_->UpdateNonce(response)) { | 1326 if (port_->UpdateNonce(response)) { |
1328 // Send RefreshRequest immediately. | 1327 // Send RefreshRequest immediately. |
1329 port_->SendRequest(new TurnRefreshRequest(port_), 0); | 1328 port_->SendRequest(new TurnRefreshRequest(port_), 0); |
1330 } | 1329 } |
1331 } else { | 1330 } else { |
1332 LOG_J(LS_WARNING, port_) << "Received TURN refresh error response" | 1331 LOG_J(LS_WARNING, port_) |
1333 << ", id=" << rtc::hex_encode(id()) | 1332 << "Received TURN refresh error response" |
1334 << ", code=" << error_code->code() | 1333 << ", id=" << rtc::hex_encode(id()) << ", code=" << error_code |
1335 << ", rtt=" << Elapsed(); | 1334 << ", rtt=" << Elapsed(); |
1336 port_->OnRefreshError(); | 1335 port_->OnRefreshError(); |
1337 port_->SignalTurnRefreshResult(port_, error_code->code()); | 1336 port_->SignalTurnRefreshResult(port_, error_code); |
1338 } | 1337 } |
1339 } | 1338 } |
1340 | 1339 |
1341 void TurnRefreshRequest::OnTimeout() { | 1340 void TurnRefreshRequest::OnTimeout() { |
1342 LOG_J(LS_WARNING, port_) << "TURN refresh timeout " << rtc::hex_encode(id()); | 1341 LOG_J(LS_WARNING, port_) << "TURN refresh timeout " << rtc::hex_encode(id()); |
1343 port_->OnRefreshError(); | 1342 port_->OnRefreshError(); |
1344 } | 1343 } |
1345 | 1344 |
1346 TurnCreatePermissionRequest::TurnCreatePermissionRequest( | 1345 TurnCreatePermissionRequest::TurnCreatePermissionRequest( |
1347 TurnPort* port, TurnEntry* entry, | 1346 TurnPort* port, TurnEntry* entry, |
(...skipping 25 matching lines...) Expand all Loading... |
1373 << ", id=" << rtc::hex_encode(id()) | 1372 << ", id=" << rtc::hex_encode(id()) |
1374 << ", code=0" // Makes logging easier to parse. | 1373 << ", code=0" // Makes logging easier to parse. |
1375 << ", rtt=" << Elapsed(); | 1374 << ", rtt=" << Elapsed(); |
1376 | 1375 |
1377 if (entry_) { | 1376 if (entry_) { |
1378 entry_->OnCreatePermissionSuccess(); | 1377 entry_->OnCreatePermissionSuccess(); |
1379 } | 1378 } |
1380 } | 1379 } |
1381 | 1380 |
1382 void TurnCreatePermissionRequest::OnErrorResponse(StunMessage* response) { | 1381 void TurnCreatePermissionRequest::OnErrorResponse(StunMessage* response) { |
1383 const StunErrorCodeAttribute* error_code = response->GetErrorCode(); | 1382 int error_code = response->GetErrorCodeValue(); |
1384 LOG_J(LS_WARNING, port_) << "Received TURN create permission error response" | 1383 LOG_J(LS_WARNING, port_) << "Received TURN create permission error response" |
1385 << ", id=" << rtc::hex_encode(id()) | 1384 << ", id=" << rtc::hex_encode(id()) |
1386 << ", code=" << error_code->code() | 1385 << ", code=" << error_code << ", rtt=" << Elapsed(); |
1387 << ", rtt=" << Elapsed(); | |
1388 if (entry_) { | 1386 if (entry_) { |
1389 entry_->OnCreatePermissionError(response, error_code->code()); | 1387 entry_->OnCreatePermissionError(response, error_code); |
1390 } | 1388 } |
1391 } | 1389 } |
1392 | 1390 |
1393 void TurnCreatePermissionRequest::OnTimeout() { | 1391 void TurnCreatePermissionRequest::OnTimeout() { |
1394 LOG_J(LS_WARNING, port_) << "TURN create permission timeout " | 1392 LOG_J(LS_WARNING, port_) << "TURN create permission timeout " |
1395 << rtc::hex_encode(id()); | 1393 << rtc::hex_encode(id()); |
1396 if (entry_) { | 1394 if (entry_) { |
1397 entry_->OnCreatePermissionTimeout(); | 1395 entry_->OnCreatePermissionTimeout(); |
1398 } | 1396 } |
1399 } | 1397 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 // threshold. The channel binding has a longer lifetime, but | 1441 // threshold. The channel binding has a longer lifetime, but |
1444 // this is the easiest way to keep both the channel and the | 1442 // this is the easiest way to keep both the channel and the |
1445 // permission from expiring. | 1443 // permission from expiring. |
1446 int delay = TURN_PERMISSION_TIMEOUT - 60000; | 1444 int delay = TURN_PERMISSION_TIMEOUT - 60000; |
1447 entry_->SendChannelBindRequest(delay); | 1445 entry_->SendChannelBindRequest(delay); |
1448 LOG_J(LS_INFO, port_) << "Scheduled channel bind in " << delay << "ms."; | 1446 LOG_J(LS_INFO, port_) << "Scheduled channel bind in " << delay << "ms."; |
1449 } | 1447 } |
1450 } | 1448 } |
1451 | 1449 |
1452 void TurnChannelBindRequest::OnErrorResponse(StunMessage* response) { | 1450 void TurnChannelBindRequest::OnErrorResponse(StunMessage* response) { |
1453 const StunErrorCodeAttribute* error_code = response->GetErrorCode(); | 1451 int error_code = response->GetErrorCodeValue(); |
1454 LOG_J(LS_WARNING, port_) << "Received TURN channel bind error response" | 1452 LOG_J(LS_WARNING, port_) << "Received TURN channel bind error response" |
1455 << ", id=" << rtc::hex_encode(id()) | 1453 << ", id=" << rtc::hex_encode(id()) |
1456 << ", code=" << error_code->code() | 1454 << ", code=" << error_code << ", rtt=" << Elapsed(); |
1457 << ", rtt=" << Elapsed(); | |
1458 if (entry_) { | 1455 if (entry_) { |
1459 entry_->OnChannelBindError(response, error_code->code()); | 1456 entry_->OnChannelBindError(response, error_code); |
1460 } | 1457 } |
1461 } | 1458 } |
1462 | 1459 |
1463 void TurnChannelBindRequest::OnTimeout() { | 1460 void TurnChannelBindRequest::OnTimeout() { |
1464 LOG_J(LS_WARNING, port_) << "TURN channel bind timeout " | 1461 LOG_J(LS_WARNING, port_) << "TURN channel bind timeout " |
1465 << rtc::hex_encode(id()); | 1462 << rtc::hex_encode(id()); |
1466 if (entry_) { | 1463 if (entry_) { |
1467 entry_->OnChannelBindTimeout(); | 1464 entry_->OnChannelBindTimeout(); |
1468 } | 1465 } |
1469 } | 1466 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 } else { | 1578 } else { |
1582 state_ = STATE_UNBOUND; | 1579 state_ = STATE_UNBOUND; |
1583 port_->FailAndPruneConnection(ext_addr_); | 1580 port_->FailAndPruneConnection(ext_addr_); |
1584 } | 1581 } |
1585 } | 1582 } |
1586 void TurnEntry::OnChannelBindTimeout() { | 1583 void TurnEntry::OnChannelBindTimeout() { |
1587 state_ = STATE_UNBOUND; | 1584 state_ = STATE_UNBOUND; |
1588 port_->FailAndPruneConnection(ext_addr_); | 1585 port_->FailAndPruneConnection(ext_addr_); |
1589 } | 1586 } |
1590 } // namespace cricket | 1587 } // namespace cricket |
OLD | NEW |