segment_other.go 809 B

12345678910111213141516171819202122
  1. //go:build !linux || android || e2e_testing
  2. package tio
  3. import "fmt"
  4. func protoFromGSOType(_ uint8) (GSOProto, error) {
  5. return 0, fmt.Errorf("GSO unsupported")
  6. }
  7. // SegmentSuperpacket invokes fn once per segment of pkt. On non-Linux
  8. // builds (and Android/e2e_testing) this package does not provide a Queue
  9. // implementation, so any caller that does construct a Packet here can only
  10. // be operating on non-superpacket bytes and the stub forwards them
  11. // directly. A non-zero GSO field is a programming error from the caller
  12. // and returns an explicit error rather than silently misbehaving.
  13. func SegmentSuperpacket(pkt Packet, fn func(seg []byte) error) error {
  14. if pkt.GSO.IsSuperpacket() {
  15. return fmt.Errorf("tio: GSO superpacket on platform without segmentation support")
  16. }
  17. return fn(pkt.Bytes)
  18. }