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 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 if (options.enable_ice_renomination) { | 40 if (options.enable_ice_renomination) { |
41 desc->AddOption(ICE_RENOMINATION_STR); | 41 desc->AddOption(ICE_RENOMINATION_STR); |
42 } | 42 } |
43 | 43 |
44 // If we are trying to establish a secure transport, add a fingerprint. | 44 // If we are trying to establish a secure transport, add a fingerprint. |
45 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) { | 45 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) { |
46 // Fail if we can't create the fingerprint. | 46 // Fail if we can't create the fingerprint. |
47 // If we are the initiator set role to "actpass". | 47 // If we are the initiator set role to "actpass". |
48 if (!SetSecurityInfo(desc.get(), CONNECTIONROLE_ACTPASS)) { | 48 if (!SetSecurityInfo(desc.get(), CONNECTIONROLE_ACTPASS)) { |
49 return NULL; | 49 return nullptr; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 return desc.release(); | 53 return desc.release(); |
54 } | 54 } |
55 | 55 |
56 TransportDescription* TransportDescriptionFactory::CreateAnswer( | 56 TransportDescription* TransportDescriptionFactory::CreateAnswer( |
57 const TransportDescription* offer, | 57 const TransportDescription* offer, |
58 const TransportOptions& options, | 58 const TransportOptions& options, |
59 const TransportDescription* current_description) const { | 59 const TransportDescription* current_description) const { |
60 // TODO(juberti): Figure out why we get NULL offers, and fix this upstream. | 60 // TODO(juberti): Figure out why we get null offers, and fix this upstream. |
61 if (!offer) { | 61 if (!offer) { |
62 LOG(LS_WARNING) << "Failed to create TransportDescription answer " << | 62 LOG(LS_WARNING) << "Failed to create TransportDescription answer " |
63 "because offer is NULL"; | 63 << "because offer is null"; |
64 return NULL; | 64 return nullptr; |
65 } | 65 } |
66 | 66 |
67 std::unique_ptr<TransportDescription> desc(new TransportDescription()); | 67 std::unique_ptr<TransportDescription> desc(new TransportDescription()); |
68 // Generate the ICE credentials if we don't already have them or ice is | 68 // Generate the ICE credentials if we don't already have them or ice is |
69 // being restarted. | 69 // being restarted. |
70 if (!current_description || options.ice_restart) { | 70 if (!current_description || options.ice_restart) { |
71 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH); | 71 desc->ice_ufrag = rtc::CreateRandomString(ICE_UFRAG_LENGTH); |
72 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH); | 72 desc->ice_pwd = rtc::CreateRandomString(ICE_PWD_LENGTH); |
73 } else { | 73 } else { |
74 desc->ice_ufrag = current_description->ice_ufrag; | 74 desc->ice_ufrag = current_description->ice_ufrag; |
75 desc->ice_pwd = current_description->ice_pwd; | 75 desc->ice_pwd = current_description->ice_pwd; |
76 } | 76 } |
77 if (options.enable_ice_renomination) { | 77 if (options.enable_ice_renomination) { |
78 desc->AddOption(ICE_RENOMINATION_STR); | 78 desc->AddOption(ICE_RENOMINATION_STR); |
79 } | 79 } |
80 | 80 |
81 // Negotiate security params. | 81 // Negotiate security params. |
82 if (offer && offer->identity_fingerprint.get()) { | 82 if (offer && offer->identity_fingerprint.get()) { |
83 // The offer supports DTLS, so answer with DTLS, as long as we support it. | 83 // The offer supports DTLS, so answer with DTLS, as long as we support it. |
84 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) { | 84 if (secure_ == SEC_ENABLED || secure_ == SEC_REQUIRED) { |
85 // Fail if we can't create the fingerprint. | 85 // Fail if we can't create the fingerprint. |
86 // Setting DTLS role to active. | 86 // Setting DTLS role to active. |
87 ConnectionRole role = (options.prefer_passive_role) ? | 87 ConnectionRole role = (options.prefer_passive_role) ? |
88 CONNECTIONROLE_PASSIVE : CONNECTIONROLE_ACTIVE; | 88 CONNECTIONROLE_PASSIVE : CONNECTIONROLE_ACTIVE; |
89 | 89 |
90 if (!SetSecurityInfo(desc.get(), role)) { | 90 if (!SetSecurityInfo(desc.get(), role)) { |
91 return NULL; | 91 return nullptr; |
92 } | 92 } |
93 } | 93 } |
94 } else if (secure_ == SEC_REQUIRED) { | 94 } else if (secure_ == SEC_REQUIRED) { |
95 // We require DTLS, but the other side didn't offer it. Fail. | 95 // We require DTLS, but the other side didn't offer it. Fail. |
96 LOG(LS_WARNING) << "Failed to create TransportDescription answer " | 96 LOG(LS_WARNING) << "Failed to create TransportDescription answer " |
97 "because of incompatible security settings"; | 97 "because of incompatible security settings"; |
98 return NULL; | 98 return nullptr; |
99 } | 99 } |
100 | 100 |
101 return desc.release(); | 101 return desc.release(); |
102 } | 102 } |
103 | 103 |
104 bool TransportDescriptionFactory::SetSecurityInfo( | 104 bool TransportDescriptionFactory::SetSecurityInfo( |
105 TransportDescription* desc, ConnectionRole role) const { | 105 TransportDescription* desc, ConnectionRole role) const { |
106 if (!certificate_) { | 106 if (!certificate_) { |
107 LOG(LS_ERROR) << "Cannot create identity digest with no certificate"; | 107 LOG(LS_ERROR) << "Cannot create identity digest with no certificate"; |
108 return false; | 108 return false; |
(...skipping 21 matching lines...) Expand all Loading... |
130 << digest_alg; | 130 << digest_alg; |
131 return false; | 131 return false; |
132 } | 132 } |
133 | 133 |
134 // Assign security role. | 134 // Assign security role. |
135 desc->connection_role = role; | 135 desc->connection_role = role; |
136 return true; | 136 return true; |
137 } | 137 } |
138 | 138 |
139 } // namespace cricket | 139 } // namespace cricket |
OLD | NEW |