use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class InstructionUtil method readInstructionHeader.
/**
* Deserialize OpenFlow instruction header.
*
* @param version OpenFlow version
* @param message OpenFlow buffered message
* @param registry deserializer registry
*/
@SuppressWarnings("checkstyle:LineLength")
public static Instruction readInstructionHeader(final short version, final ByteBuf message, final DeserializerRegistry registry) {
final int type = message.getUnsignedShort(message.readerIndex());
final HeaderDeserializer<Instruction> deserializer;
if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
deserializer = registry.getDeserializer(new MessageCodeActionExperimenterKey(version, type, Instruction.class, ActionPath.INVENTORY_FLOWNODE_TABLE_APPLY_ACTIONS, null));
} else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
deserializer = registry.getDeserializer(new MessageCodeActionExperimenterKey(version, type, Instruction.class, ActionPath.INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS, null));
} else {
Long expId = null;
if (EncodeConstants.EXPERIMENTER_VALUE == type) {
expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
}
deserializer = registry.getDeserializer(new MessageCodeExperimenterKey(version, type, Instruction.class, expId));
}
return deserializer.deserializeHeader(message);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class GroupMessageDeserializer method deserialize.
@Override
public GroupMessage deserialize(ByteBuf message) {
final GroupMessageBuilder builder = new GroupMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(GroupModCommand.forValue(message.readUnsignedShort()));
builder.setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
message.skipBytes(PADDING);
builder.setGroupId(new GroupId(message.readUnsignedInt()));
final List<Bucket> buckets = new ArrayList<>();
while (message.readableBytes() > 0) {
final int length = message.readUnsignedShort();
final BucketBuilder bucket = new BucketBuilder().setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
message.skipBytes(PADDING_IN_BUCKETS_HEADER);
if (message.readableBytes() > 0) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
final int startIndex = message.readerIndex();
final int bucketLength = length - BUCKETS_HEADER_LENGTH;
int offset = 0;
while (message.readerIndex() - startIndex < bucketLength) {
actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
offset++;
}
bucket.setAction(actions);
}
buckets.add(bucket.build());
}
buckets.sort(COMPARATOR);
return builder.setBuckets(new BucketsBuilder().setBucket(buckets).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class DeviceContextImplTest method testProcessFlowRemovedMessage.
@Test
public void testProcessFlowRemovedMessage() throws Exception {
// prepare translation result
final FlowRemovedBuilder flowRemovedMdsalBld = new FlowRemovedBuilder().setTableId((short) 0).setPriority(42).setCookie(new FlowCookie(BigInteger.ONE)).setMatch(new MatchBuilder().build());
final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
Mockito.when(messageTranslatorFlowRemoved.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(flowRemovedMdsalBld.build());
// insert flow+flowId into local registry
final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowRemovedMdsalBld.build());
final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create((short) 0, new FlowId("ut-ofp:f456"));
deviceContext.getDeviceFlowRegistry().storeDescriptor(flowRegKey, flowDescriptor);
// prepare empty input message
final FlowRemovedMessageBuilder flowRemovedBld = new FlowRemovedMessageBuilder();
// prepare path to flow to be removed
final KeyedInstanceIdentifier<Flow, FlowKey> flowToBeRemovedPath = nodeKeyIdent.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0)).child(Flow.class, new FlowKey(new FlowId("ut-ofp:f456")));
deviceContext.setNotificationPublishService(mockedNotificationPublishService);
deviceContext.processFlowRemovedMessage(flowRemovedBld.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class PortMessageSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
serializer.serialize(MESSAGE, out);
// Header
assertEquals(out.readByte(), VERSION);
assertEquals(out.readByte(), serializer.getMessageType());
assertEquals(out.readShort(), LENGTH);
assertEquals(out.readInt(), XID.intValue());
// Body
assertEquals(out.readInt(), PORT_NUMBER_VAL.intValue());
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
byte[] address = new byte[6];
out.readBytes(address);
assertEquals(new MacAddress(ByteBufUtils.macAddressToString(address)).getValue(), new MacAddress(MAC_ADDRESS).getValue());
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);
// Port config
final int config = ByteBufUtils.fillBitMaskFromMap(ImmutableMap.<Integer, Boolean>builder().put(0, IS_PORTDOWN).put(2, IS_NORECV).put(5, IS_NOFWD).put(6, IS_NOPACKETIN).build());
final int mask = ByteBufUtils.fillBitMaskFromMap(ImmutableMap.<Integer, Boolean>builder().put(0, true).put(2, true).put(5, true).put(6, true).build());
assertEquals(out.readInt(), config);
assertEquals(out.readInt(), mask);
// Port features
assertEquals(out.readInt(), ByteBufUtils.fillBitMask(0, IS_10MBHD, IS_10MBFD, IS_100MBHD, IS_100MBFD, IS_1GBHD, IS_1GBFD, IS_10GBFD, IS_40GBFD, IS_100GBFD, IS_1TBFD, IS_OTHER, IS_COPPER, IS_FIBER, IS_AUTOENG, IS_PAUSE, IS_PAUSE_ASYM));
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03);
assertEquals(out.readableBytes(), 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class TunIpv4DstCodec method deserialize.
@Override
public MatchEntry deserialize(ByteBuf message) {
MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
TunIpv4DstCaseValueBuilder caseBuilder = new TunIpv4DstCaseValueBuilder();
TunIpv4DstValuesBuilder valuesBuilder = new TunIpv4DstValuesBuilder();
valuesBuilder.setValue(message.readUnsignedInt());
caseBuilder.setTunIpv4DstValues(valuesBuilder.build());
matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntriesBuilder.build();
}
Aggregations