blob: b8a83c7709007c33de2134477d6adfa18cf66d2e [file] [log] [blame]
alshabib2ce0c732015-10-02 11:20:39 +02001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabib2ce0c732015-10-02 11:20:39 +02003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.net.mcast;
17
alshabib2ce0c732015-10-02 11:20:39 +020018import com.google.common.base.Objects;
alshabib79e52872015-12-07 16:01:01 -080019import org.onlab.packet.IpAddress;
alshabib2ce0c732015-10-02 11:20:39 +020020
21import static com.google.common.base.MoreObjects.toStringHelper;
alshabibed0951f2015-10-02 21:39:27 +020022import static com.google.common.base.Preconditions.checkNotNull;
alshabib2ce0c732015-10-02 11:20:39 +020023
24/**
25 * An entity representing a multicast route consisting of a source
26 * and a multicast group address.
Ray Milkey50b14582017-08-23 09:55:02 -070027 *
28 * @deprecated in 1.11 ("Loon") release. To be moved into an app.
alshabib2ce0c732015-10-02 11:20:39 +020029 */
Ray Milkey50b14582017-08-23 09:55:02 -070030@Deprecated
alshabib2ce0c732015-10-02 11:20:39 +020031public class McastRoute {
32
33 public enum Type {
34 /**
35 * Route originates from PIM.
36 */
37 PIM,
38
39 /**
40 * Route originates from IGMP.
41 */
42 IGMP,
43
44 /**
45 * Route originates from other config (ie. REST, CLI).
46 */
47 STATIC
48 }
49
alshabib79e52872015-12-07 16:01:01 -080050 private final IpAddress source;
51 private final IpAddress group;
alshabib2ce0c732015-10-02 11:20:39 +020052 private final Type type;
53
alshabib79e52872015-12-07 16:01:01 -080054 public McastRoute(IpAddress source, IpAddress group, Type type) {
alshabibed0951f2015-10-02 21:39:27 +020055 checkNotNull(source, "Multicast route must have a source");
56 checkNotNull(group, "Multicast route must specify a group address");
57 checkNotNull(type, "Must indicate what type of route");
alshabib2ce0c732015-10-02 11:20:39 +020058 this.source = source;
59 this.group = group;
60 this.type = type;
61 }
62
63 /**
64 * Fetches the source address of this route.
65 *
66 * @return an ip address
67 */
alshabib79e52872015-12-07 16:01:01 -080068 public IpAddress source() {
alshabib2ce0c732015-10-02 11:20:39 +020069 return source;
70 }
71
72 /**
73 * Fetches the group address of this route.
74 *
75 * @return an ip address
76 */
alshabib79e52872015-12-07 16:01:01 -080077 public IpAddress group() {
alshabib2ce0c732015-10-02 11:20:39 +020078 return group;
79 }
80
81 /**
82 * Obtains how this route was created.
83 * @return a type of route
84
85 */
86 public Type type() {
87 return type;
88 }
89
90 @Override
91 public String toString() {
92 return toStringHelper(this)
93 .add("source", source)
94 .add("group", group)
95 .add("origin", type)
96 .toString();
97 }
98
99 @Override
100 public boolean equals(Object o) {
101 if (this == o) {
102 return true;
103 }
104 if (o == null || getClass() != o.getClass()) {
105 return false;
106 }
107 McastRoute that = (McastRoute) o;
108 return Objects.equal(source, that.source) &&
109 Objects.equal(group, that.group) &&
110 Objects.equal(type, that.type);
111 }
112
113 @Override
114 public int hashCode() {
115 return Objects.hashCode(source, group, type);
116 }
117
118}