Add USB rndis_handler for rndis mode 95/223295/1 submit/tizen/20200128.093850
authorINSUN PYO <insun.pyo@samsung.com>
Tue, 28 Jan 2020 08:40:43 +0000 (17:40 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Tue, 28 Jan 2020 08:40:47 +0000 (17:40 +0900)
Rndis mode needs rndis.service and sshd.service.
Also, rndis.service should run first, and sshd.service should run later.

The rndis_handler starts rndis.service and service trigger starts sshd.service.

Change-Id: I1a2f3960b257ce56a7d49e47848ab11021ad418e

hw/usb_gadget.h
hw/usb_gadget_common.c

index 8533228..f61f966 100644 (file)
@@ -165,6 +165,8 @@ out_nomem:
        return -ENOMEM;
 }
 
+void rndis_handler(int enable);
+
 #define DEFINE_USB_FUNCTION(_id, _name, _ffs_service, _service, _handler)      \
        static struct usb_function _##_name##_function = {                      \
                .id = _id,                                                      \
@@ -184,7 +186,7 @@ DEFINE_USB_FUNCTION(USB_FUNCTION_CONN_GADGET, conn_gadget, NULL, NULL,
 DEFINE_USB_FUNCTION(USB_FUNCTION_SDB,         sdb,         "sdbd", NULL,          NULL);
 DEFINE_USB_FUNCTION(USB_FUNCTION_MTP,         mtp,         "mtp-responder", NULL, NULL);
 DEFINE_USB_FUNCTION(USB_FUNCTION_ACM,         acm,         NULL, "data-router",   NULL);
-DEFINE_USB_FUNCTION(USB_FUNCTION_RNDIS,       rndis,       NULL, "rndis",         NULL);
+DEFINE_USB_FUNCTION(USB_FUNCTION_RNDIS,       rndis,       NULL, "sshd",          rndis_handler);
 #undef DEFINE_USB_FUNCTION
 
 #define MAKE_FUNC_AVAILABLE(_name, _vname)  \
index e629b47..e9db26a 100644 (file)
@@ -24,6 +24,8 @@
 #include <errno.h>
 #include <string.h>
 
+#include <libsyscommon/dbus-systemd.h>
+
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 #define zalloc(amount) calloc(1, amount)
 
@@ -397,6 +399,14 @@ out:
        return ret;
 }
 
+void rndis_handler(int enable)
+{
+       if (enable)
+               (void)systemd_start_unit_wait_started("rndis.service", NULL, -1);
+       else
+               (void)systemd_stop_unit_wait_stopped("rndis.service", NULL, -1);
+}
+
 EXPORT
 int simple_translator_open(struct hw_info *info,
                const char *id, struct hw_common **common)