> Source: https://docs.cyberelements.io/bastion/4.7/sv/Usage/Reference/ConfigurationFiles/EdgeGateway/GatewayServicesXml/

# services.xml

`/etc/ipdiva/gateway/services.xml` declares the services of an Edge Gateway: the local listening addresses whose connections it carries to the Mediation Controller or to another Edge Gateway, and the addresses that the other nodes may reach through it. The console adds to it the services it needs for the sessions, the resources and the ACM agent.

| Property | Value |
|---|---|
| **Component** | Edge Gateway |
| **Path** | `/etc/ipdiva/gateway/services.xml` |
| **Owner and permissions** | `ipdivagateway:root`, `644` |
| **Package** | none, written at installation |
| **Format** | XML |

> **The Edge Gateway rewrites the file**
>
> Each time a service is added or removed, the Edge Gateway writes the whole file again from what it holds in memory, without comments, without your layout, and with every default value written out. A change made by hand is applied only when the Edge Gateway restarts; until then, it may be overwritten if a service is added, automatically by the product or by an administrator from the administration console. Restart the Edge Gateway as soon as the change is made.

> **One file per instance**
>
> An additional instance of the Edge Gateway has its own `services.xml`, created empty, in its own directory, `/etc/ipdiva/gateway-<instance>/`, named after the instance. What this page describes applies to each of them.

## Structure

A single `<services>` element:

| Section | Holds |
|---|---|
| [`<services>`](#services-root) | The Edge Gateways allowed to reach any address through this Edge Gateway. |
| [`<in>`](#in) | The input services: a local listening address, whose connections are carried to the Mediation Controller or to another Edge Gateway. |
| [`<out>`](#out) | The output services: an address that the other nodes may reach through this Edge Gateway. |
| [`<multicast>`](#multicast) | The multicast services: a group shared with the other Edge Gateways of the organisation. |

The installed file declares an input service `ntp`, which gives the Edge Gateway the time of the Mediation Controller, and an output service `NRPE`, used by the monitoring.

## Parameters

The tables list every element and every attribute that the Edge Gateway reads. Two columns give a value:

- **Default value**: the value written in the file as installed. A dash marks an element absent from the installed file.
- **If the element is absent**: the value that the Edge Gateway uses when it does not find the element.

An element is written as a path from its section, and `@` marks an attribute:

- `service/name` is the `<name>` element of a `<service>` of the section;
- `service/gateway/@passive` is the `passive` attribute of the `<gateway>` element of a `<service>`;
- `service/@max-rate` is the `max-rate` attribute of the `<service>` itself.

### `<services>`

Root element of the file. It holds the `<in>`, `<out>` and `<multicast>` sections, each made of repeatable `<service>` elements, and the `<dyn-gateways>` element. The file is read at startup only. A missing or unreadable file, or one whose root is not `<services>`, is skipped: the program starts with no declared service.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `dyn-gateways` | — | none | Names of the Edge Gateways allowed to reach, through this Edge Gateway, any address given as `host:port` (port 80 if omitted), even with no declared outgoing service. Names are separated by a space, a comma or a semicolon, and written without prefix as `edge-gateway@organization`. A name may hold wildcards: `*` stands for zero, one or more characters, `?` for exactly one character. For instance, `*@organization` designates every Edge Gateway of an organisation. The name must match as a whole, case included. |

### `<in>`

Incoming services. Each `<service>` opens a local listener on the Edge Gateway; every connection it receives is carried to the destination node, which hands it to the named service. The console adds here the services it creates on demand, for instance for the ACM agent.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `service/gateway` | — | the Mediation Controller the Edge Gateway is connected to | Name of the destination node: `Server` (`ServerMaster` or `ServerSlave` in a cluster) for the Mediation Controller, or `edge-gateway@organization` for another Edge Gateway; the element can be repeated. Each connection goes to one of the connected active destinations, picked at random. The prefix `S:` is added when missing. |
| `service/gateway/@passive` | — | `false` | `true`: standby destination, used only when no active destination of the service is connected. Any other value: active destination. |
| `service/@max-rate` | — | no limit | Maximum rate, in bytes per second averaged over about 20 seconds, of the data that this node reads on each connection of the service and sends into the tunnel. `0` or a non-numeric value: no limit. |
| `service/protocol` | `udp` | `tcp` | Transport protocol of the service: `tcp` or `udp`, in lowercase. A value written otherwise than in lowercase counts as `tcp`. |
| `service/name` | `ntp` | required | Name of the service requested from the destination node: the name of an outgoing service declared on it. The Mediation Controller only accepts declared services. |
| `service/listen` | `127.0.0.1:123` | required | Local listening address and port, as `address:port`. Port `0` lets the system choose a free port. The protocol and this address identify the service. |
| `service/must-exist` | `true` | `false` | `true`: the listener is opened with address reuse and, if it cannot be opened, the program stops; systemd restarts it 10 seconds later. `false`: the failure is written to the log and the service is skipped. |
| `service/crypted` | — | `false` | `true`: the data of each connection are encrypted end to end between the two nodes, with a session key exchanged by means of their certificates. `false`: they are protected by the encryption of the links only. |
| `service/timeout` | — | `0` | Time, in milliseconds, after which a connection is closed when no data has arrived from its local side. `0`: no time limit, except for a `udp` service, closed after 180 seconds. |
| `service/compression` | — | `zlib` | Compression of the data that this node sends into the tunnel: `zlib`, `lzo` or `none`, case-insensitive. Any other value counts as `lzo`. |

### `<out>`

Outgoing services. Each `<service>` allows other nodes to open, through the Edge Gateway, a connection toward an address. The console adds here the services it needs, for instance for a permanent tunnel of the Mediation Controller. A request from the Mediation Controller for an undeclared address `host:port` is also accepted; the same request from another Edge Gateway is refused, except as set by `<dyn-gateways>`.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `service/@max-rate` | — | no limit | Maximum rate, in bytes per second averaged over about 20 seconds, of the data that this node reads from the destination address and sends back into the tunnel. `0` or a non-numeric value: no limit. |
| `service/name` | `NRPE` | required | Name of the service, as requested by the incoming services of the other nodes (`<name>` of `<in>`). It identifies the service. |
| `service/connect` | `127.0.0.1:5666` | required | Address and port, as `host:port`, toward which this node opens the connection. |
| `service/gateways` | — | all nodes | Names of the nodes allowed to request the service, separated by a space, a comma or a semicolon. A name is written without prefix: `edge-gateway@organization` for an Edge Gateway, `Server` (`ServerMaster` or `ServerSlave` in a cluster) for the Mediation Controller. A name may hold wildcards: `*` stands for zero, one or more characters, `?` for exactly one character. For instance, `*@organization` designates every Edge Gateway of an organisation. The name must match as a whole, case included. Empty: all nodes. |

### `<multicast>`

Multicast services. Each connection received on the listening address joins a group; the data it sends are copied to all the other connections of the group, on this Edge Gateway and on the other Edge Gateways of the organisation that declare the same group. The console creates no such service.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `service/name` | — | required | Name of the group, shared by the Edge Gateways of the organisation that declare it. |
| `service/listen` | — | required | Local listening address and port, as `address:port`. It identifies the service. |
| `service/must-exist` | — | `false` | `true`: the listener is opened with address reuse and, if it cannot be opened, the program stops; systemd restarts it 10 seconds later. `false`: the failure is written to the log and the service is skipped. |

## Applying a change

The file is read only when the Edge Gateway starts. Edit the file, then restart the Edge Gateway to apply the change:

```
1
```

An additional instance (see “One file per instance” at the top of the page) is restarted by its own service, named after the instance:

```
1
```

> **Restarting the Edge Gateway cuts the sessions in progress**
>
> Every session that goes through this Edge Gateway is interrupted. Plan the change outside working hours.

## Upgrade

No package delivers the file as a configuration file: the installation creates it from its template if it is missing, and an upgrade neither rewrites nor completes it.
