8 #ifdef OPENDDS_SECURITY 14 #include "dds/DCPS/RTPS/RtpsCoreC.h" 34 return static_cast<ACE_UINT16
>(
username.size());
40 return static_cast<ACE_UINT16
>(4 +
error.
reason.size());
167 std::memcpy(attribute.
guid_prefix, guid_prefix,
sizeof(guid_prefix));
181 ACE_UINT16 attribute_type;
182 ACE_UINT16 attribute_length;
184 if (!(serializer >> attribute_type)) {
188 if (!(serializer >> attribute_length)) {
192 switch (attribute_type) {
197 if (!serializer.
skip(1)) {
201 if (!(serializer >> family)) {
205 if (!(serializer >> port)) {
209 if (family ==
IPv4) {
210 if (attribute_length != 8) {
216 if (!(serializer >> address)) {
221 }
else if (family ==
IPv6) {
222 if (attribute_length != 20) {
233 addr.
set_address(reinterpret_cast<const char*>(address), 16, 0);
242 if (attribute_length > 512) {
246 unsigned char buffer[512];
268 if (!(serializer >> x)) {
272 ACE_UINT32 class_ = (x & (0x7 << 8)) >> 8;
274 if (class_ < 3 || class_ >= 7) {
278 ACE_UINT32 num = x & 0xFF;
284 ACE_UINT16
code = class_ * 100 + num;
288 if (reason_length > 763) {
292 unsigned char buffer[763];
305 for (
size_t count = attribute_length / 2; count != 0; --count) {
308 if (!(serializer >> code)) {
312 unknown_attributes.push_back(static_cast<AttributeType>(code));
323 if (!serializer.
skip(1)) {
327 if (!(serializer >> family)) {
331 if (!(serializer >> port)) {
337 if (family ==
IPv4) {
338 if (attribute_length != 8) {
344 if (!(serializer >> address)) {
350 }
else if (family ==
IPv6) {
351 if (attribute_length != 20) {
365 address[4] ^= holder.
tid.
data[0];
366 address[5] ^= holder.
tid.
data[1];
367 address[6] ^= holder.
tid.
data[2];
368 address[7] ^= holder.
tid.
data[3];
369 address[8] ^= holder.
tid.
data[4];
370 address[9] ^= holder.
tid.
data[5];
371 address[10] ^= holder.
tid.
data[6];
372 address[11] ^= holder.
tid.
data[7];
373 address[12] ^= holder.
tid.
data[8];
374 address[13] ^= holder.
tid.
data[9];
375 address[14] ^= holder.
tid.
data[10];
376 address[15] ^= holder.
tid.
data[11];
380 addr.
set_address(reinterpret_cast<const char*>(address), 16, 0);
391 if (!(serializer >> priority)) {
415 if (!(serializer >> ice_tie_breaker)) {
426 if (!(serializer >> ice_tie_breaker)) {
445 if (!serializer.
skip(attribute_length)) {
455 if (!serializer.
skip((4 - (attribute_length & 0x3)) % 4)) {
466 serializer << attribute_type;
467 serializer << attribute_length;
469 switch (attribute_type) {
471 serializer << static_cast<ACE_CDR::Char>(0);
473 serializer << static_cast<ACE_CDR::Char>(
IPv4);
477 serializer << static_cast<ACE_CDR::Char>(
IPv6);
500 serializer << static_cast<ACE_CDR::Char>(0);
501 serializer << static_cast<ACE_CDR::Char>(0);
502 serializer << static_cast<ACE_CDR::Char>(class_);
503 serializer << static_cast<ACE_CDR::Char>(num);
512 serializer << static_cast<ACE_UINT16>(*pos);
518 serializer << static_cast<ACE_CDR::Char>(0);
520 serializer << static_cast<ACE_CDR::Char>(
IPv4);
524 serializer << static_cast<ACE_CDR::Char>(
IPv6);
583 while (attribute_length % 4 != 0) {
584 serializer << static_cast<ACE_CDR::Char>(0);
585 attribute_length += 1;
593 return (
memcmp(this->data, other.
data,
sizeof(data)) < 0);
598 return (
memcmp(this->data, other.
data,
sizeof(data)) == 0);
603 return (
memcmp(this->data, other.
data,
sizeof(data)) != 0);
608 TheSecurityRegistry->builtin_config()->get_utility()->generate_random_bytes(transaction_id.data,
sizeof(transaction_id.data));
613 ACE_OS::memset(transaction_id.data, 0,
sizeof(transaction_id.data));
618 std::vector<AttributeType> retval;
620 for (AttributesType::const_iterator pos = attributes_.begin(), limit = attributes_.end(); pos != limit; ++pos) {
621 const AttributesType::value_type& attribute = *pos;
622 switch (attribute.type) {
634 if (attribute.type < 0x8000) {
635 retval.push_back(attribute.type);
647 address = pos->mapped_address;
654 address = pos->mapped_address;
669 priority = pos->priority;
684 username = pos->username;
705 bool verified =
false;
709 unsigned char computed_message_integrity[20];
710 compute_message_integrity(password, computed_message_integrity);
711 verified =
memcmp(computed_message_integrity, pos->message_integrity, 20) == 0;
727 ACE_UINT16 message_length = length_for_message_integrity();
728 serializer << message_length;
736 message_length =
length();
737 serializer << message_length;
757 return pos->error.code;
768 return pos->error.reason;
772 return std::string();
790 return pos->unknown_attributes;
794 return std::vector<AttributeType>();
822 return crc ^ 0x5354554E;
862 std::memcpy(guid_prefix, pos->guid_prefix,
sizeof(guid_prefix));
872 ACE_UINT16 message_type;
873 ACE_UINT16 message_length;
874 ACE_UINT32 magic_cookie;
876 if (!(serializer >> message_type)) {
880 if (!(serializer >> message_length)) {
884 if ((message_type & 0xC000) != 0) {
888 if (message_length % 4 != 0) {
892 message.
class_ =
static_cast<Class>(((message_type & (1 << 8)) >> 7) | ((message_type & (1 << 4)) >> 4));
893 message.
method =
static_cast<Method>(((message_type & 0x3E00) >> 2) | ((message_type & 0xE0) >> 1) | (message_type & 0xF));
895 if (!(serializer >> magic_cookie)) {
908 if (serializer.
length() != message_length) {
912 bool have_integrity =
false;
913 bool have_fingerprint =
false;
915 while (serializer.
length() != 0) {
919 if (!(serializer >> holder)) {
925 if ((have_integrity && attribute.
type !=
FINGERPRINT) || have_fingerprint) {
933 if (message.
length() > message_length) {
946 ACE_UINT16 message_class = message.
class_;
947 ACE_UINT16 message_method = message.
method;
948 ACE_UINT16 message_type =
949 ((message_method & 0xF80) << 2) |
950 ((message_class & 0x2) << 7) |
951 ((message_method & 0x0070) << 1) |
952 ((message_class & 0x1) << 4) |
953 (message_method & 0x000F);
954 serializer << message_type;
956 ACE_UINT16 message_length = message.
length();
957 serializer << message_length;
962 pos != limit; ++pos) {
976 serializer << holder;
std::vector< AttributeType > unknown_attributes
void address_to_bytes(DDS::OctetArray16 &dest, const ACE_INET_Addr &addr)
OpenDDS_Rtps_Export Attribute make_guid_prefix(const DCPS::GuidPrefix_t &guid_prefix)
bool operator==(const TransactionId &other) const
const ACE_UINT32 MAGIC_COOKIE
bool has_ice_controlled() const
bool operator<(const TransactionId &other) const
size_t length(void) const
bool get_mapped_address(ACE_INET_Addr &address) const
bool skip(size_t n, int size=1)
const_iterator begin() const
Attribute make_ice_controlled(ACE_UINT64 ice_tie_breaker)
bool has_message_integrity() const
Attribute make_username(const std::string &username)
bool operator!=(const TransactionId &other) const
bool get_priority(ACE_UINT32 &priority) const
Christopher Diggins *renamed files *fixing compilation errors *adding Visual C project file *removed make Max Lybbert *removed references to missing and unused as reported by Andy Elvey and Dan Kosecki *resynced with Christopher Diggins s branch as it exists in tree building code is back Christopher Diggins *resynced codebase with Chris s branch *removed tree building code
Attribute make_xor_mapped_address(const ACE_INET_Addr &addr)
bool read_octet_array(ACE_CDR::Octet *x, ACE_CDR::ULong length)
void generate_transaction_id()
std::vector< AttributeType > get_unknown_attributes() const
Attribute make_use_candidate()
char * rd_ptr(void) const
const TransactionId & tid
bool write_octet_array(const ACE_CDR::Octet *x, ACE_CDR::ULong length)
bool has_unknown_attributes() const
Class to serialize and deserialize data for DDS.
size_t length() const
Number of bytes left to read in message block chain.
#define OpenDDS_Rtps_Export
ACE_UINT16 get_error_code() const
ACE_UINT32 get_ip_address(void) const
virtual ACE_Message_Block * release(void)
int set_address(const char *ip_addr, int len, int encode=1, int map=0)
#define TheSecurityRegistry
void compute_message_integrity(const std::string &password, unsigned char message_integrity[20]) const
virtual ACE_Message_Block * duplicate(void) const
bool get_username(std::string &username) const
Attribute make_ice_controlling(ACE_UINT64 ice_tie_breaker)
Attribute make_error_code(ACE_UINT16 code, const std::string &reason)
char * wr_ptr(void) const
Attribute make_message_integrity()
bool operator>>(DCPS::Serializer &serializer, AttributeHolder &holder)
ACE_UINT32 crc32(const char *str)
bool has_error_code() const
bool get_guid_prefix(DCPS::GuidPrefix_t &guid_pefix) const
Attribute make_fingerprint()
ACE_UINT16 length() const
unsigned char guid_prefix[sizeof(DCPS::GuidPrefix_t)]
unsigned long long ACE_UINT64
void append_attribute(const Attribute &attribute)
const_iterator end() const
Attribute make_unknown_attribute(ACE_UINT16 type, ACE_UINT16 length)
u_short get_port_number(void) const
std::string get_error_reason() const
void * memset(void *s, int c, size_t len)
int memcmp(const void *t, const void *s, size_t len)
Attribute make_unknown_attributes(const std::vector< AttributeType > &unknown_attributes)
AttributesType::const_iterator const_iterator
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
void set_port_number(u_short, int encode=1)
const TransactionId & tid
bool verify_message_integrity(const std::string &password) const
ACE_UINT32 compute_fingerprint() const
Attribute make_mapped_address(const ACE_INET_Addr &addr)
unsigned char message_integrity[20]
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
bool has_use_candidate() const
ACE_UINT64 ice_tie_breaker
bool has_ice_controlling() const
std::vector< AttributeType > unknown_comprehension_required_attributes() const
TransactionId transaction_id
The Internal API and Implementation of OpenDDS.
ACE_UINT16 unknown_length
ACE_UINT16 length() const
Attribute make_priority(ACE_UINT32 priority)
const Attribute & attribute
ACE_INET_Addr mapped_address
bool operator<<(DCPS::Serializer &serializer, ConstAttributeHolder &holder)
struct OpenDDS::STUN::Attribute::Err error
void clear_transaction_id()
bool has_fingerprint() const