use of org.onlab.packet.DHCP in project dhcpl2relay by opencord.
the class DhcpL2RelayTestBase method constructDhcpNakPacket.
/**
* Constructs DHCP Nak Packet.
*
* @return Ethernet packet
*/
Ethernet constructDhcpNakPacket(MacAddress servMac, MacAddress clientMac, String ipAddress, String dhcpClientIpAddress, VlanId clientVlan, short clientPcp) {
Ethernet pkt = constructEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY, clientMac, Ip4Address.valueOf(dhcpClientIpAddress), clientVlan, clientPcp);
IPv4 ipv4Packet = (IPv4) pkt.getPayload();
UDP udpPacket = (UDP) ipv4Packet.getPayload();
DHCP dhcpPacket = (DHCP) udpPacket.getPayload();
dhcpPacket.setOptions(constructDhcpOptions(DHCP.MsgType.DHCPNAK));
return pkt;
}
use of org.onlab.packet.DHCP in project dhcpl2relay by opencord.
the class DhcpL2RelayTestBase method constructDhcpAckPacket.
/**
* Constructs DHCP Ack Packet.
*
* @return Ethernet packet
*/
Ethernet constructDhcpAckPacket(MacAddress servMac, MacAddress clientMac, String ipAddress, String dhcpClientIpAddress) {
Ethernet pkt = construcEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY, clientMac, Ip4Address.valueOf(dhcpClientIpAddress));
IPv4 ipv4Packet = (IPv4) pkt.getPayload();
UDP udpPacket = (UDP) ipv4Packet.getPayload();
DHCP dhcpPacket = (DHCP) udpPacket.getPayload();
dhcpPacket.setOptions(constructDhcpOptions(DHCP.MsgType.DHCPACK));
return pkt;
}
use of org.onlab.packet.DHCP in project dhcpl2relay by opencord.
the class DhcpL2RelayTestBase method constructDhcpDeclinePacket.
/**
* Constructs DHCP Decline Packet.
*
* @return Ethernet packet
*/
Ethernet constructDhcpDeclinePacket(MacAddress clientMac) {
Ethernet pkt = construcEthernetPacket(clientMac, MacAddress.BROADCAST, "255.255.255.255", DHCP.OPCODE_REQUEST, clientMac, Ip4Address.valueOf("0.0.0.0"));
IPv4 ipv4Packet = (IPv4) pkt.getPayload();
UDP udpPacket = (UDP) ipv4Packet.getPayload();
DHCP dhcpPacket = (DHCP) udpPacket.getPayload();
dhcpPacket.setOptions(constructDhcpOptions(DHCP.MsgType.DHCPDECLINE));
return pkt;
}
Aggregations