// First skip mandatory stun header which is of 20 bytes.
size_t pos = kStunHeaderSize; // Loop through STUN attributes until we find STUN DATA attribute. while (pos < packet_size) { // Keep reading STUN attributes until we hit DATA attribute. // Attribute will be a TLV structure. // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | Type | Length | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | Value (variable) .... // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // The value in the length field MUST contain the length of the Value // part of the attribute, prior to padding, measured in bytes. Since // STUN aligns attributes on 32-bit boundaries, attributes whose content // is not a multiple of 4 bytes are padded with 1, 2, or 3 bytes of // padding so that its value contains a multiple of 4 bytes. The // padding bits are ignored, and may be any value.
uint16_t attr_type, attr_length; const int kAttrHeaderLength = sizeof(attr_type) + sizeof(attr_length);
if (packet_size < pos + kAttrHeaderLength) { return false;
}
// Getting attribute type and length.
attr_type = GetBE16(data_view.subspan(pos, 2));
attr_length = GetBE16(data_view.subspan(pos + sizeof(attr_type), 2));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.