1 /* 2 * Copyright 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 17 package com.google.android.iwlan.epdg; 18 19 import com.android.internal.annotations.VisibleForTesting; 20 21 import com.google.auto.value.AutoValue; 22 23 import java.net.InetAddress; 24 import java.util.Optional; 25 26 @AutoValue 27 public abstract class TunnelSetupRequest { apnName()28 abstract String apnName(); 29 apnIpProtocol()30 abstract int apnIpProtocol(); 31 srcIpv4Address()32 abstract Optional<InetAddress> srcIpv4Address(); 33 srcIpv6Address()34 abstract Optional<InetAddress> srcIpv6Address(); 35 srcIpv6AddressPrefixLength()36 abstract int srcIpv6AddressPrefixLength(); 37 pduSessionId()38 abstract int pduSessionId(); 39 isRoaming()40 abstract boolean isRoaming(); 41 isEmergency()42 abstract boolean isEmergency(); 43 requestPcscf()44 abstract boolean requestPcscf(); 45 46 @VisibleForTesting getPduSessionId()47 public int getPduSessionId() { 48 return pduSessionId(); 49 } 50 builder()51 public static Builder builder() { 52 return new AutoValue_TunnelSetupRequest.Builder() 53 .setSrcIpv4Address(Optional.empty()) 54 .setSrcIpv6Address(Optional.empty()) 55 .setSrcIpv6AddressPrefixLength(0); 56 } 57 58 @AutoValue.Builder 59 public abstract static class Builder { setApnName(String apnName)60 public abstract Builder setApnName(String apnName); 61 setApnIpProtocol(int protocol)62 public abstract Builder setApnIpProtocol(int protocol); 63 setSrcIpv4Address(InetAddress srcIpv4Address)64 public Builder setSrcIpv4Address(InetAddress srcIpv4Address) { 65 return setSrcIpv4Address(Optional.ofNullable(srcIpv4Address)); 66 } 67 setSrcIpv4Address(Optional<InetAddress> srcIpv4Address)68 public abstract Builder setSrcIpv4Address(Optional<InetAddress> srcIpv4Address); 69 setSrcIpv6Address(InetAddress srcIpv6Address)70 public Builder setSrcIpv6Address(InetAddress srcIpv6Address) { 71 return setSrcIpv6Address(Optional.ofNullable(srcIpv6Address)); 72 } 73 setSrcIpv6Address(Optional<InetAddress> srcIpv6Address)74 public abstract Builder setSrcIpv6Address(Optional<InetAddress> srcIpv6Address); 75 setSrcIpv6AddressPrefixLength(int srcIpv6AddressPrefixLength)76 public abstract Builder setSrcIpv6AddressPrefixLength(int srcIpv6AddressPrefixLength); 77 setPduSessionId(int pduSessionId)78 public abstract Builder setPduSessionId(int pduSessionId); 79 setIsRoaming(boolean isRoaming)80 public abstract Builder setIsRoaming(boolean isRoaming); 81 setIsEmergency(boolean isEmergency)82 public abstract Builder setIsEmergency(boolean isEmergency); 83 setRequestPcscf(boolean requestPcscf)84 public abstract Builder setRequestPcscf(boolean requestPcscf); 85 build()86 public abstract TunnelSetupRequest build(); 87 } 88 } 89