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

📄 wattcp.h

📁 dos下开发TCP网络的库文件部分
💻 H
📖 第 1 页 / 共 2 页
字号:
    eth_address     srcEthAddr;
    longword        srcIPAddr;
    eth_address     dstEthAddr;
    longword        dstIPAddr;
} arp_Header;

#if !defined(ETH_MSS)   // S. Lawson - allow setting in makefile
#define ETH_MSS 1500  // MSS for Ethernet
#endif                  // S. Lawson

byte *fragment( in_Header * ip );
void timeout_frags( void );

#endif


/*
 * Ethernet interface -- pcsed.c
 */
int  _eth_init( void );			// S. Lawson
byte *_eth_formatpacket( eth_address *eth_dest, word eth_type );
int   _eth_send( word len );
void  _eth_free( void *buf );
byte *_eth_arrived( word *type_ptr );
void  _eth_release( void );
#if defined(__WATTCP_KERNEL__)
extern void *_eth_hardware( byte *p );
#endif


/*
 * timers -- pctcp.c
 */
void ip_timer_init( sock_type *s, int delayseconds );
int ip_timer_expired( sock_type *s );
longword MsecClock( void );


/*
 * sock_init()  -- initialize wattcp libraries -- sock_ini.c
 */
void sock_init(void);
int sock_init_noexit(void);     // S. Lawson
void sock_exit( void );   /* normally called via atexit() in sock_init() */


        /*
         * tcp_init/tcp_shutdown -- pctcp.c
         *      - init/kill all tcp and lower services
         *      - only call if you do not use sock_init
         * (NOT RECOMMENDED)
         */
void tcp_shutdown(void);
int tcp_init_noexit(void);      // S. Lawson
void tcp_init(void);
void tcp_set_ports(word tcp_base, word udp_base);	// S. Lawson
void tcp_get_ports(word *tcp_base, word *udp_base);	// S. Lawson

/*
 * things you probably won't need to know about
 */
	/*
	 * sock_debugdump -- sock_dbu.c
	 *	- dump some socket control block parameters
	 * used for testing the kernal, not recommended
	 */
void sock_debugdump( sock_type *s );
        /*
         * tcp_config - read a configuration file
         *            - if special path desired, call after sock_init()
         *            - null reads path from executable
         * see sock_init();
         */
int tcp_config( char *path );
	/* S. Lawson
	 * tcp_config_file - sets the configuration filename
	 *                 - null silently skips config file processing
	 */
void tcp_config_file( const char *fname );
	/*
         * tcp_tick - called periodically by user application in sock_wait_...
         *          - returns 1 when our socket closes
         */
int tcp_tick( sock_type *s );
        /*
         * Retransmitter - called periodically to perform tcp retransmissions
         *          - normally called from tcp_tick, you have to be pretty
         *            low down to use this one
         */
void tcp_Retransmitter(void);
        /*
         * tcp_set_debug_state - set 1 or reset 0 - depends on what I have done
         */
void tcp_set_debug_state( int x );

/*
 * check for bugs -- pctcp.c
 */
int tcp_checkfor( sock_type *t );

/*
 * Timeout routines.
 */
unsigned long set_timeout( unsigned int seconds );
unsigned long set_ttimeout( unsigned int ticks );
int chk_timeout( unsigned long timeout );

/*
 * socket macros
 */

/*
 * sock_wait_established()
 *	- waits then aborts if timeout on s connection
 * sock_wait_input()
 *	- waits for received input on s
 * - may not be valid input for sock_gets... check returned length
 * sock_tick()
 *	- do tick and jump on abort
 * sock_wait_closed();
 *	- discards all received data
 *
 * jump to sock_err with contents of *statusptr set to
 *	 1 on closed
 *	-1 on timeout
 *
 */

int _ip_delay0( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr );
int _ip_delay1( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr);
int _ip_delay2( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr);


#if defined(__WATTCP_KERNEL__)
#define set_mstimeout( x ) (set_timeout(0)+ (x / 55))
#endif  /* defined(__WATTCP_KERNEL__) */

#define sock_wait_established( s, seconds, fn, statusptr ) \
    if (_ip_delay0( s, seconds, fn, statusptr )) goto sock_err;
#define sock_wait_input( s, seconds, fn , statusptr ) \
    if (_ip_delay1( s, seconds, fn, statusptr )) goto sock_err;
#define sock_tick( s, statusptr ) \
    if ( !tcp_tick(s)) { *statusptr = 1 ; goto sock_err; }
#define sock_wait_closed(s, seconds, fn, statusptr )\
    if (_ip_delay2( s, seconds, fn, statusptr )) goto sock_err;

/*
 * TCP or UDP specific stuff, must be used for open's and listens, but
 * sock stuff is used for everything else -- pctcp.c
 */
int tcp_open( tcp_Socket *s, word lport, longword ina, word port, dataHandler_t datahandler );
int udp_open( udp_Socket *s, word lport, longword ina, word port, dataHandler_t datahandler );
int tcp_listen( tcp_Socket *s, word lport, longword ina, word port, dataHandler_t datahandler, word timeout );
int tcp_established( tcp_Socket *s );

/*
 * Clean up a string -- pctcp.c
 */
char *rip( char *s);

/*
 * Name service / name lookup routines -- udp_dom.c
 */
longword resolve( char *name );
longword resolve_fn( char *name, sockfunct_t fn );     // S. Lawson
int reverse_addr_lookup( longword ipaddr, char *name );
int reverse_addr_lookup_fn( longword ipaddr, char *name, sockfunct_t fn );  // S. Lawson

/*
 * less general functions
 */
longword intel( longword x );
word intel16( word x );
longword MsecClock( void );

/*
 * Ctrl-break handling -- pc_cbrk.c
 */
void tcp_cbrk( int mode );

void outs( char far * string );

#if defined(__WATTCP_KERNEL__)
/* icmp handler -- pcicmp.c */
int icmp_handler( in_Header *ip );
void icmp_Unreach( in_Header *ip);	// S. Lawson
#endif


/*
 * ARP -- pcarp.c
 */
#if defined(__WATTCP_KERNEL__)
void _arp_add_gateway( char *data, longword ip );
int _arp_handler( arp_Header *in );
#endif
void _arp_register( longword use, longword instead_of );
void _arp_tick( longword ip );      /* kernel only? */
int _arp_resolve( longword ina, eth_address *ethap, int nowait );



/*
 * Packet -- pcpkt.c
 *
 * These probably shouldn't be visible to user app code.
 */
eth_address *_pkt_eth_init( void );
int pkt_send( char *buffer, int length );
void pkt_buf_wipe( void );
void pkt_buf_release( char *ptr );
void * pkt_received( void );
void pkt_release( void );

#if defined(__WATTCP_KERNEL__)
void _add_server( int *counter, int max, longword *array, longword value );
extern word debug_on;
#endif


/*
 * pcbsd.c
 */
int _chk_socket( sock_type *s );
char *inet_ntoa( char *s, longword x );
longword inet_addr( char *s );
char *sockerr( sock_type *s );
char *sockstate( sock_type *s );
longword gethostid( void );
longword sethostid( longword ip );
word ntohs( word a );
word htons( word a );
longword ntohl( longword x );
longword htonl( longword x );


#if defined(__WATTCP_KERNEL__)
void *_tcp_lookup( longword hisip, word hisport, word myport );

void _tcp_cancel( in_Header *ip, int code, char *msg, longword dummyip );
void _udp_cancel( in_Header *ip );

int _dobootp(void);
#endif


/*
 * General socket I/O -- pctcp.c
 */
word sock_mode( sock_type *, word);        /* see TCP_MODE_... */
void sock_abort( sock_type *);
void tcp_sendsoon( tcp_Socket *s );
int sock_fastwrite( sock_type *, byte *, int );
int sock_write( sock_type *, byte *, int );
int sock_read( sock_type *, byte *, int );
int sock_fastread( sock_type *, byte *, int );
int sock_gets( sock_type *, byte *, int );
void sock_close( sock_type *s );

byte sock_putc( sock_type  *s, byte c );
int sock_getc( sock_type  *s );
int sock_puts( sock_type  *s, byte *dp );
int sock_gets(sock_type *, byte *, int );

int sock_setbuf( sock_type *s, byte *dp, int len );

int sock_yield( tcp_Socket *s, void (*fn)( void ) );


/*
 *   s is the pointer to a udp or tcp socket
 */


/*
 * Socket text output/input routines -- sock_prn.c
 */
int sock_printf( sock_type  *s, char *format, ... );
int sock_scanf( sock_type  *s, char *format, ... );


/*
 * Misc. socket I/O -- pctcp.c
 */
int sock_setbuf( sock_type *s, byte *dp, int len );
int sock_enqueue( sock_type  *s, byte *dp, int len );
void sock_noflush( sock_type *s );
void sock_flush( sock_type  *s );
void sock_flushnext( sock_type  *s);
int sock_dataready( sock_type  *s );
int sock_established( sock_type *s );
void sock_sturdy( sock_type *s, int level );


/*
 * Debug output -- pcdbug.c
 */
void db_write( char *msg );
void db_open( void );
void db_close( void );
void dbug_printf( char *, ... );
void dbug_init( void );
void dbug_init( void );



/*
 * Socket Select -- select.c
 */
int sock_sselect( sock_type *s, int waitstate );



/*
 * recv routines -- pcrecv.c
 */
int sock_recv_init( sock_type *s, void *space, word len );
int sock_recv_from( sock_type *s, long *hisip, word *hisport, char *buffer, int len, word flags );
int sock_recv( sock_type *s, char *buffer, int len, word flags );


/*
 * bsd-similar stuff -- pcbuf.c
 */
int sock_rbsize( sock_type *s );
int sock_rbused( sock_type *s );
int sock_rbleft( sock_type *s );
int sock_tbsize( sock_type *s );
int sock_tbused( sock_type *s );
int sock_tbleft( sock_type *s );
int sock_preread( sock_type *s, byte *dp, int len );


/*
 * Name conversion stuff -- udp_nds.c
 */
longword aton( char *text );
int isaddr( char *text );

/*
 * Configuration -- pcconfig.c
 */
char *_inet_atoeth( char *src, byte *eth );
void _add_server( int *counter, int max, longword *array, longword value );
int tcp_config( char *path );

        /*
         * name domain constants
         */

extern char *def_domain;
extern longword def_nameservers[ MAX_NAMESERVERS ];

extern word wathndlcbrk;
extern word watcbroke;

/* user initialization file */
extern void (*usr_init)(char *name, char *value);

extern int _survivebootp;

extern int _last_cookie;
extern longword _cookie[MAX_COOKIES];

extern int _last_nameserver;
extern char *_hostname;

/*
 * Elib stuff
 */
int isstring( char *string, unsigned stringlen );     /* isstring.c */

 

#endif /* ndef _wattcp_wattcp_h */

⌨️ 快捷键说明

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