Search in sources :

Example 21 with UDP

use of org.onlab.packet.UDP in project onos by opennetworkinglab.

the class BaseOptionsTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    data = new Data();
    data.setData("testSerialize".getBytes());
    udp = new UDP();
    udp.setPayload(data);
    byte[] bytePayload = udp.serialize();
    byte[] byteHeader = { (byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00 };
    bytePacket = new byte[byteHeader.length + bytePayload.length];
    System.arraycopy(byteHeader, 0, bytePacket, 0, byteHeader.length);
    System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
}
Also used : UDP(org.onlab.packet.UDP) Data(org.onlab.packet.Data) BeforeClass(org.junit.BeforeClass)

Example 22 with UDP

use of org.onlab.packet.UDP in project onos by opennetworkinglab.

the class FragmentTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    data = new Data();
    data.setData("testSerialize".getBytes());
    udp = new UDP();
    udp.setPayload(data);
    byte[] bytePayload = udp.serialize();
    byte[] byteHeader = { (byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0xf9, (byte) 0x00, (byte) 0x00, (byte) 0x13, (byte) 0x57 };
    bytePacket = new byte[byteHeader.length + bytePayload.length];
    System.arraycopy(byteHeader, 0, bytePacket, 0, byteHeader.length);
    System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
}
Also used : UDP(org.onlab.packet.UDP) Data(org.onlab.packet.Data) BeforeClass(org.junit.BeforeClass)

Example 23 with UDP

use of org.onlab.packet.UDP in project onos by opennetworkinglab.

the class RoutingTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    data = new Data();
    data.setData("testSerialize".getBytes());
    udp = new UDP();
    udp.setPayload(data);
    byte[] bytePayload = udp.serialize();
    byte[] byteHeader = { (byte) 0x11, (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x20, (byte) 0x01, (byte) 0x0f, (byte) 0x18, (byte) 0x01, (byte) 0x13, (byte) 0x02, (byte) 0x15, (byte) 0xca, (byte) 0x2a, (byte) 0x14, (byte) 0xff, (byte) 0xfe, (byte) 0x35, (byte) 0x26, (byte) 0xce };
    bytePacket = new byte[byteHeader.length + bytePayload.length];
    System.arraycopy(byteHeader, 0, bytePacket, 0, byteHeader.length);
    System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
}
Also used : UDP(org.onlab.packet.UDP) Data(org.onlab.packet.Data) BeforeClass(org.junit.BeforeClass)

Example 24 with UDP

use of org.onlab.packet.UDP in project onos by opennetworkinglab.

the class Dhcp6IndirectPacketClassifier method match.

@Override
public boolean match(PacketContext packet) {
    Ethernet eth = packet.inPacket().parsed();
    if (eth.getEtherType() == Ethernet.TYPE_IPV6) {
        IPv6 ipv6Packet = (IPv6) eth.getPayload();
        if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_UDP) {
            UDP udpPacket = (UDP) ipv6Packet.getPayload();
            // Indirectly connected host
            if (udpPacket.getDestinationPort() == UDP.DHCP_V6_SERVER_PORT && udpPacket.getSourcePort() == UDP.DHCP_V6_SERVER_PORT && Arrays.equals(ipv6Packet.getDestinationAddress(), Ip6Address.valueOf("ff02::1:2").toOctets())) {
                DHCP6 relayMessage = (DHCP6) udpPacket.getPayload();
                DHCP6 dhcp6 = (DHCP6) relayMessage.getOptions().stream().filter(opt -> opt instanceof Dhcp6RelayOption).map(BasePacket::getPayload).map(pld -> (DHCP6) pld).findFirst().orElse(null);
                if (dhcp6.getMsgType() == DHCP6.MsgType.SOLICIT.value()) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : UDP(org.onlab.packet.UDP) IPv6(org.onlab.packet.IPv6) BasePacket(org.onlab.packet.BasePacket) Ethernet(org.onlab.packet.Ethernet) Ip6Address(org.onlab.packet.Ip6Address) DHCP6(org.onlab.packet.DHCP6) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) PacketContext(org.onosproject.net.packet.PacketContext) PacketInClassifier(org.onosproject.net.packet.PacketInClassifier) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) UDP(org.onlab.packet.UDP) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) IPv6(org.onlab.packet.IPv6) Ethernet(org.onlab.packet.Ethernet) DHCP6(org.onlab.packet.DHCP6) BasePacket(org.onlab.packet.BasePacket) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption)

Example 25 with UDP

use of org.onlab.packet.UDP in project onos by opennetworkinglab.

the class DefaultLispEncapsulatedControlTest method setup.

@Before
public void setup() {
    // Creates ecm1
    EcmBuilder builder1 = new DefaultEcmBuilder();
    IP innerIp1 = new IPv4().setSourceAddress(ECM1_SRC_IP).setDestinationAddress(ECM1_DST_IP).setProtocol(IPv4.PROTOCOL_UDP).setVersion((byte) (4 & 0xf));
    UDP innerUdp1 = new UDP().setSourcePort(1).setDestinationPort(2);
    RegisterBuilder msgBuilder = new DefaultRegisterBuilder();
    List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord());
    LispMapRegister innerMsg1 = msgBuilder.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records1).build();
    ecm1 = builder1.isSecurity(false).innerIpHeader(innerIp1).innerUdpHeader(innerUdp1).innerLispMessage(innerMsg1).build();
    // Creates sameAsEcm1
    EcmBuilder builder2 = new DefaultEcmBuilder();
    IP innerIp2 = new IPv4().setSourceAddress(ECM1_SRC_IP).setDestinationAddress(ECM1_DST_IP).setProtocol(IPv4.PROTOCOL_UDP);
    UDP innerUdp2 = new UDP().setSourcePort(1).setDestinationPort(2);
    RegisterBuilder msgBuilder2 = new DefaultRegisterBuilder();
    List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord());
    LispMapRegister innerMsg2 = msgBuilder2.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records2).build();
    sameAsEcm1 = builder2.isSecurity(false).innerIpHeader(innerIp2).innerUdpHeader(innerUdp2).innerLispMessage(innerMsg2).build();
    // Creates ecm2
    EcmBuilder builder3 = new DefaultEcmBuilder();
    IP innerIp3 = new IPv4().setSourceAddress(ECM2_SRC_IP).setDestinationAddress(ECM2_DST_IP).setProtocol(IPv4.PROTOCOL_UDP);
    UDP innerUdp3 = new UDP().setSourcePort(10).setDestinationPort(20);
    RegisterBuilder msgBuilder3 = new DefaultRegisterBuilder();
    List<LispMapRecord> records3 = ImmutableList.of(getMapRecord(), getMapRecord());
    LispMapRegister innerMsg3 = msgBuilder3.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 2).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records3).build();
    ecm2 = builder3.isSecurity(false).innerIpHeader(innerIp3).innerUdpHeader(innerUdp3).innerLispMessage(innerMsg3).build();
}
Also used : UDP(org.onlab.packet.UDP) DefaultEcmBuilder(org.onosproject.lisp.msg.protocols.DefaultLispEncapsulatedControl.DefaultEcmBuilder) EcmBuilder(org.onosproject.lisp.msg.protocols.LispEncapsulatedControl.EcmBuilder) IP(org.onlab.packet.IP) IPv4(org.onlab.packet.IPv4) DefaultEcmBuilder(org.onosproject.lisp.msg.protocols.DefaultLispEncapsulatedControl.DefaultEcmBuilder) RegisterBuilder(org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) Before(org.junit.Before)

Aggregations

UDP (org.onlab.packet.UDP)46 Ethernet (org.onlab.packet.Ethernet)36 IPv4 (org.onlab.packet.IPv4)24 DHCP (org.onlab.packet.DHCP)19 IPv6 (org.onlab.packet.IPv6)17 DHCP6 (org.onlab.packet.DHCP6)16 ConnectPoint (org.onosproject.net.ConnectPoint)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 MacAddress (org.onlab.packet.MacAddress)10 Interface (org.onosproject.net.intf.Interface)9 VlanId (org.onlab.packet.VlanId)8 DhcpOption (org.onlab.packet.dhcp.DhcpOption)8 DhcpServerInfo (org.onosproject.dhcprelay.api.DhcpServerInfo)8 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)8 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8 IpAddress (org.onlab.packet.IpAddress)7 DeviceId (org.onosproject.net.DeviceId)7 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)7 TrafficSelector (org.onosproject.net.flow.TrafficSelector)7