Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#inhmethods)

# TunnelModeChildSessionParams.Builder

*** ** * ** ***

` public static final class TunnelModeChildSessionParams.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.ipsec.ike.TunnelModeChildSessionParams.Builder |

<br />

*** ** * ** ***

This class can be used to incrementally construct a `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#Builder()() ` Create a Builder for negotiating a tunnel mode Child Session. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#Builder(android.net.ipsec.ike.TunnelModeChildSessionParams)(https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams childParams) ` Construct Builder from the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` object. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addChildSaProposal(android.net.ipsec.ike.ChildSaProposal)(https://developer.android.com/reference/android/net/ipsec/ike/ChildSaProposal proposal) ` Adds an Child SA proposal to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addInboundTrafficSelectors(android.net.ipsec.ike.IkeTrafficSelector)(https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector trafficSelector) ` Adds an inbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addInternalAddressRequest(int)(int addressFamily) ` Adds an internal IP address request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addInternalAddressRequest(java.net.Inet4Address)(https://developer.android.com/reference/java/net/Inet4Address address) ` Adds a specific internal IPv4 address request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addInternalAddressRequest(java.net.Inet6Address,%20int)(https://developer.android.com/reference/java/net/Inet6Address address, int prefixLen) ` Adds a specific internal IPv6 address request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addInternalDhcpServerRequest(int)(int addressFamily) ` Adds an internal DHCP server request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addInternalDnsServerRequest(int)(int addressFamily) ` Adds an internal DNS server request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#addOutboundTrafficSelectors(android.net.ipsec.ike.IkeTrafficSelector)(https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector trafficSelector) ` Adds an outbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#build()() ` Validates and builds the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams`. |
| ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | ` https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder#setLifetimeSeconds(int,%20int)(int hardLifetimeSeconds, int softLifetimeSeconds) ` Sets hard and soft lifetimes. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Builder

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

Create a Builder for negotiating a tunnel mode Child Session.

<br />

### Builder

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (TunnelModeChildSessionParams childParams)
```

Construct Builder from the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` object.

<br />

| Parameters ||
|---|---|
| `childParams` | `TunnelModeChildSessionParams`: the object this Builder will be constructed with. This value cannot be `null`. <br /> |

## Public methods

### addChildSaProposal

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addChildSaProposal (ChildSaProposal proposal)
```

Adds an Child SA proposal to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

<br />

| Parameters ||
|---|---|
| `proposal` | `ChildSaProposal`: Child SA proposal. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### addInboundTrafficSelectors

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addInboundTrafficSelectors (IkeTrafficSelector trafficSelector)
```

Adds an inbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

This method allows callers to limit the inbound traffic transmitted over the Child Session to the given range. The IKE server may further narrow the range. Callers should refer to `https://developer.android.com/reference/android/net/ipsec/ike/ChildSessionConfiguration` for the negotiated traffic selectors.

If no inbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector` is provided, a default value will be used that covers all IP addresses and ports.

<br />

| Parameters ||
|---|---|
| `trafficSelector` | `IkeTrafficSelector`: the inbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector`. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### addInternalAddressRequest

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addInternalAddressRequest (int addressFamily)
```

Adds an internal IP address request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

<br />

| Parameters ||
|---|---|
| `addressFamily` | `int`: the address family. Only `AF_INET` and `AF_INET6` are allowed <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### addInternalAddressRequest

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addInternalAddressRequest (Inet4Address address)
```

Adds a specific internal IPv4 address request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

<br />

| Parameters ||
|---|---|
| `address` | `Inet4Address`: the requested IPv4 address. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### addInternalAddressRequest

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addInternalAddressRequest (Inet6Address address, 
                int prefixLen)
```

Adds a specific internal IPv6 address request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

<br />

| Parameters ||
|---|---|
| `address` | `Inet6Address`: the requested IPv6 address. This value cannot be `null`. <br /> |
| `prefixLen` | `int`: length of the IPv6 address prefix length. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### addInternalDhcpServerRequest

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addInternalDhcpServerRequest (int addressFamily)
```

Adds an internal DHCP server request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

Only DHCPv4 server requests are supported.

<br />

| Parameters ||
|---|---|
| `addressFamily` | `int`: the address family. Only `AF_INET` is allowed <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### addInternalDnsServerRequest

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addInternalDnsServerRequest (int addressFamily)
```

Adds an internal DNS server request to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

<br />

| Parameters ||
|---|---|
| `addressFamily` | `int`: the address family. Only `AF_INET` and `AF_INET6` are allowed <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### addOutboundTrafficSelectors

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder addOutboundTrafficSelectors (IkeTrafficSelector trafficSelector)
```

Adds an outbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` being built.

This method allows callers to limit the outbound traffic transmitted over the Child Session to the given range. The IKE server may further narrow the range. Callers should refer to `https://developer.android.com/reference/android/net/ipsec/ike/ChildSessionConfiguration` for the negotiated traffic selectors.

If no outbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector` is provided, a default value will be used that covers all IP addresses and ports.

<br />

| Parameters ||
|---|---|
| `trafficSelector` | `IkeTrafficSelector`: the outbound `https://developer.android.com/reference/android/net/ipsec/ike/IkeTrafficSelector`. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | Builder this, to facilitate chaining. This value cannot be `null`. <br /> |

### build

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams build ()
```

Validates and builds the `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams` | the validated `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams`. This value cannot be `null`. <br /> |

### setLifetimeSeconds

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TunnelModeChildSessionParams.Builder setLifetimeSeconds (int hardLifetimeSeconds, 
                int softLifetimeSeconds)
```

Sets hard and soft lifetimes.

Lifetimes will not be negotiated with the remote IKE server.

<br />

| Parameters ||
|---|---|
| `hardLifetimeSeconds` | `int`: number of seconds after which Child SA will expire. Defaults to 7200 seconds (2 hours). Considering IPsec packet lifetime, IKE library requires hard lifetime to be a value from 300 seconds (5 minutes) to 14400 seconds (4 hours), inclusive. Value is between `https://developer.android.com/` and `https://developer.android.com/` inclusive <br /> |
| `softLifetimeSeconds` | `int`: number of seconds after which Child SA will request rekey. Defaults to 3600 seconds (1 hour). MUST be at least 120 seconds (2 minutes), and at least 60 seconds (1 minute) shorter than the hard lifetime. Value is between `https://developer.android.com/` and `https://developer.android.com/` inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/ipsec/ike/TunnelModeChildSessionParams.Builder` | This value cannot be `null`. <br /> |