Search in sources :

Example 31 with DHCP

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;
}
Also used : UDP(org.onlab.packet.UDP) Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) DHCP(org.onlab.packet.DHCP)

Example 32 with DHCP

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;
}
Also used : UDP(org.onlab.packet.UDP) Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) DHCP(org.onlab.packet.DHCP)

Example 33 with DHCP

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;
}
Also used : UDP(org.onlab.packet.UDP) Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) DHCP(org.onlab.packet.DHCP)

Aggregations

DHCP (org.onlab.packet.DHCP)33 Ethernet (org.onlab.packet.Ethernet)27 UDP (org.onlab.packet.UDP)23 IPv4 (org.onlab.packet.IPv4)22 DhcpOption (org.onlab.packet.dhcp.DhcpOption)12 ConnectPoint (org.onosproject.net.ConnectPoint)11 ArrayList (java.util.ArrayList)9 MacAddress (org.onlab.packet.MacAddress)9 Interface (org.onosproject.net.intf.Interface)9 ByteBuffer (java.nio.ByteBuffer)8 Ip4Address (org.onlab.packet.Ip4Address)8 VlanId (org.onlab.packet.VlanId)8 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)7 Lists (com.google.common.collect.Lists)7 Collection (java.util.Collection)7 List (java.util.List)7 Optional (java.util.Optional)7 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)7 Collectors (java.util.stream.Collectors)7 IpAddress (org.onlab.packet.IpAddress)7