Skip to content

Commit 9ccd35d

Browse files
author
agrabil
committed
Fixes #17: Convert IPv4 wildcard address (0.0.0.0) to IPv6 wildcard (::)
on DHCPv6 channel.
1 parent 19c8df2 commit 9ccd35d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Jagornet-DHCP/src/com/jagornet/dhcp/server/netty/DhcpV6ChannelHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import com.jagornet.dhcp.message.DhcpV6Message;
4040
import com.jagornet.dhcp.server.request.DhcpV6MessageHandler;
41+
import com.jagornet.dhcp.util.DhcpConstants;
4142

4243
/**
4344
* Title: DhcpChannelHandler
@@ -68,7 +69,10 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Ex
6869
log.info("Received: " + dhcpMessage.toString());
6970

7071
SocketAddress remoteAddress = e.getRemoteAddress();
71-
InetAddress localAddr = ((InetSocketAddress)e.getChannel().getLocalAddress()).getAddress();
72+
InetAddress localAddr = ((InetSocketAddress)e.getChannel().getLocalAddress()).getAddress();
73+
if (localAddr.equals(DhcpConstants.ZEROADDR_V4)) {
74+
localAddr = DhcpConstants.ZEROADDR_V6;
75+
}
7276
DhcpV6Message replyMessage =
7377
DhcpV6MessageHandler.handleMessage(localAddr, dhcpMessage);
7478

Jagornet-DHCP/src/com/jagornet/dhcp/server/netty/NettyDhcpServer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.net.InetAddress;
3232
import java.net.InetSocketAddress;
3333
import java.net.NetworkInterface;
34-
import java.net.SocketAddress;
3534
import java.net.SocketException;
3635
import java.util.ArrayList;
3736
import java.util.Collection;
@@ -237,7 +236,7 @@ public void start() throws Exception
237236
channel.getConfig().setSendBufferSize(sendBufSize);
238237

239238
// must be bound in order to join multicast group
240-
SocketAddress wildAddr = new InetSocketAddress(v6Port);
239+
InetSocketAddress wildAddr = new InetSocketAddress(DhcpConstants.ZEROADDR_V6, v6Port);
241240
log.info("Binding New I/O multicast channel on IPv6 wildcard address: " + wildAddr);
242241
ChannelFuture future = channel.bind(wildAddr);
243242
future.await();
@@ -350,7 +349,7 @@ public void start() throws Exception
350349
channel.getConfig().setReceiveBufferSize(receiveBufSize);
351350
channel.getConfig().setSendBufferSize(sendBufSize);
352351

353-
InetSocketAddress wildAddr = new InetSocketAddress(v4Port);
352+
InetSocketAddress wildAddr = new InetSocketAddress(DhcpConstants.ZEROADDR_V4, v4Port);
354353
log.info("Binding New I/O datagram channel on IPv4 wildcard address: " + wildAddr);
355354
ChannelFuture future = channel.bind(wildAddr);
356355
future.await();

0 commit comments

Comments
 (0)