diff mbox series

[12/13] gobi: document and validate "interfaceNumber"

Message ID 20241031220638.1582166-12-denkenz@gmail.com (mailing list archive)
State Accepted
Commit d4df0fb906f904a1f372b3d86efa298887279192
Headers show
Series [01/13] qmi: validate TLV length | expand

Commit Message

Denis Kenzior Oct. 31, 2024, 10:06 p.m. UTC
---
 plugins/gobi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/plugins/gobi.c b/plugins/gobi.c
index 6ad8a4b7f923..54b64acb7871 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -85,6 +85,7 @@  struct gobi_data {
 	uint8_t oper_mode;
 	int main_net_ifindex;
 	char main_net_name[IFNAMSIZ];
+	uint8_t interface_number;
 	uint32_t max_aggregation_size;
 	uint32_t set_powered_id;
 	bool using_mux : 1;
@@ -115,6 +116,9 @@  static void gobi_io_debug(const char *str, void *user_data)
  * NetworkInterfaceIndex
  *   The index of the main interface given by NetworkInterface
  *
+ * InterfaceNumber
+ *   The USB interface number of the network interface
+ *
  * NetworkInterfaceKernelDriver
  *   The kernel driver that is being used by the main network device.  Only
  *   'qmi_wwan' is supported.
@@ -127,6 +131,7 @@  static int gobi_probe(struct ofono_modem *modem)
 	struct gobi_data *data;
 	const char *if_driver;
 	const char *ifname;
+	uint8_t interface_number;
 	int ifindex;
 	const char *bus;
 
@@ -149,12 +154,17 @@  static int gobi_probe(struct ofono_modem *modem)
 	if (!L_IN_STRSET(bus, "usb"))
 		return -ENOTSUP;
 
+	if (l_safe_atox8(ofono_modem_get_string(modem, "InterfaceNumber"),
+				&interface_number) < 0)
+		return -EINVAL;
+
 	data = l_new(struct gobi_data, 1);
 	data->main_net_ifindex =
 		ofono_modem_get_integer(modem, "NetworkInterfaceIndex");
 	l_strlcpy(data->main_net_name,
 			ofono_modem_get_string(modem, "NetworkInterface"),
 			sizeof(data->main_net_name));
+	data->interface_number = interface_number;
 
 	ofono_modem_set_data(modem, data);
 	ofono_modem_set_capabilities(modem, OFONO_MODEM_CAPABILITY_LTE);