use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class ElanServiceTestBase method addElanInterface.
public void addElanInterface(String elanInstanceName, InterfaceInfo interfaceInfo, String prefix) {
ElanInstance existingElanInstance = elanInstanceCache.get(elanInstanceName).orNull();
String interfaceName = interfaceInfo.getInterfaceName();
if (existingElanInstance != null) {
ElanInterfaceBuilder elanInterfaceBuilder = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName));
StaticMacEntriesBuilder staticMacEntriesBuilder = new StaticMacEntriesBuilder();
List<StaticMacEntries> staticMacEntries = new ArrayList<>();
List<PhysAddress> physAddressList = Collections.singletonList(new PhysAddress(interfaceInfo.getMacAddress()));
for (PhysAddress physAddress : physAddressList) {
staticMacEntries.add(staticMacEntriesBuilder.setMacAddress(physAddress).setIpPrefix(new IpAddress(new Ipv4Address(prefix))).build());
}
elanInterfaceBuilder.setStaticMacEntries(staticMacEntries);
ElanInterface elanInterface = elanInterfaceBuilder.build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class NeutronSubnetGwMacResolver method sendArpRequest.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void sendArpRequest(IpAddress srcIpAddress, IpAddress dstIpAddress, MacAddress srcMacAddress, String interfaceName) {
if (srcIpAddress == null || dstIpAddress == null) {
LOG.trace("Skip sending ARP to external GW srcIp {} dstIp {}", srcIpAddress, dstIpAddress);
return;
}
PhysAddress srcMacPhysAddress = new PhysAddress(srcMacAddress.getValue());
try {
InterfaceAddress interfaceAddress = new InterfaceAddressBuilder().setInterface(interfaceName).setIpAddress(srcIpAddress).setMacaddress(srcMacPhysAddress).build();
SendArpRequestInput sendArpRequestInput = new SendArpRequestInputBuilder().setIpaddress(dstIpAddress).setInterfaceAddress(Collections.singletonList(interfaceAddress)).build();
ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(arpUtilService.sendArpRequest(sendArpRequestInput)), LOG, "Send ARP request");
} catch (Exception e) {
LOG.error("Failed to send ARP request to external GW {} from interface {}", dstIpAddress.getIpv4Address().getValue(), interfaceName, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class NeutronvpnUtils method buildStaticMacEntry.
public static List<StaticMacEntries> buildStaticMacEntry(Port port) {
PhysAddress physAddress = new PhysAddress(port.getMacAddress().getValue());
List<FixedIps> fixedIps = port.getFixedIps();
IpAddress ipAddress = null;
if (isNotEmpty(fixedIps)) {
ipAddress = port.getFixedIps().get(0).getIpAddress();
}
StaticMacEntriesBuilder staticMacEntriesBuilder = new StaticMacEntriesBuilder();
List<StaticMacEntries> staticMacEntries = new ArrayList<>();
if (ipAddress != null) {
staticMacEntries.add(staticMacEntriesBuilder.setMacAddress(physAddress).setIpPrefix(ipAddress).build());
} else {
staticMacEntries.add(staticMacEntriesBuilder.setMacAddress(physAddress).build());
}
return staticMacEntries;
}
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 fireArpRespRecvdNotification.
private void fireArpRespRecvdNotification(String interfaceName, InetAddress srcInetAddr, byte[] srcMacAddressBytes, int tableId, BigInteger metadata, InetAddress dstInetAddr, byte[] dstMacAddressBytes) throws InterruptedException {
arpRespRecvd.mark();
IpAddress srcIp = new IpAddress(srcInetAddr.getHostAddress().toCharArray());
IpAddress dstIp = new IpAddress(dstInetAddr.getHostAddress().toCharArray());
String srcMacAddress = NWUtil.toStringMacAddress(srcMacAddressBytes);
PhysAddress srcMac = new PhysAddress(srcMacAddress);
String dstMacAddress = NWUtil.toStringMacAddress(dstMacAddressBytes);
PhysAddress dstMac = new PhysAddress(dstMacAddress);
ArpResponseReceivedBuilder builder = new ArpResponseReceivedBuilder();
builder.setInterface(interfaceName);
builder.setSrcIpaddress(srcIp);
builder.setOfTableId((long) tableId);
builder.setSrcMac(srcMac);
builder.setMetadata(metadata);
builder.setDstIpaddress(dstIp);
builder.setDstMac(dstMac);
ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(builder.build());
if (offerNotification != null && offerNotification.equals(NotificationPublishService.REJECTED)) {
arpRespRecvdNotificationRejected.mark();
} else {
arpRespRecvdNotification.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 testSendArpResponse.
@Test
public void testSendArpResponse() throws Exception {
SendArpResponseInput builder = new SendArpResponseInputBuilder().setInterface(INTERFACE_NAME).setSrcIpaddress(new IpAddress(Ipv4Address.getDefaultInstance("192.168.0.1"))).setDstIpaddress(new IpAddress(Ipv4Address.getDefaultInstance("192.168.0.2"))).setSrcMacaddress(new PhysAddress("1F:1F:1F:1F:1F:1F")).setDstMacaddress(new PhysAddress("00:01:02:03:04:05")).build();
Assert.assertEquals(true, odlArputilService.sendArpResponse(builder).get().isSuccessful());
}
Aggregations