⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 etr_ppp.h

📁 “TCP/IP协议库及例程”和“PPP-TCP/IP协议库及例程”系英创信息技术有限公司拥有自主知识产权之软件产品(软件产品登记证书号:川DGY-2004-0033)。上述软件的获得者仅允许将上述软件
💻 H
字号:
#if !defined( _ETR_PPP_H )
#define _ETR_PPP_H
/*////////////////////////////////////////////////
	  NetBox TCP/IP over Ethernet
////////////////////////////////////////////////*/
#define NE_PARAM	-10         /* user parameter error */
#define EHOSTUNREACH	-11         /* host not reachable */
#define ETIMEDOUT	-12         /* timeout */
#define NE_HWERR	-13         /* hardware error */
#define ECONNABORTED	-14         /* protocol error */
#define ENOBUFS		-15         /* no buffer space */
#define EBADF		-16         /* connection block invalid */
#define EFAULT		-17         /* invalid pointer argument */
#define	EWOULDBLOCK	-18         /* operation would block */
#define	EMSGSIZE	-19         /* message too long */
#define	ENOPROTOOPT	-20         /* Protocol not available */

#define		BLOCKOPEN	0
#define		NONBLOCKOPEN	0x80
#define		UDP_P2P	        0x90

// Initialize the network environment. Called only once.
int InitPPPNet( int PortNum=0, char* BAUD=NULL );

// Shut off the networking. Will shut off any open ports.
int TermPPPNet( );

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**  ConnOpen()        Open a connection
**
**  PARAMETERS:
**    (in)      *to          Name, IP addr. string, or literal IP addr.
**    (in)      *protoc      Protocol -- e.g. "TCP/IP" "UDP/IP"
**    (in)      lp           The local host's port
**    (in)      rp           The remotes host's port
**    (in)      flags        Modifier flags
**
**  RETURNS:
**    conno                  Connection number
**    ENOBUFS                No connection blocks available
**    EHOSTUNREACH           Cannot reach host
**    negetive value         Lower layer open failure
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnOpen( char* to, char* protoc, int lp, int rp, int flags );

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**  ConnClose()    Dynamic Protocol Interface close connection function
**
**  PARAMETERS:
**     (in)     conno   Connection ID number
**
**  DESCRIPTION:
**     Closes the specified connection, possibly waiting for
**     a complete close handshake.  In no case should the application
**     retry the close.  In some cases, such as TCP, the connection
**     block associated with conno will be freed after a timeout,
**     on the order on a minute.
**
**  RETURNS:
**     0             Normal close occured
**     EBADF         The connection number was invalid.  No close was performed.
**     ECONNABORTED  Protocol problem.  Connection was closed.
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnClose( int conno, int flags=0 );

// return =  0: the connection conno is closed
//        != 0: the connection conno is not closed yet!
int ConnCloseCheck( int conno );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** Read routine.
**
** PARAMETERS:
**   (in)   conno               a connection number
**   (out)  buff                a data buffer
**   (in)   len
** RETURNS:
**    >0                        read data's length
**    <0                        error code
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnRead( int conno, char* buff, int len );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** Write routine.
**
** PARAMETERS:
**   (in)   conno               a connection number
**   (out)  buff                a data buffer
**   (in)   len                 data's length
**   (in)   PushFlg
** RETURNS:
**    >0                        read data's length
**    <0                        error code
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnWrite( int conno, char* buff, int len, int PushFlg=0 );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** check connection established's state
**
** PARAMETERS:
**   (in)   conno               a connection number
** RETURNS:
**    1                         connection is established
**    0                         connection is unestablished
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnIsEstablished( int conno );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** check connection to send data
**
** PARAMETERS:
**   (in)   conno               a connection number
**   (in)   len			data's length
** RETURNS:
**    1                         connection can send data
**    0                         connection cannot send data
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnCanSend( int conno, int len );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** check connection if recieved data
**
** PARAMETERS:
**   (in)   conno               a connection number
** RETURNS:
**    1                         connection recieved data
**    0                         connection unrecieved data
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnHasData( int conno );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** check connection if be finished
**
** PARAMETERS:
**   (in)   conno               a connection number
** RETURNS:
**    1                         connection is finished
**    0                         connection isn't finished
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnIsFinished( int conno );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** check connection if be fatal
**
** PARAMETERS:
**   (in)   conno               a connection number
** RETURNS:
**    1                         connection is fatal
**    0                         connection isn't fatal
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int ConnIsFatal( int conno );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** generation port number
**
** RETURNS:
**    port number, between 2000-9000
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int MyPort( );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** get connection remote IP
**
** PARAMETERS:
**   (in)   conno               a connection number
**   (out)  IPCode              IP Address
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int  GetIP( int conno, unsigned char* IPCode );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** get local IP
**
** PARAMETERS:
**   (out)  IPCode              IP Address
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int  GetOWNIP( unsigned char* IPCode );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** Set DNS server's IP
**
** PARAMETERS:
**   (in)  SvrIPStr             IP Address
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int SetDNSServer( char* SvrIPStr=NULL );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
** get information from the DNS server.
**
** PARAMETERS:
**   (in)   DomainName        Name
**   (out)  IPStr             IP Address
** RETURNS:
**         <0  		      error code
**	   >=0  	      successful
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int DNS2IP( char* DomainName, char* IPStr );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**  DESCRIPTION:    User subroutine to send or receive a file using
**                  the FTP protocol.
** PARAMETERS:
**    (in)  host     	  The other station
**    (in)  file    	  file names in format "local remote"
**                  	  if only one is given, then remote is the same
**    (in)  mode    	  ASCII or IMAGE, if call is put value 2 added
**     	            	  0: get ascii file from remote host
**          	    	  1: get binary file from remote host
**                  	  2: put ascii file to remote host
**                  	  3: put binary file to remote host
**    (in) FTPdir         remote directory
**    (in) FTPusername    FTP username
**    (in) FTPpassword    FTP password
**    (in) timeout        millonsecond
**    (in) FTPMode        0: active mode(default)
**                        1: passive mode
**  RETURNS:
**	 0        on success
**       < 0      on error - return code
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int FTP_getput(char *host, char *file, int mode, char *FTPdir,
	       char *FTPusername, char *FTPpassword, unsigned long timeout=30000l,int FTPMode=0 );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**  DESCRIPTION:    User subroutine to put stream to remote station for
**                  a file using the FTP protocol.
** PARAMETERS:
**    (in)  host     	  The other station
**    (in)  file    	  file names in format "local remote"
**                  	  if only one is given, then remote is the same
**    (in)  mode    	  ASCII or IMAGE, if call is put value 2 added
**     	            	  0: get ascii file from remote host
**          	    	  1: get binary file from remote host
**                  	  2: put ascii file to remote host
**                  	  3: put binary file to remote host
**    (in) FTPdir         remote directory
**    (in) FTPusername    FTP username
**    (in) FTPpassword    FTP password
**    (in) stream         data stream
**    (in) slen           data stream length
**    (in) timeout        millonsecond
**    (in) FTPMode        0: active mode(default)
**                        1: passive mode
**  RETURNS:
**	 0        on success
**       < 0      on error - return code
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int FTP_putstream(char *host, char *file, char *FTPdir, char *FTPusername,
		  char *FTPpassword, char* stream, unsigned int slen,
		  unsigned long timeout=30000l,int FTPMode=0 );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**  DESCRIPTION:    User subroutine to get stream from remote station's
**                  file using the FTP protocol.
** PARAMETERS:
**    (in)  host     	  The other station
**    (in)  file    	  file names in format "local remote"
**                  	  if only one is given, then remote is the same
**    (in)  mode    	  ASCII or IMAGE, if call is put value 2 added
**     	            	  0: get ascii file from remote host
**          	    	  1: get binary file from remote host
**                  	  2: put ascii file to remote host
**                  	  3: put binary file to remote host
**    (in) FTPdir         remote directory
**    (in) FTPusername    FTP username
**    (in) FTPpassword    FTP password
**    (in) stream         data stream
**    (out) plen          data stream length
**    (in) timeout        millonsecond
**    (in) FTPMode        0: active mode(default)
**                        1: passive mode
**  RETURNS:
**	 0        on success
**       < 0      on error - return code
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int FTP_getstream(char *host, char *file, char *FTPdir, char *FTPusername,
		  char *FTPpassword, char* stream, int* plen, unsigned long timeout=30000l, int FTPMode=0 );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**  FTP Server
**  PARAMETERS:
**    (in) timeout        millonsecond
**    (in) FTPusername    FTP username
**    (in) FTPpassword    FTP password
**  RETURNS:
**	 0        on success
**       < 0      on error - return code
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int FTP_server( unsigned long timeout, char *FTPusername, char *FTPpassword );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**   ping remote station
**
**  PARAMETERS:
**    (in) IPStr           remote station IP address
**    (in) Milliseconds    wait time for reply
**                         typical value: 100 - 3000 milliseconds
**  RETURNS:
**	 0        remote IP can been reached
**       other    no way
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int Ping( char* IPStr, unsigned long Milliseconds );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**   Network interface handler
**
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int NetPackagePro( );

int SetReloadWDTInNet( void (*Reload)() );

// for PPP client, start PPP linkup
//int SetupPPPLink( );
// timeout unit is sencond
int SetupPPPLink( unsigned long timeout=300l );

// return = -1:  PPP is down
//        =  0:  PPP is working to open/close
//        =  1:  PPP is up
int GetPPPState( );

// return 0:    OK!
// return -30:  PPP net fail!
int PPPLinkTest( unsigned long timeout=500l );

int SetPPPUsername( char* NewName );
int SetPPPPassword( char* NewWord );

int ForcePPPLinkDown( );

int SendATCmdString( char* ATCmdString, int len=0, int ch=0 );
int GetATCmdEcho( );
int SetSerMuxUp( );

/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
**
**  RETURNS:
**     ETR_TCP.LIB Version
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
char*  GetLibVersion( );


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -