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);
}
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);
}
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);
}
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;
}
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();
}
Aggregations