mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 12:53:23 +00:00
store Bind laddr in netip.AddrPort
This commit is contained in:
+3
-5
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user