github.com/kelleygo/clashcore@v1.0.2/component/ebpf/byteorder/byteorder.go (about)

     1  package byteorder
     2  
     3  import (
     4  	"net"
     5  )
     6  
     7  // NetIPv4ToHost32 converts an net.IP to a uint32 in host byte order. ip
     8  // must be a IPv4 address, otherwise the function will panic.
     9  func NetIPv4ToHost32(ip net.IP) uint32 {
    10  	ipv4 := ip.To4()
    11  	_ = ipv4[3] // Assert length of ipv4.
    12  	return Native.Uint32(ipv4)
    13  }