
Go to the source code of this file.
Classes | |
| struct | StunHeader |
| struct | StunAttributeHeader |
| struct | StunAttributeAddress |
| struct | StunAttributeUsername |
| struct | StunAttributeFingerprint |
| struct | StunAttributePriority |
| struct | StunAttributeFlag |
| struct | StunAttributeMessageIntegrity |
| struct | StunAttributeLifetime |
| struct | StunAttributeRequestedTransport |
| struct | StunAttributeRealm |
| struct | StunAttributeAllocationAddressFamily |
| struct | StunAttributeNonce |
| struct | StunAttributeErrorCode |
| struct | StunAttributeIceControl |
| struct | StunAttributeData |
| struct | StunAttributeChannelNumber |
| struct | StunAttributeChangeRequest |
| struct | StunPacket |
| #define GET_STUN_ERROR_CODE | ( | pClass, | |
| pCode ) |
Taking a PBYTE pointing to stun error packet's error code attribute's error class location and another PBYTE pointing to the error code location, return stun error code as UINT16
| #define PACKAGE_STUN_ATTR_HEADER | ( | pBuf, | |
| type, | |||
| dataLen ) |
Packages the attribute header into a specified buffer
| #define STUN_ATTRIBUTE_ADDRESS_FAMILY_LEN (UINT16) 2 |
| #define STUN_ATTRIBUTE_ADDRESS_HEADER_LEN (UINT16)(STUN_ATTRIBUTE_ADDRESS_FAMILY_LEN + STUN_ATTRIBUTE_ADDRESS_PORT_LEN) |
| #define STUN_ATTRIBUTE_ADDRESS_PORT_LEN (UINT16) 2 |
| #define STUN_ATTRIBUTE_CHANGE_REQUEST_FLAG_CHANGE_IP 4 |
| #define STUN_ATTRIBUTE_CHANGE_REQUEST_FLAG_CHANGE_PORT 2 |
| #define STUN_ATTRIBUTE_CHANGE_REQUEST_FLAG_LEN (UINT16) 4 |
The flag is 32 bit long but only 2 bits are used
| #define STUN_ATTRIBUTE_CHANNEL_NUMBER_LEN (UINT16) 4 |
| #define STUN_ATTRIBUTE_FINGERPRINT_LEN (UINT16) 4 |
Fingerprint attribute value length = 4 bytes = 32 bits
| #define STUN_ATTRIBUTE_FLAG_LEN (UINT16) 0 |
Candidate attribute has no size
| #define STUN_ATTRIBUTE_HEADER_DATA_LEN (UINT16) 2 |
| #define STUN_ATTRIBUTE_HEADER_LEN (UINT16)(STUN_ATTRIBUTE_HEADER_TYPE_LEN + STUN_ATTRIBUTE_HEADER_DATA_LEN) |
| #define STUN_ATTRIBUTE_HEADER_TYPE_LEN (UINT16) 2 |
Stun attribute header structure
| #define STUN_ATTRIBUTE_ICE_CONTROL_LEN (UINT16) 8 |
Ice-controll and Ice-controlling attribute value length = 8 bytes = 64 bits for a UINT64 tie breaker
| #define STUN_ATTRIBUTE_LIFETIME_LEN (UINT16) 4 |
Lifetime attribute value length = 4 bytes = 32 bits representing number of seconds until expiration
| #define STUN_ATTRIBUTE_MAX_COUNT 20 |
Max number of attributes allowed
| #define STUN_ATTRIBUTE_PRIORITY_LEN (UINT16) 4 |
Priority attribute value length = 4 bytes = 32 bits
| #define STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_LEN (UINT16) 4 |
Requested address family attribute value length = 4 bytes = 32 bits
| #define STUN_ATTRIBUTE_REQUESTED_TRANSPORT_PROTOCOL_LEN (UINT16) 4 |
Requested transport protocol attribute value length = 4 bytes = 32 bits
| #define STUN_ERROR_CODE_PACKET_ERROR_CLASS_OFFSET 2 |
| #define STUN_ERROR_CODE_PACKET_ERROR_CODE_OFFSET 3 |
| #define STUN_ERROR_CODE_PACKET_ERROR_PHRASE_OFFSET 4 |
| #define STUN_FINGERPRINT_ATTRIBUTE_XOR_VALUE (UINT32) 0x5354554e |
Need to XOR the calculate fingerprint value with this per https://tools.ietf.org/html/rfc5389#section-15.5
| #define STUN_HEADER_DATA_LEN (UINT16) 2 |
| #define STUN_HEADER_LEN (UINT16) 20 |
Stun header structure
| #define STUN_HEADER_MAGIC_COOKIE (UINT32) 0x2112A442 |
| #define STUN_HEADER_MAGIC_COOKIE_LE (UINT32) 0x42A41221 |
| #define STUN_HEADER_MAGIC_COOKIE_LEN SIZEOF(STUN_HEADER_MAGIC_COOKIE) |
| #define STUN_HEADER_TRANSACTION_ID_LEN (UINT16) 12 |
| #define STUN_HEADER_TYPE_LEN (UINT16) 2 |
| #define STUN_HMAC_VALUE_LEN KVS_SHA1_DIGEST_LENGTH |
STUN HMAC attribute value length
| #define STUN_PACKET_ALLOCATION_SIZE 2048 |
Default allocation size for a STUN packet
| #define STUN_PACKET_IS_TYPE_ERROR | ( | pPacketBuffer | ) |
| #define STUN_PACKET_TRANSACTION_ID_OFFSET 8 |
| #define STUN_SEND_INDICATION_APPLICATION_DATA_LEN_OFFSET 34 |
| #define STUN_SEND_INDICATION_APPLICATION_DATA_OFFSET 36 |
| #define STUN_SEND_INDICATION_OVERHEAD_SIZE 36 |
| #define STUN_SEND_INDICATION_XOR_PEER_ADDRESS_OFFSET 28 |
| #define STUN_SEND_INDICATION_XOR_PEER_ADDRESS_PORT_OFFSET 26 |
| #define STUN_TRANSACTION_ID_LEN (UINT16) 12 |
STUN packet transaction id = 96 bits
| typedef struct StunAttributeAddress * PStunAttributeAddress |
| typedef struct StunAttributeChangeRequest * PStunAttributeChangeRequest |
| typedef struct StunAttributeChannelNumber * PStunAttributeChannelNumber |
| typedef struct StunAttributeData * PStunAttributeData |
| typedef struct StunAttributeErrorCode * PStunAttributeErrorCode |
| typedef struct StunAttributeFingerprint * PStunAttributeFingerprint |
| typedef struct StunAttributeFlag * PStunAttributeFlag |
| typedef struct StunAttributeHeader * PStunAttributeHeader |
| typedef struct StunAttributeIceControl * PStunAttributeIceControl |
| typedef struct StunAttributeLifetime * PStunAttributeLifetime |
| typedef struct StunAttributeMessageIntegrity * PStunAttributeMessageIntegrity |
| typedef struct StunAttributeNonce * PStunAttributeNonce |
| typedef struct StunAttributePriority * PStunAttributePriority |
| typedef struct StunAttributeRealm * PStunAttributeRealm |
| typedef struct StunAttributeRequestedTransport * PStunAttributeRequestedTransport |
| typedef struct StunAttributeUsername * PStunAttributeUsername |
| typedef struct StunHeader * PStunHeader |
| typedef struct StunPacket * PStunPacket |
| enum STUN_ATTRIBUTE_TYPE |
STUN attribute types
| enum STUN_ERROR_CODE |
| enum STUN_PACKET_TYPE |
STUN packet types
| STATUS appendStunAddressAttribute | ( | PStunPacket | pStunPacket, |
| STUN_ATTRIBUTE_TYPE | addressAttributeType, | ||
| PKvsIpAddress | pAddress ) |


| STATUS appendStunAllocationAddressFamily | ( | PStunPacket | pStunPacket, |
| KVS_IP_FAMILY_TYPE | ipFamily ) |


| STATUS appendStunChangeRequestAttribute | ( | PStunPacket | pStunPacket, |
| UINT32 | changeFlag ) |


| STATUS appendStunChannelNumberAttribute | ( | PStunPacket | pStunPacket, |
| UINT16 | channelNumber ) |


| STATUS appendStunDataAttribute | ( | PStunPacket | pStunPacket, |
| PBYTE | data, | ||
| UINT16 | dataLen ) |

| STATUS appendStunErrorCodeAttribute | ( | PStunPacket | pStunPacket, |
| PCHAR | errorPhrase, | ||
| UINT16 | errorCode ) |

| STATUS appendStunFlagAttribute | ( | PStunPacket | pStunPacket, |
| STUN_ATTRIBUTE_TYPE | attrType ) |


| STATUS appendStunIceControllAttribute | ( | PStunPacket | pStunPacket, |
| STUN_ATTRIBUTE_TYPE | attributeType, | ||
| UINT64 | tieBreaker ) |


| STATUS appendStunLifetimeAttribute | ( | PStunPacket | pStunPacket, |
| UINT32 | lifetime ) |


| STATUS appendStunNonceAttribute | ( | PStunPacket | pStunPacket, |
| PBYTE | nonce, | ||
| UINT16 | nonceLen ) |


| STATUS appendStunPriorityAttribute | ( | PStunPacket | pStunPacket, |
| UINT32 | priority ) |


| STATUS appendStunRealmAttribute | ( | PStunPacket | pStunPacket, |
| PCHAR | realm ) |


| STATUS appendStunRequestedTransportAttribute | ( | PStunPacket | pStunPacket, |
| UINT8 | protocol ) |


| STATUS appendStunUsernameAttribute | ( | PStunPacket | pStunPacket, |
| PCHAR | userName ) |


| STATUS createStunPacket | ( | STUN_PACKET_TYPE | stunPacketType, |
| PBYTE | transactionId, | ||
| PStunPacket * | ppStunPacket ) |


| STATUS deserializeStunPacket | ( | PBYTE | pStunBuffer, |
| UINT32 | bufferSize, | ||
| PBYTE | password, | ||
| UINT32 | passwordLen, | ||
| PStunPacket * | ppStunPacket ) |


| STATUS freeStunPacket | ( | PStunPacket * | ppStunPacket | ) |

| STATUS getFirstAvailableStunAttribute | ( | PStunPacket | pStunPacket, |
| PStunAttributeHeader * | ppStunAttribute ) |


| UINT16 getPackagedStunAttributeSize | ( | PStunAttributeHeader | pStunAttributeHeader | ) |

| STATUS getStunAttribute | ( | PStunPacket | pStunPacket, |
| STUN_ATTRIBUTE_TYPE | attributeType, | ||
| PStunAttributeHeader * | ppStunAttribute ) |
check if PStunPacket has an attribute of type STUN_ATTRIBUTE_TYPE. If so, return the first occurrence through PStunAttributeHeader*

| STATUS serializeStunPacket | ( | PStunPacket | pStunPacket, |
| PBYTE | password, | ||
| UINT32 | passwordLen, | ||
| BOOL | generateMessageIntegrity, | ||
| BOOL | generateFingerprint, | ||
| PBYTE | pBuffer, | ||
| PUINT32 | pSize ) |


| STATUS stunPackageIpAddr | ( | PStunHeader | pStunHeader, |
| STUN_ATTRIBUTE_TYPE | type, | ||
| PKvsIpAddress | pAddress, | ||
| PBYTE | pBuffer, | ||
| PUINT32 | pDataLen ) |
Mapped address attribute structure https://tools.ietf.org/html/rfc5389#section-15.1


| STATUS updateStunNonceAttribute | ( | PStunPacket | pStunPacket, |
| PBYTE | nonce, | ||
| UINT16 | nonceLen ) |


| STATUS xorIpAddress | ( | PKvsIpAddress | pAddress, |
| PBYTE | pTransactionId ) |
xor an IP address in place
