Revision 8e6d288a6fe8c342b36cb25b8457f774ddad09bb authored by Gilberto Bertin on 20 June 2024, 14:32:57 UTC, committed by christarazi on 20 June 2024, 18:58:04 UTC
Signed-off-by: Gilberto Bertin <jibi@cilium.io>
1 parent 8c745b2
byteorder.go
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package byteorder
import (
"net"
"net/netip"
)
// NetIPv4ToHost32 converts an net.IP to a uint32 in host byte order. ip
// must be a IPv4 address, otherwise the function will panic.
func NetIPv4ToHost32(ip net.IP) uint32 {
ipv4 := ip.To4()
_ = ipv4[3] // Assert length of ipv4.
return Native.Uint32(ipv4)
}
func NetIPAddrToHost32(ip netip.Addr) uint32 {
ipv4 := ip.As4()
return Native.Uint32(ipv4[:])
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...