T
tony83ok
Unregistered / Unconfirmed
GUEST, unregistred user!
不用全部写完,重要部分给个提示就好,谢了!!!// The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the DMDLL_EXPORTS// symbol defined on the command line. this symbol should not be defined on any project// that uses this DLL. This way any other project whose source files include this file see // DMDLL_API functions as being imported from a DLL, wheras this DLL sees symbols// defined with this macro as being exported.#ifdef DMDLL_EXPORTS#define DMDLL_API __declspec(dllexport)#else#define DMDLL_API __declspec(dllimport) #endif#ifdef __cplusplusextern "C" {#endiftypedef void* DEV_HANDLE;typedef void* PARALIST_HANDLE;typedef enum tagErrorCode{ DM_ERR_OK, /* no error */ DM_ERR_PARA, /* parameter error */ DM_ERR_NOAUTH, /* device need auth login */ DM_ERR_AUTHFAIL, /* auth fail */ DM_ERR_SOCKET, /* socket error */ DM_ERR_MEM, /* memory access error */ DM_ERR_TIMEOUT, /* operation timeout */ DM_ERR_ARG, /* function argment error */ DM_ERR_MATCH, /* parameters in command and reply are not match */ DM_ERR_MAX}RET_TYPE;typedef enum enumPARA_TYPES{ BAUDRATE, DATABITS, STOPBITS, PARITY, FLOWCONTROL, FIFO, ENABLEPACKING, IDLEGAPTIME, MATCH2BYTESEQUENCE, SENDFRAMEONLY, SENDTRAILINGBYTES, INPUTWITHACTIVECONNECT, OUTPUTWITHACTIVECONNECT, INPUTWITHPASSIVECONNECT, OUTPUTWITHPASSIVECONNECT, INPUTATTIMEOFDISCONNECT, OUTPUTATTIMEOFDISCONNECT, IPCONFIGURATION, AUTONEGOTIATE, MACADDRESS, SPEED, DUPLEX, NETPROTOCOL, ACCEPTINCOMING, ARPCACHETIMEOUT, TCPKEEPACTIVE, CPUPERFORMANCEMODE, HTTPSERVERPORT, MTUSIZE, RETRYCOUNTER, IPADDRESS, FIRMWARE, UPTIME, SERIALNO, RETRYTIMEOUT, HOSTLIST1_IP, HOSTLIST1_PORT, HOSTLIST2_IP, HOSTLIST2_PORT, HOSTLIST3_IP, HOSTLIST3_PORT, HOSTLIST4_IP, HOSTLIST4_PORT, HOSTLIST5_IP, HOSTLIST5_PORT, HOSTLIST6_IP, HOSTLIST6_PORT, HOSTLIST7_IP, HOSTLIST7_PORT, HOSTLIST8_IP, HOSTLIST8_PORT, HOSTLIST9_IP, HOSTLIST9_PORT, HOSTLIST10_IP, HOSTLIST10_PORT, HOSTLIST11_IP, HOSTLIST11_PORT, HOSTLIST12_IP, HOSTLIST12_PORT, FIRSTMATCHBYTE, LASTMATCHBYTE, DATAGRAMTYPE, DEVICEADDRESSTABLE1_BEGINIP, UDPLOCALPORT, UDPREMOTEPORT, UDPNETSEGMENT, DEVICEADDRESSTABLE2_BEGINIP, DEVICEADDRESSTABLE2_PORT, DEVICEADDRESSTABLE2_ENDIP, DEVICEADDRESSTABLE3_BEGINIP, DEVICEADDRESSTABLE3_PORT, DEVICEADDRESSTABLE3_ENDIP, DEVICEADDRESSTABLE4_BEGINIP, DEVICEADDRESSTABLE4_PORT, DEVICEADDRESSTABLE4_ENDIP, UDPUNICASTLOCALPORT, ACCEPTIONINCOMING, ACTIVECONNECT, STARTCHARACTER, ONDSRDROP, HARDDISCONNECT, CHECKEOT, INACTIVITYTIMEOUT_M, INACTIVITYTIMEOUT_S, LOCALPORT, REMOTEHOST, REMOTEPORT, DNSQUERYPERIOD, DEVICEADDRESSTABLE1_ENDIP, DEVICEADDRESSTABLE1_PORT, CONNECTRESPONSE, TERMINALNAME, USEHOSTLIST, EMAILADDRESS, EMAILUSERNAME, EMAILPASSWORD, EMAILINPUTTRIGGERMESSAGE, EMAILADDRESS1, EMAILADDRESS2, EMAILADDRESS3, POP3DOMAINNAME, SMTPDOMAINNAME, POP3PORT, SMTPPORT, COLDSTART, DCDCHANGED, DSRCHANGED, WARMSTART, AUTHENTICATIONFAILURE, IPADDRESSCHANGED, ENABLESERIALTRIGGERINPUT, SERIALCHANNEL, SERIALDATASIZE, SERIALMATCHDATA1, SERIALMATCHDATA2, EMAILTRIGGERSUBJECT, PRIORITY, INPUTPRIORITY, INPUTMINNOTIFICATIONINTERVAL, MINNOTIFICATIONINTERVAL, RENOTIFICATIONINTERVAL, NEWUSERPSW, BOOTP, DHCP, AUTOIP, DHCPHOSTNAME, SUBNET, DEFAULTGATEWAY, DEVICENAME, TIMEZONE, LOCALTIME_YEAR, LOCALTIME_MONTH, LOCALTIME_DAY, LOCALTIME_HOUR, LOCALTIME_MINUTE, LOCALTIME_SECOND, TIMESERVER, WEBCONSOLE, TELNETCONSOLE, PASSWORDCHANGED, SERIALPORTOPTIONS, PREFERREDDNSSERVER, ALTERNATEDNSSERVER, SERIALMATCHDATA3, INPUT1, INPUT2, IO1, IO2, IO1TYPE, IO2TYPE, IO1STATE, IO2STATE, SERIALPORTPROTOCOL, FIRMWAREID, PPPOEUSERNAME, PPPOEPASSWORD, PPPOEWORKMODE, PPPOEMAXREDIALTIMES, PPPOEREDIALINTERVAL, PPPOEIDLETIME, PPPOESTATUS, PPPOEIP, PPPOEGATEWAY, PPPOEDNS1, PPPOEDNS2, ENABLEBACKUPLINK }PARA_TYPES;/****************************************************************************** *function: SearchCallBack *description:callback function to call when found a new device *input: devHandle :device handle * pData :user data as a parameter of searchCB *output: NULL *return: NULL *others: register when init module ******************************************************************************/typedef void (WINAPI *SearchCallBack)(DEV_HANDLE devHandle, void *pData);/****************************************************************************** *function: DM_Init *description:initialize the device manager module *input: searchCB :callback function to call when found a device * pUsrData :user data as a parameter of searchCB *output: NULL *return: refer to enum tagErrorCode *others: remember to call DM_DeInit to release module resource ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_Init(SearchCallBack searchCB, void *pData);/****************************************************************************** *function: DM_DeInit *description:destroy the device manager module and release related resource *input: NULL *output: NULL *return: refer to enum tagErrorCode *others: ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_DeInit();/****************************************************************************** *function: DM_SearchDevice *description:search devices *input: deviceIP :device ip address * timeout :timeout time of searching *output: NULL *return: refer to enum tagErrorCode *others: if set deviceIP as INADDR_BROADCAST, this function will search * on all interface, each search cycle will last timeout time ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_SearchDevice(unsigned long deviceIP, int timeout);/****************************************************************************** *function: DM_AuthLogin *description:log on to device *input: devHandle :device handle * name :user name, max charcter number is 10 * password assword of user * timeout :timeout time of login *output: NULL *return: refer to enum tagErrorCode *others: please call this function before access device ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_AuthLogin(DEV_HANDLE devHandle, char *name, char *password, int timeout);/****************************************************************************** *function: DM_GetDeviceInfo *description:get information of device by device handle *input: devhandle :device handle *output: ipaddr :ip address of device in local byte order * macaddr :mac address string in xx.xx.xx.xx.xx.xx * devname :device name sting *return: refer to enum tagErrorCode *others: ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_GetDeviceInfo(DEV_HANDLE devhandle, unsigned long *ipaddr, char *macaddr, char *devname);/****************************************************************************** *function: DM_FreeDevice *description:free a device resource *input: devhandle :device handle *output: NULL *return: refer to enum tagErrorCode *others: ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_FreeDevice(DEV_HANDLE devHandle);/****************************************************************************** *function: DM_CheckPara *description:check parameter's value *input: devhandle :device handle * listHead arameters list handle * chanNo arameter channel number, if it is not related with * channel, can be set any value. * paraType arameters type, refer to enum PARA_TYPES * valueLen arameter value buffer's length * value arameter value buffer *output: NULL *return: refer to enum tagErrorCode *others: ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_CheckPara(DEV_HANDLE devHandle, int chanNo, PARA_TYPES paraType, int valuelen, char *value);/****************************************************************************** *function: paralistCreate *description:create a parameters list *input: devHandle :device handle *output: NULL *return: parameters list handle *others: when add parameter to this list, device handle must be the same ******************************************************************************/DMDLL_API PARALIST_HANDLE WINAPI paralistCreate(DEV_HANDLE devHandle);/****************************************************************************** *function: paralistDestroy *description:destroy a parameters list and related resource *input: listHead arameters list handle *output: NULL *return: refer to enum tagErrorCode *others: After call this function, listHead can not be used any more ******************************************************************************/DMDLL_API RET_TYPE WINAPI paralistDestroy(PARALIST_HANDLE list);/****************************************************************************** *function: paralist_addnode *description:add a parameter to a parameters list *input: listHead arameters list handle * chanNo arameter channel number, if it is not related with * channel, can be set any value. * paraType arameters type, refer to enum PARA_TYPES * valueLen arameter value buffer's length * value arameter value buffer *output: NULL *return: refer to enum tagErrorCode *others: please call DM_CheckPara to * check parameters before add it to list when set parameter ******************************************************************************/DMDLL_API RET_TYPE WINAPI paralist_addnode(PARALIST_HANDLE list, int chanNo, PARA_TYPES paraType, int valueLen, char *value);/****************************************************************************** *function: paralist_delnode *description:delete a parameter from a parameters list *input: listHead arameters list handle * chanNo arameter channel number, if it is not related with * channel, can be set any value. * paraType arameters type, refer to enum PARA_TYPES *output: NULL *return: refer to enum tagErrorCode *others: ******************************************************************************/DMDLL_API RET_TYPE WINAPI paralist_delnode(PARALIST_HANDLE list, int chanNo, PARA_TYPES paraType);/****************************************************************************** *function: paralist_getnode *description:get a parameter from a parameters list *input: listHead arameters list handle * chanNo arameter channel number, if it is not related with * channel, can be set any value. * paraType arameters type, refer to enum PARA_TYPES *output: valueLen arameter value length * value arameter value buffer *return: refer to enum tagErrorCode *others: ******************************************************************************/DMDLL_API RET_TYPE WINAPI paralist_getnode(PARALIST_HANDLE list, int chanNo, PARA_TYPES paraType, int *valueLen, char *value);/****************************************************************************** *function: DM_GetPara *description:get parameters from device *input: devHandle :device handle * paraList arameter list handle * timeout :timeout time of getting parameter *output: NULL *return: refer to enum tagErrorCode *others: please call paralistCreate to create a parameters list and call * paralist_addnode to add a parameter to list ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_GetPara(DEV_HANDLE devHandle, void *paraList, int timeout);/****************************************************************************** *function: DM_SetPara *description:set parameters of device *input: devHandle :device handle * paraList arameter list handle * timeout :timeout time of setting parameter *output: NULL *return: refer to enum tagErrorCode *others: please call paralistCreate to create a parameters list and call * paralist_addnode to add a parameter to list ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_SetPara(DEV_HANDLE devHandle, void *paraList, int timeout);/****************************************************************************** *function: DM_ResetDevice *description:reboot a device *input: devHandle :device handle * timeout :timeout time of rebooting *output: NULL *return: refer to enum tagErrorCode *others: when device reboot success, must login again ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_ResetDevice(DEV_HANDLE devHandle, int timeout);/****************************************************************************** *function: DM_LogOutDevice *description:logout of a device *input: devHandle :device handle * timeout :timeout time of logout *output: NULL *return: refer to enum tagErrorCode *others: ******************************************************************************/DMDLL_API RET_TYPE WINAPI DM_LogOutDevice(DEV_HANDLE devHandle, int timeout);#ifdef __cplusplus}#endifextern DMDLL_API int nDmdll;DMDLL_API int fnDmdll(void);