blob: 31d607b7d5ac317e11f4800a750e38ebae3b0a75 [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.IpAddress;
19
Jian Lie9af3b42016-08-08 15:50:01 +090020import java.util.Objects;
21
Jian Li6b77dc02016-07-14 16:04:25 +090022import static com.google.common.base.Preconditions.checkArgument;
23
24/**
25 * IPv4 address that is used by LISP Locator.
26 */
27public class LispIpv4Address extends LispIpAddress {
28
29 /**
30 * Initializes LISP locator's IPv4 address.
31 *
32 * @param address IP address
33 */
34 public LispIpv4Address(IpAddress address) {
35 super(address, AddressFamilyIdentifierEnum.IP);
36 checkArgument(address.isIp4());
37 }
Jian Lie9af3b42016-08-08 15:50:01 +090038
39 @Override
40 public boolean equals(Object obj) {
41 if (this == obj) {
42 return true;
43 }
44
45 if (obj instanceof LispIpv4Address) {
46 final LispIpv4Address other = (LispIpv4Address) obj;
47 return Objects.equals(this.address, other.address) &&
48 Objects.equals(this.getAfi(), other.getAfi());
49 }
50 return false;
51 }
52
53 @Override
54 public int hashCode() {
55 return Objects.hash(address, getAfi());
56 }
Jian Li6b77dc02016-07-14 16:04:25 +090057}