MCPcopy
hub / github.com/microsoft/retina / ipToHex

Function ipToHex

shell/tracescript.go:667–674  ·  view source on GitHub ↗

ipToHex converts an IPv4 address to a uint32 in network byte order. SECURITY: This function only outputs hex digits - no user input passes through.

(ip net.IP)

Source from the content-addressed store, hash-verified

665// ipToHex converts an IPv4 address to a uint32 in network byte order.
666// SECURITY: This function only outputs hex digits - no user input passes through.
667func ipToHex(ip net.IP) uint32 {
668 ipv4 := ip.To4()
669 if ipv4 == nil {
670 return 0
671 }
672 // Network byte order (big endian) - this matches how IPs are stored in IP headers
673 return binary.BigEndian.Uint32(ipv4)
674}
675
676// DropReasonsCommand returns the command to fetch SKB drop reason enum from kernel.
677// The enum values are kernel-version specific and must be read at runtime.

Callers 3

TestIPToHexFunction · 0.85
TestIPToHexOnlyHexOutputFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestIPToHexFunction · 0.68
TestIPToHexOnlyHexOutputFunction · 0.68