const.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package yamux
  2. const (
  3. // protoVersion is the only version we support
  4. protoVersion = 0
  5. )
  6. const (
  7. // Data is used for data frames. They are followed
  8. // by length bytes worth of payload.
  9. typeData uint8 = iota
  10. // WindowUpdate is used to change the window of
  11. // a given stream. The length indicates the delta
  12. // update to the window.
  13. typeWindowUpdate
  14. // Ping is sent as a keep-alive or to measure
  15. // the RTT. The StreamID and Length value are echoed
  16. // back in the response.
  17. typePing
  18. // GoAway is sent to terminate a session. The StreamID
  19. // should be 0 and the length is an error code.
  20. typeGoAway
  21. )
  22. const (
  23. // SYN is sent to signal a new stream. May
  24. // be sent with a data payload
  25. flagSYN uint8 = 1 << iota
  26. // ACK is sent to acknowledge a new stream. May
  27. // be sent with a data payload
  28. flagACK
  29. // FIN is sent to half-close the given stream.
  30. // May be sent with a data payload.
  31. flagFIN
  32. // RST is used to hard close a given stream.
  33. flagRST
  34. // LZW is used to indicate that the payload is
  35. // compressed with the LZW algorithm
  36. flagLZW
  37. )
  38. const (
  39. // initialSessionWindow is the initial session window size
  40. initialSessionWindow = 2 * 1024 * 1024
  41. // initialStreamWindow is the initial stream window size
  42. initialStreamWindow = 256 * 1024
  43. )
  44. const (
  45. // goAwayNormal is sent on a normal termination
  46. goAwayNormal uint32 = iota
  47. // goAwayProtoErr sent on a protocol error
  48. goAwayProtoErr
  49. // goAwayInternalErr sent on an internal error
  50. goAwayInternalErr
  51. )