Saurav Das | f710bd3 | 2014-09-25 16:56:00 -0700 | [diff] [blame^] | 1 | package net.floodlightcontroller.core; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.HashSet; |
| 5 | import java.util.Set; |
| 6 | |
| 7 | import net.onrc.onos.core.matchaction.MatchActionOperationEntry; |
| 8 | import net.onrc.onos.core.util.Dpid; |
| 9 | |
| 10 | import com.google.common.primitives.Longs; |
| 11 | |
| 12 | |
| 13 | public interface IOF13Switch extends IOFSwitch { |
| 14 | |
| 15 | // ************************** |
| 16 | // Flow related |
| 17 | // ************************** |
| 18 | |
| 19 | /** |
| 20 | * Pushes a single flow to the switch as described by the match-action |
| 21 | * operation and match-action definition, and subject to the TTP supported |
| 22 | * by a switch implementing this interface. It is up to the implementation |
| 23 | * to translate the 'matchActionOp' into a match-instruction with actions, |
| 24 | * as expected by OF 1.3 switches. |
| 25 | * |
| 26 | * @param matchActionOp |
| 27 | */ |
| 28 | public void pushFlow(MatchActionOperationEntry matchActionOp); |
| 29 | |
| 30 | /** |
| 31 | * Pushes a collection of flows to the switch. |
| 32 | * |
| 33 | * @param matchActionOps |
| 34 | */ |
| 35 | public void pushFlows(Collection<MatchActionOperationEntry> matchActionOps); |
| 36 | |
| 37 | // **************************** |
| 38 | // Group related |
| 39 | // **************************** |
| 40 | |
| 41 | /** |
| 42 | * Representation of a set of neighbor switch dpids. Meant to be used as a |
| 43 | * lookup-key in a hash-map to retrieve an ECMP-group that hashes packets to |
| 44 | * a set of ports connecting to the neighbors in this set. |
| 45 | */ |
| 46 | public class NeighborSet { |
| 47 | Set<Dpid> dpids; |
| 48 | |
| 49 | /** |
| 50 | * Constructor |
| 51 | * |
| 52 | * @param dpids A variable number of Dpids represention neighbor |
| 53 | * switches |
| 54 | */ |
| 55 | public NeighborSet(Dpid... dpids) { |
| 56 | this.dpids = new HashSet<Dpid>(); |
| 57 | for (Dpid d : dpids) { |
| 58 | this.dpids.add(d); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | public void addDpid(Dpid d) { |
| 63 | dpids.add(d); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public boolean equals(Object o) { |
| 68 | if (!(o instanceof NeighborSet)) { |
| 69 | return false; |
| 70 | } |
| 71 | NeighborSet that = (NeighborSet) o; |
| 72 | return this.dpids.equals(that.dpids); |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public int hashCode() { |
| 77 | int result = 17; |
| 78 | for (Dpid d : dpids) { |
| 79 | result = 31 * result + Longs.hashCode(d.value()); |
| 80 | } |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public String toString() { |
| 86 | return " Sw: {} Neighbors: " + dpids; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Get the ECMP group-id for the ECMP group in this switch that includes |
| 92 | * ports that connect to the neighbor-switches included in the NeighborSet |
| 93 | * 'ns' |
| 94 | * |
| 95 | * @param ns the set of Neighbor Dpids |
| 96 | * @return the ecmp group id, or -1 if no such group exists |
| 97 | */ |
| 98 | public int getEcmpGroupId(NeighborSet ns); |
| 99 | |
| 100 | |
| 101 | } |