Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction; |
| 2 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 3 | import java.util.List; |
| 4 | |
Toshio Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 5 | import net.onrc.onos.api.batchoperation.BatchOperationTarget; |
Toshio Koide | d8b077a | 2014-08-13 10:47:21 -0700 | [diff] [blame] | 6 | import net.onrc.onos.core.matchaction.action.Action; |
Toshio Koide | d8b077a | 2014-08-13 10:47:21 -0700 | [diff] [blame] | 7 | import net.onrc.onos.core.matchaction.match.Match; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 8 | import net.onrc.onos.core.util.SwitchPort; |
| 9 | |
| 10 | /** |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 11 | * A filter and actions for traffic. Objects of this class are immutable. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 12 | */ |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 13 | public final class MatchAction implements BatchOperationTarget { |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 14 | private final MatchActionId id; |
| 15 | private final SwitchPort port; |
| 16 | private final Match match; |
| 17 | private final List<Action> actions; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Constructor. |
| 21 | * |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 22 | * @param id ID for this MatchAction object |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 23 | * @param port switch port to apply changes to |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 24 | * @param match the Match object as match condition on the port |
| 25 | * @param actions the list of Action objects as actions on the switch |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 26 | */ |
Ray Milkey | 9ed4b96 | 2014-08-20 15:43:40 -0700 | [diff] [blame] | 27 | public MatchAction(MatchActionId id, SwitchPort port, Match match, List<Action> actions) { |
| 28 | this.id = id; |
| 29 | this.port = port; |
| 30 | this.match = match; |
| 31 | this.actions = actions; |
| 32 | } |
| 33 | |
| 34 | /** |
Brian O'Connor | 0efc906 | 2014-09-02 14:47:28 -0700 | [diff] [blame] | 35 | * no-arg constructor for Kryo. |
| 36 | */ |
| 37 | protected MatchAction() { |
| 38 | id = null; |
| 39 | port = null; |
| 40 | match = null; |
| 41 | actions = null; |
| 42 | } |
| 43 | |
| 44 | /** |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 45 | * Gets ID for this object. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 46 | * |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 47 | * @return the ID for this object |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 48 | */ |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 49 | public MatchActionId getId() { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 50 | return id; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Gets the switch-port which is the target of this match-action. |
| 55 | * |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 56 | * @return the target switch-port of this match-action |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 57 | */ |
| 58 | public SwitchPort getSwitchPort() { |
| 59 | return port; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Gets the traffic filter of the match-action. |
| 64 | * |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 65 | * @return the traffic filter |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 66 | */ |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 67 | public Match getMatch() { |
| 68 | return match; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Gets the list of actions of the match-action. |
| 73 | * |
Toshio Koide | 80db184 | 2014-08-11 17:08:32 -0700 | [diff] [blame] | 74 | * @return the list of actions |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 75 | */ |
Toshio Koide | d8b077a | 2014-08-13 10:47:21 -0700 | [diff] [blame] | 76 | public List<Action> getActions() { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 77 | return actions; |
| 78 | } |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 79 | |
| 80 | @Override |
| 81 | public int hashCode() { |
| 82 | return id.hashCode(); |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public boolean equals(Object obj) { |
| 87 | if (obj instanceof MatchAction) { |
| 88 | MatchAction other = (MatchAction) obj; |
| 89 | return (id.equals(other.id)); |
| 90 | } |
| 91 | return false; |
| 92 | } |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 93 | } |