xref: /OK3568_Linux_fs/app/forlinx/quectelCM/QMIThread.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun #ifndef __QMI_THREAD_H__
2*4882a593Smuzhiyun #define __QMI_THREAD_H__
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #define CONFIG_GOBINET
5*4882a593Smuzhiyun #define CONFIG_QMIWWAN
6*4882a593Smuzhiyun #define CONFIG_SIM
7*4882a593Smuzhiyun #define CONFIG_APN
8*4882a593Smuzhiyun #define CONFIG_VERSION
9*4882a593Smuzhiyun // #define CONFIG_SIGNALINFO
10*4882a593Smuzhiyun #define CONFIG_DEFAULT_PDP 1
11*4882a593Smuzhiyun //#define CONFIG_IMSI_ICCID
12*4882a593Smuzhiyun #define QUECTEL_UL_DATA_AGG
13*4882a593Smuzhiyun //#define QUECTEL_QMI_MERGE
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <stdio.h>
16*4882a593Smuzhiyun #include <string.h>
17*4882a593Smuzhiyun #include <termios.h>
18*4882a593Smuzhiyun #include <stdio.h>
19*4882a593Smuzhiyun #include <ctype.h>
20*4882a593Smuzhiyun #include <time.h>
21*4882a593Smuzhiyun #include <fcntl.h>
22*4882a593Smuzhiyun #include <signal.h>
23*4882a593Smuzhiyun #include <errno.h>
24*4882a593Smuzhiyun #include <string.h>
25*4882a593Smuzhiyun #include <stdlib.h>
26*4882a593Smuzhiyun #include <unistd.h>
27*4882a593Smuzhiyun #include <errno.h>
28*4882a593Smuzhiyun #include <pthread.h>
29*4882a593Smuzhiyun #include <sys/types.h>
30*4882a593Smuzhiyun #include <sys/stat.h>
31*4882a593Smuzhiyun #include <sys/epoll.h>
32*4882a593Smuzhiyun #include <poll.h>
33*4882a593Smuzhiyun #include <sys/ioctl.h>
34*4882a593Smuzhiyun #include <sys/socket.h>
35*4882a593Smuzhiyun #include <stddef.h>
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #include "MPQMI.h"
38*4882a593Smuzhiyun #include "MPQCTL.h"
39*4882a593Smuzhiyun #include "MPQMUX.h"
40*4882a593Smuzhiyun #include "util.h"
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #define DEVICE_CLASS_UNKNOWN           0
43*4882a593Smuzhiyun #define DEVICE_CLASS_CDMA              1
44*4882a593Smuzhiyun #define DEVICE_CLASS_GSM               2
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #define WWAN_DATA_CLASS_NONE            0x00000000
47*4882a593Smuzhiyun #define WWAN_DATA_CLASS_GPRS            0x00000001
48*4882a593Smuzhiyun #define WWAN_DATA_CLASS_EDGE            0x00000002 /* EGPRS */
49*4882a593Smuzhiyun #define WWAN_DATA_CLASS_UMTS            0x00000004
50*4882a593Smuzhiyun #define WWAN_DATA_CLASS_HSDPA           0x00000008
51*4882a593Smuzhiyun #define WWAN_DATA_CLASS_HSUPA           0x00000010
52*4882a593Smuzhiyun #define WWAN_DATA_CLASS_LTE             0x00000020
53*4882a593Smuzhiyun #define WWAN_DATA_CLASS_5G_NSA        0x00000040
54*4882a593Smuzhiyun #define WWAN_DATA_CLASS_5G_SA        0x00000080
55*4882a593Smuzhiyun #define WWAN_DATA_CLASS_1XRTT           0x00010000
56*4882a593Smuzhiyun #define WWAN_DATA_CLASS_1XEVDO          0x00020000
57*4882a593Smuzhiyun #define WWAN_DATA_CLASS_1XEVDO_REVA     0x00040000
58*4882a593Smuzhiyun #define WWAN_DATA_CLASS_1XEVDV          0x00080000
59*4882a593Smuzhiyun #define WWAN_DATA_CLASS_3XRTT           0x00100000
60*4882a593Smuzhiyun #define WWAN_DATA_CLASS_1XEVDO_REVB     0x00200000 /* for future use */
61*4882a593Smuzhiyun #define WWAN_DATA_CLASS_UMB             0x00400000
62*4882a593Smuzhiyun #define WWAN_DATA_CLASS_CUSTOM          0x80000000
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun struct wwan_data_class_str {
65*4882a593Smuzhiyun     ULONG class;
66*4882a593Smuzhiyun     CHAR *str;
67*4882a593Smuzhiyun };
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #pragma pack(push, 1)
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun typedef struct _QCQMIMSG {
72*4882a593Smuzhiyun     QCQMI_HDR QMIHdr;
73*4882a593Smuzhiyun     union {
74*4882a593Smuzhiyun         QMICTL_MSG CTLMsg;
75*4882a593Smuzhiyun         QMUX_MSG MUXMsg;
76*4882a593Smuzhiyun     };
77*4882a593Smuzhiyun } __attribute__ ((packed)) QCQMIMSG, *PQCQMIMSG;
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun typedef struct __IPV4 {
80*4882a593Smuzhiyun     uint32_t Address;
81*4882a593Smuzhiyun     uint32_t Gateway;
82*4882a593Smuzhiyun     uint32_t SubnetMask;
83*4882a593Smuzhiyun     uint32_t DnsPrimary;
84*4882a593Smuzhiyun     uint32_t DnsSecondary;
85*4882a593Smuzhiyun     uint32_t Mtu;
86*4882a593Smuzhiyun } IPV4_T;
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun typedef struct __IPV6 {
89*4882a593Smuzhiyun     UCHAR Address[16];
90*4882a593Smuzhiyun     UCHAR Gateway[16];
91*4882a593Smuzhiyun     UCHAR SubnetMask[16];
92*4882a593Smuzhiyun     UCHAR DnsPrimary[16];
93*4882a593Smuzhiyun     UCHAR DnsSecondary[16];
94*4882a593Smuzhiyun     UCHAR PrefixLengthIPAddr;
95*4882a593Smuzhiyun     UCHAR PrefixLengthGateway;
96*4882a593Smuzhiyun     ULONG Mtu;
97*4882a593Smuzhiyun } IPV6_T;
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun typedef struct {
100*4882a593Smuzhiyun     UINT size;
101*4882a593Smuzhiyun     UINT rx_urb_size;
102*4882a593Smuzhiyun     UINT ep_type;
103*4882a593Smuzhiyun     UINT iface_id;
104*4882a593Smuzhiyun     UINT MuxId;
105*4882a593Smuzhiyun     UINT ul_data_aggregation_max_datagrams; //0x17
106*4882a593Smuzhiyun     UINT ul_data_aggregation_max_size ;//0x18
107*4882a593Smuzhiyun     UINT dl_minimum_padding; //0x1A
108*4882a593Smuzhiyun } QMAP_SETTING;
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun //Configured downlink data aggregationprotocol
111*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_DISABLED (0x00) //DL data aggregation is disabled (default)
112*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_TLP_ENABLED (0x01) // DL TLP is enabled
113*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_QC_NCM_ENABLED (0x02) // DL QC_NCM isenabled
114*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_MBIM_ENABLED (0x03) // DL MBIM isenabled
115*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_RNDIS_ENABLED (0x04) // DL RNDIS is enabled
116*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_QMAP_ENABLED (0x05) // DL QMAP isenabled
117*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_QMAP_V2_ENABLED (0x06) // DL QMAP V2 is enabled
118*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_QMAP_V3_ENABLED (0x07) // DL QMAP V3 is enabled
119*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_QMAP_V4_ENABLED (0x08) // DL QMAP V4 is enabled
120*4882a593Smuzhiyun #define WDA_DL_DATA_AGG_QMAP_V5_ENABLED (0x09) // DL QMAP V5 is enabled
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun typedef struct {
123*4882a593Smuzhiyun     unsigned int size;
124*4882a593Smuzhiyun     unsigned int rx_urb_size;
125*4882a593Smuzhiyun     unsigned int ep_type;
126*4882a593Smuzhiyun     unsigned int iface_id;
127*4882a593Smuzhiyun     unsigned int qmap_mode;
128*4882a593Smuzhiyun     unsigned int qmap_version;
129*4882a593Smuzhiyun     unsigned int dl_minimum_padding;
130*4882a593Smuzhiyun     char ifname[8][16];
131*4882a593Smuzhiyun     unsigned char mux_id[8];
132*4882a593Smuzhiyun } RMNET_INFO;
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun #define IpFamilyV4 (0x04)
135*4882a593Smuzhiyun #define IpFamilyV6 (0x06)
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun struct __PROFILE;
138*4882a593Smuzhiyun struct qmi_device_ops {
139*4882a593Smuzhiyun 	int (*init)(struct __PROFILE *profile);
140*4882a593Smuzhiyun 	int (*deinit)(void);
141*4882a593Smuzhiyun 	int (*send)(PQCQMIMSG pRequest);
142*4882a593Smuzhiyun 	void* (*read)(void *pData);
143*4882a593Smuzhiyun };
144*4882a593Smuzhiyun extern const struct qmi_device_ops gobi_qmidev_ops;
145*4882a593Smuzhiyun extern const struct qmi_device_ops qmiwwan_qmidev_ops;
146*4882a593Smuzhiyun extern const struct qmi_device_ops mbim_dev_ops;
147*4882a593Smuzhiyun extern const struct qmi_device_ops atc_dev_ops;
148*4882a593Smuzhiyun extern int (*qmidev_send)(PQCQMIMSG pRequest);
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun struct usb_device_info {
151*4882a593Smuzhiyun     int idVendor;
152*4882a593Smuzhiyun     int idProduct;
153*4882a593Smuzhiyun     int  busnum;
154*4882a593Smuzhiyun     int devnum;
155*4882a593Smuzhiyun     int bNumInterfaces;
156*4882a593Smuzhiyun };
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun struct usb_interface_info {
159*4882a593Smuzhiyun     int bNumEndpoints;
160*4882a593Smuzhiyun     int bInterfaceClass;
161*4882a593Smuzhiyun     int bInterfaceSubClass;
162*4882a593Smuzhiyun     int bInterfaceProtocol;
163*4882a593Smuzhiyun     char driver[32];
164*4882a593Smuzhiyun };
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun #define LIBQMI_PROXY "qmi-proxy" //src/libqmi-glib/qmi-proxy.h
167*4882a593Smuzhiyun #define LIBMBIM_PROXY "mbim-proxy"
168*4882a593Smuzhiyun #define QUECTEL_QMI_PROXY "quectel-qmi-proxy"
169*4882a593Smuzhiyun #define QUECTEL_MBIM_PROXY "quectel-mbim-proxy"
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun #ifndef bool
172*4882a593Smuzhiyun #define bool uint8_t
173*4882a593Smuzhiyun #endif
174*4882a593Smuzhiyun struct request_ops;
175*4882a593Smuzhiyun typedef struct __PROFILE {
176*4882a593Smuzhiyun     char qmichannel[32];
177*4882a593Smuzhiyun     char usbnet_adapter[32];
178*4882a593Smuzhiyun     char qmapnet_adapter[32];
179*4882a593Smuzhiyun     char driver_name[32];
180*4882a593Smuzhiyun     int qmap_mode;
181*4882a593Smuzhiyun     int qmap_size;
182*4882a593Smuzhiyun     int qmap_version;
183*4882a593Smuzhiyun     const char *apn;
184*4882a593Smuzhiyun     const char *user;
185*4882a593Smuzhiyun     const char *password;
186*4882a593Smuzhiyun     const char *pincode;
187*4882a593Smuzhiyun     char proxy[32];
188*4882a593Smuzhiyun     int auth;
189*4882a593Smuzhiyun     int pdp;
190*4882a593Smuzhiyun     int curIpFamily;
191*4882a593Smuzhiyun     int rawIP;
192*4882a593Smuzhiyun     int muxid;
193*4882a593Smuzhiyun     int enable_bridge;
194*4882a593Smuzhiyun     int wda_client;
195*4882a593Smuzhiyun     IPV4_T ipv4;
196*4882a593Smuzhiyun     IPV6_T ipv6;
197*4882a593Smuzhiyun     UINT PCSCFIpv4Addr1;
198*4882a593Smuzhiyun     UINT PCSCFIpv4Addr2;
199*4882a593Smuzhiyun     UCHAR PCSCFIpv6Addr1[16];
200*4882a593Smuzhiyun     UCHAR PCSCFIpv6Addr2[16];
201*4882a593Smuzhiyun     bool enable_ipv4;
202*4882a593Smuzhiyun     bool enable_ipv6;
203*4882a593Smuzhiyun     int  apntype;
204*4882a593Smuzhiyun     bool reattach_flag;
205*4882a593Smuzhiyun     int hardware_interface;
206*4882a593Smuzhiyun     int software_interface;
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun     struct usb_device_info usb_dev;
209*4882a593Smuzhiyun     struct usb_interface_info usb_intf;
210*4882a593Smuzhiyun 
211*4882a593Smuzhiyun     int usbmon_fd;
212*4882a593Smuzhiyun     FILE  *usbmon_logfile_fp;
213*4882a593Smuzhiyun     bool loopback_state;
214*4882a593Smuzhiyun     int replication_factor;
215*4882a593Smuzhiyun 
216*4882a593Smuzhiyun     char BaseBandVersion[64];
217*4882a593Smuzhiyun 
218*4882a593Smuzhiyun     const struct qmi_device_ops *qmi_ops;
219*4882a593Smuzhiyun     const struct request_ops *request_ops;
220*4882a593Smuzhiyun     RMNET_INFO rmnet_info;
221*4882a593Smuzhiyun } PROFILE_T;
222*4882a593Smuzhiyun 
223*4882a593Smuzhiyun #ifdef QUECTEL_QMI_MERGE
224*4882a593Smuzhiyun #define MERGE_PACKET_IDENTITY 0x2c7c
225*4882a593Smuzhiyun #define MERGE_PACKET_VERSION 0x0001
226*4882a593Smuzhiyun #define MERGE_PACKET_MAX_PAYLOAD_SIZE 56
227*4882a593Smuzhiyun typedef struct __QMI_MSG_HEADER {
228*4882a593Smuzhiyun     uint16_t idenity;
229*4882a593Smuzhiyun     uint16_t version;
230*4882a593Smuzhiyun     uint16_t cur_len;
231*4882a593Smuzhiyun     uint16_t total_len;
232*4882a593Smuzhiyun } QMI_MSG_HEADER;
233*4882a593Smuzhiyun 
234*4882a593Smuzhiyun typedef struct __QMI_MSG_PACKET {
235*4882a593Smuzhiyun     QMI_MSG_HEADER header;
236*4882a593Smuzhiyun     uint16_t len;
237*4882a593Smuzhiyun     char buf[4096];
238*4882a593Smuzhiyun } QMI_MSG_PACKET;
239*4882a593Smuzhiyun #endif
240*4882a593Smuzhiyun 
241*4882a593Smuzhiyun typedef enum {
242*4882a593Smuzhiyun     SIM_ABSENT = 0,
243*4882a593Smuzhiyun     SIM_NOT_READY = 1,
244*4882a593Smuzhiyun     SIM_READY = 2, /* SIM_READY means the radio state is RADIO_STATE_SIM_READY */
245*4882a593Smuzhiyun     SIM_PIN = 3,
246*4882a593Smuzhiyun     SIM_PUK = 4,
247*4882a593Smuzhiyun     SIM_NETWORK_PERSONALIZATION = 5,
248*4882a593Smuzhiyun     SIM_BAD = 6,
249*4882a593Smuzhiyun } SIM_Status;
250*4882a593Smuzhiyun 
251*4882a593Smuzhiyun #pragma pack(pop)
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun #define WDM_DEFAULT_BUFSIZE	256
254*4882a593Smuzhiyun #define RIL_REQUEST_QUIT    0x1000
255*4882a593Smuzhiyun #define RIL_INDICATE_DEVICE_CONNECTED    0x1002
256*4882a593Smuzhiyun #define RIL_INDICATE_DEVICE_DISCONNECTED    0x1003
257*4882a593Smuzhiyun #define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED    0x1004
258*4882a593Smuzhiyun #define RIL_UNSOL_DATA_CALL_LIST_CHANGED    0x1005
259*4882a593Smuzhiyun #define MODEM_REPORT_RESET_EVENT 0x1006
260*4882a593Smuzhiyun #define RIL_UNSOL_LOOPBACK_CONFIG_IND 0x1007
261*4882a593Smuzhiyun 
262*4882a593Smuzhiyun extern pthread_mutex_t cm_command_mutex;
263*4882a593Smuzhiyun extern pthread_cond_t cm_command_cond;
264*4882a593Smuzhiyun extern unsigned int cm_recv_buf[1024];
265*4882a593Smuzhiyun extern int cm_open_dev(const char *dev);
266*4882a593Smuzhiyun extern int cm_open_proxy(const char *name);
267*4882a593Smuzhiyun extern int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t * mutex, unsigned msecs);
268*4882a593Smuzhiyun extern int QmiThreadSendQMITimeout(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse, unsigned msecs, const char *funcname);
269*4882a593Smuzhiyun #define QmiThreadSendQMI(pRequest, ppResponse) QmiThreadSendQMITimeout(pRequest, ppResponse, 30 * 1000, __func__)
270*4882a593Smuzhiyun extern void QmiThreadRecvQMI(PQCQMIMSG pResponse);
271*4882a593Smuzhiyun extern void udhcpc_start(PROFILE_T *profile);
272*4882a593Smuzhiyun extern void udhcpc_stop(PROFILE_T *profile);
273*4882a593Smuzhiyun extern void ql_set_driver_link_state(PROFILE_T *profile, int link_state);
274*4882a593Smuzhiyun extern void ql_set_driver_qmap_setting(PROFILE_T *profile, QMAP_SETTING *qmap_settings);
275*4882a593Smuzhiyun extern void ql_get_driver_rmnet_info(PROFILE_T *profile, RMNET_INFO *rmnet_info);
276*4882a593Smuzhiyun extern void dump_qmi(void *dataBuffer, int dataLen);
277*4882a593Smuzhiyun extern void qmidevice_send_event_to_main(int triger_event);
278*4882a593Smuzhiyun extern void qmidevice_send_event_to_main_ext(int triger_event, void *data, unsigned len);
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun struct request_ops {
281*4882a593Smuzhiyun     int (*requestBaseBandVersion)(PROFILE_T *profile);
282*4882a593Smuzhiyun     int (*requestSetEthMode)(PROFILE_T *profile);
283*4882a593Smuzhiyun     int (*requestSetLoopBackState)(UCHAR loopback_state, ULONG replication_factor);
284*4882a593Smuzhiyun     int (*requestGetSIMStatus)(SIM_Status *pSIMStatus);
285*4882a593Smuzhiyun     int (*requestEnterSimPin)(const CHAR *pPinCode);
286*4882a593Smuzhiyun     int (*requestSetProfile)(PROFILE_T *profile) ;
287*4882a593Smuzhiyun     int (*requestGetProfile)(PROFILE_T *profile);
288*4882a593Smuzhiyun     int (*requestRegistrationState)(UCHAR *pPSAttachedState);
289*4882a593Smuzhiyun     int (*requestSetupDataCall)(PROFILE_T *profile, int curIpFamily);
290*4882a593Smuzhiyun     int (*requestQueryDataCall)(UCHAR  *pConnectionStatus, int curIpFamily);
291*4882a593Smuzhiyun     int (*requestDeactivateDefaultPDP)(PROFILE_T *profile, int curIpFamily);
292*4882a593Smuzhiyun     int (*requestGetIPAddress)(PROFILE_T *profile, int curIpFamily);
293*4882a593Smuzhiyun     int (*requestGetSignalInfo)(void);
294*4882a593Smuzhiyun     int (*requestGetICCID)(void);
295*4882a593Smuzhiyun     int (*requestGetIMSI)(void);
296*4882a593Smuzhiyun };
297*4882a593Smuzhiyun extern const struct request_ops qmi_request_ops;
298*4882a593Smuzhiyun extern const struct request_ops mbim_request_ops;
299*4882a593Smuzhiyun extern const struct request_ops atc_request_ops;
300*4882a593Smuzhiyun 
301*4882a593Smuzhiyun extern int get_driver_type(PROFILE_T *profile);
302*4882a593Smuzhiyun extern BOOL qmidevice_detect(char *qmichannel, char *usbnet_adapter, unsigned bufsize, PROFILE_T *profile);
303*4882a593Smuzhiyun int mhidevice_detect(char *qmichannel, char *usbnet_adapter, PROFILE_T *profile);
304*4882a593Smuzhiyun extern int ql_bridge_mode_detect(PROFILE_T *profile);
305*4882a593Smuzhiyun extern int ql_enable_qmi_wwan_rawip_mode(PROFILE_T *profile);
306*4882a593Smuzhiyun extern int ql_qmap_mode_detect(PROFILE_T *profile);
307*4882a593Smuzhiyun 
308*4882a593Smuzhiyun #define qmidev_is_gobinet(_qmichannel) (strncmp(_qmichannel, "/dev/qcqmi", strlen("/dev/qcqmi")) == 0)
309*4882a593Smuzhiyun #define qmidev_is_qmiwwan(_qmichannel) (strncmp(_qmichannel, "/dev/cdc-wdm", strlen("/dev/cdc-wdm")) == 0)
310*4882a593Smuzhiyun #define qmidev_is_pciemhi(_qmichannel) (strncmp(_qmichannel, "/dev/mhi_", strlen("/dev/mhi_")) == 0)
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun #define driver_is_qmi(_drv_name) (strncasecmp(_drv_name, "qmi_wwan", strlen("qmi_wwan")) == 0)
313*4882a593Smuzhiyun #define driver_is_mbim(_drv_name) (strncasecmp(_drv_name, "cdc_mbim", strlen("cdc_mbim")) == 0)
314*4882a593Smuzhiyun 
315*4882a593Smuzhiyun extern FILE *logfilefp;
316*4882a593Smuzhiyun extern int debug_qmi;
317*4882a593Smuzhiyun extern int qmidevice_control_fd[2];
318*4882a593Smuzhiyun extern USHORT le16_to_cpu(USHORT v16);
319*4882a593Smuzhiyun extern UINT  le32_to_cpu (UINT v32);
320*4882a593Smuzhiyun extern UINT  ql_swap32(UINT v32);
321*4882a593Smuzhiyun extern USHORT cpu_to_le16(USHORT v16);
322*4882a593Smuzhiyun extern UINT cpu_to_le32(UINT v32);
323*4882a593Smuzhiyun extern void update_resolv_conf(int iptype, const char *ifname, const char *dns1, const char *dns2);
324*4882a593Smuzhiyun void update_ipv4_address(const char *ifname, const char *ip, const char *gw, unsigned prefix);
325*4882a593Smuzhiyun void update_ipv6_address(const char *ifname, const char *ip, const char *gw, unsigned prefix);
326*4882a593Smuzhiyun int reattach_driver(PROFILE_T *profile);
327*4882a593Smuzhiyun 
328*4882a593Smuzhiyun enum
329*4882a593Smuzhiyun {
330*4882a593Smuzhiyun 	DRV_INVALID,
331*4882a593Smuzhiyun 	SOFTWARE_QMI,
332*4882a593Smuzhiyun 	SOFTWARE_MBIM,
333*4882a593Smuzhiyun 	SOFTWARE_ECM_RNDIS_NCM,
334*4882a593Smuzhiyun 	HARDWARE_PCIE,
335*4882a593Smuzhiyun 	HARDWARE_USB,
336*4882a593Smuzhiyun };
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun enum
339*4882a593Smuzhiyun {
340*4882a593Smuzhiyun     SIG_EVENT_START,
341*4882a593Smuzhiyun     SIG_EVENT_CHECK,
342*4882a593Smuzhiyun     SIG_EVENT_STOP,
343*4882a593Smuzhiyun };
344*4882a593Smuzhiyun 
345*4882a593Smuzhiyun #ifdef CM_DEBUG
346*4882a593Smuzhiyun #define dbg_time(fmt, args...) do { \
347*4882a593Smuzhiyun     fprintf(stdout, "[%15s-%04d: %s] " fmt "\n", __FILE__, __LINE__, get_time(), ##args); \
348*4882a593Smuzhiyun     if (logfilefp) fprintf(logfilefp, "[%s-%04d: %s] " fmt "\n", __FILE__, __LINE__, get_time(), ##args); \
349*4882a593Smuzhiyun } while(0)
350*4882a593Smuzhiyun #else
351*4882a593Smuzhiyun #define dbg_time(fmt, args...) do { \
352*4882a593Smuzhiyun     fprintf(stdout, "[%s] " fmt "\n", get_time(), ##args); \
353*4882a593Smuzhiyun     if (logfilefp) fprintf(logfilefp, "[%s] " fmt "\n", get_time(), ##args); \
354*4882a593Smuzhiyun } while(0)
355*4882a593Smuzhiyun #endif
356*4882a593Smuzhiyun #endif
357