+ public static BigInteger getDeadBeefBytesForMac() {
+ return new BigInteger("FFFFFFFF", 16).and(new BigInteger(IfmConstants.DEAD_BEEF_MAC_PREFIX, 16)).shiftLeft(16);
+ }
+
+ public static BigInteger fillPortNumberToMac(long portNumber) {
+ return new BigInteger("FFFF", 16).and(BigInteger.valueOf(portNumber));
+ }
+
+ public static String generateMacAddress(long portNo){
+ String unformattedMAC = getDeadBeefBytesForMac().or(fillPortNumberToMac(portNo)).toString(16);
+ return unformattedMAC.replaceAll("(.{2})", "$1"+IfmConstants.MAC_SEPARATOR).
+ substring(0, IfmConstants.MAC_STRING_LENGTH);
+ }
+
+ public static PhysAddress getPhyAddress(long portNo, FlowCapableNodeConnector flowCapableNodeConnector){
+ String southboundMacAddress = flowCapableNodeConnector.getHardwareAddress().getValue();
+ if(IfmConstants.INVALID_MAC.equals(southboundMacAddress)){
+ LOG.debug("Invalid MAC Address received for {}, generating MAC Address", flowCapableNodeConnector.getName());
+ southboundMacAddress = generateMacAddress(portNo);
+ }
+ return new PhysAddress(southboundMacAddress);
+ }
+
+ public static void updateInterfaceParentRef(WriteTransaction t, String interfaceName, String parentInterface) {
+ InstanceIdentifier<ParentRefs> parentRefIdentifier = InstanceIdentifier.builder(Interfaces.class)
+ .child(Interface.class, new InterfaceKey(interfaceName)).augmentation(ParentRefs.class).build();
+ ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentInterface).build();
+ t.merge(LogicalDatastoreType.CONFIGURATION, parentRefIdentifier, parentRefs);
+ LOG.debug("Updating parentRefInterface for interfaceName {}. interfaceKey {}, with parentRef augmentation pointing to {}",
+ interfaceName, new InterfaceKey(interfaceName), parentInterface);
+ }
+
+ public static InstanceIdentifier<BoundServices> buildBoundServicesIId(short servicePriority, String interfaceName,
+ Class<? extends ServiceModeBase> serviceMode) {
+ return InstanceIdentifier.builder(ServiceBindings.class)
+ .child(ServicesInfo.class, new ServicesInfoKey(interfaceName, serviceMode))
+ .child(BoundServices.class, new BoundServicesKey(servicePriority))
+ .build();
+ }
+