1 /* 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 package android.net.ipsec.ike.exceptions; 17 18 import android.net.ipsec.ike.ChildSessionCallback; 19 import android.net.ipsec.ike.IkeSessionCallback; 20 21 /** 22 * This exception is thrown if the remote server hits an error in assigning an internal IP address. 23 * 24 * <p>This exception indicates the remote server encounters an error while attempting to assign an 25 * internal IP address during Child creation. 26 * 27 * @see <a href="https://tools.ietf.org/html/rfc7296#section-3.15.4">RFC 7296, Internet Key Exchange 28 * Protocol Version 2 (IKEv2)</a> 29 * @hide 30 */ 31 public final class InternalAddressFailureException extends IkeProtocolException { 32 private static final int EXPECTED_ERROR_DATA_LEN = 0; 33 34 /** 35 * Construct an instance of InternalAddressFailureException. 36 * 37 * <p>Except for testing, IKE library users normally do not instantiate this object themselves 38 * but instead get a reference via {@link IkeSessionCallback} or {@link ChildSessionCallback}. 39 */ InternalAddressFailureException()40 public InternalAddressFailureException() { 41 super(ERROR_TYPE_INTERNAL_ADDRESS_FAILURE); 42 } 43 44 /** 45 * Construct a instance of InternalAddressFailureException from a notify payload. 46 * 47 * @param notifyData the notify data included in the payload. 48 * @hide 49 */ InternalAddressFailureException(byte[] notifyData)50 public InternalAddressFailureException(byte[] notifyData) { 51 super(ERROR_TYPE_INTERNAL_ADDRESS_FAILURE, notifyData); 52 } 53 54 /** @hide */ 55 @Override isValidDataLength(int dataLen)56 protected boolean isValidDataLength(int dataLen) { 57 return EXPECTED_ERROR_DATA_LEN == dataLen; 58 } 59 } 60