alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.flow.instructions; |
2 | |||||
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame^] | 3 | import org.onlab.packet.IpPrefix; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 4 | |
5 | /** | ||||
6 | * Abstraction of a single traffic treatment step. | ||||
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 7 | */ |
8 | public abstract class L3ModificationInstruction implements Instruction { | ||||
9 | |||||
10 | /** | ||||
11 | * Represents the type of traffic treatment. | ||||
12 | */ | ||||
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 13 | public enum L3SubType { |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 14 | /** |
15 | * Ether src modification. | ||||
16 | */ | ||||
17 | L3_SRC, | ||||
18 | |||||
19 | /** | ||||
20 | * Ether dst modification. | ||||
21 | */ | ||||
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 22 | L3_DST |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 23 | |
24 | //TODO: remaining types | ||||
25 | } | ||||
26 | |||||
27 | /** | ||||
28 | * Returns the subtype of the modification instruction. | ||||
29 | * @return type of instruction | ||||
30 | */ | ||||
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 31 | public abstract L3SubType subtype(); |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 32 | |
33 | @Override | ||||
34 | public Type type() { | ||||
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 35 | return Type.L3MODIFICATION; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 36 | } |
37 | |||||
38 | /** | ||||
39 | * Represents a L3 src/dst modification instruction. | ||||
40 | */ | ||||
41 | public static final class ModIPInstruction extends L3ModificationInstruction { | ||||
42 | |||||
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 43 | private final L3SubType subtype; |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame^] | 44 | private final IpPrefix ip; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 45 | |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame^] | 46 | public ModIPInstruction(L3SubType subType, IpPrefix addr) { |
alshabib | 64231f6 | 2014-09-16 17:58:36 -0700 | [diff] [blame] | 47 | |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 48 | this.subtype = subType; |
49 | this.ip = addr; | ||||
50 | } | ||||
51 | |||||
52 | @Override | ||||
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 53 | public L3SubType subtype() { |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 54 | return this.subtype; |
55 | } | ||||
56 | |||||
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame^] | 57 | public IpPrefix ip() { |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 58 | return this.ip; |
59 | } | ||||
60 | |||||
61 | } | ||||
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 62 | } |