libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / usbmodeswitch / usb_modeswitch.h
blobc17f68aad8a624131210c2043881241a8566f027
1 /*
2 This file is part of usb_modeswitch, a mode switching tool for controlling
3 flip flop (multiple device) USB gear
5 Version 1.1.9, 2011/08/05
6 Copyright (C) 2007 - 2011 Josua Dietze
8 Config file parsing stuff borrowed from Guillaume Dargaud
9 (http://www.gdargaud.net/Hack/SourceCode.html)
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details:
21 http://www.gnu.org/licenses/gpl.txt
26 #include <stdlib.h>
27 #include <libusb.h>
29 void readConfigFile(const char *configFilename);
30 void printConfig();
31 int switchSendMessage();
32 int switchConfiguration();
33 int switchAltSetting();
34 void switchHuaweiMode();
35 void switchSierraMode();
36 void switchGCTMode();
37 int switchKobilMode();
38 int switchSequansMode();
39 int switchActionMode();
40 int switchSonyMode();
41 int switchCiscoMode();
42 int detachDriver();
43 int checkSuccess();
44 int sendMessage(char* message, int count);
45 int write_bulk(int endpoint, char *message, int length);
46 int read_bulk(int endpoint, char *buffer, int length);
47 void release_usb_device(int dummy);
48 struct libusb_device* search_devices( int *numFound, int vendor, int product, char* productList,
49 int targetClass, int configuration, int mode);
50 int find_first_bulk_output_endpoint(struct libusb_device *dev);
51 int find_first_bulk_input_endpoint(struct libusb_device *dev);
52 int get_current_configuration(struct libusb_device_handle* devh);
53 int get_interface0_class(struct libusb_device *dev, int devconfig);
54 char* ReadParseParam(const char* FileName, char *VariableName);
55 int hex2num(char c);
56 int hex2byte(const char *hex);
57 int hexstr2bin(const char *hex, char *buffer, int len);
58 void printVersion();
59 void printHelp();
60 int readArguments(int argc, char **argv);
61 void deviceDescription();
62 int deviceInquire();
63 void resetUSB();
64 void release_usb_device(int dummy);
66 // Boolean
67 #define and &&
68 #define or ||
69 #define not !
71 // Bitwise
72 #define bitand &
73 #define bitor |
74 #define compl ~
75 #define xor ^
77 // Equals
78 #define and_eq &=
79 #define not_eq !=
80 #define or_eq |=
81 #define xor_eq ^=
83 extern char* ReadParseParam(const char* FileName, char *VariableName);
85 extern char *TempPP;
87 #define ParseParamString(ParamFileName, Str) \
88 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
89 strcpy(Str, TempPP); else Str[0]='\0'
91 #define ParseParamInt(ParamFileName, Int) \
92 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
93 Int=atoi(TempPP)
95 #define ParseParamHex(ParamFileName, Int) \
96 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
97 Int=strtol(TempPP, NULL, 16)
99 #define ParseParamFloat(ParamFileName, Flt) \
100 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
101 Flt=atof(TempPP)
103 #define ParseParamBool(ParamFileName, B) \
104 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
105 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0