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();
}
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();
}
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());
}
}
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();
}
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);
}
}
Aggregations