shared-qmi: fix byteorder for supl server IP

It was noted, that when supl server is set using IP address. Modem
doesn't connect to the SUPL server anymore. When IP address is inverted,
then modem connects to SUPL server successfuly.

IP address is stored as uint32_t. According to Telit's documentation [1]
numeric values are encoded in little-endian format in QMI.

After converting IP address from string to binary using inet_pton
IP address is stored in network byte order (big-endian). Therefore it's
needed another convertion from big-endian to host endianness. Final
conversion from host endianness to endianness needed for QMI will be
done in generated
qmi_message_pds_set_agps_config_input_set_location_server_address.

Vendor's Android GNSS hal uses htonl() to convert from struct in_addr
(already in big-endian) before sending QMI request as well [2].

Tested on Quectel EG25-G and SDM845 (OnePlus 6T).

1. FN980 Family Telit Proprietary QMI Command Reference Guide. 4.1.3.1 Byte Ordering
2. https://github.com/ugly-kid-af/device_xiaomi_violet/blob/snow/gps/gnss/GnssAdapter.cpp#L1110

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
This commit is contained in:
Andrey Skvortsov
2025-08-10 21:05:13 +00:00
parent 14031a4b1b
commit f51cc9488b
+4 -4
View File
@@ -4541,7 +4541,7 @@ pds_set_supl_server (GTask *task)
qmi_message_pds_set_agps_config_input_set_network_mode (input, QMI_PDS_NETWORK_MODE_CDMA, NULL);
if (mm_parse_supl_address (ctx->supl, NULL, &ip, &port, NULL))
qmi_message_pds_set_agps_config_input_set_location_server_address (input, ip, port, NULL);
qmi_message_pds_set_agps_config_input_set_location_server_address (input, GUINT32_FROM_BE (ip), port, NULL);
else {
url = parse_as_utf16_url (ctx->supl);
qmi_message_pds_set_agps_config_input_set_location_server_url (input, url, NULL);
@@ -4655,7 +4655,7 @@ loc_set_supl_server (GTask *task)
qmi_message_loc_set_server_input_set_server_type (input, QMI_LOC_SERVER_TYPE_CDMA_PDE, NULL);
if (mm_parse_supl_address (ctx->supl, NULL, &ip, &port, NULL))
qmi_message_loc_set_server_input_set_ipv4 (input, ip, (guint32) port, NULL);
qmi_message_loc_set_server_input_set_ipv4 (input, GUINT32_FROM_BE (ip), (guint32) port, NULL);
else
qmi_message_loc_set_server_input_set_url (input, ctx->supl, NULL);
@@ -4771,7 +4771,7 @@ pds_get_agps_config_ready (QmiClientPds *client,
NULL) &&
ip != 0 &&
port != 0) {
struct in_addr a = { .s_addr = ip };
struct in_addr a = { .s_addr = GUINT32_FROM_BE (ip) };
gchar buf[INET_ADDRSTRLEN + 1];
memset (buf, 0, sizeof (buf));
@@ -4882,7 +4882,7 @@ loc_location_get_server_indication_cb (QmiClientLoc *client,
&ipv4_port,
NULL) &&
ipv4_address != 0 && ipv4_port != 0) {
struct in_addr a = { .s_addr = ipv4_address };
struct in_addr a = { .s_addr = GUINT32_FROM_BE (ipv4_address) };
gchar buf[INET_ADDRSTRLEN + 1];
memset (buf, 0, sizeof (buf));