store Bind laddr in netip.AddrPort

This commit is contained in:
Scott Feldman
2023-12-02 17:14:47 -08:00
committed by Ron Evans
parent 7a7235f83b
commit d6ae0b0d8b
+3 -5
View File
@@ -45,8 +45,7 @@ type Config struct {
type socket struct { type socket struct {
inUse bool inUse bool
protocol int protocol int
lip netip.Addr laddr netip.AddrPort
lport uint16
} }
type Device struct { type Device struct {
@@ -180,8 +179,7 @@ func (d *Device) Socket(domain int, stype int, protocol int) (int, error) {
} }
func (d *Device) Bind(sockfd int, ip netip.AddrPort) error { func (d *Device) Bind(sockfd int, ip netip.AddrPort) error {
d.socket.lip = ip.Addr() d.socket.laddr = ip
d.socket.lport = ip.Port()
return nil return nil
} }
@@ -189,7 +187,7 @@ func (d *Device) Connect(sockfd int, host string, ip netip.AddrPort) error {
var err error var err error
var addr = ip.Addr().String() var addr = ip.Addr().String()
var rport = strconv.Itoa(int(ip.Port())) var rport = strconv.Itoa(int(ip.Port()))
var lport = strconv.Itoa(int(d.socket.lport)) var lport = strconv.Itoa(int(d.socket.laddr.Port()))
switch d.socket.protocol { switch d.socket.protocol {
case netdev.IPPROTO_TCP: case netdev.IPPROTO_TCP: