blob: 39693076b6a6e0b3d7738cb4c6b109801f902297 [file] [log] [blame]
Alan Viverette3da604b2020-06-10 18:34:39 +00001/*
2 * Copyright (C) 2020 The Android Open Source Project
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 */
16
17package android.net.ipsec.ike;
18
19import android.annotation.NonNull;
20import android.annotation.SystemApi;
21import android.net.Network;
22
23import java.net.InetAddress;
24import java.util.Objects;
25
26/**
27 * IkeSessionConnectionInfo represents the connection information of a {@link IkeSession}.
28 *
29 * <p>Connection information includes IP addresses of both the IKE client and server and the network
30 * being used.
31 *
32 * @hide
33 */
34@SystemApi
35public final class IkeSessionConnectionInfo {
36 private final InetAddress mLocalAddress;
37 private final InetAddress mRemoteAddress;
38 private final Network mNetwork;
39
40 /**
41 * Construct an instance of {@link IkeSessionConnectionInfo}.
42 *
43 * @hide
44 */
45 public IkeSessionConnectionInfo(
46 InetAddress localAddress, InetAddress remoteAddress, Network network) {
47 Objects.requireNonNull(localAddress, "localAddress not provided");
48 Objects.requireNonNull(remoteAddress, "remoteAddress not provided");
49 Objects.requireNonNull(network, "network not provided");
50
51 mLocalAddress = localAddress;
52 mRemoteAddress = remoteAddress;
53 mNetwork = network;
54 }
55
56 /**
57 * Returns the local IP address for the underlying {@link Network} being used.
58 *
59 * @return the local IP address.
60 */
61 @NonNull
62 public InetAddress getLocalAddress() {
63 return mLocalAddress;
64 }
65
66 /**
67 * Returns the remote IP address for the underlying {@link Network} being used.
68 *
69 * @return the remote IP address.
70 */
71 @NonNull
72 public InetAddress getRemoteAddress() {
73 return mRemoteAddress;
74 }
75
76 /**
77 * Returns the underlying {@link Network} being used.
78 *
79 * @return the underlying {@link Network} that carries all IKE traffic.
80 */
81 @NonNull
82 public Network getNetwork() {
83 return mNetwork;
84 }
85}