()
| 15 | ) |
| 16 | |
| 17 | func (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 | |
| 32 | func (e *StdNetEndpoint) SrcIfidx() int32 { |
| 33 | switch len(e.src) { |
no outgoing calls