Search in sources :

Example 31 with PhysAddress

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);
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) StaticMacEntriesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntriesBuilder) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ArrayList(java.util.ArrayList) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 32 with PhysAddress

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);
    }
}
Also used : InterfaceAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddressBuilder) SendArpRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.SendArpRequestInput) InterfaceAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddress) SendArpRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.SendArpRequestInputBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 33 with PhysAddress

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;
}
Also used : StaticMacEntriesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntriesBuilder) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 34 with 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 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();
    }
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ArpResponseReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.ArpResponseReceivedBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 35 with 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 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());
}
Also used : SendArpResponseInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.SendArpResponseInputBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SendArpResponseInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.SendArpResponseInput) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) Test(org.junit.Test)

Aggregations

PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)38 ArrayList (java.util.ArrayList)17 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)17 BigInteger (java.math.BigInteger)15 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)8 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 Collections (java.util.Collections)7 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)7 StaticMacEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries)6 List (java.util.List)5 Inject (javax.inject.Inject)5 Singleton (javax.inject.Singleton)5 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)5 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)5 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)5 ElanInterfaceMac (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)5 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)5 StaticMacEntriesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntriesBuilder)5