usb-ctrl: fix optional mac-addresses
The `help` usb-ctrl declares the MAC options for ecm|emm|rndis optional.
But if they are skipped, the operation will fail.
The change fixes the problem and the MAC settings can now be safely
omitted.
Tested: each of the commands below works fine:
* `usb-ctrl ecm usb0 on`
* `usb-ctrl ecm usb0 on .`
* `usb-ctrl ecm usb0 on . 5e:e9:8e:01:fa:b4`
* `usb-ctrl ecm usb0 on 5e:e9:8e:01:fa:b3 5e:e9:8e:01:fa:b3`
Change-Id: I7096476656d2f830c32fbc6cb9c784b3ba6bbd2f
Signed-off-by: Igor Kononenko <i.kononenko.e@gmail.com>
diff --git a/usb-ctrl/usb-ctrl b/usb-ctrl/usb-ctrl
index 943e7d4..f9711ef 100644
--- a/usb-ctrl/usb-ctrl
+++ b/usb-ctrl/usb-ctrl
@@ -202,8 +202,12 @@
echo "${storage}" > "${gadget_function}/lun.0/file"
;;
ecm|eem|rndis)
- echo "${bmc_mac}" > "${gadget_function}/dev_addr"
- echo "${host_mac}" > "${gadget_function}/host_addr"
+ if [[ -n ${bmc_mac} && "${bmc_mac}" != "." ]]; then
+ echo "${bmc_mac}" > "${gadget_function}/dev_addr"
+ fi
+ if [[ -n "${host_mac}" ]]; then
+ echo "${host_mac}" > "${gadget_function}/host_addr"
+ fi
;;
esac
if [ "${is_multifunction}" = false ]; then