mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
"stun and dtls done"
This commit is contained in:
parent
30d8b2209f
commit
9d5495c0c2
19 changed files with 1220 additions and 160 deletions
|
@ -29,16 +29,81 @@
|
|||
#include <srs_core.hpp>
|
||||
#include <srs_kernel_error.hpp>
|
||||
|
||||
class SrsBuffer;
|
||||
|
||||
enum SrsStunMessageType
|
||||
{
|
||||
// see @ https://tools.ietf.org/html/rfc3489#section-11.1
|
||||
BindingRequest = 0x0001,
|
||||
BindingResponse = 0x0101,
|
||||
BindingErrorResponse = 0x0111,
|
||||
SharedSecretRequest = 0x0002,
|
||||
SharedSecretResponse = 0x0102,
|
||||
SharedSecretErrorResponse = 0x0112,
|
||||
};
|
||||
|
||||
enum SrsStunMessageAttribute
|
||||
{
|
||||
// see @ https://tools.ietf.org/html/rfc3489#section-11.2
|
||||
MappedAddress = 0x0001,
|
||||
ResponseAddress = 0x0002,
|
||||
ChangeRequest = 0x0003,
|
||||
SourceAddress = 0x0004,
|
||||
ChangedAddress = 0x0005,
|
||||
Username = 0x0006,
|
||||
Password = 0x0007,
|
||||
MessageIntegrity = 0x0008,
|
||||
ErrorCode = 0x0009,
|
||||
UnknownAttributes = 0x000A,
|
||||
ReflectedFrom = 0x000B,
|
||||
|
||||
// see @ https://tools.ietf.org/html/rfc5389#section-18.2
|
||||
Realm = 0x0014,
|
||||
Nonce = 0x0015,
|
||||
XorMappedAddress = 0x0020,
|
||||
Software = 0x8022,
|
||||
AlternateServer = 0x8023,
|
||||
Fingerprint = 0x8028,
|
||||
};
|
||||
|
||||
class SrsStunPacket
|
||||
{
|
||||
private:
|
||||
uint16_t message_type;
|
||||
std::string local_ufrag;
|
||||
std::string remote_ufrag;
|
||||
std::string transcation_id;
|
||||
uint32_t mapped_address;
|
||||
uint16_t mapped_port;
|
||||
public:
|
||||
SrsStunPacket();
|
||||
virtual ~SrsStunPacket();
|
||||
|
||||
std::string ufrag();
|
||||
std::string pwd();
|
||||
bool is_binding_request() const { return message_type == BindingRequest; }
|
||||
bool is_binding_response() const { return message_type == BindingResponse; }
|
||||
|
||||
uint16_t get_message_type() const { return message_type; }
|
||||
std::string get_local_ufrag() const { return local_ufrag; }
|
||||
std::string get_remote_ufrag() const { return remote_ufrag; }
|
||||
std::string get_transcation_id() const { return transcation_id; }
|
||||
uint32_t get_mapped_address() const { return mapped_address; }
|
||||
uint16_t get_mapped_port() const { return mapped_port; }
|
||||
|
||||
void set_message_type(const uint16_t& m) { message_type = m; }
|
||||
void set_local_ufrag(const std::string& u) { local_ufrag = u; }
|
||||
void set_remote_ufrag(const std::string& u) { remote_ufrag = u; }
|
||||
void set_transcation_id(const std::string& t) { transcation_id = t; }
|
||||
void set_mapped_address(const uint32_t& addr) { mapped_address = addr; }
|
||||
void set_mapped_port(const uint32_t& port) { mapped_port = port; }
|
||||
|
||||
srs_error_t decode(const char* buf, const int nb_buf);
|
||||
srs_error_t encode(const std::string& pwd, SrsBuffer* stream);
|
||||
private:
|
||||
srs_error_t encode_binding_response(const std::string& pwd, SrsBuffer* stream);
|
||||
std::string encode_username();
|
||||
std::string encode_mapped_address();
|
||||
std::string encode_hmac(char* hamc_buf, const int hmac_buf_len);
|
||||
std::string encode_fingerprint(uint32_t crc32);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue