This is a simple implementation of the IMS Data service on QMI/QRTR. It handles
the known and important requests to start and stop a connection through the
ModemManager D-Bus API, treating other requests as no operation.

Some known issues remain:

- Stopping the implementation does not release or disconnect any bearers. This
  makes it hard to debug, requiring the modem be set to low-power, then back
  online.
- ModemManager errors are not communicated to the modem.

# IMS Data Protocol

The IMS Data service is served over the known QMI/QRTR protocols, with service number 770 and version number 1. Requests are sent by the modem (where firmware runs) and prompt responses from the Application Processor (where the FOSS drivers run). The AP can also send indications which are not directly requested.

The critical QMI request is IMSD 0x20, by which the modem requests the AP to start a connection via WDS Start Network with the specified parameters. The rest of the IMSD requests can succeed through a simple response with the operation result (field 0x02) set to zero.

Another important QMI request is IMSD 0x21, by which the modem requests to stop the connection. This must be properly implemented so the modem attempts to reconnect after being put in low power mode and brought back online.

## Request 0x20: Start Connection

Field 0x01 is a sequence of:

- a string containing the APN name with an 8-bit length prefix
- a 32-bit number, valid from 0 to 5 inclusive
- a 32-bit enumerable indicating which profile IDs to include in the WDS Start Network request
    - 0 = 3GPP2 profile ID only
    - 1 = 3GPP profile ID only
    - 2 = 3GPP and 3GPP2 profile IDs
- a 32-bit enumerable representing the IP family
    - 0 = IPv4
    - 1 = IPv6
- the 3GPP profile ID sign-extended to 16 bits
- the 3GPP2 profile ID sign-extended to 16 bits

Thanks to Dylan's research, field 0x13 is known to be a subscription ID. Binding a subscription is probably not required most of the time, but this number is used to track the connection.

Field 0x10 is an ID for the connection.

Example: APN "ims", IPv6, 3GPP profile 2, 3GPP2 profile 255, Connection 101, Subscription 1

    Type  Length Value (in hexadecimal)
    01    1400   03 696d73 00000000 02000000 01000000 0200 ffff
    10    0400   65000000
    11    0400   00000000
    12    0400   01000000
    13    0400   01000000

## Response 0x20

Field 0x11 is the connection ID from the request.

Field 0x12 is the subscription ID from the request.

Field 0x10 is an updated connection ID. If the connection ID and subscription ID are valid, the modem will refer to the connection with this new connection ID.

Example: New ID 21, Connection 101, Subscription 1

    Type  Length Value
    02    0400   0000 0000
    10    0100   15
    11    0400   65000000
    12    0400   01000000

## Request 0x21: Stop Connection

If a valid indication 0x20 was emitted, field 0x01 is the connection ID from the indication. If the corresponding 0x20 request was given a valid response but an indication was not emitted, field 0x01 is the connection ID from the response. Otherwise, field 0x01 is the connection ID from the request.

Example: Connection 21, Subscription 1

    Type  Length Value
    01    0100   15
    10    0400   01000000

## Response 0x21

Field 0x11 is set to field 0x10 of the request.

Field 0x10 is set to -6.

Example:

    Type  Length Value
    02    0400   0000 0000
    10    0100   fa
    11    0400   01000000

## Indication 0x20: Connection Changed

Field 0x02 is the operation result. If the connection is up, the error status and code are zero. If the connection is down due to request 0x20, the error status is zero and the error code is 13.

Field 0x01 is the new connection ID, and will be used to update the connection ID if it differs.

Field 0x10 is the connection ID of the request.

If the connection is up, field 0x11 is a sequence of:

- a 32-bit integer, set to 1 for IPv6 addresses
- a string containing the IP address obtained by the device with an 8-bit length prefix

Field 0x12 is the subscription ID.

Example: Connection 21, Old Connection ID 101, Subscription 1, IPv6 Address 2606:4700::1111

    Type  Length Value
    02    0400   0000 0000
    01    0100   15
    10    0400   65000000
    11    1400   01000000 0f 323630363a343730303a3a31313131
    12    0400   01000000
