Skip to content

Commit d7ae6d1

Browse files
committed
Make DontFragmentAttr implement stun.Getter
As its needed for fuzzing it.
1 parent 503ad7b commit d7ae6d1

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

internal/proto/dontfrag.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
package proto
22

3-
import "github.com/pion/stun"
3+
import (
4+
"github.com/pion/stun"
5+
)
46

57
// DontFragmentAttr represents DONT-FRAGMENT attribute.
68
type DontFragmentAttr struct{}
79

10+
const dontFragmentSize = 0
11+
812
// AddTo adds DONT-FRAGMENT attribute to message.
913
func (DontFragmentAttr) AddTo(m *stun.Message) error {
1014
m.Add(stun.AttrDontFragment, nil)
1115
return nil
1216
}
1317

18+
// GetFrom decodes DONT-FRAGMENT from message.
19+
func (d *DontFragmentAttr) GetFrom(m *stun.Message) error {
20+
v, err := m.Get(stun.AttrDontFragment)
21+
if err != nil {
22+
return err
23+
}
24+
if err = stun.CheckSize(stun.AttrDontFragment, len(v), dontFragmentSize); err != nil {
25+
return err
26+
}
27+
return nil
28+
}
29+
1430
// IsSet returns true if DONT-FRAGMENT attribute is set.
1531
func (DontFragmentAttr) IsSet(m *stun.Message) bool {
1632
_, err := m.Get(stun.AttrDontFragment)

0 commit comments

Comments
 (0)