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