1 /*
2  * Copyright (C) 2023 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 
17 package com.google.android.iwlan.epdg;
18 
19 import com.google.android.iwlan.IwlanError;
20 
21 /** A state machine that infers the current IkeSession state. */
22 enum IkeSessionState {
23     NO_IKE_SESSION {
24         @Override
getErrorType()25         public int getErrorType() {
26             return IwlanError.NO_ERROR;
27         }
28     },
29     IKE_SESSION_INIT_IN_PROGRESS {
30         @Override
getErrorType()31         public int getErrorType() {
32             return IwlanError.IKE_INIT_TIMEOUT;
33         }
34     },
35     IKE_MOBILITY_IN_PROGRESS {
36         @Override
getErrorType()37         public int getErrorType() {
38             return IwlanError.IKE_MOBILITY_TIMEOUT;
39         }
40     },
41     CHILD_SESSION_OPENED {
42         @Override
getErrorType()43         public int getErrorType() {
44             return IwlanError.IKE_DPD_TIMEOUT;
45         }
46     };
47 
48     /**
49      * Called when IkeSession report error with IkeIOException, check current IkeSession state and
50      * return corresponding time out error.
51      *
52      * @return NO_ERROR or IWLAN IKE time out error
53      */
getErrorType()54     public abstract int getErrorType();
55 }
56