blob: aa47634b295f436d67d5571e603aaae21a55f6d3 [file] [log] [blame]
alshabib7410fea2014-09-16 13:48:39 -07001package org.onlab.onos.net.flow.instructions;
2
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -07003import org.onlab.packet.IpPrefix;
alshabib7410fea2014-09-16 13:48:39 -07004
5/**
6 * Abstraction of a single traffic treatment step.
alshabib7410fea2014-09-16 13:48:39 -07007 */
8public abstract class L3ModificationInstruction implements Instruction {
9
10 /**
11 * Represents the type of traffic treatment.
12 */
alshabib35edb1a2014-09-16 17:44:44 -070013 public enum L3SubType {
alshabib7410fea2014-09-16 13:48:39 -070014 /**
15 * Ether src modification.
16 */
17 L3_SRC,
18
19 /**
20 * Ether dst modification.
21 */
alshabib35edb1a2014-09-16 17:44:44 -070022 L3_DST
alshabib7410fea2014-09-16 13:48:39 -070023
24 //TODO: remaining types
25 }
26
27 /**
28 * Returns the subtype of the modification instruction.
29 * @return type of instruction
30 */
alshabib35edb1a2014-09-16 17:44:44 -070031 public abstract L3SubType subtype();
alshabib7410fea2014-09-16 13:48:39 -070032
33 @Override
34 public Type type() {
alshabib35edb1a2014-09-16 17:44:44 -070035 return Type.L3MODIFICATION;
alshabib7410fea2014-09-16 13:48:39 -070036 }
37
38 /**
39 * Represents a L3 src/dst modification instruction.
40 */
41 public static final class ModIPInstruction extends L3ModificationInstruction {
42
alshabib35edb1a2014-09-16 17:44:44 -070043 private final L3SubType subtype;
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -070044 private final IpPrefix ip;
alshabib7410fea2014-09-16 13:48:39 -070045
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -070046 public ModIPInstruction(L3SubType subType, IpPrefix addr) {
alshabib64231f62014-09-16 17:58:36 -070047
alshabib7410fea2014-09-16 13:48:39 -070048 this.subtype = subType;
49 this.ip = addr;
50 }
51
52 @Override
alshabib35edb1a2014-09-16 17:44:44 -070053 public L3SubType subtype() {
alshabib7410fea2014-09-16 13:48:39 -070054 return this.subtype;
55 }
56
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -070057 public IpPrefix ip() {
alshabib7410fea2014-09-16 13:48:39 -070058 return this.ip;
59 }
60
61 }
alshabib7410fea2014-09-16 13:48:39 -070062}