summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/turn/v2/internal/proto/data.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/pion/turn/v2/internal/proto/data.go')
-rw-r--r--vendor/github.com/pion/turn/v2/internal/proto/data.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/github.com/pion/turn/v2/internal/proto/data.go b/vendor/github.com/pion/turn/v2/internal/proto/data.go
new file mode 100644
index 0000000..64243e0
--- /dev/null
+++ b/vendor/github.com/pion/turn/v2/internal/proto/data.go
@@ -0,0 +1,30 @@
+package proto
+
+import "github.com/pion/stun"
+
+// Data represents DATA attribute.
+//
+// The DATA attribute is present in all Send and Data indications. The
+// value portion of this attribute is variable length and consists of
+// the application data (that is, the data that would immediately follow
+// the UDP header if the data was been sent directly between the client
+// and the peer).
+//
+// RFC 5766 Section 14.4
+type Data []byte
+
+// AddTo adds DATA to message.
+func (d Data) AddTo(m *stun.Message) error {
+ m.Add(stun.AttrData, d)
+ return nil
+}
+
+// GetFrom decodes DATA from message.
+func (d *Data) GetFrom(m *stun.Message) error {
+ v, err := m.Get(stun.AttrData)
+ if err != nil {
+ return err
+ }
+ *d = v
+ return nil
+}