Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
attributes: add RFC 8489 constants
Browse files Browse the repository at this point in the history
* Add constants
* Update String()
* Update IANA stun parameters csv
  • Loading branch information
ernado committed Nov 1, 2020
1 parent 951fb87 commit e7972d2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 34 deletions.
15 changes: 14 additions & 1 deletion attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ const (
AttrOrigin AttrType = 0x802F
)

// Attributes from RFC 8489 STUN.
const (
AttrMessageIntegritySHA256 AttrType = 0x001C // MESSAGE-INTEGRITY-SHA256
AttrPasswordAlgorithm AttrType = 0x001D // PASSWORD-ALGORITHM
AttrUserhash AttrType = 0x001E // USERHASH
AttrPasswordAlgorithms AttrType = 0x8002 // PASSWORD-ALGORITHMS
AttrAlternateDomain AttrType = 0x8003 // ALTERNATE-DOMAIN
)

// Value returns uint16 representation of attribute type.
func (t AttrType) Value() uint16 {
return uint16(t)
Expand Down Expand Up @@ -121,7 +130,11 @@ var attrNames = map[AttrType]string{
AttrReservationToken: "RESERVATION-TOKEN",
AttrConnectionID: "CONNECTION-ID",
AttrRequestedAddressFamily: "REQUESTED-ADDRESS-FAMILY",
AttrOrigin: "ORIGIN",
AttrMessageIntegritySHA256: "MESSAGE-INTEGRITY-SHA256",
AttrPasswordAlgorithm: "PASSWORD-ALGORITHM",
AttrUserhash: "USERHASH",
AttrPasswordAlgorithms: "PASSWORD-ALGORITHMS",
AttrAlternateDomain: "ALTERNATE-DOMAIN",
}

func (t AttrType) String() string {
Expand Down
84 changes: 51 additions & 33 deletions testdata/stun-parameters-4.csv
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
Value,Name,Reference
0x0000,Reserved,[RFC5389]
0x0001,MAPPED-ADDRESS,[RFC5389]
0x0002,Reserved; was RESPONSE-ADDRESS,[RFC5389]
0x0003,CHANGE-REQUEST,[RFC5780]
0x0004,Reserved; was SOURCE-ADDRESS,[RFC5389]
0x0005,Reserved; was CHANGED-ADDRESS,[RFC5389]
0x0006,USERNAME,[RFC5389]
0x0007,Reserved; was PASSWORD,[RFC5389]
0x0008,MESSAGE-INTEGRITY,[RFC5389]
0x0009,ERROR-CODE,[RFC5389]
0x000A,UNKNOWN-ATTRIBUTES,[RFC5389]
0x000B,Reserved; was REFLECTED-FROM,[RFC5389]
0x000C,CHANNEL-NUMBER,[RFC5766]
0x000D,LIFETIME,[RFC5766]
0x0000,Reserved,[RFC8489]
0x0001,MAPPED-ADDRESS,[RFC8489]
0x0002,Reserved; was RESPONSE-ADDRESS prior to [RFC5389],[RFC8489]
0x0003,Reserved; was CHANGE-REQUEST prior to [RFC5389],[RFC5780][RFC Errata 4233]
0x0004,Reserved; was SOURCE-ADDRESS prior to [RFC5389],[RFC8489]
0x0005,Reserved; was CHANGED-ADDRESS prior to [RFC5389],[RFC8489]
0x0006,USERNAME,[RFC8489]
0x0007,Reserved; was PASSWORD prior to [RFC5389],[RFC8489]
0x0008,MESSAGE-INTEGRITY,[RFC8489]
0x0009,ERROR-CODE,[RFC8489]
0x000A,UNKNOWN-ATTRIBUTES,[RFC8489]
0x000B,Reserved; was REFLECTED-FROM prior to [RFC5389],[RFC8489]
0x000C,CHANNEL-NUMBER,[RFC8656]
0x000D,LIFETIME,[RFC8656]
0x000E-0x000F,Reserved,
0x0010,Reserved (was BANDWIDTH),[RFC5766]
0x0010,Reserved (was BANDWIDTH),[RFC8656]
0x0011,Reserved,
0x0012,XOR-PEER-ADDRESS,[RFC5766]
0x0013,DATA,[RFC5766]
0x0014,REALM,[RFC5389]
0x0015,NONCE,[RFC5389]
0x0016,XOR-RELAYED-ADDRESS,[RFC5766]
0x0017,REQUESTED-ADDRESS-FAMILY,[RFC6156]
0x0018,EVEN-PORT,[RFC5766]
0x0019,REQUESTED-TRANSPORT,[RFC5766]
0x001A,DONT-FRAGMENT,[RFC5766]
0x0012,XOR-PEER-ADDRESS,[RFC8656]
0x0013,DATA,[RFC8656]
0x0014,REALM,[RFC8489]
0x0015,NONCE,[RFC8489]
0x0016,XOR-RELAYED-ADDRESS,[RFC8656]
0x0017,REQUESTED-ADDRESS-FAMILY,[RFC8656]
0x0018,EVEN-PORT,[RFC8656]
0x0019,REQUESTED-TRANSPORT,[RFC8656]
0x001A,DONT-FRAGMENT,[RFC8656]
0x001B,ACCESS-TOKEN,[RFC7635]
0x001C-0x001F,Unassigned,
0x0020,XOR-MAPPED-ADDRESS,[RFC5389]
0x0021,Reserved (was TIMER-VAL),[RFC5766]
0x0022,RESERVATION-TOKEN,[RFC5766]
0x001C,MESSAGE-INTEGRITY-SHA256,[RFC8489]
0x001D,PASSWORD-ALGORITHM,[RFC8489]
0x001E,USERHASH,[RFC8489]
0x001F-0x001F,Unassigned,
0x0020,XOR-MAPPED-ADDRESS,[RFC8489]
0x0021,Reserved (was TIMER-VAL),[RFC8656]
0x0022,RESERVATION-TOKEN,[RFC8656]
0x0023,Reserved,
0x0024,PRIORITY,[RFC8445]
0x0025,USE-CANDIDATE,[RFC8445]
Expand All @@ -40,14 +43,19 @@ Value,Name,Reference
0x002B-0x002F,Unassigned,
0x0030,Reserved,
0x0031-0x7FFF,Unassigned,
0x8000-0x8021,Unassigned,
0x8022,SOFTWARE,[RFC5389]
0x8023,ALTERNATE-SERVER,[RFC5389]
0x8000,ADDITIONAL-ADDRESS-FAMILY,[RFC8656]
0x8001,ADDRESS-ERROR-CODE,[RFC8656]
0x8002,PASSWORD-ALGORITHMS,[RFC8489]
0x8003,ALTERNATE-DOMAIN,[RFC8489]
0x8004,ICMP,[RFC8656]
0x8005-0x8021,Unassigned,
0x8022,SOFTWARE,[RFC8489]
0x8023,ALTERNATE-SERVER,[RFC8489]
0x8024,Reserved,
0x8025,TRANSACTION_TRANSMIT_COUNTER,[RFC7982]
0x8026,Reserved,
0x8027,CACHE-TIMEOUT,[RFC5780]
0x8028,FINGERPRINT,[RFC5389]
0x8028,FINGERPRINT,[RFC8489]
0x8029,ICE-CONTROLLED,[RFC8445]
0x802A,ICE-CONTROLLING,[RFC8445]
0x802B,RESPONSE-ORIGIN,[RFC5780]
Expand All @@ -60,4 +68,14 @@ Value,Name,Reference
0xC000,CISCO-STUN-FLOWDATA,[Dan_Wing]
0xC001,ENF-FLOW-DESCRIPTION,[Pål_Erik_Martinsen]
0xC002,ENF-NETWORK-STATUS,[Pål_Erik_Martinsen]
0xC003-0xFFFF,Unassigned,
0xC003-0xC056,Unassigned,
0xC057,GOOG-NETWORK-INFO,[Jonas_Oreland]
0xC058,GOOG-LAST-ICE-CHECK-RECEIVED,[Jonas_Oreland]
0xC059,GOOG-MISC-INFO,[Jonas_Oreland]
0xC05A,GOOG-OBSOLETE-1,[Jonas_Oreland]
0xC05B,GOOG-CONNECTION-ID,[Jonas_Oreland]
0xC05C,GOOG-DELTA,[Jonas_Oreland]
0xC05D,GOOG-DELTA-ACK,[Jonas_Oreland]
0xC05E-0xC05F,Unassigned,
0xC060,GOOG-MESSAGE-INTEGRITY-32,[Jonas_Oreland]
0xC061-0xFFFF,Unassigned,

0 comments on commit e7972d2

Please sign in to comment.