blob: 3a36255a71f98239e0363ff52fdd4a852267db3a [file] [log] [blame]
Jian Li6b77dc02016-07-14 16:04:25 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
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.lisp.msg.types;
17
18import org.onlab.packet.MacAddress;
19
Jian Lie9af3b42016-08-08 15:50:01 +090020import java.util.Objects;
21
Jian Li6b77dc02016-07-14 16:04:25 +090022/**
23 * MAC address that is used by LISP Locator.
24 */
25public class LispMacAddress extends LispAfiAddress {
26
27 protected final MacAddress address;
28
29 /**
30 * Initializes MAC address.
31 *
32 * @param address MAC address
33 */
34 public LispMacAddress(MacAddress address) {
35 super(AddressFamilyIdentifierEnum.MAC);
36 this.address = address;
37 }
38
39 /**
40 * Obtains LISP locator's MAC address.
41 *
42 * @return MAC address
43 */
44 public MacAddress getAddress() {
45 return address;
46 }
47
48 @Override
49 public int hashCode() {
50 return address.hashCode();
51 }
52
53 @Override
54 public boolean equals(Object obj) {
Jian Lie9af3b42016-08-08 15:50:01 +090055 if (this == obj) {
56 return true;
57 }
58
59 if (obj instanceof LispMacAddress) {
60 final LispMacAddress other = (LispMacAddress) obj;
61 return Objects.equals(this.address, other.address) &&
62 Objects.equals(this.getAfi(), other.getAfi());
63 }
64 return false;
Jian Li6b77dc02016-07-14 16:04:25 +090065 }
66
67 @Override
68 public String toString() {
69 return address.toString();
70 }
71}