Search in sources :

Example 96 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project openflowplugin by opendaylight.

the class MeterFeaturesService method transformToNotification.

@Override
public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
    final int mpSize = result.size();
    Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
    MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
    notification.setId(getDeviceInfo().getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
    MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
    notification.setMaxBands(replyBody.getMaxBands());
    notification.setMaxColor(replyBody.getMaxColor());
    notification.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
    notification.setMeterCapabilitiesSupported(extractMeterCapabilities(replyBody.getCapabilities()));
    notification.setMeterBandSupported(extractSupportedMeterBand(replyBody, replyBody.getBandTypes()));
    return notification.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFeaturesUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)

Example 97 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project openflowplugin by opendaylight.

the class SystemNotificationsListenerImplTest method testOnSwitchIdleEvent1.

/**
 * First encounter of idle event, echo received successfully.
 */
@Test
public void testOnSwitchIdleEvent1() throws Exception {
    final Future<RpcResult<EchoOutput>> echoReply = Futures.immediateFuture(RpcResultBuilder.success(new EchoOutputBuilder().setXid(0L).build()).build());
    Mockito.when(connectionAdapter.echo(Matchers.any(EchoInput.class))).thenReturn(echoReply);
    SwitchIdleEvent notification = new SwitchIdleEventBuilder().setInfo("wake up, device sleeps").build();
    systemNotificationsListener.onSwitchIdleEvent(notification);
    // make sure that the idle notification processing thread started
    Thread.sleep(SAFE_TIMEOUT);
    verifyCommonInvocations();
    Mockito.verify(connectionAdapter, Mockito.timeout(SAFE_TIMEOUT)).echo(Matchers.any(EchoInput.class));
    Mockito.verify(connectionAdapter, Mockito.never()).disconnect();
    Mockito.verify(connectionContext).changeStateToTimeouting();
    Mockito.verify(connectionContext).changeStateToWorking();
}
Also used : SwitchIdleEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder) EchoInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput) SwitchIdleEvent(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) EchoOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder) Test(org.junit.Test)

Example 98 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project openflowplugin by opendaylight.

the class LearningSwitchHandlerSimpleImpl method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived notification) {
    if (!isLearning) {
        // ignoring packets - this should not happen
        return;
    }
    LOG.debug("Received packet via match: {}", notification.getMatch());
    // detect and compare node - we support one switch
    if (!nodePath.contains(notification.getIngress().getValue())) {
        return;
    }
    // read src MAC and dst MAC
    byte[] dstMacRaw = PacketUtils.extractDstMac(notification.getPayload());
    byte[] srcMacRaw = PacketUtils.extractSrcMac(notification.getPayload());
    byte[] etherType = PacketUtils.extractEtherType(notification.getPayload());
    MacAddress dstMac = PacketUtils.rawMacToMac(dstMacRaw);
    MacAddress srcMac = PacketUtils.rawMacToMac(srcMacRaw);
    NodeConnectorKey ingressKey = InstanceIdentifierUtils.getNodeConnectorKey(notification.getIngress().getValue());
    LOG.debug("Received packet from MAC match: {}, ingress: {}", srcMac, ingressKey.getId());
    LOG.debug("Received packet to   MAC match: {}", dstMac);
    LOG.debug("Ethertype: {}", Integer.toHexString(0x0000ffff & ByteBuffer.wrap(etherType).getShort()));
    // learn by IPv4 traffic only
    if (Arrays.equals(ETH_TYPE_IPV4, etherType)) {
        NodeConnectorRef previousPort = mac2portMapping.put(srcMac, notification.getIngress());
        if (previousPort != null && !notification.getIngress().equals(previousPort)) {
            NodeConnectorKey previousPortKey = InstanceIdentifierUtils.getNodeConnectorKey(previousPort.getValue());
            LOG.debug("mac2port mapping changed by mac {}: {} -> {}", srcMac, previousPortKey, ingressKey.getId());
        }
        // if dst MAC mapped:
        NodeConnectorRef destNodeConnector = mac2portMapping.get(dstMac);
        if (destNodeConnector != null) {
            synchronized (coveredMacPaths) {
                if (!destNodeConnector.equals(notification.getIngress())) {
                    // add flow
                    addBridgeFlow(srcMac, dstMac, destNodeConnector);
                    addBridgeFlow(dstMac, srcMac, notification.getIngress());
                } else {
                    LOG.debug("useless rule ignoring - both MACs are behind the same port");
                }
            }
            LOG.debug("packetIn-directing.. to {}", InstanceIdentifierUtils.getNodeConnectorKey(destNodeConnector.getValue()).getId());
            sendPacketOut(notification.getPayload(), notification.getIngress(), destNodeConnector);
        } else {
            // flood
            LOG.debug("packetIn-still flooding.. ");
            flood(notification.getPayload(), notification.getIngress());
        }
    } else {
        // non IPv4 package
        flood(notification.getPayload(), notification.getIngress());
    }
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)

Example 99 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method registerAddressAndQuery.

// takes an address, packs it in a MapRegister, sends it, returns the
// MapReply
private MapReply registerAddressAndQuery(Eid eid) throws SocketTimeoutException {
    mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
    sleepForSeconds(1);
    MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
    LOG.trace("Sending Map-Register via socket: {}", mapRegister);
    sendMapRegister(mapRegister);
    MapNotify mapNotify = receiveMapNotify();
    LOG.trace("Received Map-Notify via socket: {}", mapNotify);
    assertEquals(8, mapNotify.getNonce().longValue());
    // wait for the notifications to propagate
    sleepForSeconds(1);
    MapRequest mapRequest = MappingServiceIntegrationTestUtil.getDefaultMapRequestBuilder(eid).build();
    sendMapRequest(mapRequest);
    return receiveMapReply();
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) GotMapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)

Example 100 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method checkSmr.

/**
 * Read packets from the given socket until a Map-Request is found. Assert that the request is an SMR, and the
 * Source EID field contains the given IPv4 EID. Note that the source EID does not have a mask length. If a
 * reference to the LISP Mapping Service is passed, send an SMR-invoked Map-Request, to simulate what would happen
 * in the real world. If a reference to the Mapping Service is passed, the internal state of the map caches and
 * subscribers is logged.
 *
 * @param socket the receive socket
 * @param lms reference to the LISP Mapping Service, if present, an SMR-invoked Map-Request is sent in reply to the
 *            SMR
 * @param ms reference to the Mapping System, if present, the internal state of map-caches and subscribers is logged
 * @param vni the VNI for the expected EID
 * @param eids the expected EIDs, as an IPv4 string, without mask length
 */
static void checkSmr(DatagramSocket socket, IFlowMapping lms, IMappingService ms, long vni, String... eids) {
    LOG.debug("checkSmr: expecting {} SMRs: {}", eids.length, eids);
    List<MapRequest> mapRequests = receiveExpectedSmrs(socket, eids.length);
    assertNoMoreSMRs(socket, ms);
    HashMap<Eid, Integer> eidSet = prepareExpectedEids(vni, eids);
    for (MapRequest mapRequest : mapRequests) {
        LOG.trace("Solicit Map-Request: {}", mapRequest);
        Eid originalSourceEid = mapRequest.getEidItem().get(0).getEid();
        assertEquals(DEFAULT_IPV4_EID_PREFIX, originalSourceEid);
        Eid smrEid = mapRequest.getSourceEid().getEid();
        int counterDecremented = eidSet.get(smrEid) - 1;
        if (counterDecremented < 0) {
            fail("checkSmr: SMR contains EID " + LispAddressStringifier.getString(smrEid) + ", which is not in the list of expected EIDs: " + eidSet);
        } else {
            LOG.debug("checkSmr: successfully received expected SMR for {}", LispAddressStringifier.getString(smrEid));
        }
        if (lms != null) {
            sendSMRInvokedMapRequestMessage(mapRequest, lms);
        // TODO Capture the reply to the SMR-invoked Map-Request and assert on the expected result
        }
    }
    if (ms != null) {
        printMapCacheState(ms);
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)29 ArrayList (java.util.ArrayList)24 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)23 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)18 BigInteger (java.math.BigInteger)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)16 List (java.util.List)13 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 Test (org.junit.Test)12 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)12 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 UnknownHostException (java.net.UnknownHostException)10 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)10 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)9 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)9 Collections (java.util.Collections)8 Map (java.util.Map)8 VpnInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface)8