# &adminguide;

## Overview

The B2BUA implementation in OpenSIPS is separated in two layers:

- a lower one(coded in this module)- which implements the basic functions of a UAS and UAC
- a upper one - which represents the logic engine of B2BUA, responsible of actually implementing the B2BUA services using the functions offered by the low level.

This module stores records corresponding to the dialogs in which the B2BUA is involved. It exports an API to be called from other modules which offers functions for creating a new dialog record, for sending requests or replies in one dialog and will also notify the upper level module when a request or reply is received inside one stored dialog. The records are separated in two types: b2b server entities and b2b client entities depending on the mode they are created. An entity created for a received initial message will be a server entity, while a entity that will send an initial request(create a new dialog) will be a b2b client entity. The name corresponds to the behavior in the first transaction - if UAS - server entity and if UAC - client entity. This module does not implement a B2BUA alone, but needs a B2B logic implementing module.

The module is able to respond to authentication challanges if the uac_auth module is loaded first. The list of credentials for b2b authentication is also provided by the uac_auth module.

## Dependencies

### &osips; Modules

- tm

- a db module

- uac_auth (mandatory if authentication is required)

### External Libraries or Applications

The following libraries or applications must be installed before running &osips; with this module loaded:

- none

## Exported Parameters

### `server_hsize` (int)

The size of the hash table that stores the b2b server entities. It is the 2 logarithmic value of the real size.

Default value is 9 (512 records).

#### Set `server_hsize` parameter

    ...
    modparam("b2b_entities", "server_hsize", 10)
    ...

### `client_hsize` (int)

The size of the hash table that stores the b2b client entities. It is the 2 logarithmic value of the real size.

Default value is 9 (512 records).

#### Set `client_hsize` parameter

    ...
    modparam("b2b_entities", "client_hsize", 10)
    ...

### `script_req_route` (str)

The name of the b2b script route that will be called when B2B requests are received.

#### Set `script_req_route` parameter

    ...
    modparam("b2b_entities", "script_req_route", "b2b_request")
    ...

### `script_reply_route` (str)

The name of the b2b script route that will be called when B2B replies are received.

#### Set `script_repl_route` parameter

    ...
    modparam("b2b_entities", "script_reply_route", "b2b_reply")
    ...

### `db_url` (str)

Database URL. It is not compulsory, if not set data is not stored in database.

#### Set `db_url` parameter

    ...
    modparam("b2b_entities", "db_url", "mysql://opensips:opensipsrw@127.0.0.1/opensips")
    ...

### `update_period` (int)

The time interval at which to update the info in database.

Default value is 100.

#### Set `update_period` parameter

    ...
    modparam("b2b_entities", "update_period", 60)
    ...

### `b2b_key_prefix` (string)

The string to use when generating the key ( it is inserted in the SIP messages as callid or to tag. It is useful to set this prefix if you use more instances of opensips B2BUA cascaded in the same architecture. Sometimes opensips B2BUA looks at the callid or totag to see if it has the format it uses to determine if the request was sent by it.

Default value is B2B.

#### Set `b2b_key_prefix` parameter

    ...
    modparam("b2b_entities", "b2b_key_prefix", "B2B1")
    ...

### `db_mode` (int)

The B2B modules have support for the 3 type of database storage

- NO DB STORAGE - set this parameter to 0
- WRITE THROUGH (synchronous write in database) - set this parameter to 1
- WRITE BACK (update in db from time to time) - set this parameter to 2

Default value is 2 (WRITE BACK).

#### Set `db_mode` parameter

    ...
    modparam("b2b_entities", "db_mode", 1)
    ...

### `db_table` (str)

The name of the table that will be used for storing B2B entities

Default value is b2b_entities

#### Set `db_table` parameter

    ...
    modparam("b2b_entities", "db_table", "some table name")
    ...

### `replication_mode` (int)

Controls if the callid should be the same in more instances running at the same time. 0 will lead to generating of different callid's per instance 1 will lead to generating of the same callid's in more instances

Default value is 0

#### Set `replication_mode` parameter

    ...
    modparam("b2b_entities", "replication_mode", 1)
    ...

## Exported Functions

The module does not export functions to be used in configuration script.