Search in sources :

Example 86 with Destination

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

the class OfToSalIpv6DstCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull Ipv6DstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
    final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = data.getIpv6MatchArbitraryBitMaskBuilder();
    Ipv6Dst ipv6Dst = source.getIpv6Dst();
    if (ipv6Dst != null) {
        byte[] mask = ipv6Dst.getMask();
        if (mask != null && IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
            if (ipv6MatchBuilder.getIpv6Source() != null) {
                Ipv6Prefix ipv6PrefixSourceAddress = ipv6MatchBuilder.getIpv6Source();
                Ipv6Address ipv6SrcAddress = IpConversionUtil.extractIpv6Address(ipv6PrefixSourceAddress);
                Ipv6ArbitraryMask srcIpv6Arbitrary = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.extractIpv6AddressMask(ipv6PrefixSourceAddress));
                setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, srcIpv6Arbitrary, IpConversionUtil.compressedIpv6AddressFormat(ipv6SrcAddress));
            }
            Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.createIpv6ArbitraryBitMask(mask));
            Ipv6Address stringIpv6DstAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Dst.getIpv6Address());
            setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, dstIpv6ArbitraryMask, stringIpv6DstAddress);
            matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
        } else if (ipv6MatchArbitraryBitMaskBuilder.getIpv6SourceAddressNoMask() != null) {
            /*
                         TODO Change comments
                        Case where source is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
                        source which of type ipv6Match needs to be converted to ipv6MatchArbitraryBitMask.
                        We convert 1::/32 to 1::/FFFF:FFFF::
                        example:-
                        <ipv6-destination>1::/32</ipv6-destination>
                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
                        after conversion output example:-
                        <ipv6-destination-address-no-mask>1::</ipv6-destination-address-no-mask>
                        <ipv6-destination-arbitrary-bitmask>FFFF:FFFF::</ipv6-destination-arbitrary-bitmask>
                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
                        */
            Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.createIpv6ArbitraryBitMask(mask));
            Ipv6Address stringIpv6DstAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Dst.getIpv6Address());
            setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, dstIpv6ArbitraryMask, stringIpv6DstAddress);
            matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
        } else {
            Ipv6Address stringIpv6DstAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Dst.getIpv6Address());
            setIpv6MatchBuilderFields(ipv6MatchBuilder, mask, stringIpv6DstAddress);
            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
        }
    }
    return Optional.of(matchBuilder);
}
Also used : Ipv6Dst(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6Dst) Ipv6ArbitraryMask(org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask) Ipv6MatchArbitraryBitMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 87 with Destination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project lispflowmapping by opendaylight.

the class MapServerTest method handleMapRegisterTest_withTwoMappingRecords.

@Test
@Ignore
public void handleMapRegisterTest_withTwoMappingRecords() throws NoSuchFieldException, IllegalAccessException {
    setConfigIniMappingMergeField(true);
    // Input
    // Add a MappingRecord with SrcDestKey Eid Type
    final MappingRecordItemBuilder mappingRecordItemBuilder = new MappingRecordItemBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(SOURCE_DEST_KEY_EID).build());
    final MapRegisterBuilder mapRegisterSrcDstBuilder = getDefaultMapRegisterBuilder();
    final List<MappingRecordItem> list = mapRegisterSrcDstBuilder.getMappingRecordItem();
    list.add(mappingRecordItemBuilder.build());
    // ------------- Stubbing for SourceDestKey type Eid mapping -------------------
    Mockito.when(mapService.getAuthenticationKey(SOURCE_DEST_KEY_EID)).thenReturn(MAPPING_AUTHKEY);
    Mockito.when(mapService.getMapping(MappingOrigin.Southbound, SOURCE_DEST_KEY_EID)).thenReturn(OLD_MAPPING_DATA_1).thenReturn(OLD_MAPPING_DATA_2).thenReturn(OLD_MAPPING_DATA_2);
    // return a subscriberSet for SrcDestKeyEid MappingRecord
    Mockito.when(mapService.getData(MappingOrigin.Southbound, SOURCE_DEST_KEY_EID, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_1);
    // return a subscriberSet for SrcDestKeyEid destination MappingRecord
    Mockito.when(mapService.getData(MappingOrigin.Southbound, SourceDestKeyHelper.getDstBinary(SOURCE_DEST_KEY_EID), SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_2);
    // ----------------- Stubbing for Ipv4 type Eid mapping ------------------------
    Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
    Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1)).thenReturn(OLD_MAPPING_DATA_1).thenReturn(OLD_MAPPING_DATA_2);
    // return a subscriberSet for Ipv4Eid MappingRecord
    Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_3);
    // -----------------------------------------------------------------------------
    // result
    mapServer.handleMapRegister(mapRegisterSrcDstBuilder.build());
    // for SrcDstKey mapping
    final ArgumentCaptor<MapRequest> captor_1 = ArgumentCaptor.forClass(MapRequest.class);
    Mockito.verify(notifyHandler, Mockito.times(1)).handleSMR(captor_1.capture(), Mockito.eq(RLOC_2));
    final Eid resultEid_1 = captor_1.getValue().getEidItem().iterator().next().getEid();
    assertEquals(IPV4_SOURCE_EID_2, resultEid_1);
    // for SrcDst destination mapping
    final ArgumentCaptor<MapRequest> captor_2 = ArgumentCaptor.forClass(MapRequest.class);
    Mockito.verify(notifyHandler, Mockito.times(1)).handleSMR(captor_2.capture(), Mockito.eq(RLOC_4));
    final Eid resultEid_2 = captor_2.getValue().getEidItem().iterator().next().getEid();
    assertEquals(IPV4_SOURCE_EID_4, resultEid_2);
    // for Ipv4 mapping
    final ArgumentCaptor<MapRequest> captor_3 = ArgumentCaptor.forClass(MapRequest.class);
    Mockito.verify(notifyHandler, Mockito.times(2)).handleSMR(captor_3.capture(), Mockito.eq(RLOC_6));
    final Eid resultEid_3 = captor_3.getValue().getEidItem().iterator().next().getEid();
    assertEquals(IPV4_SOURCE_EID_6, resultEid_3);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 88 with Destination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project lispflowmapping by opendaylight.

the class LispAddressStringifier method getStringFromExplicitLocatorPath.

protected static String getStringFromExplicitLocatorPath(Destination dst, ExplicitLocatorPath addr) {
    // AFI = 16387, LCAF Type 10, Explicit Locator Path
    // Example rendering:
    // {192.0.2.1->192.0.2.2|lps->192.0.2.3}
    List<Hop> hops = addr.getExplicitLocatorPath().getHop();
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    boolean needArrow = false;
    for (Hop hop : hops) {
        if (needArrow) {
            sb.append("->");
        }
        sb.append(LispSimpleAddressStringifier.getString(dst, hop.getAddress()));
        LrsBits lrs = hop.getLrsBits();
        if (lrs.isLookup() || lrs.isRlocProbe() || lrs.isStrict()) {
            sb.append("|");
        }
        if (lrs.isLookup()) {
            sb.append("l");
        }
        if (lrs.isRlocProbe()) {
            sb.append("p");
        }
        if (lrs.isStrict()) {
            sb.append("s");
        }
        needArrow = true;
    }
    sb.append("}");
    return sb.toString();
}
Also used : LrsBits(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop)

Example 89 with Destination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project genius by opendaylight.

the class ArpUtilTestUtil method createPayload.

public static PacketReceived createPayload(int oc) {
    final short ID = 2;
    byte[] payload = bytePayload(// Destination MAC
    "1F 1F 1F 1F 1F 1F", // Source MAC
    "00 01 02 03 04 05", // Ethernet type
    "08 06", // Hardware type
    "0 1", // Protocol type
    "8 0", // Hardware size
    "6", // Protocol size
    "4", // Opcode
    OP_CODE[oc], // Sender MAC Address
    "00 01 02 03 04 05", // Sender IP Address
    "C0 A8 0 2", // Target MAC Address
    "00 01 02 03 04 05", // Target IP Address
    "C0 A8 0 2");
    return new PacketReceivedBuilder().setPacketInReason(SendToController.class).setTableId(new TableId(ID)).setPayload(payload).setIngress(new NodeConnectorRef(InstanceIdentifier.create(Node.class))).setMatch(new MatchBuilder().setMetadata(new MetadataBuilder().setMetadata(META_DATA).build()).build()).build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) SendToController(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController) MetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder)

Example 90 with Destination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project genius by opendaylight.

the class AlivenessProtocolHandlerARP method startMonitoringTask.

@Override
public void startMonitoringTask(MonitoringInfo monitorInfo) {
    if (arpService == null) {
        LOG.debug("ARP Service not available to send the packet");
        return;
    }
    EndpointType source = monitorInfo.getSource().getEndpointType();
    final String sourceInterface = Preconditions.checkNotNull(getInterfaceName(source), "Source interface is required to send ARP Packet for monitoring");
    final String srcIp = Preconditions.checkNotNull(getIpAddress(source), "Source Ip address is required to send ARP Packet for monitoring");
    final Optional<PhysAddress> srcMacAddressOptional = getMacAddress(source);
    if (srcMacAddressOptional.isPresent()) {
        PhysAddress srcMacAddress = srcMacAddressOptional.get();
        EndpointType target = monitorInfo.getDestination().getEndpointType();
        final String targetIp = Preconditions.checkNotNull(getIpAddress(target), "Target Ip address is required to send ARP Packet for monitoring");
        if (LOG.isTraceEnabled()) {
            LOG.trace("sendArpRequest interface {}, senderIPAddress {}, targetAddress {}", sourceInterface, srcIp, targetIp);
        }
        InterfaceAddressBuilder interfaceAddressBuilder = new InterfaceAddressBuilder().setInterface(sourceInterface).setIpAddress(IpAddressBuilder.getDefaultInstance(srcIp));
        if (srcMacAddress != null) {
            interfaceAddressBuilder.setMacaddress(srcMacAddress);
        }
        List<InterfaceAddress> addresses = Collections.singletonList(interfaceAddressBuilder.build());
        SendArpRequestInput input = new SendArpRequestInputBuilder().setInterfaceAddress(addresses).setIpaddress(IpAddressBuilder.getDefaultInstance(targetIp)).build();
        Future<RpcResult<Void>> future = arpService.sendArpRequest(input);
        final String msgFormat = String.format("Send ARP Request on interface %s to destination %s", sourceInterface, targetIp);
        Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future), new FutureCallback<RpcResult<Void>>() {

            @Override
            public void onFailure(Throwable error) {
                LOG.error("Error - {}", msgFormat, error);
            }

            @Override
            public void onSuccess(RpcResult<Void> result) {
                if (result != null && !result.isSuccessful()) {
                    LOG.warn("Rpc call to {} failed {}", msgFormat, getErrorText(result.getErrors()));
                } else {
                    LOG.debug("Successful RPC Result - {}", msgFormat);
                }
            }
        });
    }
}
Also used : SendArpRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.SendArpRequestInput) InterfaceAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddress) SendArpRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.SendArpRequestInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) InterfaceAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddressBuilder) EndpointType(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.EndpointType) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Aggregations

ArrayList (java.util.ArrayList)36 Test (org.junit.Test)25 ExecutionException (java.util.concurrent.ExecutionException)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)14 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)14 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)13 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)13 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)13 List (java.util.List)12 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)12 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)11 BigInteger (java.math.BigInteger)10 Collections (java.util.Collections)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 Inject (javax.inject.Inject)9 Singleton (javax.inject.Singleton)9 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)9 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)8 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)8