/** * Using L2agent, get the output port toward this IP from this * node (switch). */ public Output getOutputPortL2Agent(Node node, InetAddress ip) { Output op = null; if (l2agent != null) { /* Look up the output port leading to the waypoint. */ HostNodeConnector host = (HostNodeConnector) hostTracker.hostFind(ip); log.info("output port on node {} toward host {}", node, host); NodeConnector dst_connector = l2agent.lookup_output_port(node, host.getDataLayerAddressBytes()); if (dst_connector != null) { op = new Output(dst_connector); } } else { log.info("l2agent is not set!!!"); } return op; }
@Override public NodeConnector getOutputPort(Node node, String flowName) { for (FlowEntryInstall index : this.nodeFlows.get(node)) { FlowEntryInstall flow = this.installedSwView.get(index); if (flow.getFlowName().equals(flowName)) { for (Action action : flow.getOriginal().getFlow().getActions()) { if (action.getType() == ActionType.OUTPUT) { return ((Output) action).getPort(); } } } } return null; }
private List<FlowOnNode> forwardingTableEntriesToFlows(Map<String, Integer> entries, Node node){ List<FlowOnNode> list = new ArrayList<FlowOnNode>(); for(Map.Entry<String, Integer> entry : entries.entrySet()){ Match match = new Match(); String str = entry.getKey(); short vlan = Short.parseShort(str.substring(0, str.indexOf("."))); byte[] macAddrBytes = OIDToMacAddrBytes(str.substring(str.indexOf(".") + 1)); if(macAddrBytes == null){ logger.debug("ERROR: forwardingTableEntriesToFlows(): nodeID is {}, call OIDToMacAddrBytes() fail", (Long)node.getID()); return null; } match.setField(MatchType.DL_VLAN, vlan); match.setField(MatchType.DL_DST, macAddrBytes); List<Action> actions = new ArrayList<Action>(); NodeConnector oport = NodeConnectorCreator.createNodeConnector("SNMP", Short.parseShort(entry.getValue().toString()), node); actions.add(new Output(oport)); Flow flow = new Flow(match, actions); list.add(new FlowOnNode(flow)); } return list; }
private static OutputActionCase _toAction(final Output sourceAction) { return new OutputActionCaseBuilder() .setOutputAction( new OutputActionBuilder().setOutputNodeConnector(MDFlowMapping.toUri(sourceAction.getPort())).build() ).build(); }
@Override public void removeOutputPort(Node node, String flowName, List<NodeConnector> portList) { for (FlowEntryInstall index : this.nodeFlows.get(node)) { FlowEntryInstall flow = this.installedSwView.get(index); if (flow.getFlowName().equals(flowName)) { FlowEntry currentFlowEntry = flow.getOriginal(); FlowEntry newFlowEntry = currentFlowEntry.clone(); for (NodeConnector dstPort : portList) { Action action = new Output(dstPort); newFlowEntry.getFlow().removeAction(action); } Status status = modifyEntry(currentFlowEntry, newFlowEntry, false); if (status.isSuccess()) { log.trace("Ports {} removed from FlowEntry {}", portList, flowName); } else { log.warn("Failed to remove ports {} from Flow entry {}. The failure is: {}", portList, currentFlowEntry.toString(), status.getDescription()); } return; } } log.warn("Failed to remove ports from Flow {} on Node {}: Entry Not Found", flowName, node); }
NodeConnector outputPort = out.getPort(); if (!switchManager.getNodeConnectors(node).contains(outputPort)) { String msg = String.format("Output port %s is not present on this container", outputPort);
@Override public void addOutputPort(Node node, String flowName, List<NodeConnector> portList) { for (FlowEntryInstall flow : this.nodeFlows.get(node)) { if (flow.getFlowName().equals(flowName)) { FlowEntry currentFlowEntry = flow.getOriginal(); FlowEntry newFlowEntry = currentFlowEntry.clone(); for (NodeConnector dstPort : portList) { newFlowEntry.getFlow().addAction(new Output(dstPort)); } Status error = modifyEntry(currentFlowEntry, newFlowEntry, false); if (error.isSuccess()) { log.trace("Ports {} added to FlowEntry {}", portList, flowName); } else { log.warn("Failed to add ports {} to Flow entry {}. The failure is: {}", portList, currentFlowEntry.toString(), error.getDescription()); } return; } } log.warn("Failed to add ports to Flow {} on Node {}: Entry Not Found", flowName, node); }
return new Status(StatusCode.NOTALLOWED, "SNMPHandler.sendBySNMP(): flow's action is not to set OUTPUT port!"); NodeConnector oport = ((Output)action).getPort();
public Output getOutputPort(Node node, InetAddress wp) { IHostId id = HostIdFactory.create(wp, null); HostNodeConnector hnConnector = this.hostTracker.hostFind(id); Node destNode = hnConnector.getnodeconnectorNode(); log.debug("from node: {}", node.toString()); log.debug("dest node: {}", destNode.toString()); // Get path between both the nodes NodeConnector forwardPort = null; if (node.getNodeIDString().equals(destNode.getNodeIDString())) { forwardPort = hnConnector.getnodeConnector(); log.info("Both source and destination are connected to same switch nodes. output port is {}", forwardPort); } else { Path route = this.routing.getRoute(node, destNode); log.info("Path between source and destination switch nodes : {}", route.toString()); forwardPort = route.getEdges().get(0).getTailNodeConnector(); } return(new Output(forwardPort)); }
outPorts.append(" "); actions.append(action.getType().toString()).append(" = ").append(ao.getPort().getNodeConnectorIdAsString()).append("<br>"); } else if (action instanceof SetVlanId) { SetVlanId av = (SetVlanId) action;
if (t != null) { String nc = String.format("%s|%s@%s", node.getType(), t, node.toString()); actionList.add(new Output(NodeConnector.fromString(nc)));
private boolean doesFlowContainNodeConnector(Flow flow, NodeConnector nc) { if (nc == null) { return false; } Match match = flow.getMatch(); if (match.isPresent(MatchType.IN_PORT)) { NodeConnector matchPort = (NodeConnector) match.getField(MatchType.IN_PORT).getValue(); if (matchPort.equals(nc)) { return true; } } List<Action> actionsList = flow.getActions(); if (actionsList != null) { for (Action action : actionsList) { if (action instanceof Output) { NodeConnector actionPort = ((Output) action).getPort(); if (actionPort.equals(nc)) { return true; } } } } return false; }
actions.add(new Output(dst_connector));
/** * Check whether the ports in the flow match and flow actions for * the specified node belong to the container * * @param container * @param node * @param flow * @return */ private boolean flowPortsBelongToContainer(String container, Node node, Flow flow) { Match m = flow.getMatch(); if (m.isPresent(MatchType.IN_PORT)) { NodeConnector inPort = (NodeConnector) m.getField(MatchType.IN_PORT).getValue(); // If the incoming port is specified, check if it belongs to if (!containerOwnsNodeConnector(container, inPort)) { return false; } } // If an outgoing port is specified, it must belong to this container for (Action action : flow.getActions()) { if (action.getType() == ActionType.OUTPUT) { NodeConnector outPort = ((Output) action).getPort(); if (!containerOwnsNodeConnector(container, outPort)) { return false; } } } return true; }
newFlowEntry.getFlow().addAction(new Output(outPort));
if (action.getType() == ActionType.OUTPUT) { NodeConnector outPort = (NodeConnector) ((Output) action) .getPort(); if (!containerOwnsNodeConnector(container, outPort)) { return false;
actionList.add(new HwPath()); try { actionList.add(new Output(new NodeConnector("STUB", 0xCAFE, node))); } catch (ConstructionException e) {
OFActionOutput ofAction = new OFActionOutput(); ofAction.setMaxLength((short) 0xffff); ofAction.setPort(PortConverter.toOFPort(a.getPort())); actionsList.add(ofAction); actionsLength += OFActionOutput.MINIMUM_LENGTH;
actions.add(new Output(oport)); Flow flown = new Flow(flow.getMatch(), actions); return new FlowOnNode(flown);
actions.add(new Output(oport)); actions.add(new PopVlan()); actions.add(new Flood());