MCPcopy Create free account
hub / github.com/encodeous/nylon / SrcIP

Method SrcIP

polyamide/conn/sticky_linux.go:17–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15)
16
17func (e *StdNetEndpoint) SrcIP() netip.Addr {
18 switch len(e.src) {
19 case unix.CmsgSpace(unix.SizeofInet4Pktinfo):
20 info := (*unix.Inet4Pktinfo)(unsafe.Pointer(&e.src[unix.CmsgLen(0)]))
21 return netip.AddrFrom4(info.Spec_dst)
22 case unix.CmsgSpace(unix.SizeofInet6Pktinfo):
23 info := (*unix.Inet6Pktinfo)(unsafe.Pointer(&e.src[unix.CmsgLen(0)]))
24 // TODO: set zone. in order to do so we need to check if the address is
25 // link local, and if it is perform a syscall to turn the ifindex into a
26 // zone string because netip uses string zones.
27 return netip.AddrFrom16(info.Addr)
28 }
29 return netip.Addr{}
30}
31
32func (e *StdNetEndpoint) SrcIfidx() int32 {
33 switch len(e.src) {

Callers 3

Test_setSrcControlFunction · 0.95
Test_getSrcFromControlFunction · 0.95
SrcToStringMethod · 0.95

Calls

no outgoing calls

Tested by 2

Test_setSrcControlFunction · 0.76
Test_getSrcFromControlFunction · 0.76