frames.go 842 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package wire
  2. import (
  3. "bytes"
  4. "io"
  5. )
  6. type SNACError struct {
  7. Code uint16
  8. TLVRestBlock
  9. }
  10. const (
  11. FLAPFrameSignon uint8 = 0x01
  12. FLAPFrameData uint8 = 0x02
  13. FLAPFrameError uint8 = 0x03
  14. FLAPFrameSignoff uint8 = 0x04
  15. FLAPFrameKeepAlive uint8 = 0x05
  16. )
  17. type FLAPFrame struct {
  18. StartMarker uint8
  19. FrameType uint8
  20. Sequence uint16
  21. PayloadLength uint16
  22. }
  23. func (f FLAPFrame) ReadBody(r io.Reader) (*bytes.Buffer, error) {
  24. b := make([]byte, f.PayloadLength)
  25. if f.PayloadLength > 0 {
  26. if _, err := io.ReadFull(r, b); err != nil {
  27. return nil, err
  28. }
  29. }
  30. return bytes.NewBuffer(b), nil
  31. }
  32. type SNACFrame struct {
  33. FoodGroup uint16
  34. SubGroup uint16
  35. Flags uint16
  36. RequestID uint32
  37. }
  38. type FLAPSignonFrame struct {
  39. FLAPVersion uint32
  40. TLVRestBlock
  41. }
  42. type SNACMessage struct {
  43. Frame SNACFrame
  44. Body any
  45. }