use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.
the class OvsInterfaceStateAddHelper method addState.
public List<ListenableFuture<Void>> addState(String interfaceName, Interface parentInterface) {
if (parentInterface.getLowerLayerIf() == null || parentInterface.getLowerLayerIf().isEmpty()) {
LOG.trace("Cannot obtain lower layer if, not proceeding with Interface State addition for interface: {}", interfaceName);
}
NodeConnectorId nodeConnectorId = new NodeConnectorId(parentInterface.getLowerLayerIf().get(0));
PhysAddress physAddress = parentInterface.getPhysAddress();
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
return addState(nodeConnectorId, interfaceName, portNo, physAddress);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.
the class OvsInterfaceStateUpdateHelper method updateState.
public List<ListenableFuture<Void>> updateState(String interfaceName, FlowCapableNodeConnector flowCapableNodeConnectorNew, FlowCapableNodeConnector flowCapableNodeConnectorOld) {
LOG.debug("Updating interface state information for interface: {}", interfaceName);
Interface.OperStatus operStatusNew = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorNew);
MacAddress macAddressNew = flowCapableNodeConnectorNew.getHardwareAddress();
Interface.OperStatus operStatusOld = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorOld);
MacAddress macAddressOld = flowCapableNodeConnectorOld.getHardwareAddress();
boolean opstateModified = !operStatusNew.equals(operStatusOld);
boolean hardwareAddressModified = !macAddressNew.equals(macAddressOld);
if (!opstateModified && !hardwareAddressModified) {
LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
return Collections.emptyList();
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName);
// For monitoring enabled tunnels, skip opstate update
if (isTunnelInterface(iface) && !modifyTunnelOpState(iface, opstateModified)) {
LOG.debug("skip interface-state updation for monitoring enabled tunnel interface {}", interfaceName);
opstateModified = false;
}
if (!opstateModified && !hardwareAddressModified) {
LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
return Collections.emptyList();
}
InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
if (hardwareAddressModified) {
LOG.debug("Hw-Address Modified for Port: {}", interfaceName);
PhysAddress physAddress = new PhysAddress(macAddressNew.getValue());
ifaceBuilder.setPhysAddress(physAddress);
}
if (opstateModified) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// modify the attributes in interface operational DS
handleInterfaceStateUpdates(iface, tx, ifaceBuilder, true, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
// start/stop monitoring based on opState
if (isTunnelInterface(iface)) {
handleTunnelMonitoringUpdates(iface.getAugmentation(IfTunnel.class), iface.getName(), operStatusNew);
}
}));
} else {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// modify the attributes in interface operational DS
handleInterfaceStateUpdates(iface, tx, ifaceBuilder, false, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
}));
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.
the class ArpUtilImpl method checkAndFireMacChangedNotification.
private void checkAndFireMacChangedNotification(String interfaceName, InetAddress inetAddr, byte[] macAddressBytes) throws InterruptedException {
IpAddress ip = new IpAddress(inetAddr.getHostAddress().toCharArray());
String macAddress = NWUtil.toStringMacAddress(macAddressBytes);
PhysAddress mac = new PhysAddress(macAddress);
if (!macAddress.equals(macsDB.get(interfaceName + "-" + inetAddr.getHostAddress()))) {
if (LOG.isTraceEnabled()) {
LOG.trace("mac address changed for {}", inetAddr);
}
MacChangedBuilder builder = new MacChangedBuilder();
builder.setInterface(interfaceName);
builder.setIpaddress(ip);
builder.setMacaddress(mac);
notificationPublishService.putNotification(builder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.
the class ArpUtilImpl method fireArpReqRecvdNotification.
private void fireArpReqRecvdNotification(String interfaceName, InetAddress srcInetAddr, byte[] srcMac, InetAddress dstInetAddr, int tableId, BigInteger metadata) throws InterruptedException {
arpReqRecvd.mark();
String macAddress = NWUtil.toStringMacAddress(srcMac);
ArpRequestReceivedBuilder builder = new ArpRequestReceivedBuilder();
builder.setInterface(interfaceName);
builder.setOfTableId((long) tableId);
builder.setSrcIpaddress(new IpAddress(srcInetAddr.getHostAddress().toCharArray()));
builder.setDstIpaddress(new IpAddress(dstInetAddr.getHostAddress().toCharArray()));
builder.setSrcMac(new PhysAddress(macAddress));
builder.setMetadata(metadata);
ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(builder.build());
if (offerNotification != null && offerNotification.equals(NotificationPublishService.REJECTED)) {
arpReqRecvdNotificationRejected.mark();
} else {
arpReqRecvdNotification.mark();
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.
the class ArpUtilTest method testGetMac.
@Test
public void testGetMac() throws Exception {
final InterfaceAddress interfaceAddress = new InterfaceAddressBuilder().setInterface(INTERFACE_NAME).setIpAddress(new IpAddress(Ipv4Address.getDefaultInstance("192.168.0.1"))).setMacaddress(new PhysAddress("1F:1F:1F:1F:1F:1F")).build();
final List<InterfaceAddress> itf = Arrays.asList(interfaceAddress);
GetMacInput getMacInput = new GetMacInputBuilder().setIpaddress(new IpAddress(Ipv4Address.getDefaultInstance("192.168.0.2"))).setInterfaceAddress(itf).build();
// request payload
PacketReceived packetReceived = ArpUtilTestUtil.createPayload(0);
Future<RpcResult<GetMacOutput>> output = odlArputilService.getMac(getMacInput);
arpUtil.onPacketReceived(packetReceived);
Assert.assertEquals("00:01:02:03:04:05", output.get().getResult().getMacaddress().getValue());
}
Aggregations