GenericRecord instrRecord = null;
for (Tuple<String, OFStructureInstructionRef> tuple : instrList) {
boolean isActions = false;
//Tuple<String, OFStructureInstruction> tuple = instrIter.next();
String name = tuple.getName();
OFStructureInstructionRef instruction = tuple.getValue();
// TODO Improvs: Replace Switch with a structure... say, HashMap
// TODO Improvs: How to control type compatibility between Schema types and incoming tlvs?
switch (name) {
case "apply_actions":
instrHeaderSchema = protocol.getType("of12.instruction_apply_actions_header");
instrSchema = protocol.getType("of12.ofp_instruction_apply_actions");
instrRecord = new GenericData.Record(instrSchema);
isActions = true;
break;
case "write_actions":
instrHeaderSchema = protocol.getType("of12.instruction_write_actions_header");
instrSchema = protocol.getType("of12.ofp_instruction_write_actions");
instrRecord = new GenericData.Record(instrSchema);
isActions = true;
break;
case "clear_actions":
instrHeaderSchema = protocol.getType("of12.instruction_clear_actions_header");
instrSchema = protocol.getType("of12.ofp_instruction_clear_actions");
instrRecord = new GenericData.Record(instrSchema);
isActions = true;
break;
case "goto_table":
instrHeaderSchema = protocol.getType("of12.instruction_goto_table_header");
instrSchema = protocol.getType("of12.ofp_instruction_goto_table");
instrRecord = new GenericData.Record(instrSchema);
instrRecord.put("table_id", getUint8Fixed((byte)15));
instrRecord.put("pad", getPad3(0));
isActions = false;
break;
case "write_metadata":
instrHeaderSchema = protocol.getType("of12.instruction_write_metadata_header");
instrSchema = protocol.getType("of12.ofp_instruction_write_metadata");
instrRecord = new GenericData.Record(instrSchema);
isActions = false;
break;
case "meter":
instrHeaderSchema = protocol.getType("of12.instruction_meter_header");
instrSchema = protocol.getType("of12.ofp_instruction_meter");
instrRecord = new GenericData.Record(instrSchema);
isActions = false;
break;
}
GenericRecordBuilder instrHeaderBuilder = new GenericRecordBuilder(instrHeaderSchema);
instrHeaderRecord = instrHeaderBuilder.build();
instrRecord.put("header", instrHeaderRecord);
if (isActions) {
List<Tuple<String, String>> actionList = instruction.getActions().getActions();
// Iterator<Tuple<String, String>> actionIter = instruction.getActions().getIterator();
Schema ofpActionSchema = protocol.getType("of12.ofp_action");
List<GenericRecord> actions = new LinkedList<GenericRecord>();
GenericRecord actionSetRecord = null;