📄 gprs_dll.h
字号:
#ifndef __COMM_NET_H
#define __COMM_NET_H
#ifndef DSCDLLAPI
#define DSCDLLAPI extern "C"
#endif
typedef long int32; /* 32-bit signed integer */
typedef unsigned int uint; /* 16 or 32-bit unsigned integer */
typedef unsigned long uint32; /* 32-bit unsigned integer */
typedef unsigned short uint16; /* 16-bit unsigned integer */
typedef unsigned char byte_t; /* 8-bit unsigned integer */
typedef unsigned char uint8; /* 8-bit unsigned integer */
#define MAX_RECEIVE_BUF 1024 //the max data packet length that would be received
//add by sea On Nov 14,2002
#define MAX_SEND_BUF MAX_RECEIVE_BUF //the max data packet length that would be sent
#define DEFAULT_CLIENT_PORT 5001 //the default monitoring port on terminal
#ifndef HDCALL
#define HDCALL WINAPI
#endif
/*
* user info interface
*/
typedef struct GPRS_USER_INFO{
char m_userid[12]; //DTU Identify number
uint32 m_sin_addr; //the ip address of DTU in Internet,maybe a gateway ip addr
uint16 m_sin_port; //the ip port of DTU in Internet
uint32 m_local_addr; //the ip address of DTU in local mobile net
uint16 m_local_port; //the local port of DTU in local mobile net
char m_logon_date[20]; //the date that the DTU logon
char m_update_time[20]; //the last date that receive IP packet
uint8 m_status; //DTU status, on line 1 : offline 0
//char m_peer_id[12]; //relative mobile terminal identity number
}user_info;
/*
* user data record interface
* as param when call function do_read_proc()
*/
typedef struct GPRS_DATA_RECORD{
char m_userid[12]; //DTU Identify number
char m_recv_date[20]; //the date that receive data packet
char m_data_buf[MAX_RECEIVE_BUF]; //store data packet
//char m_data_buf[MAX_RECEIVE_BUF+1]; //store data packet
uint16 m_data_len; //the data length
uint8 m_data_type; //data type,if 0 unknown type, 0x01 logon data type,0x02 logout data type,0x09 user data type
}data_record;
/*
* Get the user amount in user list
* return uint
*/
DSCDLLAPI uint HDCALL get_max_user_amount();
/*
* Get the online user amount in user list
*/
DSCDLLAPI uint HDCALL get_online_user_amount();
/*
* Get the user info in user list, if exist 0,else -1
* @param userid: [in] The user's identity number.
* @param infoPtr: [out] A pointer to a buffer that receives the user info
*/
DSCDLLAPI int HDCALL get_user_info(uint8 *userid,user_info *infoPtr);
/*
* Get a user's info at one position
* @param index: [in] 0 ~ get_max_user_amount().
* @param infoPtr: [out] A pointer to a buffer that receives the user info
*/
DSCDLLAPI int HDCALL get_user_at(uint index,user_info *infoPtr);
/*
* Get Local Host Name
* @param namebuf: [out] A pointer to a buffer that receives the local host name
* @param len: [in] The length of the buffer.
* @param mess: [out] A pointer to a buffer that store error message
* return -1 error,0 successful
*/
DSCDLLAPI int HDCALL get_server_name(char *namebuf,int len,char *mess);
/*
* Start net service
*hWnd A handle identifying the window that will receive a message when a network event occurs.
*wMsg The message to be received when a network event occurs.
* default value: const int WM_CLIENT_READCLOSE=WM_USER+105;
*nServerPort network monitor port,default 5002
*/
DSCDLLAPI int HDCALL start_gprs_server(HWND hWnd,unsigned int wMsg,int nServerPort,char *mess);
/*
* Stop net service
* @param mess: [out] A pointer to a buffer that store error message
* return -1 failed or nonexistent,0 successful
*/
DSCDLLAPI int HDCALL stop_gprs_server(char *mess);
/*
* Process all data from DTU
* @param recdPtr: [out] A pointer to a struct that store dtu data info
* @param mess: [out] A pointer to a buffer that store message
* @param reply: [in] The flag that used to indicate answer or not answer the dtu when it receive dtu data.
* when release your program,use false,when debug your program,use true
* return -1 failed,0 successful
*/
DSCDLLAPI int HDCALL do_read_proc(data_record *recdPtr,char *mess,BOOL reply);
/*
* Send data to DTU
* @param userid: [in] The user's identity number.
* @param data: [in] The data that will be sent
* @param len: [in] The length of the data.
* @param mess: [out] A pointer to a buffer that store error message
* return -1 failed,0 successful
*/
DSCDLLAPI int HDCALL do_send_user_data(uint8* userid,uint8*data,uint len,char *mess);
/*
* Close one DTU in current user list but not really send close command to dtu
* @param userid: [in] The user's identity number.
* @param mess: [out] A pointer to a buffer that store error message
* return -1 failed or nonexistent,0 successful
*/
DSCDLLAPI int HDCALL do_close_one_user(uint8* userid,char *mess);
/*
* Close all DTU in current user list but not really send close command to dtu
* @param mess: [out] A pointer to a buffer that store error message
* return -1 failed or nonexistent,0 successful
*/
DSCDLLAPI int HDCALL do_close_all_user(char *mess);
/*
* Close one DTU in current user list and send close command to dtu
* @param userid: [in] The user's identity number.
* @param mess: [out] A pointer to a buffer that store error message
* return -1 failed or nonexistent,0 successful
*/
DSCDLLAPI int HDCALL do_close_one_user2(uint8* userid,char *mess);
/*
* Close all DTU in current user list and send close command to dtu
* @param mess: [out] A pointer to a buffer that store error message
* return -1 failed or nonexistent,0 successful
*/
DSCDLLAPI int HDCALL do_close_all_user2(char *mess);
/*
* if u want to discard the default DTU maintenance list and implement the list of
* yourself,u can reload the functions below
*/
typedef void (HDCALL* LOGONCALLBACK)(user_info *m_userPtr);
typedef void (HDCALL* LOGOUTCALLBACK)(user_info *m_userPtr);
typedef void (HDCALL* RECVDATACALLBACK)(user_info *m_userPtr,data_record *recdPtr,BOOL bReply);
typedef void (HDCALL* RECVDATAREPLYCALLBACK)(user_info *m_userPtr);
typedef void (HDCALL* INVALIDCMDCALLBACK)(user_info *m_userPtr);
DSCDLLAPI void HDCALL SetLogonCALLBACK (LOGONCALLBACK logonProc);
DSCDLLAPI void HDCALL SetLogoutCALLBACK (LOGOUTCALLBACK logonProc);
DSCDLLAPI void HDCALL SetRecvdataCALLBACK (RECVDATACALLBACK logonProc);
DSCDLLAPI void HDCALL SetRecvDataReplyCALLBACK (RECVDATAREPLYCALLBACK logonProc);
DSCDLLAPI void HDCALL SetInvalidcmdCALLBACK (INVALIDCMDCALLBACK logonProc);
DSCDLLAPI void HDCALL SetEvtCALLBACK(
LOGONCALLBACK logonProc,LOGOUTCALLBACK logoutProc,
RECVDATACALLBACK RecvUserDataProc,RECVDATAREPLYCALLBACK RecvDTUReplyProc,
INVALIDCMDCALLBACK InvalidCmdProc);
int DTUCallServer(data_record *,char *,int);
//void PollUserTable(void);
//void GetDllVersion(char *);
DSCDLLAPI int HDCALL AddFilterIP(unsigned long ulIPAddr);
DSCDLLAPI int HDCALL DelFilterIP(unsigned long ulIPAddr=0);
DSCDLLAPI int HDCALL FindFilterIP(unsigned long ulIPAddr);
DSCDLLAPI int HDCALL GetFilterIPCount(void);
DSCDLLAPI unsigned long HDCALL GetCurrentIP(void);
DSCDLLAPI unsigned long HDCALL GetIP(int iIndex);
// 指定使用的IP
DSCDLLAPI void HDCALL SetCustomIP(unsigned long ulIPAddr); //ulIPAddr采用网络字节序
DSCDLLAPI void HDCALL DeleteAllUser(void);
/*
*when start server,u can call this function to add a user.
*/
DSCDLLAPI int HDCALL AddOneUser(user_info *pUserInfo);
/*
*Add by SEA on Oct 28,2003
*Modified by SEA Oct 29,2003
*Setup work mode
*@param nWorkMode: [in] The Mode of dll to work.
*0-use blocking mode and uses thread to receive data
*1-use nonblocking mode,not need windows's handle and message
*2-use nonblocking mode,must transfer valid window's handle and message
*default value is 2 ,it is compatible with previous version
*/
DSCDLLAPI int HDCALL SetWorkMode(int nWorkMode);
/*新增加函数,
该函数的作用是:选择通讯协议
必须在start_gprs_server函数前调用才有效
0 UDP
1 TCP
*/
DSCDLLAPI int HDCALL SelectProtocol(int nProtocol);
////////////////////////////////////////////////////////////////////////////////
#define PARAM_SERVER_CODE 0x01
#define PARAM_USER_NAME 0x02
#define PARAM_PASSWORDS 0x03
#define PARAM_APN 0x04
#define PARAM_SIMPIN 0x05
#define PARAM_LOCAL_MT 0x06
#define PARAM_LOCAL_PORT 0x07
#define PARAM_TIMEVAL 0x08
#define PARAM_PACK_LEN 0x09
#define PARAM_RECONNECT_INTERVAL 0x0a
#define PARAM_DEBUG_TYPE 0x0b
#define PARAM_LAST_PACKET_IDLE 0x0c
#define PARAM_CENTER_ADDR 0x0d
#define PARAM_CENTER_NAME 0x0e
#define PARAM_DOMAIN_TTL 0x0f
#define PARAM_CENTER_PORT 0x10
#define PARAM_DNS_ADDR 0x11
#define PARAM_SERIAL_PORT 0x12
#define PARAM_MT_TYPE 0x13
#define PARAM_CALL_TYPE 0x14
#define PARAM_CALL_TIMEVAL 0x15
#define PARAM_OFF_LINETIME 0x16
#define PARAM_PEER_MT 0x17
//#define PARAM_TRANSPORT_TYPE 0x18
//#define PARAM_DSC_CONNECTION_TYPE 0x19
#define PARAM_VERSION 0x30
#define PARAM_HARDWARE_VERSION 0x31
#define PARAM_PROGRAM_BUILT_DATE 0x32
//参数配置函数组
//清除设置参数
DSCDLLAPI void HDCALL ClearParam();
//加入设置参数,0失败,1成功
DSCDLLAPI int HDCALL SetParam(int nParamType, char *cpValue, int nParamLenth, int *iErrorCode);
//更新dtu参数,0失败,1成功
//destIP: DTU的IP地址(主机字节顺序)
//destPort: DTU的端口(主机字节顺序)
DSCDLLAPI int HDCALL DoUpdateParam(const unsigned long destIP,const unsigned short destPort, char *m_userid);
//读取DTU参数,0失败,1成功
DSCDLLAPI int HDCALL DoReadParam(const unsigned long destIP,const unsigned short destPort, char *m_userid);
//读取dtu某项参数,0失败,1成功
//nParamLenth表示参数长度
DSCDLLAPI int HDCALL GetParam(int nParamType, char *cpValue, int *nParamLenth);
////////////////////////////////////////////////////////////////////////////////
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -