Search in sources :

Example 96 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project openflowplugin by opendaylight.

the class OF13MatchSerializerTest method testIpv6Flabel.

/**
 * Test for correct serialization of Ipv4Address match entry.
 */
@Test
public void testIpv6Flabel() {
    Match match = buildIpv6FLabelMatch(0x0f9e8dL, false, null);
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    matchSerializer.serialize(match, out);
    Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
    out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
    Assert.assertEquals("Wrong field and mask", 56, out.readUnsignedByte());
    out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    byte[] label = new byte[4];
    out.readBytes(label);
    LOG.debug("label: {}", ByteBufUtils.bytesToHexString(label));
    Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[] { 0, 0x0f, (byte) 0x9e, (byte) 0x8d }, label);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) Test(org.junit.Test)

Example 97 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project openflowplugin by opendaylight.

the class OF13MatchSerializerTest method testIpv6FlabelWithMaskBad.

/**
 * Test for correct serialization of Ipv4Address match entry with wrong mask.
 */
@Test
public void testIpv6FlabelWithMaskBad() {
    Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[] { 0x0c, 0x7b, 0x6a });
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    try {
        matchSerializer.serialize(match, out);
        Assert.fail("incorrect length of mask ignored");
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) Test(org.junit.Test)

Example 98 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project openflowplugin by opendaylight.

the class HandshakeManagerImpl method sendHelloMessage.

/**
 * send hello reply without versionBitmap.
 *
 * @param helloVersion initial hello version for openflow connection negotiation
 * @param helloXid     transaction id
 */
private ListenableFuture<Void> sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception {
    HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
    final SettableFuture<Void> resultFtr = SettableFuture.create();
    LOG.debug("sending hello message: version{}, xid={}, version bitmap={}", helloVersion, helloXid, MessageFactory.digVersions(helloInput.getElements()));
    Future<RpcResult<Void>> helloResult = connectionAdapter.hello(helloInput);
    ListenableFuture<RpcResult<Void>> rpcResultListenableFuture = JdkFutureAdapters.listenInPoolThread(helloResult);
    Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> result) {
            if (result.isSuccessful()) {
                LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress());
                resultFtr.set(null);
            } else {
                for (RpcError error : result.getErrors()) {
                    LOG.debug("hello sending failed [{}]: i:{} s:{} m:{}, addr:{}", helloXid, error.getInfo(), error.getSeverity(), error.getMessage(), connectionAdapter.getRemoteAddress());
                    if (error.getCause() != null) {
                        LOG.trace("DETAIL of sending hello failure", error.getCause());
                    }
                }
                resultFtr.cancel(false);
                handshakeListener.onHandshakeFailure();
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
            LOG.trace("DETAIL of sending of hello failure:", throwable);
            resultFtr.cancel(false);
            handshakeListener.onHandshakeFailure();
        }
    }, MoreExecutors.directExecutor());
    LOG.trace("sending hello message [{}] - result hooked ..", helloXid);
    return resultFtr;
}
Also used : HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 99 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project openflowplugin by opendaylight.

the class DeviceContextImpl method processPacketInMessage.

@Override
public void processPacketInMessage(final PacketInMessage packetInMessage) {
    if (isMasterOfDevice()) {
        final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, getDeviceInfo(), null);
        handlePacketInMessage(packetReceived, packetInMessage.getImplementedInterface(), packetReceived.getMatch());
    } else {
        LOG.debug("Controller is not owner of the device {}, skipping packet_in message", deviceInfo.getLOGValue());
    }
}
Also used : PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived)

Example 100 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project openflowplugin by opendaylight.

the class DeviceContextImpl method processExperimenterMessage.

@Override
public void processExperimenterMessage(final ExperimenterMessage notification) {
    if (isMasterOfDevice()) {
        // lookup converter
        final ExperimenterDataOfChoice vendorData = notification.getExperimenterDataOfChoice();
        final MessageTypeKey<? extends ExperimenterDataOfChoice> key = new MessageTypeKey<>(getDeviceInfo().getVersion(), (Class<? extends ExperimenterDataOfChoice>) vendorData.getImplementedInterface());
        final ConvertorMessageFromOFJava<ExperimenterDataOfChoice, MessagePath> messageConverter = extensionConverterProvider.getMessageConverter(key);
        if (messageConverter == null) {
            LOG.warn("custom converter for {}[OF:{}] not found", notification.getExperimenterDataOfChoice().getImplementedInterface(), getDeviceInfo().getVersion());
            return;
        }
        // build notification
        final ExperimenterMessageOfChoice messageOfChoice;
        try {
            messageOfChoice = messageConverter.convert(vendorData, MessagePath.MESSAGE_NOTIFICATION);
            final ExperimenterMessageFromDevBuilder experimenterMessageFromDevBld = new ExperimenterMessageFromDevBuilder().setNode(new NodeRef(getDeviceInfo().getNodeInstanceIdentifier())).setExperimenterMessageOfChoice(messageOfChoice);
            // publish
            notificationPublishService.offerNotification(experimenterMessageFromDevBld.build());
        } catch (final ConversionException e) {
            LOG.error("Conversion of experimenter notification failed", e);
        }
    } else {
        LOG.debug("Controller is not owner of the device {}, skipping experimenter message", deviceInfo.getLOGValue());
    }
}
Also used : ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) MessagePath(org.opendaylight.openflowplugin.extension.api.path.MessagePath) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) ExperimenterMessageFromDevBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDevBuilder) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) MessageTypeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)

Aggregations

ArrayList (java.util.ArrayList)376 Test (org.junit.Test)275 ByteBuf (io.netty.buffer.ByteBuf)262 ExecutionException (java.util.concurrent.ExecutionException)130 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)123 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)121 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)114 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)100 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder)99 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)98 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)93 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)91 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)85 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)83 BigInteger (java.math.BigInteger)82 List (java.util.List)82 DropActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder)82 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)82 ControllerActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder)81 DropAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction)81