Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 2 | |
| 3 | import net.floodlightcontroller.util.MACAddress; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 4 | import net.onrc.onos.core.util.Dpid; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 5 | |
| 6 | /** |
| 7 | * @author Toshio Koide (t-koide@onlab.us) |
| 8 | */ |
| 9 | public class ShortestPathIntent extends Intent { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 10 | protected long srcSwitchDpid; |
| 11 | protected long srcPortNumber; |
| 12 | protected long srcMacAddress; |
| 13 | protected long dstSwitchDpid; |
| 14 | protected long dstPortNumber; |
| 15 | protected long dstMacAddress; |
| 16 | protected String pathIntentId = null; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 17 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 18 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 19 | * Default constructor for Kryo deserialization. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 20 | */ |
| 21 | protected ShortestPathIntent() { |
| 22 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 23 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Constructor for ShortestPathIntent. |
| 26 | * |
| 27 | * @param id Intent ID |
| 28 | * @param srcSwitch Source Switch DPID |
| 29 | * @param srcPort Source Port |
| 30 | * @param srcMac Source Host MAC Address |
| 31 | * @param dstSwitch Destination Switch DPID |
| 32 | * @param dstPort Destination Port |
| 33 | * @param dstMac Destination Host MAC Address |
| 34 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 35 | public ShortestPathIntent(String id, |
| 36 | long srcSwitch, long srcPort, long srcMac, |
| 37 | long dstSwitch, long dstPort, long dstMac) { |
| 38 | super(id); |
| 39 | srcSwitchDpid = srcSwitch; |
| 40 | srcPortNumber = srcPort; |
| 41 | srcMacAddress = srcMac; |
| 42 | dstSwitchDpid = dstSwitch; |
| 43 | dstPortNumber = dstPort; |
| 44 | dstMacAddress = dstMac; |
| 45 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 46 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Gets the source Switch DPID. |
| 49 | * |
| 50 | * @return Source Switch DPID |
| 51 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 52 | public long getSrcSwitchDpid() { |
| 53 | return srcSwitchDpid; |
| 54 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 55 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 56 | /** |
| 57 | * Gets the source Port. |
| 58 | * |
| 59 | * @return Source Port |
| 60 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 61 | public long getSrcPortNumber() { |
| 62 | return srcPortNumber; |
| 63 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 64 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 65 | /** |
| 66 | * Gets the source Host MAC Address. |
| 67 | * |
| 68 | * @return Source Host MAC Address |
| 69 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 70 | public long getSrcMac() { |
| 71 | return srcMacAddress; |
| 72 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 73 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 74 | /** |
| 75 | * Gets the destination Switch DPID. |
| 76 | * |
| 77 | * @return Destination Switch DPID |
| 78 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 79 | public long getDstSwitchDpid() { |
| 80 | return dstSwitchDpid; |
| 81 | } |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 82 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 83 | /** |
| 84 | * Gets the destination Port. |
| 85 | * |
| 86 | * @return Destination Port |
| 87 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 88 | public long getDstPortNumber() { |
| 89 | return dstPortNumber; |
| 90 | } |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 91 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 92 | /** |
| 93 | * Gets the destination Host MAC Address. |
| 94 | * |
| 95 | * @return Destination Host MAC Address |
| 96 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 97 | public long getDstMac() { |
| 98 | return dstMacAddress; |
| 99 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 100 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 101 | public void setPathIntent(PathIntent pathIntent) { |
| 102 | pathIntentId = pathIntent.getId(); |
| 103 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 104 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 105 | public String getPathIntentId() { |
| 106 | return pathIntentId; |
| 107 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 108 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 109 | @Override |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 110 | public int hashCode() { |
| 111 | // TODO: Is this the intended behavior? |
| 112 | return (super.hashCode()); |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public boolean equals(Object obj) { |
| 117 | // TODO: Is this the intended behavior? |
| 118 | return (super.equals(obj)); |
| 119 | } |
| 120 | |
| 121 | @Override |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 122 | public String toString() { |
| 123 | return String.format("id:%s, state:%s, srcDpid:%s, srcPort:%d, srcMac:%s, dstDpid:%s, dstPort:%d, dstMac:%s", |
| 124 | getId(), getState(), |
| 125 | new Dpid(srcSwitchDpid), srcPortNumber, MACAddress.valueOf(srcMacAddress), |
| 126 | new Dpid(dstSwitchDpid), dstPortNumber, MACAddress.valueOf(dstMacAddress)); |
| 127 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 128 | } |