blob: 5b32b2332eb263aea330a1114bd64ebe811da3bd [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.routing;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.List;
6
7import net.floodlightcontroller.core.FloodlightContext;
8import net.floodlightcontroller.devicemanager.IDevice;
9import net.floodlightcontroller.devicemanager.SwitchPort;
10
11
12public class RoutingDecision implements IRoutingDecision {
13
14 protected RoutingAction action;
15 protected Integer wildcards;
16 protected SwitchPort srcPort;
17 protected IDevice srcDevice;
18 protected List<IDevice> destDevices;
19 protected List<SwitchPort> broadcastIntertfaces;
20
21 public RoutingDecision(long swDipd,
22 short inPort,
23 IDevice srcDevice,
24 RoutingAction action) {
25 this.srcPort = new SwitchPort(swDipd, inPort);
26 this.srcDevice = srcDevice;
27 this.destDevices =
28 Collections.synchronizedList(new ArrayList<IDevice>());
29 this.broadcastIntertfaces =
30 Collections.synchronizedList(new ArrayList<SwitchPort>());
31 this.action = action;
32 this.wildcards = null;
33 }
34
35 @Override
36 public RoutingAction getRoutingAction() {
37 return this.action;
38 }
39
40 @Override
41 public void setRoutingAction(RoutingAction action) {
42 this.action = action;
43 }
44
45 @Override
46 public SwitchPort getSourcePort() {
47 return this.srcPort;
48 }
49
50 @Override
51 public IDevice getSourceDevice() {
52 return this.srcDevice;
53 }
54
55 @Override
56 public List<IDevice> getDestinationDevices() {
57 return this.destDevices;
58 }
59
60 @Override
61 public void addDestinationDevice(IDevice d) {
62 if (!destDevices.contains(d)) {
63 destDevices.add(d);
64 }
65 }
66
67 @Override
68 public void setMulticastInterfaces(List<SwitchPort> lspt) {
69 this.broadcastIntertfaces = lspt;
70 }
71
72 @Override
73 public List<SwitchPort> getMulticastInterfaces() {
74 return this.broadcastIntertfaces;
75 }
76
77 @Override
78 public Integer getWildcards() {
79 return this.wildcards;
80 }
81
82 @Override
83 public void setWildcards(Integer wildcards) {
84 this.wildcards = wildcards;
85 }
86
87 @Override
88 public void addToContext(FloodlightContext cntx) {
89 rtStore.put(cntx, IRoutingDecision.CONTEXT_DECISION, this);
90 }
91
92 public String toString() {
93 return "action " + action +
94 " wildcard " +
95 ((wildcards == null) ? null : "0x"+Integer.toHexString(wildcards.intValue()));
96 }
97}