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