- public void _printMatrixData(CommandInterpreter ci) {
- ci.println("Configs : ");
- ci.println("---------");
- ci.println(portGroupConfigs);
-
- ci.println("Data : ");
- ci.println("------");
- ci.println(portGroupData);
- }
-
- public void _addMatrixConfig(CommandInterpreter ci) {
- String name = ci.nextArgument();
- String regex = ci.nextArgument();
- addPortGroupConfig(name, regex, false);
- }
-
- public void _delMatrixConfig(CommandInterpreter ci) {
- String name = ci.nextArgument();
- delPortGroupConfig(name);
- }
-
- public void _useMatrixConfig(CommandInterpreter ci) {
- String name = ci.nextArgument();
- usePortGroupConfig(name);
- }
-
- public void _arpPunt(CommandInterpreter ci) {
- String switchId = ci.nextArgument();
- long swid = HexEncode.stringToLong(switchId);
- Node node = NodeCreator.createOFNode(swid);
- installImplicitARPReplyPunt(node);
- }
-
- public void _frmaddflow(CommandInterpreter ci) throws UnknownHostException {
- Node node = null;
- String nodeId = ci.nextArgument();
- if (nodeId == null) {
- ci.print("Node id not specified");
- return;
- }
- try {
- node = NodeCreator.createOFNode(Long.valueOf(nodeId));
- } catch (NumberFormatException e) {
- ci.print("Node id not a number");
- return;
- }
- ci.println(this.programmer.addFlow(node, getSampleFlow(node)));
- }
-
- public void _frmremoveflow(CommandInterpreter ci) throws UnknownHostException {
- Node node = null;
- String nodeId = ci.nextArgument();
- if (nodeId == null) {
- ci.print("Node id not specified");
- return;
- }
- try {
- node = NodeCreator.createOFNode(Long.valueOf(nodeId));
- } catch (NumberFormatException e) {
- ci.print("Node id not a number");
- return;
- }
- ci.println(this.programmer.removeFlow(node, getSampleFlow(node)));
- }
-
- private Flow getSampleFlow(Node node) throws UnknownHostException {
- NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
- NodeConnector oport = NodeConnectorCreator.createOFNodeConnector((short) 30, node);
- byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
- byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
- InetAddress srcIP = InetAddress.getByName("172.28.30.50");
- InetAddress dstIP = InetAddress.getByName("171.71.9.52");
- InetAddress ipMask = InetAddress.getByName("255.255.255.0");
- InetAddress ipMask2 = InetAddress.getByName("255.0.0.0");
- short ethertype = EtherTypes.IPv4.shortValue();
- short vlan = (short) 27;
- byte vlanPr = 3;
- Byte tos = 4;
- byte proto = IPProtocols.TCP.byteValue();
- short src = (short) 55000;
- short dst = 80;
-
- /*
- * Create a SAL Flow aFlow
- */
- Match match = new Match();
- match.setField(MatchType.IN_PORT, port);
- match.setField(MatchType.DL_SRC, srcMac);
- match.setField(MatchType.DL_DST, dstMac);
- match.setField(MatchType.DL_TYPE, ethertype);
- match.setField(MatchType.DL_VLAN, vlan);
- match.setField(MatchType.DL_VLAN_PR, vlanPr);
- match.setField(MatchType.NW_SRC, srcIP, ipMask);
- match.setField(MatchType.NW_DST, dstIP, ipMask2);
- match.setField(MatchType.NW_TOS, tos);
- match.setField(MatchType.NW_PROTO, proto);
- match.setField(MatchType.TP_SRC, src);
- match.setField(MatchType.TP_DST, dst);
-
- List<Action> actions = new ArrayList<Action>();
- actions.add(new Output(oport));
- actions.add(new PopVlan());
- actions.add(new Flood());
- actions.add(new Controller());
- return new Flow(match, actions);
- }
-