github.com/vishvananda/netlink@v1.3.0/order.go (about)

     1  package netlink
     2  
     3  import (
     4  	"encoding/binary"
     5  
     6  	"github.com/vishvananda/netlink/nl"
     7  )
     8  
     9  var (
    10  	native       = nl.NativeEndian()
    11  	networkOrder = binary.BigEndian
    12  )
    13  
    14  func htonl(val uint32) []byte {
    15  	bytes := make([]byte, 4)
    16  	binary.BigEndian.PutUint32(bytes, val)
    17  	return bytes
    18  }
    19  
    20  func htons(val uint16) []byte {
    21  	bytes := make([]byte, 2)
    22  	binary.BigEndian.PutUint16(bytes, val)
    23  	return bytes
    24  }
    25  
    26  func ntohl(buf []byte) uint32 {
    27  	return binary.BigEndian.Uint32(buf)
    28  }
    29  
    30  func ntohs(buf []byte) uint16 {
    31  	return binary.BigEndian.Uint16(buf)
    32  }