@Test public void testHandleMessage() throws Exception { DhcpV6RelayMessage relayMessage = TestDhcpRelayMessage.buildMockDhcpRelayMessage(); relayMessage.setMessageType(DhcpConstants.V6MESSAGE_TYPE_RELAY_FORW); DhcpV6Message dhcpMessage = new DhcpV6Message(new InetSocketAddress("2001:db8:1::1", DhcpConstants.V6_SERVER_PORT), new InetSocketAddress("fe80::1", DhcpConstants.V6_CLIENT_PORT)); dhcpMessage.setMessageType(DhcpConstants.V6MESSAGE_TYPE_INFO_REQUEST); dhcpMessage.setTransactionId(90599); OpaqueData opaque = new OpaqueData(); opaque.setAsciiValue("jagornet-dhcp-server"); dhcpMessage.putDhcpOption(new DhcpV6ClientIdOption(OpaqueDataUtil.toBaseOpaqueData(opaque))); DhcpV6RelayOption relayOption = relayMessage.getRelayOption(); relayOption.setDhcpMessage(dhcpMessage); relayMessage.setRelayOption(relayOption); relayMessage.putDhcpOption(TestDhcpRelayMessage.buildMockInterfaceIdOption()); DhcpV6Message replyMessage = DhcpV6MessageHandler.handleMessage(InetAddress.getByName("3ffe::1"), relayMessage); DhcpV6InterfaceIdOption ifIdOption = (DhcpV6InterfaceIdOption) replyMessage.getDhcpOption(DhcpConstants.V6OPTION_INTERFACE_ID); assertNotNull(ifIdOption); }
public static DhcpV6Message handleMessage(InetAddress localAddress, DhcpV6Message dhcpMessage) { DhcpV6Message replyMessage = null; if (dhcpMessage instanceof DhcpV6RelayMessage) { if (dhcpMessage.getMessageType() == DhcpConstants.V6MESSAGE_TYPE_RELAY_FORW) { DhcpV6RelayMessage relayMessage = (DhcpV6RelayMessage) dhcpMessage; replyMessage = handleRelayForward(relayMessage); } else { log.error("Unsupported message type: " + dhcpMessage.getMessageType()); } } else { log.info("Handling client request on local client link address: " + localAddress.getHostAddress()); replyMessage = handleClientRequest(localAddress, dhcpMessage); } return replyMessage; }
DhcpV6MessageHandler { public static DhcpV6Message handleMessage(InetAddress localAddress, DhcpV6Message dhcpMessage) { DhcpV6Message replyMessage = null; if (dhcpMessage instanceof DhcpV6RelayMessage) { if (dhcpMessage.getMessageType() == DhcpConstants.V6MESSAGE_TYPE_RELAY_FORW) { DhcpV6RelayMessage relayMessage = (DhcpV6RelayMessage) dhcpMessage; replyMessage = handleRelayForward(relayMessage); } else { log.error("Unsupported message type: " + dhcpMessage.getMessageType()); } } else { log.info("Handling client request on local client link address: " + localAddress.getHostAddress()); replyMessage = handleClientRequest(localAddress, dhcpMessage); } return replyMessage; } }
DhcpV6MessageHandler { public static DhcpV6Message handleMessage(InetAddress localAddress, DhcpV6Message dhcpMessage) { DhcpV6Message replyMessage = null; if (dhcpMessage instanceof DhcpV6RelayMessage) { if (dhcpMessage.getMessageType() == DhcpConstants.V6MESSAGE_TYPE_RELAY_FORW) { DhcpV6RelayMessage relayMessage = (DhcpV6RelayMessage) dhcpMessage; replyMessage = handleRelayForward(relayMessage); } else { log.error("Unsupported message type: " + dhcpMessage.getMessageType()); } } else { log.info("Handling client request on local client link address: " + localAddress.getHostAddress()); replyMessage = handleClientRequest(localAddress, dhcpMessage); } return replyMessage; }  }
DhcpV6MessageHandler { public static DhcpV6Message handleMessage(InetAddress localAddress, DhcpV6Message dhcpMessage) { DhcpV6Message replyMessage = null; if (dhcpMessage instanceof DhcpV6RelayMessage) { if (dhcpMessage.getMessageType() == DhcpConstants.V6MESSAGE_TYPE_RELAY_FORW) { DhcpV6RelayMessage relayMessage = (DhcpV6RelayMessage) dhcpMessage; replyMessage = handleRelayForward(relayMessage); } else { log.error("Unsupported message type: " + dhcpMessage.getMessageType()); } } else { log.info("Handling client request on local client link address: " + localAddress.getHostAddress()); replyMessage = handleClientRequest(localAddress, dhcpMessage); } return replyMessage; }  static DhcpV6Message handleMessage(InetAddress localAddress, DhcpV6Message dhcpMessage); static DhcpV6Message handleClientRequest(InetAddress linkAddress, DhcpV6Message dhcpMessage); }
DhcpV6MessageHandler { public static DhcpV6Message handleMessage(InetAddress localAddress, DhcpV6Message dhcpMessage) { DhcpV6Message replyMessage = null; if (dhcpMessage instanceof DhcpV6RelayMessage) { if (dhcpMessage.getMessageType() == DhcpConstants.V6MESSAGE_TYPE_RELAY_FORW) { DhcpV6RelayMessage relayMessage = (DhcpV6RelayMessage) dhcpMessage; replyMessage = handleRelayForward(relayMessage); } else { log.error("Unsupported message type: " + dhcpMessage.getMessageType()); } } else { log.info("Handling client request on local client link address: " + localAddress.getHostAddress()); replyMessage = handleClientRequest(localAddress, dhcpMessage); } return replyMessage; }  static DhcpV6Message handleMessage(InetAddress localAddress, DhcpV6Message dhcpMessage); static DhcpV6Message handleClientRequest(InetAddress linkAddress, DhcpV6Message dhcpMessage);  }