| 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 |
| 11 #ifndef WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ | 11 #ifndef WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ |
| 12 #define WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ | 12 #define WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ |
| 13 | 13 |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/p2p/base/candidate.h" | |
| 19 #include "webrtc/p2p/base/constants.h" | 18 #include "webrtc/p2p/base/constants.h" |
| 20 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
| 21 #include "webrtc/base/sslfingerprint.h" | 20 #include "webrtc/base/sslfingerprint.h" |
| 22 | 21 |
| 23 namespace cricket { | 22 namespace cricket { |
| 24 | 23 |
| 25 // SEC_ENABLED and SEC_REQUIRED should only be used if the session | 24 // SEC_ENABLED and SEC_REQUIRED should only be used if the session |
| 26 // was negotiated over TLS, to protect the inline crypto material | 25 // was negotiated over TLS, to protect the inline crypto material |
| 27 // exchange. | 26 // exchange. |
| 28 // SEC_DISABLED: No crypto in outgoing offer, ignore any supplied crypto. | 27 // SEC_DISABLED: No crypto in outgoing offer, ignore any supplied crypto. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 }; | 61 }; |
| 63 | 62 |
| 64 extern const char CONNECTIONROLE_ACTIVE_STR[]; | 63 extern const char CONNECTIONROLE_ACTIVE_STR[]; |
| 65 extern const char CONNECTIONROLE_PASSIVE_STR[]; | 64 extern const char CONNECTIONROLE_PASSIVE_STR[]; |
| 66 extern const char CONNECTIONROLE_ACTPASS_STR[]; | 65 extern const char CONNECTIONROLE_ACTPASS_STR[]; |
| 67 extern const char CONNECTIONROLE_HOLDCONN_STR[]; | 66 extern const char CONNECTIONROLE_HOLDCONN_STR[]; |
| 68 | 67 |
| 69 bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role); | 68 bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role); |
| 70 bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str); | 69 bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str); |
| 71 | 70 |
| 72 typedef std::vector<Candidate> Candidates; | |
| 73 | |
| 74 struct TransportDescription { | 71 struct TransportDescription { |
| 75 TransportDescription() | 72 TransportDescription() |
| 76 : ice_mode(ICEMODE_FULL), | 73 : ice_mode(ICEMODE_FULL), |
| 77 connection_role(CONNECTIONROLE_NONE) {} | 74 connection_role(CONNECTIONROLE_NONE) {} |
| 78 | 75 |
| 79 TransportDescription(const std::vector<std::string>& transport_options, | 76 TransportDescription(const std::vector<std::string>& transport_options, |
| 80 const std::string& ice_ufrag, | 77 const std::string& ice_ufrag, |
| 81 const std::string& ice_pwd, | 78 const std::string& ice_pwd, |
| 82 IceMode ice_mode, | 79 IceMode ice_mode, |
| 83 ConnectionRole role, | 80 ConnectionRole role, |
| 84 const rtc::SSLFingerprint* identity_fingerprint, | 81 const rtc::SSLFingerprint* identity_fingerprint) |
| 85 const Candidates& candidates) | |
| 86 : transport_options(transport_options), | 82 : transport_options(transport_options), |
| 87 ice_ufrag(ice_ufrag), | 83 ice_ufrag(ice_ufrag), |
| 88 ice_pwd(ice_pwd), | 84 ice_pwd(ice_pwd), |
| 89 ice_mode(ice_mode), | 85 ice_mode(ice_mode), |
| 90 connection_role(role), | 86 connection_role(role), |
| 91 identity_fingerprint(CopyFingerprint(identity_fingerprint)), | 87 identity_fingerprint(CopyFingerprint(identity_fingerprint)) {} |
| 92 candidates(candidates) {} | |
| 93 TransportDescription(const std::string& ice_ufrag, | 88 TransportDescription(const std::string& ice_ufrag, |
| 94 const std::string& ice_pwd) | 89 const std::string& ice_pwd) |
| 95 : ice_ufrag(ice_ufrag), | 90 : ice_ufrag(ice_ufrag), |
| 96 ice_pwd(ice_pwd), | 91 ice_pwd(ice_pwd), |
| 97 ice_mode(ICEMODE_FULL), | 92 ice_mode(ICEMODE_FULL), |
| 98 connection_role(CONNECTIONROLE_NONE) {} | 93 connection_role(CONNECTIONROLE_NONE) {} |
| 99 TransportDescription(const TransportDescription& from) | 94 TransportDescription(const TransportDescription& from) |
| 100 : transport_options(from.transport_options), | 95 : transport_options(from.transport_options), |
| 101 ice_ufrag(from.ice_ufrag), | 96 ice_ufrag(from.ice_ufrag), |
| 102 ice_pwd(from.ice_pwd), | 97 ice_pwd(from.ice_pwd), |
| 103 ice_mode(from.ice_mode), | 98 ice_mode(from.ice_mode), |
| 104 connection_role(from.connection_role), | 99 connection_role(from.connection_role), |
| 105 identity_fingerprint(CopyFingerprint(from.identity_fingerprint.get())), | 100 identity_fingerprint(CopyFingerprint(from.identity_fingerprint.get())) { |
| 106 candidates(from.candidates) {} | 101 } |
| 107 | 102 |
| 108 TransportDescription& operator=(const TransportDescription& from) { | 103 TransportDescription& operator=(const TransportDescription& from) { |
| 109 // Self-assignment | 104 // Self-assignment |
| 110 if (this == &from) | 105 if (this == &from) |
| 111 return *this; | 106 return *this; |
| 112 | 107 |
| 113 transport_options = from.transport_options; | 108 transport_options = from.transport_options; |
| 114 ice_ufrag = from.ice_ufrag; | 109 ice_ufrag = from.ice_ufrag; |
| 115 ice_pwd = from.ice_pwd; | 110 ice_pwd = from.ice_pwd; |
| 116 ice_mode = from.ice_mode; | 111 ice_mode = from.ice_mode; |
| 117 connection_role = from.connection_role; | 112 connection_role = from.connection_role; |
| 118 | 113 |
| 119 identity_fingerprint.reset(CopyFingerprint( | 114 identity_fingerprint.reset(CopyFingerprint( |
| 120 from.identity_fingerprint.get())); | 115 from.identity_fingerprint.get())); |
| 121 candidates = from.candidates; | |
| 122 return *this; | 116 return *this; |
| 123 } | 117 } |
| 124 | 118 |
| 125 bool HasOption(const std::string& option) const { | 119 bool HasOption(const std::string& option) const { |
| 126 return (std::find(transport_options.begin(), transport_options.end(), | 120 return (std::find(transport_options.begin(), transport_options.end(), |
| 127 option) != transport_options.end()); | 121 option) != transport_options.end()); |
| 128 } | 122 } |
| 129 void AddOption(const std::string& option) { | 123 void AddOption(const std::string& option) { |
| 130 transport_options.push_back(option); | 124 transport_options.push_back(option); |
| 131 } | 125 } |
| 132 bool secure() const { return identity_fingerprint != NULL; } | 126 bool secure() const { return identity_fingerprint != NULL; } |
| 133 | 127 |
| 134 static rtc::SSLFingerprint* CopyFingerprint( | 128 static rtc::SSLFingerprint* CopyFingerprint( |
| 135 const rtc::SSLFingerprint* from) { | 129 const rtc::SSLFingerprint* from) { |
| 136 if (!from) | 130 if (!from) |
| 137 return NULL; | 131 return NULL; |
| 138 | 132 |
| 139 return new rtc::SSLFingerprint(*from); | 133 return new rtc::SSLFingerprint(*from); |
| 140 } | 134 } |
| 141 | 135 |
| 142 std::vector<std::string> transport_options; | 136 std::vector<std::string> transport_options; |
| 143 std::string ice_ufrag; | 137 std::string ice_ufrag; |
| 144 std::string ice_pwd; | 138 std::string ice_pwd; |
| 145 IceMode ice_mode; | 139 IceMode ice_mode; |
| 146 ConnectionRole connection_role; | 140 ConnectionRole connection_role; |
| 147 | 141 |
| 148 rtc::scoped_ptr<rtc::SSLFingerprint> identity_fingerprint; | 142 rtc::scoped_ptr<rtc::SSLFingerprint> identity_fingerprint; |
| 149 Candidates candidates; | |
| 150 }; | 143 }; |
| 151 | 144 |
| 152 } // namespace cricket | 145 } // namespace cricket |
| 153 | 146 |
| 154 #endif // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ | 147 #endif // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ |
| OLD | NEW |