blob: 797df9bc72a11e6c2af699223d08f80c1062616f [file] [log] [blame]
alshabib7410fea2014-09-16 13:48:39 -07001package org.onlab.onos.net.flow.instructions;
2
Ayaka Koshibea9c199f2014-09-16 16:21:40 -07003import org.onlab.packet.IpAddress;
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 Koshibea9c199f2014-09-16 16:21:40 -070044 private final IpAddress ip;
alshabib7410fea2014-09-16 13:48:39 -070045
alshabib64231f62014-09-16 17:58:36 -070046 public ModIPInstruction(L3SubType subType, IpAddress addr) {
47
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 Koshibea9c199f2014-09-16 16:21:40 -070057 public IpAddress ip() {
alshabib7410fea2014-09-16 13:48:39 -070058 return this.ip;
59 }
60
61 }
alshabib7410fea2014-09-16 13:48:39 -070062}