Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / usbmodeswitch / usb_modeswitch.h
blobf5a4820ad5950a293ba29b8c8e7b43f25c4e0945
1 /*
2 This file is part of usb_modeswitch, a mode switching tool for controlling
3 flip flop (multiple device) USB gear
5 Version 2.0.1, 2013/09/03
6 Copyright (C) 2007 - 2013 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
25 #include <stdlib.h>
26 #include <libusb.h>
28 void readConfigFile(const char *configFilename);
29 void printConfig();
30 int switchSendMessage();
31 int switchConfiguration();
32 int switchAltSetting();
33 void switchHuaweiMode();
35 void switchSierraMode();
36 void switchGCTMode();
37 void switchKobilMode();
38 void switchQisdaMode();
39 void switchQuantaMode();
40 void switchSequansMode();
41 void switchActionMode();
42 void switchBlackberryMode();
43 void switchPantechMode();
44 void switchCiscoMode();
45 int switchSonyMode();
46 int detachDriver();
47 int checkSuccess();
48 int sendMessage(char* message, int count);
49 int write_bulk(int endpoint, char *message, int length);
50 int read_bulk(int endpoint, char *buffer, int length);
51 void release_usb_device(int dummy);
52 struct libusb_device* search_devices( int *numFound, int vendor, char* productList,
53 int targetClass, int configuration, int mode);
54 int find_first_bulk_output_endpoint(struct libusb_device *dev);
55 int find_first_bulk_input_endpoint(struct libusb_device *dev);
56 int get_current_configuration(struct libusb_device_handle* devh);
57 int get_interface_class(struct libusb_config_descriptor *cfg, int ifcNumber);
58 char* ReadParseParam(const char* FileName, char *VariableName);
59 int hex2num(char c);
60 int hex2byte(const char *hex);
61 int hexstr2bin(const char *hex, char *buffer, int len);
62 void printVersion();
63 void printHelp();
64 int readArguments(int argc, char **argv);
65 void deviceDescription();
66 int deviceInquire();
67 void resetUSB();
68 void release_usb_device(int dummy);
69 int findMBIMConfig(int vendor, int product, int mode);
72 // Boolean
73 #define and &&
74 #define or ||
75 #define not !
77 // Bitwise
78 #define bitand &
79 #define bitor |
80 #define compl ~
81 #define xor ^
83 // Equals
84 #define and_eq &=
85 #define not_eq !=
86 #define or_eq |=
87 #define xor_eq ^=
89 extern char* ReadParseParam(const char* FileName, char *VariableName);
91 extern char *TempPP;
93 #define ParseParamString(ParamFileName, Str) \
94 if ((TempPP=ReadParseParam((ParamFileName), #Str))!=NULL) \
95 strcpy(Str, TempPP); else Str[0]='\0'
97 #define ParseParamInt(ParamFileName, Int) \
98 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
99 Int=atoi(TempPP)
101 #define ParseParamHex(ParamFileName, Int) \
102 if ((TempPP=ReadParseParam((ParamFileName), #Int))!=NULL) \
103 Int=strtol(TempPP, NULL, 16)
105 #define ParseParamFloat(ParamFileName, Flt) \
106 if ((TempPP=ReadParseParam((ParamFileName), #Flt))!=NULL) \
107 Flt=atof(TempPP)
109 #define ParseParamBool(ParamFileName, B) \
110 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
111 B=(toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1'); else B=0
113 #define ParseParamBoolMap(ParamFileName, B, M, Const) \
114 if ((TempPP=ReadParseParam((ParamFileName), #B))!=NULL) \
115 if (toupper(TempPP[0])=='Y' || toupper(TempPP[0])=='T'|| TempPP[0]=='1') \
116 M=M+Const