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

# Builder

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/net/ipsec/ike/TransportModeChildSessionParams.Builder "View this page in Java")

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.net.ipsec.ike.TransportModeChildSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#) |

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

## Summary

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

| Public methods ||
|---|---|
| [TransportModeChildSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#) | `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#addChildSaProposal(android.net.ipsec.ike.ChildSaProposal)(proposal: https://developer.android.com/reference/kotlin/android/net/ipsec/ike/ChildSaProposal)` Adds a Child SA proposal to the `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams` being built. |
| [TransportModeChildSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#) | `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#addInboundTrafficSelectors(android.net.ipsec.ike.IkeTrafficSelector)(trafficSelector: https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector)` Adds an inbound `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams` being built. |
| [TransportModeChildSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#) | `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#addOutboundTrafficSelectors(android.net.ipsec.ike.IkeTrafficSelector)(trafficSelector: https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector)` Adds an outbound `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams` being built. |
| [TransportModeChildSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams) | `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#build()()` Validates and builds the `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams`. |
| [TransportModeChildSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#) | `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#setLifetimeSeconds(kotlin.Int,%20kotlin.Int)(hardLifetimeSeconds: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, softLifetimeSeconds: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets hard and soft lifetimes. |

## Public constructors

### Builder

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

```
Builder()
```

Create a Builder for negotiating a transport mode Child Session.

### Builder

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

```
Builder(childParams: TransportModeChildSessionParams)
```

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

| Parameters ||
|---|---|
| `childParams` | [TransportModeChildSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams): the object this Builder will be constructed with. This value cannot be `null`. |

## Public methods

### addChildSaProposal

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

```
fun addChildSaProposal(proposal: ChildSaProposal): TransportModeChildSessionParams.Builder
```

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

| Parameters ||
|---|---|
| `proposal` | [ChildSaProposal](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/ChildSaProposal): Child SA proposal. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#` | Builder this, to facilitate chaining. This value cannot be `null`. |

### addInboundTrafficSelectors

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

```
fun addInboundTrafficSelectors(trafficSelector: IkeTrafficSelector): TransportModeChildSessionParams.Builder
```

Adds an inbound `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams` 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/kotlin/android/net/ipsec/ike/ChildSessionConfiguration` for the negotiated traffic selectors.

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

| Parameters ||
|---|---|
| `trafficSelector` | [IkeTrafficSelector](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector): the inbound `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector`. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#` | Builder this, to facilitate chaining. This value cannot be `null`. |

### addOutboundTrafficSelectors

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

```
fun addOutboundTrafficSelectors(trafficSelector: IkeTrafficSelector): TransportModeChildSessionParams.Builder
```

Adds an outbound `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector` to the `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams` 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/kotlin/android/net/ipsec/ike/ChildSessionConfiguration` for the negotiated traffic selectors.

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

| Parameters ||
|---|---|
| `trafficSelector` | [IkeTrafficSelector](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector): the outbound `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeTrafficSelector`. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#` | Builder this, to facilitate chaining. This value cannot be `null`. |

### build

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

```
fun build(): TransportModeChildSessionParams
```

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams` | the validated `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams`. This value cannot be `null`. |

### setLifetimeSeconds

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

```
fun setLifetimeSeconds(
    hardLifetimeSeconds: Int, 
    softLifetimeSeconds: Int
): TransportModeChildSessionParams.Builder
```

Sets hard and soft lifetimes.

Lifetimes will not be negotiated with the remote IKE server.

| Parameters ||
|---|---|
| `hardLifetimeSeconds` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): 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 android.net.ipsec.ike.ChildSessionParams#CHILD_HARD_LIFETIME_SEC_MINIMUM and android.net.ipsec.ike.ChildSessionParams#CHILD_HARD_LIFETIME_SEC_MAXIMUM inclusive |
| `softLifetimeSeconds` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): 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 android.net.ipsec.ike.ChildSessionParams#CHILD_SOFT_LIFETIME_SEC_MINIMUM and android.net.ipsec.ike.ChildSessionParams#CHILD_HARD_LIFETIME_SEC_MAXIMUM inclusive |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/ipsec/ike/TransportModeChildSessionParams.Builder#` | This value cannot be `null`. |