mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-03-27 01:51:45 +01:00
restuctred project layout, updated cobra on cli client, updated gRPC proto
This commit is contained in:
parent
e2873af144
commit
3a777c42a1
@ -1,19 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
// "reflect"
|
||||
"flag" //will be replaced with cobra
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
pb "./proto"
|
||||
"./cli_cmd"
|
||||
"reflect"
|
||||
"./cli_client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
/*
|
||||
//Parse cli flags, should be replaced with cobra
|
||||
getUsbGadgetConf := flag.Bool("get_gadget_state", false, "Retrieves the current USB gadget state")
|
||||
blinkCountPtr := flag.Int("blink", -1, "LED blink count (0 = LED off, 255 = LED solid, 1..254 blink n times)")
|
||||
@ -22,8 +14,11 @@ func main() {
|
||||
flag.StringVar(&rpcHostPtr, "host", "localhost", "The remote RPC host running P4wnP1 service")
|
||||
flag.StringVar(&rpcPortPtr, "port", "50051", "The remote RPC port of P4wnP1 service")
|
||||
flag.Parse()
|
||||
|
||||
|
||||
*/
|
||||
|
||||
cli_client.Execute()
|
||||
|
||||
/*
|
||||
// Set up a connection to the server.
|
||||
address := rpcHostPtr + ":" + rpcPortPtr
|
||||
log.Printf("Connecting %s ...", address)
|
||||
@ -52,7 +47,8 @@ func main() {
|
||||
}
|
||||
log.Printf("USB Settings %s: %+v", reflect.TypeOf(*r), *r)
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
r, err := c.GetGadgetSettings(ctx, &pb.Empty{})
|
||||
if err != nil {
|
||||
@ -64,5 +60,5 @@ func main() {
|
||||
c.SetLEDSettings(ctx, &pb.LEDSettings{ BlinkCount: 3})
|
||||
*/
|
||||
|
||||
cli_cmd.Execute()
|
||||
|
||||
}
|
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"log"
|
||||
|
||||
"./core"
|
||||
"./service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -15,24 +15,26 @@ func main() {
|
||||
}
|
||||
*/
|
||||
|
||||
//ToDo: Check for root privs
|
||||
|
||||
var err error
|
||||
err = core.CheckLibComposite()
|
||||
err = service.CheckLibComposite()
|
||||
if err != nil {
|
||||
log.Fatalf("Couldn't load libcomposite: %v", err)
|
||||
}
|
||||
|
||||
err = core.DestroyAllGadgets()
|
||||
err = service.DestroyAllGadgets()
|
||||
if err != nil {
|
||||
log.Fatalf("Error while rolling back existing USB gadgets: %v", err)
|
||||
}
|
||||
|
||||
err = core.InitDefaultGadgetSettings()
|
||||
err = service.InitDefaultGadgetSettings()
|
||||
if err != nil {
|
||||
log.Fatalf("Error while setting up the default gadget: %v", err)
|
||||
}
|
||||
|
||||
|
||||
core.InitLed(false) //Set LED to manual triger
|
||||
service.InitLed(false) //Set LED to manual triger
|
||||
//core.StartRpcServer("127.0.0.1", "50051") //start gRPC service
|
||||
core.StartRpcServer("", "50051") //start gRPC service
|
||||
service.StartRpcServer("", "50051") //start gRPC service
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package cli_cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// usbCmd represents the usb command
|
||||
var ledCmd = &cobra.Command{
|
||||
Use: "led",
|
||||
Short: "Set LED of P4wnP1",
|
||||
Long: ``,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("usb called")
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(ledCmd)
|
||||
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// usbCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// usbCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package cli_cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var cfgFile string
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "cli_client",
|
||||
Short: "P4wnP1 (remote) CLI configuration",
|
||||
Long: `The cli_client tool could be used to configure P4wnP1
|
||||
from the command line. The tool relies on RPC so it could be used
|
||||
remotely.`,
|
||||
// Uncomment the following line if your bare application
|
||||
// has an action associated with it:
|
||||
// Run: func(cmd *cobra.Command, args []string) { },
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
// Cobra supports persistent flags, which, if defined here,
|
||||
// will be global for your application.
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.test.yaml)")
|
||||
|
||||
// Cobra also supports local flags, which will only run
|
||||
// when this action is called directly.
|
||||
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
func initConfig() {
|
||||
if cfgFile != "" {
|
||||
// Use config file from the flag.
|
||||
viper.SetConfigFile(cfgFile)
|
||||
} else {
|
||||
// Find home directory.
|
||||
home, err := homedir.Dir()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Search config in home directory with name ".test" (without extension).
|
||||
viper.AddConfigPath(home)
|
||||
viper.SetConfigName(".test")
|
||||
}
|
||||
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
|
||||
// If a config file is found, read it in.
|
||||
if err := viper.ReadInConfig(); err == nil {
|
||||
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
package cli_cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// usbCmd represents the usb command
|
||||
var usbCmd = &cobra.Command{
|
||||
Use: "usb",
|
||||
Short: "Set or get USB Gadget settings",
|
||||
Long: ``,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("usb called")
|
||||
},
|
||||
}
|
||||
|
||||
var usbGetCmd = &cobra.Command{
|
||||
Use: "get",
|
||||
Short: "Get USB Gadget settings",
|
||||
Long: ``,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("usb get called %v", args)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(usbCmd)
|
||||
usbCmd.AddCommand(usbGetCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// usbCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// usbCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
69
core/led.go
69
core/led.go
@ -1,69 +0,0 @@
|
||||
package core
|
||||
|
||||
import(
|
||||
"os"
|
||||
"log"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
"sync/atomic"
|
||||
|
||||
pb "../proto"
|
||||
)
|
||||
|
||||
const (
|
||||
LED_TRIGGER_PATH = "/sys/class/leds/led0/trigger"
|
||||
LED_BRIGHTNESS_PATH = "/sys/class/leds/led0/brightness"
|
||||
LED_TRIGGER_MANUAL = "none"
|
||||
LED_ON = "0"
|
||||
LED_OFF = "1"
|
||||
LED_DELAY_ON = 200 * time.Millisecond
|
||||
LED_DELAY_OFF = 200 * time.Millisecond
|
||||
LED_DELAY_PAUSE = 500 * time.Millisecond
|
||||
)
|
||||
|
||||
var (
|
||||
blink_count uint32 = 0
|
||||
)
|
||||
|
||||
func InitLed(led_on bool) (error) {
|
||||
//set trigger of LED to manual
|
||||
log.Println("Setting LED to manual trigger ...")
|
||||
ioutil.WriteFile(LED_TRIGGER_PATH, []byte(LED_TRIGGER_MANUAL), os.ModePerm)
|
||||
if led_on {
|
||||
log.Println("Setting LED to ON ...")
|
||||
ioutil.WriteFile(LED_BRIGHTNESS_PATH, []byte(LED_ON), os.ModePerm)
|
||||
} else {
|
||||
log.Println("Setting LED to OFF ...")
|
||||
ioutil.WriteFile(LED_BRIGHTNESS_PATH, []byte(LED_OFF), os.ModePerm)
|
||||
}
|
||||
atomic.StoreUint32(&blink_count, 0)
|
||||
|
||||
go led_loop()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func led_loop() {
|
||||
|
||||
for {
|
||||
for i := uint32(0); i < atomic.LoadUint32(&blink_count); i++ {
|
||||
ioutil.WriteFile(LED_BRIGHTNESS_PATH, []byte(LED_ON), os.ModePerm)
|
||||
time.Sleep(LED_DELAY_ON)
|
||||
|
||||
//Don't turn off led if blink_count >= 255 (solid)
|
||||
if 255 > atomic.LoadUint32(&blink_count) {
|
||||
ioutil.WriteFile(LED_BRIGHTNESS_PATH, []byte(LED_OFF), os.ModePerm)
|
||||
time.Sleep(LED_DELAY_OFF)
|
||||
}
|
||||
}
|
||||
time.Sleep(LED_DELAY_PAUSE)
|
||||
}
|
||||
}
|
||||
|
||||
func setLed(s pb.LEDSettings) (error) {
|
||||
log.Printf("setLED called with %+v", s)
|
||||
|
||||
atomic.StoreUint32(&blink_count, s.BlinkCount)
|
||||
|
||||
return nil
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/docker/libcontainer/netlink"
|
||||
"net"
|
||||
"log"
|
||||
)
|
||||
|
||||
func CreateBridge(name string) error {
|
||||
return netlink.CreateBridge(name, false)
|
||||
}
|
||||
|
||||
func DeleteBridge(name string) error {
|
||||
return netlink.DeleteBridge(name)
|
||||
}
|
||||
|
||||
func CheckInterfaceExistence(name string) (res bool, err error) {
|
||||
_, err = net.InterfaceByName(name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, err
|
||||
}
|
||||
|
||||
func NetworkLinkUp(name string) (err error) {
|
||||
iface, err := net.InterfaceByName(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = netlink.NetworkLinkUp(iface)
|
||||
return
|
||||
}
|
||||
|
||||
func AddInterfaceToBridgeIfExistent(bridgeName string, ifName string) (err error) {
|
||||
br, err := net.InterfaceByName(bridgeName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
iface, err := net.InterfaceByName(ifName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = netlink.AddToBridge(iface, br)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Interface %s added to bridge %s", ifName, bridgeName)
|
||||
return nil
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
//package rpcserv
|
||||
package core
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
pb "../proto"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
type server struct{}
|
||||
|
||||
//Attach handler function implementing the "GetGadgetSettings" interface to server
|
||||
func (s *server) GetGadgetSettings(context.Context, *pb.Empty) (usbset *pb.GadgetSettings, err error) {
|
||||
usbset, err = ParseGadgetState(USB_GADGET_NAME)
|
||||
|
||||
if err == nil {
|
||||
j_usbset, _ := json.Marshal(usbset)
|
||||
log.Printf("Gadget settings requested %v", string(j_usbset))
|
||||
} else {
|
||||
log.Printf("Error parsing current gadget config: %v", err)
|
||||
}
|
||||
|
||||
|
||||
return usbset, err
|
||||
}
|
||||
|
||||
//Attach handler function implementing the "SetGadgetSettings" interface to server
|
||||
func (s *server) SetGadgetSettings(context.Context, *pb.GadgetSettings) (*pb.Error, error) {
|
||||
return &pb.Error{Err: 0}, nil
|
||||
}
|
||||
|
||||
//Attach handler function implementing the "StartGadget" interface to server
|
||||
func (s *server) StartGadget(context.Context, *pb.Empty) (*pb.Error, error) {
|
||||
return &pb.Error{Err: 0}, nil
|
||||
}
|
||||
|
||||
//Attach handler function implementing the "StopGadget" interface to server
|
||||
func (s *server) StopGadget(context.Context, *pb.Empty) (*pb.Error, error) {
|
||||
return &pb.Error{Err: 0}, nil
|
||||
}
|
||||
|
||||
func (s *server) GetLEDSettings(context.Context, *pb.Empty) (*pb.LEDSettings, error) {
|
||||
led_settings := &pb.LEDSettings{}
|
||||
return led_settings, nil
|
||||
}
|
||||
|
||||
func (s *server) SetLEDSettings(ctx context.Context, ledSettings *pb.LEDSettings) (rpcerr *pb.Error, err error) {
|
||||
log.Printf("SetLEDSettings %+v", ledSettings)
|
||||
setLed(*ledSettings)
|
||||
return &pb.Error{Err: 0}, nil
|
||||
}
|
||||
|
||||
func StartRpcServer(host string, port string) {
|
||||
listen_address := host + ":" + port
|
||||
//Open TCP listener
|
||||
log.Printf("P4wnP1 RPC server listening on " + listen_address)
|
||||
lis, err := net.Listen("tcp", listen_address)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
//Create gRPC Server
|
||||
s := grpc.NewServer()
|
||||
pb.RegisterP4WNP1Server(s, &server{})
|
||||
// Register reflection service on gRPC server.
|
||||
reflection.Register(s)
|
||||
if err := s.Serve(lis); err != nil {
|
||||
log.Fatalf("Failed to serve: %v", err)
|
||||
}
|
||||
}
|
571
core/usb.go
571
core/usb.go
@ -1,571 +0,0 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
pb "../proto"
|
||||
"time"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
USB_GADGET_NAME = "mame82_gadget"
|
||||
USB_GADGET_DIR_BASE = "/sys/kernel/config/usb_gadget"
|
||||
USB_GADGET_DIR = USB_GADGET_DIR_BASE + "/" + USB_GADGET_NAME
|
||||
|
||||
USB_ETHERNET_BRIDGE_NAME = "usbeth"
|
||||
|
||||
USB_bcdDevice = "0x0100" //Version 1.00
|
||||
USB_bcdUSB = "0x0200" //mode: USB 2.0
|
||||
|
||||
// composite class / subclass / proto (needs single configuration)
|
||||
USB_bDeviceClass = "0xEF"
|
||||
USB_bDeviceSubClass = "0x02"
|
||||
USB_bDeviceProtocol = "0x01"
|
||||
|
||||
USB_CONFIGURATION_MaxPower = "250"
|
||||
USB_CONFIGURATION_bmAttributes = "0x80" //should be 0x03 for USB_OTG_SRP | USB_OTG_HNP
|
||||
|
||||
/*
|
||||
//RNDIS function constants
|
||||
USB_FUNCTION_RNDIS_DEFAULT_host_addr = "42:63:65:12:34:56"
|
||||
USB_FUNCTION_RNDIS_DEFAULT_dev_addr = "42:63:65:56:34:12"
|
||||
*/
|
||||
//OS descriptors for RNDIS composite function on Windows
|
||||
USB_FUNCTION_RNDIS_os_desc_use = "1"
|
||||
USB_FUNCTION_RNDIS_os_desc_b_vendor_code = "0xbc"
|
||||
USB_FUNCTION_RNDIS_os_desc_qw_sign = "MSFT100"
|
||||
USB_FUNCTION_RNDIS_os_desc_interface_compatible_id = "RNDIS"
|
||||
USB_FUNCTION_RNDIS_os_desc_interface_sub_compatible_id = "5162001"
|
||||
|
||||
/*
|
||||
//CDC ECM function constants
|
||||
USB_FUNCTION_CDC_ECM_DEFAULT_host_addr = "42:63:66:12:34:56"
|
||||
USB_FUNCTION_CDC_ECM_DEFAULT_dev_addr = "42:63:66:56:34:12"
|
||||
*/
|
||||
|
||||
//HID function, keyboard constants
|
||||
USB_FUNCTION_HID_KEYBOARD_protocol = "1"
|
||||
USB_FUNCTION_HID_KEYBOARD_subclass = "1"
|
||||
USB_FUNCTION_HID_KEYBOARD_report_length = "8"
|
||||
USB_FUNCTION_HID_KEYBOARD_report_desc = "\x05\x01\t\x06\xa1\x01\x05\x07\x19\xe0)\xe7\x15\x00%\x01u\x01\x95\x08\x81\x02\x95\x01u\x08\x81\x03\x95\x05u\x01\x05\x08\x19\x01)\x05\x91\x02\x95\x01u\x03\x91\x03\x95\x06u\x08\x15\x00%e\x05\x07\x19\x00)e\x81\x00\xc0"
|
||||
USB_FUNCTION_HID_KEYBOARD_name = "hid.keyboard"
|
||||
|
||||
//HID function, mouse constants
|
||||
USB_FUNCTION_HID_MOUSE_protocol = "2"
|
||||
USB_FUNCTION_HID_MOUSE_subclass = "1"
|
||||
USB_FUNCTION_HID_MOUSE_report_length = "6"
|
||||
USB_FUNCTION_HID_MOUSE_report_desc = "\x05\x01\t\x02\xa1\x01\t\x01\xa1\x00\x85\x01\x05\t\x19\x01)\x03\x15\x00%\x01\x95\x03u\x01\x81\x02\x95\x01u\x05\x81\x03\x05\x01\t0\t1\x15\x81%\x7fu\x08\x95\x02\x81\x06\x95\x02u\x08\x81\x01\xc0\xc0\x05\x01\t\x02\xa1\x01\t\x01\xa1\x00\x85\x02\x05\t\x19\x01)\x03\x15\x00%\x01\x95\x03u\x01\x81\x02\x95\x01u\x05\x81\x01\x05\x01\t0\t1\x15\x00&\xff\x7f\x95\x02u\x10\x81\x02\xc0\xc0"
|
||||
USB_FUNCTION_HID_MOUSE_name = "hid.mouse"
|
||||
|
||||
//HID function, custom vendor device constants
|
||||
USB_FUNCTION_HID_RAW_protocol = "1"
|
||||
USB_FUNCTION_HID_RAW_subclass = "1"
|
||||
USB_FUNCTION_HID_RAW_report_length = "64"
|
||||
USB_FUNCTION_HID_RAW_report_desc = "\x06\x00\xff\t\x01\xa1\x01\t\x01\x15\x00&\xff\x00u\x08\x95@\x81\x02\t\x02\x15\x00&\xff\x00u\x08\x95@\x91\x02\xc0"
|
||||
USB_FUNCTION_HID_RAW_name = "hid.raw"
|
||||
)
|
||||
|
||||
func addUSBEthernetBridge() {
|
||||
//Create the bridge
|
||||
CreateBridge(USB_ETHERNET_BRIDGE_NAME)
|
||||
|
||||
//add the interfaces
|
||||
if err := AddInterfaceToBridgeIfExistent(USB_ETHERNET_BRIDGE_NAME, "usb0"); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
if err := AddInterfaceToBridgeIfExistent(USB_ETHERNET_BRIDGE_NAME, "usb1"); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
//enable the bridge
|
||||
NetworkLinkUp(USB_ETHERNET_BRIDGE_NAME)
|
||||
}
|
||||
|
||||
func deleteUSBEthernetBridge() {
|
||||
//we ignore error results
|
||||
DeleteBridge(USB_ETHERNET_BRIDGE_NAME)
|
||||
}
|
||||
|
||||
/*
|
||||
Polls for presence of "usb0" / "usb1" till one of both is active or timeout is reached
|
||||
*/
|
||||
|
||||
func pollForUSBEthrnet(timeout time.Duration) error {
|
||||
for startTime := time.Now(); time.Since(startTime) < timeout; {
|
||||
if present, _ := CheckInterfaceExistence("usb0"); present {
|
||||
return nil
|
||||
}
|
||||
if present, _ := CheckInterfaceExistence("usb1"); present {
|
||||
return nil
|
||||
}
|
||||
|
||||
//Take a breath
|
||||
time.Sleep(100*time.Millisecond)
|
||||
fmt.Print(".")
|
||||
}
|
||||
return errors.New(fmt.Sprintf("Timeout %v reached before usb0 or usb1 cam up"))
|
||||
}
|
||||
|
||||
func InitDefaultGadgetSettings() error {
|
||||
return InitGadget(CreateDefaultGadgetSettings())
|
||||
}
|
||||
|
||||
func CreateDefaultGadgetSettings() (res pb.GadgetSettings) {
|
||||
res = pb.GadgetSettings{
|
||||
Vid: "0x1d6b",
|
||||
Pid: "0x1337",
|
||||
Manufacturer: "MaMe82",
|
||||
Product: "P4wnP1 by MaMe82",
|
||||
Serial: "deadbeef1337",
|
||||
Use_CDC_ECM: true,
|
||||
Use_RNDIS: true,
|
||||
Use_HID_KEYBOARD: false,
|
||||
Use_HID_MOUSE: false,
|
||||
Use_HID_RAW: false,
|
||||
Use_UMS: false,
|
||||
Use_SERIAL: false,
|
||||
RndisSettings: &pb.GadgetSettingsEthernet{
|
||||
HostAddr: "42:63:65:12:34:56",
|
||||
DevAddr: "42:63:65:56:34:12",
|
||||
},
|
||||
CdcEcmSettings: &pb.GadgetSettingsEthernet{
|
||||
HostAddr: "42:63:66:12:34:56",
|
||||
DevAddr: "42:63:66:56:34:12",
|
||||
},
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
//depends on `bash`, `grep` and `lsmod` binary
|
||||
func CheckLibComposite() error {
|
||||
log.Printf("Checking for libcomposite...")
|
||||
out, err := exec.Command("lsmod").Output()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if strings.Contains(string(out), "libcomposite") {
|
||||
log.Printf("... libcomposite loaded")
|
||||
return nil
|
||||
}
|
||||
|
||||
//if here, libcomposite isn't loaded ... try to load
|
||||
log.Printf("Libcomposite not loaded, trying to fix ...")
|
||||
err = exec.Command("modprobe", "libcomposite").Run()
|
||||
if err == nil {
|
||||
log.Printf("... libcomposite loaded")
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func ParseGadgetState(gadgetName string) (result *pb.GadgetSettings, err error) {
|
||||
err = nil
|
||||
result = &pb.GadgetSettings{}
|
||||
result.CdcEcmSettings = &pb.GadgetSettingsEthernet{}
|
||||
result.RndisSettings = &pb.GadgetSettingsEthernet{}
|
||||
|
||||
//gadget_root := "./test"
|
||||
gadget_dir := USB_GADGET_DIR_BASE + "/" + gadgetName
|
||||
|
||||
//check if root exists, return error otherwise
|
||||
if _, err = os.Stat(gadget_dir); os.IsNotExist(err) {
|
||||
err = errors.New(fmt.Sprintf("Gadget %s doesn't exist", gadgetName))
|
||||
result = nil
|
||||
return
|
||||
}
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/idVendor"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading Vid", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.Vid = strings.TrimSuffix(string(res), "\n")
|
||||
}
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/idProduct"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading Pid", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.Pid = strings.TrimSuffix(string(res), "\n")
|
||||
}
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/strings/0x409/serialnumber"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading Serial", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.Serial = strings.TrimSuffix(string(res), "\n")
|
||||
}
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/strings/0x409/manufacturer"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading Manufacturer", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.Manufacturer = strings.TrimSuffix(string(res), "\n")
|
||||
}
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/strings/0x409/product"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading Product", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.Product = strings.TrimSuffix(string(res), "\n")
|
||||
}
|
||||
|
||||
//Check enabled functions in configuration
|
||||
|
||||
//USB RNDIS
|
||||
if _, err1 := os.Stat(gadget_dir+"/configs/c.1/rndis.usb0"); !os.IsNotExist(err1) {
|
||||
result.Use_RNDIS = true
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/functions/rndis.usb0/host_addr"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading RNDIS host_addr", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.RndisSettings.HostAddr = strings.TrimSuffix(string(res), "\000\n")
|
||||
}
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/functions/rndis.usb0/dev_addr"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading RNDIS dev_addr", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.RndisSettings.DevAddr = strings.TrimSuffix(string(res), "\000\n")
|
||||
}
|
||||
}
|
||||
|
||||
//USB CDC ECM
|
||||
if _, err1 := os.Stat(gadget_dir+"/configs/c.1/ecm.usb1"); !os.IsNotExist(err1) {
|
||||
result.Use_CDC_ECM = true
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/functions/ecm.usb1/host_addr"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading CDC ECM host_addr", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.CdcEcmSettings.HostAddr = strings.TrimSuffix(string(res), "\000\n")
|
||||
}
|
||||
|
||||
if res, err := ioutil.ReadFile(gadget_dir + "/functions/ecm.usb1/dev_addr"); err != nil {
|
||||
err1 := errors.New(fmt.Sprintf("Gadget %s error reading CDC ECM dev_addr", gadgetName))
|
||||
return nil, err1
|
||||
} else {
|
||||
result.CdcEcmSettings.DevAddr = strings.TrimSuffix(string(res), "\000\n")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//USB serial
|
||||
if _, err1 := os.Stat(gadget_dir+"/configs/c.1/acm.GS0"); !os.IsNotExist(err1) {
|
||||
result.Use_SERIAL = true
|
||||
}
|
||||
|
||||
//USB HID Keyboard
|
||||
if _, err1 := os.Stat(gadget_dir+"/configs/c.1/"+USB_FUNCTION_HID_KEYBOARD_name); !os.IsNotExist(err1) {
|
||||
result.Use_HID_KEYBOARD = true
|
||||
}
|
||||
|
||||
//USB HID Mouse
|
||||
if _, err1 := os.Stat(gadget_dir+"/configs/c.1/"+USB_FUNCTION_HID_MOUSE_name); !os.IsNotExist(err1) {
|
||||
result.Use_HID_KEYBOARD = true
|
||||
}
|
||||
|
||||
//USB HID RAW
|
||||
if _, err1 := os.Stat(gadget_dir+"/configs/c.1/"+USB_FUNCTION_HID_RAW_name); !os.IsNotExist(err1) {
|
||||
result.Use_HID_RAW = true
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func InitGadget(settings pb.GadgetSettings) error {
|
||||
var usesUSBEthernet bool
|
||||
|
||||
//gadget_root := "./test"
|
||||
gadget_root := USB_GADGET_DIR_BASE
|
||||
|
||||
//check if root exists, return error otherwise
|
||||
if _, err := os.Stat(gadget_root); os.IsNotExist(err) {
|
||||
return errors.New("Configfs path for gadget doesn't exist")
|
||||
}
|
||||
|
||||
//ToDo: check if UDC is present and usable
|
||||
|
||||
//create gadget folder
|
||||
os.Mkdir(USB_GADGET_DIR, os.ModePerm)
|
||||
log.Printf("Creating composite gadget '%s'", USB_GADGET_NAME)
|
||||
|
||||
//set vendor ID, product ID
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/idVendor", []byte(settings.Vid), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/idProduct", []byte(settings.Pid), os.ModePerm)
|
||||
|
||||
//set USB mode to 2.0 and device version to 1.0
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/bcdUSB", []byte(USB_bcdUSB), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/bcdDevice", []byte(USB_bcdDevice), os.ModePerm)
|
||||
|
||||
//composite class / subclass / proto (needs single configuration)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/bDeviceClass", []byte(USB_bDeviceClass), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/bDeviceSubClass", []byte(USB_bDeviceSubClass), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/bDeviceProtocol", []byte(USB_bDeviceProtocol), os.ModePerm)
|
||||
|
||||
// set device descriptions
|
||||
os.Mkdir(USB_GADGET_DIR+"/strings/0x409", os.ModePerm) // English language strings
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/strings/0x409/serialnumber", []byte(settings.Serial), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/strings/0x409/manufacturer", []byte(settings.Manufacturer), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/strings/0x409/product", []byte(settings.Product), os.ModePerm)
|
||||
|
||||
// create configuration instance (only one, as multiple configs aren't valid for Windows composite devices)
|
||||
os.MkdirAll(USB_GADGET_DIR+"/configs/c.1/strings/0x409", os.ModePerm) // English language strings
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/configs/c.1/strings/0x409/configuration", []byte("Config 1: Composite"), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/configs/c.1/MaxPower", []byte(USB_CONFIGURATION_MaxPower), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/configs/c.1/bmAttributes", []byte(USB_CONFIGURATION_bmAttributes), os.ModePerm)
|
||||
|
||||
// RNDIS has to be the first interface on Composite device for Windows (first function initialized)
|
||||
if settings.Use_RNDIS {
|
||||
log.Printf("... creating USB RNDIS function")
|
||||
usesUSBEthernet = true
|
||||
os.Mkdir(USB_GADGET_DIR+"/functions/rndis.usb0", os.ModePerm) //create RNDIS function
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/functions/rndis.usb0/host_addr", []byte(settings.RndisSettings.HostAddr), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/functions/rndis.usb0/dev_addr", []byte(settings.RndisSettings.DevAddr), os.ModePerm)
|
||||
|
||||
/*
|
||||
add OS specific device descriptors to force Windows to load RNDIS drivers
|
||||
=============================================================================
|
||||
Witout this additional descriptors, most Windows system detect the RNDIS interface as "Serial COM port"
|
||||
To prevent this, the Microsoft specific OS descriptors are added in here
|
||||
!! Important:
|
||||
If the device already has been connected to the Windows System without providing the
|
||||
OS descriptor, Windows never asks again for them and thus never installs the RNDIS driver
|
||||
This behavior is driven by creation of an registry hive, the first time a device without
|
||||
OS descriptors is attached. The key is build like this:
|
||||
|
||||
HKLM\SYSTEM\CurrentControlSet\Control\usbflags\[USB_VID+USB_PID+bcdRelease\osvc
|
||||
|
||||
To allow Windows to read the OS descriptors again, the according registry hive has to be
|
||||
deleted manually or USB descriptor values have to be cahnged (f.e. USB_PID).
|
||||
*/
|
||||
|
||||
//set OS descriptors for Windows
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/os_desc/use", []byte(USB_FUNCTION_RNDIS_os_desc_use), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/os_desc/b_vendor_code", []byte(USB_FUNCTION_RNDIS_os_desc_b_vendor_code), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/os_desc/qw_sign", []byte(USB_FUNCTION_RNDIS_os_desc_qw_sign), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/functions/rndis.usb0/os_desc/interface.rndis/compatible_id", []byte(USB_FUNCTION_RNDIS_os_desc_interface_compatible_id), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id", []byte(USB_FUNCTION_RNDIS_os_desc_interface_sub_compatible_id), os.ModePerm)
|
||||
|
||||
//activate function by symlinking to config 1
|
||||
err := os.Symlink(USB_GADGET_DIR+"/functions/rndis.usb0", USB_GADGET_DIR+"/configs/c.1/rndis.usb0")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
// add config 1 to OS descriptors
|
||||
err = os.Symlink(USB_GADGET_DIR+"/configs/c.1", USB_GADGET_DIR+"/os_desc/c.1")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
if settings.Use_CDC_ECM {
|
||||
log.Printf("... creating USB CDC ECM function")
|
||||
usesUSBEthernet = true
|
||||
os.Mkdir(USB_GADGET_DIR+"/functions/ecm.usb1", os.ModePerm) //create CDC ECM function
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/functions/ecm.usb1/host_addr", []byte(settings.CdcEcmSettings.HostAddr), os.ModePerm)
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/functions/ecm.usb1/dev_addr", []byte(settings.CdcEcmSettings.DevAddr), os.ModePerm)
|
||||
|
||||
//activate function by symlinking to config 1
|
||||
err := os.Symlink(USB_GADGET_DIR+"/functions/ecm.usb1", USB_GADGET_DIR+"/configs/c.1/ecm.usb1")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
if settings.Use_SERIAL {
|
||||
log.Printf("... creating USB serial function")
|
||||
os.Mkdir(USB_GADGET_DIR+"/functions/acm.GS0", os.ModePerm) //create ACM function
|
||||
|
||||
//activate function by symlinking to config 1
|
||||
err := os.Symlink(USB_GADGET_DIR+"/functions/acm.GS0", USB_GADGET_DIR+"/configs/c.1/acm.GS0")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if settings.Use_HID_KEYBOARD {
|
||||
log.Printf("... creating USB HID Keyboard function")
|
||||
funcdir := USB_GADGET_DIR + "/functions/" + USB_FUNCTION_HID_KEYBOARD_name
|
||||
os.Mkdir(funcdir, os.ModePerm) //create HID function for keyboard
|
||||
|
||||
ioutil.WriteFile(funcdir+"/protocol", []byte(USB_FUNCTION_HID_KEYBOARD_protocol), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/subclass", []byte(USB_FUNCTION_HID_KEYBOARD_subclass), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/report_length", []byte(USB_FUNCTION_HID_KEYBOARD_report_length), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/report_desc", []byte(USB_FUNCTION_HID_KEYBOARD_report_desc), os.ModePerm)
|
||||
|
||||
err := os.Symlink(funcdir, USB_GADGET_DIR+"/configs/c.1/"+USB_FUNCTION_HID_KEYBOARD_name)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
if settings.Use_HID_MOUSE {
|
||||
log.Printf("... creating USB HID Mouse function")
|
||||
funcdir := USB_GADGET_DIR + "/functions/" + USB_FUNCTION_HID_MOUSE_name
|
||||
os.Mkdir(funcdir, os.ModePerm) //create HID function for mouse
|
||||
|
||||
ioutil.WriteFile(funcdir+"/protocol", []byte(USB_FUNCTION_HID_MOUSE_protocol), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/subclass", []byte(USB_FUNCTION_HID_MOUSE_subclass), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/report_length", []byte(USB_FUNCTION_HID_MOUSE_report_length), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/report_desc", []byte(USB_FUNCTION_HID_MOUSE_report_desc), os.ModePerm)
|
||||
|
||||
err := os.Symlink(funcdir, USB_GADGET_DIR+"/configs/c.1/"+USB_FUNCTION_HID_MOUSE_name)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
if settings.Use_HID_RAW {
|
||||
log.Printf("... creating USB HID Generic device function")
|
||||
funcdir := USB_GADGET_DIR + "/functions/" + USB_FUNCTION_HID_RAW_name
|
||||
os.Mkdir(funcdir, os.ModePerm) //create HID function for mouse
|
||||
|
||||
ioutil.WriteFile(funcdir+"/protocol", []byte(USB_FUNCTION_HID_RAW_protocol), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/subclass", []byte(USB_FUNCTION_HID_RAW_subclass), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/report_length", []byte(USB_FUNCTION_HID_RAW_report_length), os.ModePerm)
|
||||
ioutil.WriteFile(funcdir+"/report_desc", []byte(USB_FUNCTION_HID_RAW_report_desc), os.ModePerm)
|
||||
|
||||
err := os.Symlink(funcdir, USB_GADGET_DIR+"/configs/c.1/"+USB_FUNCTION_HID_RAW_name)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
//get UDC driver name and bind to gadget
|
||||
files, err := ioutil.ReadDir("/sys/class/udc")
|
||||
if err != nil {
|
||||
return errors.New("Couldn't find working UDC driver")
|
||||
}
|
||||
if len(files) < 1 {
|
||||
return errors.New("Couldn't find working UDC driver")
|
||||
}
|
||||
udc_name := files[0].Name()
|
||||
ioutil.WriteFile(USB_GADGET_DIR+"/UDC", []byte(udc_name), os.ModePerm)
|
||||
|
||||
|
||||
deleteUSBEthernetBridge() //delete former used bridge, if there's any
|
||||
//In case USB ethernet is uesd (RNDIS or CDC ECM), we add a bridge interface
|
||||
if usesUSBEthernet {
|
||||
//wait till "usb0" or "usb1" comes up
|
||||
err = pollForUSBEthrnet(10*time.Second)
|
||||
if err == nil {
|
||||
//add USBEthernet bridge including the usb interfaces
|
||||
log.Printf("... creating network bridge for USB ethernet devices")
|
||||
addUSBEthernetBridge()
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.Printf("... done")
|
||||
return nil
|
||||
}
|
||||
|
||||
func DestroyAllGadgets() error {
|
||||
//gadget_root := "./test"
|
||||
gadget_root := USB_GADGET_DIR_BASE
|
||||
|
||||
//check if root exists, return error otherwise
|
||||
if _, err := os.Stat(gadget_root); os.IsNotExist(err) {
|
||||
return errors.New("Configfs path for gadget doesn't exist")
|
||||
}
|
||||
|
||||
gadget_dirs, err := ioutil.ReadDir(gadget_root)
|
||||
if err != nil {
|
||||
return errors.New("No gadgets")
|
||||
}
|
||||
|
||||
for _, gadget_dir_obj := range gadget_dirs {
|
||||
gadget_name := gadget_dir_obj.Name()
|
||||
log.Println("Found gadget: " + gadget_name)
|
||||
err = DestroyGadget(gadget_name)
|
||||
if err != nil {
|
||||
log.Println(err) //don't return, continue with next
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DestroyGadget(Gadget_name string) error {
|
||||
//gadget_root := "./test"
|
||||
gadget_dir := USB_GADGET_DIR_BASE + "/" + Gadget_name
|
||||
|
||||
//check if root exists, return error otherwise
|
||||
if _, err := os.Stat(USB_GADGET_DIR_BASE); os.IsNotExist(err) {
|
||||
return errors.New("Gadget " + Gadget_name + " doesn't exist")
|
||||
}
|
||||
log.Println("Deconstructing gadget " + Gadget_name + "...")
|
||||
|
||||
//Assure gadget gets unbound from UDC
|
||||
ioutil.WriteFile(gadget_dir+"/UDC", []byte("\x00"), os.ModePerm)
|
||||
|
||||
//Iterate over configurations
|
||||
config_dirs, _ := ioutil.ReadDir(gadget_dir + "/configs")
|
||||
for _, conf_dir_obj := range config_dirs {
|
||||
conf_name := conf_dir_obj.Name()
|
||||
conf_dir := gadget_dir + "/configs/" + conf_name
|
||||
log.Println("Found config: " + conf_name)
|
||||
|
||||
//find linked functions
|
||||
conf_content, _ := ioutil.ReadDir(conf_dir)
|
||||
for _, function := range conf_content {
|
||||
//Remove link from function to config
|
||||
if function.Mode()&os.ModeSymlink > 0 {
|
||||
log.Println("\tRemoving function " + function.Name() + " from config " + conf_name)
|
||||
os.Remove(conf_dir + "/" + function.Name())
|
||||
}
|
||||
}
|
||||
|
||||
//find string directories in config
|
||||
strings_content, _ := ioutil.ReadDir(conf_dir + "/strings")
|
||||
for _, str := range strings_content {
|
||||
string_dir := str.Name()
|
||||
//Remove string from config
|
||||
log.Println("\tRemoving string dir '" + string_dir + "' from configuration")
|
||||
os.Remove(conf_dir + "/strings/" + string_dir)
|
||||
}
|
||||
|
||||
//Check if there's an OS descriptor refering this config
|
||||
if _, err := os.Stat(gadget_dir + "/os_desc/" + conf_name); !os.IsNotExist(err) {
|
||||
log.Println("\tDeleting link to '" + conf_name + "' from gadgets OS descriptor")
|
||||
os.Remove(gadget_dir + "/os_desc/" + conf_name)
|
||||
}
|
||||
|
||||
// remove config folder, finally
|
||||
log.Println("\tDeleting configuration '" + conf_name + "'")
|
||||
os.Remove(conf_dir)
|
||||
}
|
||||
|
||||
// remove functions
|
||||
log.Println("Removing functions from '" + Gadget_name + "'")
|
||||
os.RemoveAll(gadget_dir + "/functions/")
|
||||
|
||||
//find string directories in gadget
|
||||
strings_content, _ := ioutil.ReadDir(gadget_dir + "/strings")
|
||||
for _, str := range strings_content {
|
||||
string_dir := str.Name()
|
||||
//Remove string from config
|
||||
log.Println("Removing string dir '" + string_dir + "' from " + Gadget_name)
|
||||
os.Remove(gadget_dir + "/strings/" + string_dir)
|
||||
}
|
||||
|
||||
//And now remove the gadget itself
|
||||
log.Println("Removing gadget " + Gadget_name)
|
||||
os.Remove(gadget_dir)
|
||||
|
||||
return nil
|
||||
}
|
257
proto/grpc.pb.go
257
proto/grpc.pb.go
@ -12,7 +12,6 @@ It has these top-level messages:
|
||||
GadgetSettingsEthernet
|
||||
GadgetSettings
|
||||
WiFiSettings
|
||||
Error
|
||||
Empty
|
||||
*/
|
||||
package P4wnP1_grpc
|
||||
@ -123,20 +122,21 @@ func (m *GadgetSettingsEthernet) GetDevAddr() string {
|
||||
}
|
||||
|
||||
type GadgetSettings struct {
|
||||
Vid string `protobuf:"bytes,1,opt,name=vid" json:"vid,omitempty"`
|
||||
Pid string `protobuf:"bytes,2,opt,name=pid" json:"pid,omitempty"`
|
||||
Manufacturer string `protobuf:"bytes,3,opt,name=manufacturer" json:"manufacturer,omitempty"`
|
||||
Product string `protobuf:"bytes,4,opt,name=product" json:"product,omitempty"`
|
||||
Serial string `protobuf:"bytes,5,opt,name=serial" json:"serial,omitempty"`
|
||||
Use_CDC_ECM bool `protobuf:"varint,6,opt,name=use_CDC_ECM,json=useCDCECM" json:"use_CDC_ECM,omitempty"`
|
||||
Use_RNDIS bool `protobuf:"varint,7,opt,name=use_RNDIS,json=useRNDIS" json:"use_RNDIS,omitempty"`
|
||||
Use_HID_KEYBOARD bool `protobuf:"varint,8,opt,name=use_HID_KEYBOARD,json=useHIDKEYBOARD" json:"use_HID_KEYBOARD,omitempty"`
|
||||
Use_HID_MOUSE bool `protobuf:"varint,9,opt,name=use_HID_MOUSE,json=useHIDMOUSE" json:"use_HID_MOUSE,omitempty"`
|
||||
Use_HID_RAW bool `protobuf:"varint,10,opt,name=use_HID_RAW,json=useHIDRAW" json:"use_HID_RAW,omitempty"`
|
||||
Use_UMS bool `protobuf:"varint,11,opt,name=use_UMS,json=useUMS" json:"use_UMS,omitempty"`
|
||||
Use_SERIAL bool `protobuf:"varint,12,opt,name=use_SERIAL,json=useSERIAL" json:"use_SERIAL,omitempty"`
|
||||
RndisSettings *GadgetSettingsEthernet `protobuf:"bytes,13,opt,name=rndis_settings,json=rndisSettings" json:"rndis_settings,omitempty"`
|
||||
CdcEcmSettings *GadgetSettingsEthernet `protobuf:"bytes,14,opt,name=cdc_ecm_settings,json=cdcEcmSettings" json:"cdc_ecm_settings,omitempty"`
|
||||
Enabled bool `protobuf:"varint,1,opt,name=enabled" json:"enabled,omitempty"`
|
||||
Vid string `protobuf:"bytes,2,opt,name=vid" json:"vid,omitempty"`
|
||||
Pid string `protobuf:"bytes,3,opt,name=pid" json:"pid,omitempty"`
|
||||
Manufacturer string `protobuf:"bytes,4,opt,name=manufacturer" json:"manufacturer,omitempty"`
|
||||
Product string `protobuf:"bytes,5,opt,name=product" json:"product,omitempty"`
|
||||
Serial string `protobuf:"bytes,6,opt,name=serial" json:"serial,omitempty"`
|
||||
Use_CDC_ECM bool `protobuf:"varint,7,opt,name=use_CDC_ECM,json=useCDCECM" json:"use_CDC_ECM,omitempty"`
|
||||
Use_RNDIS bool `protobuf:"varint,8,opt,name=use_RNDIS,json=useRNDIS" json:"use_RNDIS,omitempty"`
|
||||
Use_HID_KEYBOARD bool `protobuf:"varint,9,opt,name=use_HID_KEYBOARD,json=useHIDKEYBOARD" json:"use_HID_KEYBOARD,omitempty"`
|
||||
Use_HID_MOUSE bool `protobuf:"varint,10,opt,name=use_HID_MOUSE,json=useHIDMOUSE" json:"use_HID_MOUSE,omitempty"`
|
||||
Use_HID_RAW bool `protobuf:"varint,11,opt,name=use_HID_RAW,json=useHIDRAW" json:"use_HID_RAW,omitempty"`
|
||||
Use_UMS bool `protobuf:"varint,12,opt,name=use_UMS,json=useUMS" json:"use_UMS,omitempty"`
|
||||
Use_SERIAL bool `protobuf:"varint,13,opt,name=use_SERIAL,json=useSERIAL" json:"use_SERIAL,omitempty"`
|
||||
RndisSettings *GadgetSettingsEthernet `protobuf:"bytes,14,opt,name=rndis_settings,json=rndisSettings" json:"rndis_settings,omitempty"`
|
||||
CdcEcmSettings *GadgetSettingsEthernet `protobuf:"bytes,15,opt,name=cdc_ecm_settings,json=cdcEcmSettings" json:"cdc_ecm_settings,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GadgetSettings) Reset() { *m = GadgetSettings{} }
|
||||
@ -144,6 +144,13 @@ func (m *GadgetSettings) String() string { return proto.CompactTextSt
|
||||
func (*GadgetSettings) ProtoMessage() {}
|
||||
func (*GadgetSettings) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||
|
||||
func (m *GadgetSettings) GetEnabled() bool {
|
||||
if m != nil {
|
||||
return m.Enabled
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *GadgetSettings) GetVid() string {
|
||||
if m != nil {
|
||||
return m.Vid
|
||||
@ -338,36 +345,19 @@ func (m *WiFiSettings) GetDisableNexmon() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
Err int32 `protobuf:"varint,1,opt,name=err" json:"err,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Error) Reset() { *m = Error{} }
|
||||
func (m *Error) String() string { return proto.CompactTextString(m) }
|
||||
func (*Error) ProtoMessage() {}
|
||||
func (*Error) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
||||
|
||||
func (m *Error) GetErr() int32 {
|
||||
if m != nil {
|
||||
return m.Err
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Empty struct {
|
||||
}
|
||||
|
||||
func (m *Empty) Reset() { *m = Empty{} }
|
||||
func (m *Empty) String() string { return proto.CompactTextString(m) }
|
||||
func (*Empty) ProtoMessage() {}
|
||||
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
|
||||
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*LEDSettings)(nil), "P4wnP1_grpc.LEDSettings")
|
||||
proto.RegisterType((*GadgetSettingsEthernet)(nil), "P4wnP1_grpc.GadgetSettingsEthernet")
|
||||
proto.RegisterType((*GadgetSettings)(nil), "P4wnP1_grpc.GadgetSettings")
|
||||
proto.RegisterType((*WiFiSettings)(nil), "P4wnP1_grpc.WiFiSettings")
|
||||
proto.RegisterType((*Error)(nil), "P4wnP1_grpc.Error")
|
||||
proto.RegisterType((*Empty)(nil), "P4wnP1_grpc.Empty")
|
||||
proto.RegisterEnum("P4wnP1_grpc.WiFiSettings_Mode", WiFiSettings_Mode_name, WiFiSettings_Mode_value)
|
||||
proto.RegisterEnum("P4wnP1_grpc.WiFiSettings_APAuthMode", WiFiSettings_APAuthMode_name, WiFiSettings_APAuthMode_value)
|
||||
@ -384,12 +374,14 @@ const _ = grpc.SupportPackageIsVersion4
|
||||
// Client API for P4WNP1 service
|
||||
|
||||
type P4WNP1Client interface {
|
||||
GetDeployedGadgetSetting(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GadgetSettings, error)
|
||||
DeployGadgetSetting(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GadgetSettings, error)
|
||||
GetGadgetSettings(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GadgetSettings, error)
|
||||
SetGadgetSettings(ctx context.Context, in *GadgetSettings, opts ...grpc.CallOption) (*Error, error)
|
||||
SetGadgetSettings(ctx context.Context, in *GadgetSettings, opts ...grpc.CallOption) (*GadgetSettings, error)
|
||||
GetLEDSettings(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*LEDSettings, error)
|
||||
SetLEDSettings(ctx context.Context, in *LEDSettings, opts ...grpc.CallOption) (*Error, error)
|
||||
StopGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Error, error)
|
||||
StartGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Error, error)
|
||||
SetLEDSettings(ctx context.Context, in *LEDSettings, opts ...grpc.CallOption) (*Empty, error)
|
||||
StopGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
|
||||
StartGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
|
||||
}
|
||||
|
||||
type p4WNP1Client struct {
|
||||
@ -400,6 +392,24 @@ func NewP4WNP1Client(cc *grpc.ClientConn) P4WNP1Client {
|
||||
return &p4WNP1Client{cc}
|
||||
}
|
||||
|
||||
func (c *p4WNP1Client) GetDeployedGadgetSetting(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GadgetSettings, error) {
|
||||
out := new(GadgetSettings)
|
||||
err := grpc.Invoke(ctx, "/P4wnP1_grpc.P4WNP1/GetDeployedGadgetSetting", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *p4WNP1Client) DeployGadgetSetting(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GadgetSettings, error) {
|
||||
out := new(GadgetSettings)
|
||||
err := grpc.Invoke(ctx, "/P4wnP1_grpc.P4WNP1/DeployGadgetSetting", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *p4WNP1Client) GetGadgetSettings(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GadgetSettings, error) {
|
||||
out := new(GadgetSettings)
|
||||
err := grpc.Invoke(ctx, "/P4wnP1_grpc.P4WNP1/GetGadgetSettings", in, out, c.cc, opts...)
|
||||
@ -409,8 +419,8 @@ func (c *p4WNP1Client) GetGadgetSettings(ctx context.Context, in *Empty, opts ..
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *p4WNP1Client) SetGadgetSettings(ctx context.Context, in *GadgetSettings, opts ...grpc.CallOption) (*Error, error) {
|
||||
out := new(Error)
|
||||
func (c *p4WNP1Client) SetGadgetSettings(ctx context.Context, in *GadgetSettings, opts ...grpc.CallOption) (*GadgetSettings, error) {
|
||||
out := new(GadgetSettings)
|
||||
err := grpc.Invoke(ctx, "/P4wnP1_grpc.P4WNP1/SetGadgetSettings", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -427,8 +437,8 @@ func (c *p4WNP1Client) GetLEDSettings(ctx context.Context, in *Empty, opts ...gr
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *p4WNP1Client) SetLEDSettings(ctx context.Context, in *LEDSettings, opts ...grpc.CallOption) (*Error, error) {
|
||||
out := new(Error)
|
||||
func (c *p4WNP1Client) SetLEDSettings(ctx context.Context, in *LEDSettings, opts ...grpc.CallOption) (*Empty, error) {
|
||||
out := new(Empty)
|
||||
err := grpc.Invoke(ctx, "/P4wnP1_grpc.P4WNP1/SetLEDSettings", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -436,8 +446,8 @@ func (c *p4WNP1Client) SetLEDSettings(ctx context.Context, in *LEDSettings, opts
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *p4WNP1Client) StopGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Error, error) {
|
||||
out := new(Error)
|
||||
func (c *p4WNP1Client) StopGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) {
|
||||
out := new(Empty)
|
||||
err := grpc.Invoke(ctx, "/P4wnP1_grpc.P4WNP1/StopGadget", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -445,8 +455,8 @@ func (c *p4WNP1Client) StopGadget(ctx context.Context, in *Empty, opts ...grpc.C
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *p4WNP1Client) StartGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Error, error) {
|
||||
out := new(Error)
|
||||
func (c *p4WNP1Client) StartGadget(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) {
|
||||
out := new(Empty)
|
||||
err := grpc.Invoke(ctx, "/P4wnP1_grpc.P4WNP1/StartGadget", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -457,18 +467,56 @@ func (c *p4WNP1Client) StartGadget(ctx context.Context, in *Empty, opts ...grpc.
|
||||
// Server API for P4WNP1 service
|
||||
|
||||
type P4WNP1Server interface {
|
||||
GetDeployedGadgetSetting(context.Context, *Empty) (*GadgetSettings, error)
|
||||
DeployGadgetSetting(context.Context, *Empty) (*GadgetSettings, error)
|
||||
GetGadgetSettings(context.Context, *Empty) (*GadgetSettings, error)
|
||||
SetGadgetSettings(context.Context, *GadgetSettings) (*Error, error)
|
||||
SetGadgetSettings(context.Context, *GadgetSettings) (*GadgetSettings, error)
|
||||
GetLEDSettings(context.Context, *Empty) (*LEDSettings, error)
|
||||
SetLEDSettings(context.Context, *LEDSettings) (*Error, error)
|
||||
StopGadget(context.Context, *Empty) (*Error, error)
|
||||
StartGadget(context.Context, *Empty) (*Error, error)
|
||||
SetLEDSettings(context.Context, *LEDSettings) (*Empty, error)
|
||||
StopGadget(context.Context, *Empty) (*Empty, error)
|
||||
StartGadget(context.Context, *Empty) (*Empty, error)
|
||||
}
|
||||
|
||||
func RegisterP4WNP1Server(s *grpc.Server, srv P4WNP1Server) {
|
||||
s.RegisterService(&_P4WNP1_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _P4WNP1_GetDeployedGadgetSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(P4WNP1Server).GetDeployedGadgetSetting(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/P4wnP1_grpc.P4WNP1/GetDeployedGadgetSetting",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(P4WNP1Server).GetDeployedGadgetSetting(ctx, req.(*Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _P4WNP1_DeployGadgetSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(P4WNP1Server).DeployGadgetSetting(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/P4wnP1_grpc.P4WNP1/DeployGadgetSetting",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(P4WNP1Server).DeployGadgetSetting(ctx, req.(*Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _P4WNP1_GetGadgetSettings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
@ -581,6 +629,14 @@ var _P4WNP1_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "P4wnP1_grpc.P4WNP1",
|
||||
HandlerType: (*P4WNP1Server)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetDeployedGadgetSetting",
|
||||
Handler: _P4WNP1_GetDeployedGadgetSetting_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeployGadgetSetting",
|
||||
Handler: _P4WNP1_DeployGadgetSetting_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetGadgetSettings",
|
||||
Handler: _P4WNP1_GetGadgetSettings_Handler,
|
||||
@ -613,55 +669,56 @@ var _P4WNP1_serviceDesc = grpc.ServiceDesc{
|
||||
func init() { proto.RegisterFile("grpc.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 791 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x5d, 0x6f, 0xdb, 0x36,
|
||||
0x14, 0x8d, 0xe3, 0x2f, 0xe9, 0xca, 0xd6, 0x34, 0x0e, 0xeb, 0xd4, 0x76, 0x6d, 0x03, 0xad, 0x03,
|
||||
0xf2, 0x30, 0x18, 0xa8, 0x57, 0x6c, 0xaf, 0xd3, 0x24, 0x25, 0xf1, 0x1a, 0x27, 0x82, 0xd4, 0xcc,
|
||||
0xd8, 0x13, 0xc1, 0x88, 0x9c, 0x2d, 0xc4, 0x96, 0x04, 0x92, 0xca, 0xb6, 0x7f, 0xb0, 0x97, 0xfd,
|
||||
0xc8, 0xfd, 0x93, 0x81, 0x94, 0x9c, 0xc4, 0x9d, 0x53, 0x6c, 0x6f, 0xe4, 0x39, 0xf7, 0x1c, 0x5e,
|
||||
0xf1, 0x1e, 0x50, 0x00, 0x4b, 0x5e, 0x65, 0x93, 0x8a, 0x97, 0xb2, 0x44, 0x56, 0xfc, 0xf6, 0xb7,
|
||||
0x22, 0x7e, 0x83, 0x15, 0xe4, 0x4d, 0xc0, 0x3a, 0x8f, 0xc2, 0x94, 0x49, 0x99, 0x17, 0x4b, 0x81,
|
||||
0x5e, 0x81, 0x75, 0xbd, 0xce, 0x8b, 0x1b, 0x9c, 0x95, 0x75, 0x21, 0xdd, 0xce, 0x51, 0xe7, 0x78,
|
||||
0x9c, 0x80, 0x86, 0x02, 0x85, 0x78, 0x31, 0x3c, 0x39, 0x25, 0x74, 0xc9, 0xe4, 0x56, 0x12, 0xc9,
|
||||
0x15, 0xe3, 0x05, 0x93, 0xe8, 0x39, 0x98, 0xab, 0x52, 0x48, 0x4c, 0x28, 0xe5, 0x5a, 0x68, 0x26,
|
||||
0x86, 0x02, 0x7c, 0x4a, 0x39, 0x7a, 0x0a, 0x06, 0x65, 0xb7, 0x0d, 0x77, 0xa8, 0xb9, 0x21, 0x65,
|
||||
0xb7, 0x8a, 0xf2, 0xfe, 0xec, 0x81, 0xbd, 0x6b, 0x89, 0x1c, 0xe8, 0xde, 0xe6, 0xb4, 0x35, 0x51,
|
||||
0x4b, 0x85, 0x54, 0x39, 0x6d, 0xa5, 0x6a, 0x89, 0x3c, 0x18, 0x6d, 0x48, 0x51, 0xff, 0x4a, 0x32,
|
||||
0x59, 0x73, 0xc6, 0xdd, 0xae, 0xa6, 0x76, 0x30, 0xe4, 0xc2, 0xb0, 0xe2, 0x25, 0xad, 0x33, 0xe9,
|
||||
0xf6, 0x9a, 0x43, 0xdb, 0x2d, 0x7a, 0x02, 0x03, 0xc1, 0x78, 0x4e, 0xd6, 0x6e, 0x5f, 0x13, 0xed,
|
||||
0x0e, 0xbd, 0x04, 0xab, 0x16, 0x0c, 0x07, 0x61, 0x80, 0xa3, 0x60, 0xee, 0x0e, 0x8e, 0x3a, 0xc7,
|
||||
0x46, 0x62, 0xd6, 0x82, 0x05, 0x61, 0x10, 0x05, 0x73, 0xf5, 0x91, 0x8a, 0x4f, 0x2e, 0xc2, 0x59,
|
||||
0xea, 0x0e, 0x35, 0x6b, 0xd4, 0x82, 0xe9, 0x3d, 0x3a, 0x06, 0x47, 0x91, 0x67, 0xb3, 0x10, 0xbf,
|
||||
0x8b, 0x7e, 0xf9, 0xf1, 0xd2, 0x4f, 0x42, 0xd7, 0xd0, 0x35, 0x76, 0x2d, 0xd8, 0xd9, 0x2c, 0xdc,
|
||||
0xa2, 0xc8, 0x83, 0xf1, 0xb6, 0x72, 0x7e, 0x79, 0x95, 0x46, 0xae, 0xa9, 0xcb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af, 0x1d, 0x5f, 0x3f, 0xee, 0xe8, 0xc7,
|
||||
0x7e, 0x2d, 0x57, 0xda, 0xd7, 0x20, 0xed, 0x4a, 0x8d, 0x82, 0x54, 0x38, 0x5b, 0x91, 0xa2, 0x60,
|
||||
0x6b, 0x9d, 0xa6, 0x71, 0x62, 0x92, 0x2a, 0x68, 0x00, 0xf4, 0x39, 0x0c, 0x48, 0x85, 0x2b, 0x71,
|
||||
0xa3, 0xa3, 0x64, 0x26, 0x7d, 0x52, 0xc5, 0xe2, 0x06, 0x1d, 0xc1, 0x88, 0x54, 0x78, 0x95, 0x53,
|
||||
0xd6, 0xb4, 0xd5, 0x64, 0x08, 0x48, 0x75, 0x96, 0x53, 0xa6, 0x5b, 0x7b, 0x05, 0x56, 0xb6, 0xce,
|
||||
0x59, 0x21, 0x9b, 0x02, 0x53, 0xab, 0xa1, 0x81, 0x74, 0xc1, 0x0b, 0x68, 0x77, 0xda, 0x1d, 0x34,
|
||||
0x6f, 0x36, 0x88, 0x3a, 0xe1, 0x6b, 0xb0, 0x69, 0xae, 0x6f, 0x11, 0x17, 0xec, 0xf7, 0x4d, 0x59,
|
||||
0xb4, 0x11, 0x1a, 0xb7, 0xe8, 0x85, 0x06, 0xbd, 0x6f, 0xa0, 0xa7, 0x3f, 0x63, 0x00, 0x87, 0x7e,
|
||||
0xec, 0x1c, 0xa0, 0x21, 0x74, 0xd3, 0xf7, 0xbe, 0xd3, 0x41, 0x9f, 0xc1, 0x27, 0xe9, 0x7b, 0x1f,
|
||||
0x9f, 0xf8, 0xb3, 0xf3, 0xcb, 0x9f, 0xa3, 0x04, 0xfb, 0xb1, 0x73, 0xe8, 0xbd, 0x06, 0xb8, 0xbf,
|
||||
0x04, 0x34, 0x02, 0x63, 0x11, 0xfb, 0x53, 0x1c, 0xa7, 0xef, 0x9c, 0x03, 0x64, 0x40, 0xef, 0x32,
|
||||
0x8e, 0x2e, 0x9c, 0x8e, 0xf7, 0x14, 0xfa, 0x11, 0xe7, 0x25, 0x57, 0xd3, 0x63, 0xbc, 0x79, 0x29,
|
||||
0xfa, 0x89, 0x5a, 0x7a, 0x43, 0xe8, 0x47, 0x9b, 0x4a, 0xfe, 0x31, 0xfd, 0xab, 0x0b, 0x83, 0xf8,
|
||||
0xed, 0xe2, 0x22, 0x7e, 0x83, 0x4e, 0xe0, 0xd3, 0x53, 0x26, 0x3f, 0x78, 0x1f, 0xd0, 0xce, 0x18,
|
||||
0xb4, 0xe6, 0xd9, 0xf3, 0x8f, 0x04, 0xce, 0x3b, 0x50, 0x3e, 0xe9, 0xbf, 0x7c, 0x3e, 0xa6, 0x79,
|
||||
0xf6, 0xc1, 0x21, 0xaa, 0x67, 0xef, 0x00, 0xfd, 0x00, 0xf6, 0x29, 0x93, 0x0f, 0x9f, 0xcc, 0x7d,
|
||||
0xcd, 0xb8, 0x3b, 0xd8, 0x83, 0xea, 0xc6, 0x21, 0xdd, 0x75, 0x78, 0xb4, 0xfa, 0x91, 0x1e, 0xbe,
|
||||
0x03, 0x48, 0x65, 0x59, 0x35, 0xfd, 0xee, 0x3d, 0x7f, 0xbf, 0xee, 0x7b, 0xb0, 0x52, 0x49, 0xb8,
|
||||
0xfc, 0xbf, 0xc2, 0xeb, 0x81, 0xfe, 0x71, 0x7c, 0xfb, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x18,
|
||||
0x23, 0xdf, 0x1e, 0x46, 0x06, 0x00, 0x00,
|
||||
// 806 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xdf, 0x6e, 0xdb, 0x36,
|
||||
0x14, 0xc6, 0xe3, 0xc4, 0xb1, 0xad, 0x23, 0xdb, 0x75, 0x59, 0xac, 0xd3, 0xda, 0xb5, 0x0d, 0xb4,
|
||||
0x0e, 0xc8, 0xc5, 0x60, 0xa0, 0x5e, 0xb1, 0xdd, 0x4e, 0xb3, 0x94, 0xd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 0xf4, 0x4f, 0x1a, 0xa7, 0xf6, 0xe8, 0x8b, 0xe1, 0x56,
|
||||
0x62, 0x86, 0xfb, 0xaf, 0x3f, 0xee, 0x99, 0xd6, 0xbb, 0x2b, 0x0c, 0x61, 0x90, 0xd2, 0x14, 0xb3,
|
||||
0x74, 0x7d, 0x4f, 0x7b, 0xf0, 0xef, 0x69, 0xfd, 0x94, 0xa6, 0x41, 0xba, 0xde, 0xe8, 0xee, 0x1f,
|
||||
0x47, 0xd0, 0x9d, 0xf3, 0x33, 0x7e, 0xc7, 0xff, 0x1c, 0x2c, 0xca, 0x89, 0xdc, 0x0e, 0xc9, 0xbd,
|
||||
0xa0, 0x43, 0x51, 0xb0, 0xc5, 0x26, 0x26, 0x05, 0x5b, 0xa0, 0x11, 0x34, 0xd7, 0x39, 0x65, 0x26,
|
||||
0x27, 0xfd, 0xd1, 0xf3, 0x9d, 0x19, 0xb6, 0xc1, 0xc3, 0x30, 0xa7, 0x2c, 0x36, 0xb5, 0xfa, 0x1c,
|
||||
0x89, 0xc0, 0x52, 0x72, 0x5a, 0x67, 0xa8, 0x45, 0x44, 0x22, 0x39, 0x45, 0x1e, 0x58, 0xa4, 0x54,
|
||||
0x4b, 0x6c, 0x88, 0xc7, 0x86, 0xf8, 0xf2, 0xfd, 0x44, 0x2f, 0xf2, 0x4a, 0xb5, 0x34, 0xdc, 0x0e,
|
||||
0xa9, 0x9f, 0xf4, 0x55, 0x10, 0x81, 0xd3, 0x25, 0xc9, 0x32, 0x56, 0x45, 0xad, 0x17, 0x5b, 0x44,
|
||||
0x8c, 0x2b, 0x01, 0x7d, 0x02, 0x2d, 0x22, 0xb0, 0x90, 0x37, 0x26, 0x68, 0x56, 0x7c, 0x4c, 0x44,
|
||||
0x24, 0x6f, 0xd0, 0x09, 0x74, 0x89, 0xc0, 0x4b, 0x4e, 0x59, 0x35, 0x56, 0x95, 0x33, 0x20, 0x62,
|
||||
0xc2, 0x29, 0x33, 0xa3, 0xbd, 0x00, 0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0xf4, 0xcf, 0x99, 0xda, 0xfe, 0xa6, 0xef, 0x9b, 0xca, 0xd9, 0xd1,
|
||||
0xb6, 0xaa, 0x2b, 0x42, 0xb2, 0x4b, 0x78, 0x6f, 0xf5, 0x93, 0x3d, 0x6c, 0xf7, 0x00, 0x7d, 0x03,
|
||||
0x90, 0xa8, 0x5c, 0x54, 0xb3, 0xed, 0xdd, 0x7f, 0x7f, 0xdf, 0xb7, 0x60, 0x27, 0x8a, 0x14, 0xea,
|
||||
0xbf, 0x36, 0x5e, 0xb7, 0xcc, 0x9f, 0xed, 0xeb, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x4a, 0x89,
|
||||
0x01, 0x89, 0xe7, 0x06, 0x00, 0x00,
|
||||
}
|
||||
|
@ -3,12 +3,14 @@ syntax = "proto3";
|
||||
package P4wnP1_grpc;
|
||||
|
||||
service P4WNP1 {
|
||||
rpc GetGadgetSettings (Empty) returns (GadgetSettings) {}
|
||||
rpc SetGadgetSettings (GadgetSettings) returns (Error) {}
|
||||
rpc GetLEDSettings (Empty) returns (LEDSettings) {}
|
||||
rpc SetLEDSettings (LEDSettings) returns (Error) {}
|
||||
rpc StopGadget (Empty) returns (Error) {}
|
||||
rpc StartGadget (Empty) returns (Error) {}
|
||||
rpc GetDeployedGadgetSetting (Empty) returns (GadgetSettings) {}
|
||||
rpc DeployGadgetSetting (Empty) returns (GadgetSettings) {}
|
||||
rpc GetGadgetSettings (Empty) returns (GadgetSettings) {}
|
||||
rpc SetGadgetSettings (GadgetSettings) returns (GadgetSettings) {}
|
||||
rpc GetLEDSettings (Empty) returns (LEDSettings) {}
|
||||
rpc SetLEDSettings (LEDSettings) returns (Empty) {}
|
||||
rpc StopGadget (Empty) returns (Empty) {}
|
||||
rpc StartGadget (Empty) returns (Empty) {}
|
||||
}
|
||||
|
||||
message LEDSettings {
|
||||
@ -21,21 +23,22 @@ message GadgetSettingsEthernet {
|
||||
}
|
||||
|
||||
message GadgetSettings {
|
||||
string vid = 1;
|
||||
string pid = 2;
|
||||
string manufacturer = 3;
|
||||
string product = 4;
|
||||
string serial = 5;
|
||||
bool use_CDC_ECM = 6;
|
||||
bool use_RNDIS = 7;
|
||||
bool use_HID_KEYBOARD = 8;
|
||||
bool use_HID_MOUSE = 9;
|
||||
bool use_HID_RAW = 10;
|
||||
bool use_UMS = 11;
|
||||
bool use_SERIAL = 12;
|
||||
GadgetSettingsEthernet rndis_settings = 13;
|
||||
GadgetSettingsEthernet cdc_ecm_settings = 14;
|
||||
|
||||
bool enabled = 1;
|
||||
string vid = 2;
|
||||
string pid = 3;
|
||||
string manufacturer = 4;
|
||||
string product = 5;
|
||||
string serial = 6;
|
||||
bool use_CDC_ECM = 7;
|
||||
bool use_RNDIS = 8;
|
||||
bool use_HID_KEYBOARD = 9;
|
||||
bool use_HID_MOUSE = 10;
|
||||
bool use_HID_RAW = 11;
|
||||
bool use_UMS = 12;
|
||||
bool use_SERIAL = 13;
|
||||
GadgetSettingsEthernet rndis_settings = 14;
|
||||
GadgetSettingsEthernet cdc_ecm_settings = 15;
|
||||
|
||||
}
|
||||
|
||||
message WiFiSettings {
|
||||
@ -56,15 +59,12 @@ message WiFiSettings {
|
||||
uint32 ap_channel = 6;
|
||||
string ap_psk = 7; //pre-shared key if auth_mode == WPA2_PSK
|
||||
bool ap_hide_ssid = 8; //if true, SSID gets hidden for spawned AP
|
||||
|
||||
|
||||
string client_ssid = 9;
|
||||
string client_psk = 10;
|
||||
|
||||
|
||||
bool disable_nexmon = 11; //if true, legacy driver / firmware is used instead of nexmon
|
||||
}
|
||||
|
||||
message Error {
|
||||
int32 err = 1;
|
||||
}
|
||||
|
||||
message Empty {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user