github.com/aristanetworks/goarista@v0.0.0-20240514173732-cca2755bbd44/dscp/dscp_other.go (about)

     1  // Copyright (c) 2021 Arista Networks, Inc.
     2  // Use of this source code is governed by the Apache License 2.0
     3  // that can be found in the COPYING file.
     4  
     5  //go:build !linux && !darwin
     6  // +build !linux,!darwin
     7  
     8  package dscp
     9  
    10  import (
    11  	"errors"
    12  	"net"
    13  	"syscall"
    14  
    15  	"github.com/aristanetworks/goarista/logger"
    16  )
    17  
    18  // ListenTCPWithTOS is similar to net.ListenTCP but with the socket configured
    19  // to the use the given ToS (Type of Service), to specify DSCP / ECN / class
    20  // of service flags to use for incoming connections.
    21  func ListenTCPWithTOS(address *net.TCPAddr, tos byte) (*net.TCPListener, error) {
    22  	if tos != 0 {
    23  		return nil, errors.New("TOS is not supported by this library on this platform")
    24  	}
    25  	return net.ListenTCP("tcp", address)
    26  }
    27  
    28  // ListenTCPWithTOSLogger is similar to net.ListenTCP but with the
    29  // socket configured to the use the given ToS (Type of Service), to
    30  // specify DSCP / ECN / class of service flags to use for incoming
    31  // connections. Allows passing in a Logger.
    32  func ListenTCPWithTOSLogger(address *net.TCPAddr, tos byte, l logger.Logger) (*net.TCPListener,
    33  	error) {
    34  	return ListenTCPWithTOS(address, tos)
    35  }
    36  
    37  // SetTOS will set the TOS byte on a unix system. It's intended to be
    38  // used in a net.Dialer's Control function.
    39  func SetTOS(network string, c syscall.RawConn, tos byte) error {
    40  	if tos != 0 {
    41  		return errors.New("TOS is not supported by this library on this platform")
    42  	}
    43  	return nil
    44  }