- private void handleVlanOut(Long dpidLong, Short writeTable,
- Short goToTableId, String segmentationId,
- Long ethPort, String attachedMac, boolean write) {
-
- String nodeName = OPENFLOW + dpidLong;
-
- MatchBuilder matchBuilder = new MatchBuilder();
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
- FlowBuilder flowBuilder = new FlowBuilder();
-
- // Create the OF Match using MatchBuilder
- flowBuilder.setMatch(
- MatchUtils.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
- flowBuilder.setMatch(MatchUtils.createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
-
- String flowId = "VlanOut_"+segmentationId+"_"+ethPort+"_"+attachedMac;
- // Add Flow Attributes
- flowBuilder.setId(new FlowId(flowId));
- FlowKey key = new FlowKey(new FlowId(flowId));
- flowBuilder.setStrict(true);
- flowBuilder.setBarrier(false);
- flowBuilder.setTableId(writeTable);
- flowBuilder.setKey(key);
- flowBuilder.setFlowName(flowId);
- flowBuilder.setHardTimeout(0);
- flowBuilder.setIdleTimeout(0);
-
- if (write) {
- // Instantiate the Builders for the OF Actions and Instructions
- InstructionBuilder ib = new InstructionBuilder();
- InstructionsBuilder isb = new InstructionsBuilder();
-
- // Instructions List Stores Individual Instructions
- List<Instruction> instructions = Lists.newArrayList();
-
- // GOTO Instructions
- InstructionUtils.createGotoTableInstructions(ib, goToTableId);
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- instructions.add(ib.build());
-
- // Add InstructionBuilder to the Instruction(s)Builder List
- isb.setInstruction(instructions);
-
- // Add InstructionsBuilder to FlowBuilder
- flowBuilder.setInstructions(isb.build());
-
- writeFlow(flowBuilder, nodeBuilder);
- } else {
- removeFlow(flowBuilder, nodeBuilder);
- }
- }
-
- /*
- * (Table:1) Egress Tunnel Traffic
- * Match: Destination Ethernet Addr and Local InPort
- * Instruction: Set TunnelID and GOTO Table Tunnel Table (n)
- * table=1,priority=16384,tun_id=0x5,dl_dst=ff:ff:ff:ff:ff:ff \
- * actions=output:10,output:11,goto_table:2
- */
-
- private void handleTunnelFloodOut(Long dpidLong, Short writeTable,
- Short localTable, String segmentationId,
- Long OFPortOut, boolean write) {
-
- String nodeName = OPENFLOW + dpidLong;
-
- MatchBuilder matchBuilder = new MatchBuilder();
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
- FlowBuilder flowBuilder = new FlowBuilder();
-
- // Create the OF Match using MatchBuilder
- // Match TunnelID
- flowBuilder.setMatch(MatchUtils.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
- // Match DMAC
-
- flowBuilder.setMatch(MatchUtils.createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"),
- new MacAddress("01:00:00:00:00:00")).build());
-
- String flowId = "TunnelFloodOut_"+segmentationId;
- // Add Flow Attributes
- flowBuilder.setId(new FlowId(flowId));
- FlowKey key = new FlowKey(new FlowId(flowId));
- flowBuilder.setBarrier(true);
- flowBuilder.setTableId(writeTable);
- flowBuilder.setKey(key);
- flowBuilder.setPriority(16384);
- flowBuilder.setFlowName(flowId);
- flowBuilder.setHardTimeout(0);
- flowBuilder.setIdleTimeout(0);
-
- Flow flow = this.getFlow(flowBuilder, nodeBuilder);
- // Instantiate the Builders for the OF Actions and Instructions
- InstructionBuilder ib = new InstructionBuilder();
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = Lists.newArrayList();
- List<Instruction> existingInstructions = null;
- if (flow != null) {
- Instructions ins = flow.getInstructions();
- if (ins != null) {
- existingInstructions = ins.getInstruction();
- }
- }
-
- if (write) {
- // GOTO Instruction
- InstructionUtils.createGotoTableInstructions(ib, localTable);
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- instructions.add(ib.build());
- // Set the Output Port/Iface
- //createOutputGroupInstructions(nodeBuilder, ib, dpidLong, OFPortOut, existingInstructions);
- createOutputPortInstructions(ib, dpidLong, OFPortOut, existingInstructions);
- ib.setOrder(1);
- ib.setKey(new InstructionKey(1));
- instructions.add(ib.build());
-
- // Add InstructionBuilder to the Instruction(s)Builder List
- isb.setInstruction(instructions);
-
- // Add InstructionsBuilder to FlowBuilder
- flowBuilder.setInstructions(isb.build());
-
- writeFlow(flowBuilder, nodeBuilder);
- } else {
- /* remove port from action list */
- boolean flowRemove = InstructionUtils.removeOutputPortFromInstructions(ib, dpidLong,
- OFPortOut, existingInstructions);
- if (flowRemove) {
- /* if all port are removed, remove the flow too. */
- removeFlow(flowBuilder, nodeBuilder);
- } else {
- /* Install instruction with new output port list*/
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- instructions.add(ib.build());
-
- // Add InstructionBuilder to the Instruction(s)Builder List
- isb.setInstruction(instructions);
-
- // Add InstructionsBuilder to FlowBuilder
- flowBuilder.setInstructions(isb.build());
- }
- }