mirror of
https://github.com/danderson/netboot.git
synced 2025-10-17 10:31:28 +02:00
dhcp4: fix portable Conn initialization and packet transmission.
Conn is supposed to accept "" to mean "listen for DHCP on all interfaces", but portableConn didn't correctly handle that. And I got the comparison wrong on ifidx in the portable send function, so packets got sent out entirely the wrong interface :(.
This commit is contained in:
parent
684f93040b
commit
c9ec51e475
@ -167,6 +167,9 @@ type portableConn struct {
|
||||
}
|
||||
|
||||
func newPortableConn(addr string) (conn, error) {
|
||||
if addr == "" {
|
||||
addr = ":67"
|
||||
}
|
||||
c, err := net.ListenPacket("udp4", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -192,7 +195,7 @@ func (c *portableConn) Recv(b []byte) (rb []byte, addr *net.UDPAddr, ifidx int,
|
||||
}
|
||||
|
||||
func (c *portableConn) Send(b []byte, addr *net.UDPAddr, ifidx int) error {
|
||||
if ifidx > 0 {
|
||||
if ifidx <= 0 {
|
||||
_, err := c.conn.WriteTo(b, nil, addr)
|
||||
return err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user