#!/bin/sh

case "$1" in
        start)
		echo "Loading usb gadget drivers"

		modprobe usb_f_ncm.ko

		cd /sys/kernel/config/usb_gadget

		# create a gadget device
		mkdir g1
		cd g1

		echo 0x0200 > bcdUSB

		# FNet vid pid
		echo "0x0f7e" > idVendor
		echo "0x0006" > idProduct

		# set device strings
		mkdir strings/0x409
		echo "Fluke Networks" > strings/0x409/manufacturer
		echo "USBLAN" > strings/0x409/product
		echo "0123456" > strings/0x409/serialnumber

		#create a configuration instance
		mkdir configs/c.1

		# set self powered
		echo 0xc0 > configs/c.1/bmAttributes

		# create config strings
		mkdir configs/c.1/strings/0x409
		echo "USBLAN" > configs/c.1/strings/0x409/configuration

		# create and bind Network Control Model (ncm) instance
		mkdir functions/ncm.usb0
		ln -s functions/ncm.usb0 configs/c.1

		# attach the gadget device to the USB Device Controler (UDC) driver
		ls /sys/class/udc > UDC
        ;;
        stop)
        ;;
        *)
        ;;
esac
