// // SlanTcp library related interface file. // #if !defined __SLANINTERFACE_H_ #define __SLANINTERFACE_H_ #define AVG_BUFF 50 typedef struct _CLIENT_INFO { TCHAR szClientIp[AVG_BUFF]; //IP Address [Optional] TCHAR szClientPort[10]; //TCP port number [Optional] } CLIENT_INFO, *PCLIENT_INFO; typedef enum _OPMODE { TCP_SRVR, TCP_CLNT, UDP } OPMODE; typedef union _INPUTS { struct _tcp { char ip[AVG_BUFF]; int portno; }tcp; struct _udp { char localip[AVG_BUFF]; int localport; char remoteip[AVG_BUFF]; int remoteport; }udp; } INPUTS,*PINPUTS; // //Service Control Routines // __declspec(dllexport) int slan_init (void); __declspec(dllexport) int slan_end (void); //----------------------------------------------------------------------------- //Port Control Routines //----------------------------------------------------------------------------- //Returns the Port Index __declspec(dllexport) int slan_open (OPMODE eMode, INPUTS sParam); __declspec(dllexport) int slan_close (int port_id); __declspec(dllexport) int slan_acceptconnection (int port_index, PCLIENT_INFO pClientInfo); // //Input/Output Routines // __declspec(dllexport) int slan_read (int port_id, char *buf, int *pLen); __declspec(dllexport) int slan_SetReadTimeouts (int port_id, DWORD timeouts); __declspec(dllexport) int slan_write (int port_id, PCHAR buf, int len); __declspec(dllexport) int slan_SetWriteTimeouts (int port_id, DWORD timeouts); // //Port Status Inquiry Routines // __declspec(dllexport) int slan_modemstatus (int port_id); __declspec(dllexport) int slan_linestatus (int port_id); // //New Commands // __declspec(dllexport) int slan_resetserver(PTCHAR server_ip,PTCHAR password); __declspec(dllexport) int slan_checkalive(PTCHAR serverip,DWORD Timeout); //----------------------------------------------------------------------------- // Defines //----------------------------------------------------------------------------- #define RECVBUFF_SIZE /*4096 2048 128*/ 1024 //[Socket receive() buff] #define SENDBUFF_SIZE /*4096 2048 128*/ 1024 //[Socket send() buff] //----------------------------------------------------------------------------- // Return Values //----------------------------------------------------------------------------- #define SLAN_OK 0 //OK #define SLAN_BADPORT -1 //No such port or port not opened #define SLAN_BADPARM -2 //Bad parameter #define SLAN_THREAD_ERR -3 //Create background thread fail. #define SLAN_MAXCONNECTIONSERR -4 //Exceeding the maimum connection count allowed. #define SLAN_SOCK_CREATE_FAIL -200 //Connect to NPort fail. Maybe the NPortis power down or network cable is disconnected. #define SLAN_CONNECT_FAIL -201 //Connect to NPort fail. Maybe the NPortis power down or network cable is disconnected. #define SLAN_SOCK_INIT_FAIL -202 //Socket initialize error. #define SLAN_RECV_ERR -203 //Communication with NPort error #define SLAN_SND_ERR -204 //Communication with NPort error #define SLAN_RCVTIMEOUT_FAIL -205 //Setting RECV TIMEOUT failed #define SLAN_SNDTIMEOUT_FAIL -206 //Setting SEND TIMEOUT failed #define SLAN_CANCEL -207 //User cancelled the application #define SLAN_HANDSHAKEFAIL -208 //Handshake with server failed #define SLAN_PING_FAIL -209 //Ping Failed #define SLAN_PREPMESSAGE_FAIL -210 //PrepareMessage: Insifficient size. ERROR #define SLAN_BIND_FAIL -211 //Bind fail #define SLAN_LISTEN_FAIL -212 //Listen fail #define SLAN_ACCEPT_FAIL -213 //Accept fail #define SLAN_NAMERESLTN_FAIL -214 //Name Resolution fail #define SLAN_SOCK_ERR -215 // Sock Error occured #define SLAN_NOT_ALIVE -216 // Slan Device not alive #define SLAN_RESET_TIMEOUT -217 // Slan Server Resetting Timed out #define SLAN_INVALID_PASSWORD -218 // Invalid Password #define SLAN_TIMEOUT -219 // Timed out #define SNAN_SOCK_CLOSE_FAIL -220 //Socket Closing closesocket() failed #endif //__SLANINTERFACE_H_