Search in sources :

Example 1 with Timestamp

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp in project netvirt by opendaylight.

the class ElanPacketInHandler method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived notification) {
    Class<? extends PacketInReason> pktInReason = notification.getPacketInReason();
    short tableId = notification.getTableId().getValue();
    if (pktInReason == NoMatch.class && tableId == NwConstants.ELAN_SMAC_TABLE) {
        ElanManagerCounters.unknown_smac_pktin_rcv.inc();
        try {
            byte[] data = notification.getPayload();
            Ethernet res = new Ethernet();
            res.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
            byte[] srcMac = res.getSourceMACAddress();
            final String macAddress = NWUtil.toStringMacAddress(srcMac);
            final BigInteger metadata = notification.getMatch().getMetadata().getMetadata();
            final long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
            long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
            Optional<IfIndexInterface> interfaceInfoOp = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
            if (!interfaceInfoOp.isPresent()) {
                LOG.warn("There is no interface for given portTag {}", portTag);
                return;
            }
            String interfaceName = interfaceInfoOp.get().getInterfaceName();
            LOG.debug("Received a packet with srcMac: {} ElanTag: {} PortTag: {} InterfaceName: {}", macAddress, elanTag, portTag, interfaceName);
            ElanTagName elanTagName = elanUtils.getElanInfoByElanTag(elanTag);
            if (elanTagName == null) {
                LOG.warn("not able to find elanTagName in elan-tag-name-map for elan tag {}", elanTag);
                return;
            }
            ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName);
            if (elanInterfaceMac == null) {
                LOG.info("There is no ElanInterfaceForwardingEntryDS created for interface :{}", interfaceName);
                return;
            }
            String elanName = elanTagName.getName();
            PhysAddress physAddress = new PhysAddress(macAddress);
            MacEntry oldMacEntry = elanUtils.getMacEntryForElanInstance(elanName, physAddress).orNull();
            boolean isVlanOrFlatProviderIface = interfaceManager.isExternalInterface(interfaceName);
            Optional<IpAddress> srcIpAddress = elanUtils.getSourceIpAddress(res);
            MacEntry newMacEntry = null;
            BigInteger timeStamp = new BigInteger(String.valueOf(System.currentTimeMillis()));
            if (!srcIpAddress.isPresent()) {
                newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
            } else {
                newMacEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress).setIpPrefix(srcIpAddress.get()).setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp).setIsStaticAddress(false).build();
            }
            if (srcIpAddress.isPresent()) {
                String prefix = srcIpAddress.get().getIpv4Address().getValue();
                InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
                ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
                evpnUtils.advertisePrefix(elanInstance, macAddress, prefix, interfaceName, interfaceInfo.getDpId());
            }
            enqueueJobForMacSpecificTasks(macAddress, elanTag, interfaceName, elanName, physAddress, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
            ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
            InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
            if (interfaceInfo == null) {
                LOG.trace("Interface:{} is not present under Config DS", interfaceName);
                return;
            }
            enqueueJobForDPNSpecificTasks(macAddress, elanTag, interfaceName, physAddress, elanInstance, interfaceInfo, oldMacEntry, newMacEntry, isVlanOrFlatProviderIface);
        } catch (PacketException e) {
            LOG.error("Failed to decode packet: {}", notification, e);
        }
    }
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) MacEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder) NoMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.NoMatch) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) MacEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey)

Example 2 with Timestamp

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp in project bgpcep by opendaylight.

the class AbstractBmpPerPeerMessageParserTest method testPerPeerHeaderIpv6.

@Test
public void testPerPeerHeaderIpv6() {
    final PeerHeader perHeader = AbstractBmpPerPeerMessageParser.parsePerPeerHeader(Unpooled.wrappedBuffer(this.ipv6MsgWithDistinguishergBytes));
    final PeerHeaderBuilder phBuilder = new PeerHeaderBuilder();
    phBuilder.setType(PeerType.L3vpn);
    phBuilder.setPeerDistinguisher(new PeerDistinguisher(new RouteDistinguisher(new RdTwoOctetAs("0:" + RD))));
    phBuilder.setAdjRibInType(AdjRibInType.forValue(1));
    phBuilder.setIpv4(false);
    phBuilder.setAddress(new IpAddress(new Ipv6Address("2001::1")));
    phBuilder.setAs(new AsNumber(168L));
    phBuilder.setBgpId(new Ipv4Address("1.1.1.2"));
    phBuilder.setTimestampSec(new Timestamp(0L));
    phBuilder.setTimestampMicro(new Timestamp(0L));
    assertEquals(phBuilder.build(), perHeader);
    final ByteBuf aggregator = Unpooled.buffer();
    phBuilder.setTimestampSec(null);
    phBuilder.setTimestampMicro(null);
    this.parser.serializePerPeerHeader(phBuilder.build(), aggregator);
    assertArrayEquals(this.ipv6MsgWithDistinguishergBytes, ByteArray.getAllBytes(aggregator));
}
Also used : RdTwoOctetAs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RdTwoOctetAs) PeerHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeader) RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PeerHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeaderBuilder) ByteBuf(io.netty.buffer.ByteBuf) PeerDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Peer.PeerDistinguisher) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) Timestamp(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 3 with Timestamp

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp in project bgpcep by opendaylight.

the class AbstractBmpPerPeerMessageParser method parsePerPeerHeader.

protected static PeerHeader parsePerPeerHeader(final ByteBuf bytes) {
    Preconditions.checkArgument(bytes.readableBytes() >= PER_PEER_HEADER_SIZE);
    final PeerHeaderBuilder phBuilder = new PeerHeaderBuilder();
    final PeerType peerType = PeerType.forValue(bytes.readByte());
    phBuilder.setType(peerType);
    final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    phBuilder.setAdjRibInType(AdjRibInType.forValue(flags.get(L_FLAG_POS) ? 1 : 0));
    phBuilder.setIpv4(!flags.get(V_FLAG_POS));
    switch(peerType) {
        case L3vpn:
            phBuilder.setPeerDistinguisher(new PeerDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(bytes)));
            break;
        case Local:
            phBuilder.setPeerDistinguisher(new PeerDistinguisher(ByteArray.readBytes(bytes, PEER_DISTINGUISHER_SIZE)));
            break;
        case Global:
        default:
            bytes.skipBytes(PEER_DISTINGUISHER_SIZE);
            break;
    }
    if (phBuilder.isIpv4()) {
        bytes.skipBytes(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
        phBuilder.setAddress(new IpAddress(Ipv4Util.addressForByteBuf(bytes)));
    } else {
        phBuilder.setAddress(new IpAddress(Ipv6Util.addressForByteBuf(bytes)));
    }
    phBuilder.setAs(new AsNumber(bytes.readUnsignedInt()));
    phBuilder.setBgpId(Ipv4Util.addressForByteBuf(bytes));
    phBuilder.setTimestampSec(new Timestamp(bytes.readUnsignedInt()));
    phBuilder.setTimestampMicro(new Timestamp(bytes.readUnsignedInt()));
    return phBuilder.build();
}
Also used : PeerType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerType) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BitArray(org.opendaylight.protocol.util.BitArray) PeerHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeaderBuilder) PeerDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Peer.PeerDistinguisher) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) Timestamp(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp)

Example 4 with Timestamp

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp in project java-mapollage by trixon.

the class Operation method addPhoto.

private void addPhoto(File file) throws ImageProcessingException, IOException {
    mPhotoInfo = new PhotoInfo(file, mProfileSource.isIncludeNullCoordinate());
    try {
        mPhotoInfo.init();
    } catch (ImageProcessingException | IOException e) {
        if (mPhotoInfo.hasExif()) {
            mNumOfExif++;
        }
        throw e;
    }
    boolean hasLocation = false;
    if (mPhotoInfo.hasExif()) {
        mNumOfExif++;
        hasLocation = mPhotoInfo.hasGps() && !mPhotoInfo.isZeroCoordinate();
        if (hasLocation) {
            mNumOfGps++;
        }
    } else {
        throw new ImageProcessingException(String.format("E010 %s", file.getAbsolutePath()));
    }
    Date exifDate = mPhotoInfo.getDate();
    if (hasLocation && mProfilePath.isDrawPath()) {
        mLineNodes.add(new LineNode(exifDate, mPhotoInfo.getLat(), mPhotoInfo.getLon()));
    }
    if (hasLocation || mProfileSource.isIncludeNullCoordinate()) {
        Folder folder = getFolder(file, exifDate);
        String imageId = String.format("%08x", FileUtils.checksumCRC32(file));
        String styleNormalId = String.format("s_%s", imageId);
        String styleHighlightId = String.format("s_%s_hl", imageId);
        String styleMapId = String.format("m_%s", imageId);
        Style normalStyle = mDocument.createAndAddStyle().withId(styleNormalId);
        IconStyle normalIconStyle = normalStyle.createAndSetIconStyle().withScale(1.0);
        Style highlightStyle = mDocument.createAndAddStyle().withBalloonStyle(mBalloonStyle).withId(styleHighlightId);
        IconStyle highlightIconStyle = highlightStyle.createAndSetIconStyle().withScale(1.1);
        if (mProfilePlacemark.isSymbolAsPhoto()) {
            Icon icon = KmlFactory.createIcon().withHref(String.format("%s/%s.jpg", mThumbsDir.getName(), imageId));
            normalIconStyle.setIcon(icon);
            normalIconStyle.setScale(mProfilePlacemark.getScale());
            double highlightZoom = mProfilePlacemark.getZoom() * mProfilePlacemark.getScale();
            highlightIconStyle.setIcon(icon);
            highlightIconStyle.setScale(highlightZoom);
        }
        if (mProfilePlacemark.isSymbolAsPhoto() || mProfilePhoto.getReference() == ProfilePhoto.Reference.THUMBNAIL) {
            File thumbFile = new File(mThumbsDir, imageId + ".jpg");
            mFileThumbMap.put(file, thumbFile);
            if (Files.isWritable(thumbFile.getParentFile().toPath())) {
                mPhotoInfo.createThumbnail(thumbFile);
            } else {
                mListener.onOperationLog(String.format(mBundle.getString("insufficient_privileges"), mDestinationFile.getAbsolutePath()));
                Thread.currentThread().interrupt();
                return;
            }
        }
        mDocument.createAndAddStyleMap().withId(styleMapId).addToPair(KmlFactory.createPair().withKey(StyleState.NORMAL).withStyleUrl("#" + styleNormalId)).addToPair(KmlFactory.createPair().withKey(StyleState.HIGHLIGHT).withStyleUrl("#" + styleHighlightId));
        Placemark placemark = KmlFactory.createPlacemark().withName(getSafeXmlString(getPlacemarkName(file, exifDate))).withOpen(Boolean.TRUE).withStyleUrl("#" + styleMapId);
        String desc = getPlacemarkDescription(file, mPhotoInfo, exifDate);
        if (!StringUtils.isBlank(desc)) {
            placemark.setDescription(desc);
        }
        placemark.createAndSetPoint().addToCoordinates(mPhotoInfo.getLon(), mPhotoInfo.getLat(), 0F);
        if (mProfilePlacemark.isTimestamp()) {
            TimeStamp timeStamp = KmlFactory.createTimeStamp();
            timeStamp.setWhen(mTimeStampDateFormat.format(exifDate));
            placemark.setTimePrimitive(timeStamp);
        }
        folder.addToFeature(placemark);
        mNumOfPlacemarks++;
    }
    mListener.onOperationLog(file.getAbsolutePath());
}
Also used : ImageProcessingException(com.drew.imaging.ImageProcessingException) ProfilePlacemark(se.trixon.mapollage.profile.ProfilePlacemark) Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) IOException(java.io.IOException) LineString(de.micromata.opengis.kml.v_2_2_0.LineString) Folder(de.micromata.opengis.kml.v_2_2_0.Folder) ProfileFolder(se.trixon.mapollage.profile.ProfileFolder) Date(java.util.Date) TimeStamp(de.micromata.opengis.kml.v_2_2_0.TimeStamp) IconStyle(de.micromata.opengis.kml.v_2_2_0.IconStyle) LineStyle(de.micromata.opengis.kml.v_2_2_0.LineStyle) PolyStyle(de.micromata.opengis.kml.v_2_2_0.PolyStyle) Style(de.micromata.opengis.kml.v_2_2_0.Style) IconStyle(de.micromata.opengis.kml.v_2_2_0.IconStyle) BalloonStyle(de.micromata.opengis.kml.v_2_2_0.BalloonStyle) Icon(de.micromata.opengis.kml.v_2_2_0.Icon) File(java.io.File)

Example 5 with Timestamp

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp in project bgpcep by opendaylight.

the class PcepStateUtils method showMessages.

private static void showMessages(final ShellTable table, final Messages messages) {
    if (messages == null) {
        return;
    }
    addHeader(table, "Messages");
    table.addRow().addContent("Last Sent Msg Timestamp", messages.getLastSentMsgTimestamp());
    table.addRow().addContent("Received Msg Count", messages.getReceivedMsgCount());
    table.addRow().addContent("Sent Msg Count", messages.getSentMsgCount());
    table.addRow().addContent("Unknown Msg Received", messages.getUnknownMsgReceived());
    final StatefulMessagesStatsAug statefulMessages = messages.getAugmentation(StatefulMessagesStatsAug.class);
    if (statefulMessages == null) {
        return;
    }
    addHeader(table, " Stateful Messages");
    table.addRow().addContent("Last Received RptMsg Timestamp", statefulMessages.getLastReceivedRptMsgTimestamp());
    table.addRow().addContent("Received RptMsg", statefulMessages.getReceivedRptMsgCount());
    table.addRow().addContent("Sent Init Msg", statefulMessages.getSentInitMsgCount());
    table.addRow().addContent("Sent Upd Msg", statefulMessages.getSentUpdMsgCount());
}
Also used : StatefulMessagesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAug)

Aggregations

Date (java.util.Date)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 SimpleDateFormat (java.text.SimpleDateFormat)3 Test (org.junit.Test)3 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3 Timestamp (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp)3 FlowCapableStatisticsGatheringStatus (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus)3 PeerHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeaderBuilder)3 ByteBuf (io.netty.buffer.ByteBuf)2 TransactionChainClosedException (org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2 DateAndTime (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime)2 SnapshotGatheringStatusEnd (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd)2 EidLispAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddress)2 PeerDistinguisher (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Peer.PeerDistinguisher)2 ImageProcessingException (com.drew.imaging.ImageProcessingException)1 BalloonStyle (de.micromata.opengis.kml.v_2_2_0.BalloonStyle)1 Folder (de.micromata.opengis.kml.v_2_2_0.Folder)1 Icon (de.micromata.opengis.kml.v_2_2_0.Icon)1 IconStyle (de.micromata.opengis.kml.v_2_2_0.IconStyle)1