use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project openflowplugin by opendaylight.
the class LearningSwitchHandlerSimpleImpl method addBridgeFlow.
private void addBridgeFlow(MacAddress srcMac, MacAddress dstMac, NodeConnectorRef destNodeConnector) {
synchronized (coveredMacPaths) {
String macPath = srcMac.toString() + dstMac.toString();
if (!coveredMacPaths.contains(macPath)) {
LOG.debug("covering mac path: {} by [{}]", macPath, destNodeConnector.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId());
coveredMacPaths.add(macPath);
FlowId flowId = new FlowId(String.valueOf(flowIdInc.getAndIncrement()));
FlowKey flowKey = new FlowKey(flowId);
/**
* Path to the flow we want to program.
*/
InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
Short tableId = InstanceIdentifierUtils.getTableId(tablePath);
FlowBuilder srcToDstFlow = FlowUtils.createDirectMacToMacFlow(tableId, DIRECT_FLOW_PRIORITY, srcMac, dstMac, destNodeConnector);
srcToDstFlow.setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement())));
dataStoreAccessor.writeFlowToConfig(flowPath, srcToDstFlow.build());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project openflowplugin by opendaylight.
the class PortStatusMessageFactoryTest method testWithDifferentBitmaps.
/**
* Testing {@link PortStatusMessageFactory} for correct translation into POJO.
*/
@Test
public void testWithDifferentBitmaps() {
ByteBuf bb = BufferHelper.buildBuffer(// reason, padding
"01 00 00 00 00 00 00 00 " + // port no, padding
"00 01 02 03 00 00 00 00 " + // mac address, padding
"08 00 27 00 B0 EB 00 00 " + // port name, String "s1-eth1"
"73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port config
"00 00 00 24 " + // port state
"00 00 00 02 " + // current + advertised features
"00 00 00 81 00 00 00 A1 " + // supported + peer features
"00 00 FF FF 00 00 00 00 " + // curr speed, max speed
"00 00 00 81 00 00 00 80");
PortStatusMessage message = BufferHelper.deserialize(statusFactory, bb);
Assert.assertEquals("Wrong portConfig", new PortConfig(true, false, true, false), message.getConfig());
Assert.assertEquals("Wrong portState", new PortState(true, false, false), message.getState());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true), message.getSupportedFeatures());
Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), message.getPeerFeatures());
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project lispflowmapping by opendaylight.
the class LispAddressUtil method toEid.
public static Eid toEid(MacAddress mac, InstanceIdType vni) {
EidBuilder builder = new EidBuilder();
builder.setAddressType(MacAfi.class);
builder.setVirtualNetworkId(vni);
builder.setAddress((Address) new MacBuilder().setMac(mac).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asBinaryEidTest_mac.
/**
* Tests {@link LispAddressUtil#asBinaryEid(SimpleAddress, InstanceIdType)} method with mac.
*/
@Test
public void asBinaryEidTest_mac() {
final Eid result = LispAddressUtil.asBinaryEid(SIMPLE_ADDRESS_MAC_TEST, INSTANCE_ID_TYPE_TEST);
assertEquals(MAC_ADDRESS_EID, result);
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project genius by opendaylight.
the class AlivenessProtocolHandlerLLDP method startMonitoringTask.
@Override
public void startMonitoringTask(MonitoringInfo monitorInfo) {
String sourceInterface;
EndpointType source = monitorInfo.getSource().getEndpointType();
if (source instanceof Interface) {
Interface intf = (Interface) source;
sourceInterface = intf.getInterfaceName();
} else {
LOG.warn("Invalid source endpoint. Could not retrieve source interface to send LLDP Packet");
return;
}
// Get Mac Address for the source interface
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState;
try {
interfaceState = getInterfaceFromOperDS(sourceInterface);
} catch (ReadFailedException e) {
LOG.error("getInterfaceFromOperDS failed for sourceInterface: {}", sourceInterface, e);
return;
}
Optional<byte[]> optSourceMac = getMacAddress(interfaceState);
if (!optSourceMac.isPresent()) {
LOG.error("Could not read mac address for the source interface {} from the Inventory. " + "LLDP packet cannot be send.", sourceInterface);
return;
}
byte[] sourceMac = optSourceMac.get();
String lowerLayerIf = interfaceState.getLowerLayerIf().get(0);
NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
long nodeId = Long.parseLong(getDpnFromNodeConnectorId(nodeConnectorId));
long portNum = Long.parseLong(getPortNoFromNodeConnectorId(nodeConnectorId));
Ethernet ethenetLLDPPacket = makeLLDPPacket(Long.toString(nodeId), portNum, sourceMac, sourceInterface);
try {
List<ActionInfo> actions = getInterfaceActions(interfaceState, portNum);
if (actions.isEmpty()) {
LOG.error("No interface actions to send packet out over interface {}", sourceInterface);
return;
}
TransmitPacketInput transmitPacketInput = MDSALUtil.getPacketOut(actions, ethenetLLDPPacket.serialize(), nodeId, MDSALUtil.getNodeConnRef(BigInteger.valueOf(nodeId), "0xfffffffd"));
addErrorLogging(packetProcessingService.transmitPacket(transmitPacketInput), LOG, "transmitPacket() failed: {}", transmitPacketInput);
} catch (InterruptedException | ExecutionException | PacketException e) {
LOG.error("Error while sending LLDP Packet", e);
}
}
Aggregations