home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / PPPBCKP / SRC / SRC15B82.ZIP / WATTCP.H < prev    next >
C/C++ Source or Header  |  1998-01-02  |  21KB  |  738 lines

  1.  
  2. #ifndef _wattcp_wattcp_h
  3. #define _wattcp_wattcp_h
  4.  
  5. /*
  6.  * Are we compiling the kernel?
  7.  *    or an application using the kernel?
  8.  */
  9. /*
  10. #ifndef(__WATTCP_USER__)
  11. #define __WATTCP_KERNEL__
  12. #endif
  13. */
  14.  
  15. /*
  16.  * Note that some stuff is not available to user applications.
  17.  *   This is generally detail you shouldn't need to worry about,
  18.  *   and best stay away from to preserve the kernel integrity.
  19.  * Note also that there is a lot of other stuff that should probably
  20.  *   be protected but isn't.
  21.  */
  22.  
  23. #define WATTCPH
  24.  
  25. /* these are visible for select.c routine return values */
  26. #define SOCKESTABLISHED 1
  27. #define SOCKDATAREADY   2
  28. #define SOCKCLOSED      4
  29.  
  30. #if defined(__WATTCP_KERNEL__)
  31.  
  32. #define IP_TYPE     0x0008
  33.  
  34. /*
  35. #define DEBUG
  36. */
  37.  
  38. #include <stdio.h>
  39. #include <elib.h>
  40.  
  41. #define MAX_GATE_DATA 12
  42. #define MAX_STRING 50    /* most strings are limited */
  43. #endif  /* defined(__WATTCP_KERNEL__) */
  44.  
  45. #define MAX_NAMESERVERS 10
  46. #define MAX_COOKIES 10
  47.  
  48. #if defined(__WATTCP_KERNEL__)
  49.  
  50. #define MAXVJSA     1440 /* 10 s */
  51. #define MAXVJSD     360  /* 10 s */
  52. #define SAFETYTCP  0x538f25a3L
  53. #define SAFETYUDP  0x3e45e154L
  54. #define TRUE        1
  55. #define true        TRUE
  56. #define FALSE       0
  57. #define false       FALSE
  58.  
  59. #define EL_INUSE        0x0001
  60. #define EL_DELAY        0x0002
  61. #define EL_TCP          0x0004
  62. #define EL_SERVER       0x0008
  63. #define EL_ASCII        0x0010
  64. #define EL_NEVER        0x0020
  65.  
  66. /* These are Ethernet protocol numbers but I use them for other things too */
  67. #define UDP_PROTO  0x11
  68. #define TCP_PROTO  0x06
  69. #define ICMP_PROTO 0x01
  70.  
  71. #endif /* defined(__WATTCP_KERNEL__) */
  72.  
  73. #define TCP_MODE_BINARY  0       /* default mode */
  74. #define TCP_MODE_ASCII   1
  75. #define UDP_MODE_CHK     0       /* default to having checksums */
  76. #define UDP_MODE_NOCHK   2       /* turn off checksums */
  77. #define TCP_MODE_NAGLE   0       /* Nagle algorithm */
  78. #define TCP_MODE_NONAGLE 4
  79.  
  80. typedef unsigned long longword;     /* 32 bits */
  81. typedef unsigned short word;        /* 16 bits */
  82. typedef unsigned char byte;         /*  8 bits */
  83.  
  84. typedef struct { byte eaddr[6]; } eth_address;    // 94.11.19 -- made an array
  85.  
  86. #if defined(__WATTCP_KERNEL__)
  87.  
  88. /* undesirable */
  89. extern longword MsecClock();
  90. #define clock_ValueRough() MsecClock()
  91.  
  92. #define TICKS_SEC 18
  93.  
  94. #define checksum( p, len) inchksum( p, len )
  95.  
  96. #define PD_ETHER 1
  97. #define PD_SLIP  6
  98.  
  99. extern word sock_inactive;      /* in pcbootp.c */
  100. extern word _pktdevclass;
  101. extern word _mss;
  102. extern word _bootptimeout;    /* in pcbootp.c */
  103. extern longword _bootphost;    /* in pcbootp.c */
  104. extern word _bootpon;
  105.  
  106. /* The Ethernet header */
  107. typedef struct {
  108.     eth_address     destination;
  109.     eth_address     source;
  110.     word            type;
  111. } eth_Header;
  112.  
  113. /* The Internet Header: */
  114. typedef struct {
  115.     unsigned        hdrlen  : 4;
  116.     unsigned        ver     : 4;
  117.     byte        tos;
  118.     word            length;
  119.     word            identification;
  120.     word            frags;
  121.     byte        ttl;
  122.     byte        proto;
  123.     word            checksum;
  124.     longword        source;
  125.     longword        destination;
  126. } in_Header;
  127.  
  128.  
  129. #define in_GetVersion(ip) ( (ip)->ver )
  130. #define in_GetHdrlen(ip)  ( (ip)->hdrlen )  /* 32 bit word size */
  131. #define in_GetHdrlenBytes(ip)  ( in_GetHdrlen(ip) << 2 ) /* 8 bit byte size */
  132. #define in_GetTos(ip)      ( (ip)->tos)
  133.  
  134. #define in_GetTTL(ip)      ((ip)->ttl)
  135. #define in_GetProtocol(ip) ((ip)->proto )
  136.  
  137. typedef struct {
  138.     word        srcPort;
  139.     word        dstPort;
  140.     word        length;
  141.     word        checksum;
  142. } udp_Header;
  143.  
  144. #define UDP_LENGTH ( sizeof( udp_Header ))
  145.  
  146. typedef struct {
  147.     word            srcPort;
  148.     word            dstPort;
  149.     longword        seqnum;
  150.     longword        acknum;
  151.     word            flags;
  152.     word            window;
  153.     word            checksum;
  154.     word            urgentPointer;
  155. } tcp_Header;
  156.  
  157. #define tcp_FlagFIN     0x0001
  158. #define tcp_FlagSYN     0x0002
  159. #define tcp_FlagRST     0x0004
  160. #define tcp_FlagPUSH    0x0008
  161. #define tcp_FlagACK     0x0010
  162. #define tcp_FlagURG     0x0020
  163. #define tcp_FlagDO      0xF000
  164. #define tcp_GetDataOffset(tp) (intel16((tp)->flags) >> 12)
  165.  
  166. #endif /* defined(__WATTCP_KERNEL__) */
  167.  
  168. /* The TCP/UDP Pseudo Header */
  169. typedef struct {
  170.     longword    src;
  171.     longword    dst;
  172.     byte        mbz;
  173.     byte        protocol;
  174.     word        length;
  175.     word        checksum;
  176. } tcp_PseudoHeader;
  177.  
  178.  
  179. /* A datahandler for tcp or udp sockets */
  180. typedef int (*dataHandler_t)( void *s, byte *data, int len, tcp_PseudoHeader *pseudohdr, void *protohdr );
  181. /* A socket function for delay routines */
  182. typedef int (*sockfunct_t)( void *s );
  183.  
  184. #if defined(__WATTCP_KERNEL__)
  185. /*
  186.  * TCP states, from tcp manual.
  187.  * Note: close-wait state is bypassed by automatically closing a connection
  188.  *       when a FIN is received.  This is easy to undo.
  189.  */
  190. #define tcp_StateLISTEN  0      /* listening for connection */
  191. #define tcp_StateSYNSENT 1      /* syn sent, active open */
  192. #define tcp_StateSYNREC  2      /* syn received, synack+syn sent. */
  193. #define tcp_StateESTAB   3      /* established */
  194. #define tcp_StateESTCL   4      /* established, but will FIN */
  195. #define tcp_StateFINWT1  5      /* sent FIN */
  196. #define tcp_StateFINWT2  6      /* sent FIN, received FINACK */
  197. #define tcp_StateCLOSWT  7      /* received FIN waiting for close */
  198. #define tcp_StateCLOSING 8      /* sent FIN, received FIN (waiting for FINACK) */
  199. #define tcp_StateLASTACK 9      /* fin received, finack+fin sent */
  200. #define tcp_StateTIMEWT  10     /* dally after sending final FINACK */
  201. #define tcp_StateCLOSEMSL 11
  202. #define tcp_StateCLOSED  12     /* finack received */
  203.  
  204. #define tcp_MaxBufSize 2048         /* maximum bytes to buffer on input */
  205.  
  206. #endif
  207.  
  208.  
  209. #if defined(__WATTCP_KERNEL__)
  210. /*
  211.  * UDP socket definition
  212.  */
  213. typedef struct _udp_socket {
  214.     struct _udp_socket *next;
  215.     word        ip_type;        /* always set to UDP_PROTO */
  216.     char       *err_msg;        /* null when all is ok */
  217.     char           *usr_name;
  218.     void      (*usr_yield)( void );
  219.     byte            rigid;
  220.     byte            stress;
  221.     word        sock_mode;            /* a logical OR of bits */
  222.     longword        usertimer;        /* ip_timer_set, ip_timer_timeout */
  223.     dataHandler_t  dataHandler;
  224.     eth_address     hisethaddr;        /* peer's ethernet address */
  225.     longword        hisaddr;        /* peer's internet address */
  226.     word        hisport;        /* peer's UDP port */
  227.     longword        myaddr;
  228.     word        myport;
  229.     word            locflags;
  230.  
  231.     int             queuelen;
  232.     byte           *queue;
  233.  
  234.     int             rdatalen;           /* must be signed */
  235.     word            maxrdatalen;
  236.     byte           *rdata;
  237.     byte            rddata[ tcp_MaxBufSize + 1];         /* if dataHandler = 0, len == 512 */
  238.     longword        safetysig;
  239. } udp_Socket;
  240. #else /* __WATTCP_USER */
  241. /*
  242.  * Don't give users access to the fields.
  243.  */
  244. typedef struct {
  245.     byte undoc[ 2200 ];
  246. } udp_Socket;
  247. #endif /* __WATTCP_USER__ */
  248.  
  249. #if defined(__WATTCP_KERNEL__)
  250. /*
  251.  * TCP Socket definition
  252.  */
  253. typedef struct _tcp_socket {
  254.     struct _tcp_socket *next;
  255.     word        ip_type;        /* always set to TCP_PROTO */
  256.     char        *err_msg;
  257.     char           *usr_name;
  258.     void          (*usr_yield)(void);
  259.     byte            rigid;
  260.     byte            stress;
  261.     word        sock_mode;        /* a logical OR of bits */
  262.  
  263.     longword        usertimer;        /* ip_timer_set, ip_timer_timeout */
  264.     dataHandler_t   dataHandler;    /* called with incoming data */
  265.     eth_address     hisethaddr;     /* ethernet address of peer */
  266.     longword        hisaddr;        /* internet address of peer */
  267.     word            hisport;        /* tcp ports for this connection */
  268.     longword        myaddr;
  269.     word        myport;
  270.     word            locflags;
  271.  
  272.     int             queuelen;
  273.     byte           *queue;
  274.  
  275.     int             rdatalen;       /* must be signed */
  276.     word            maxrdatalen;
  277.     byte           *rdata;
  278.     byte            rddata[tcp_MaxBufSize+1];    /* received data */
  279.     longword        safetysig;
  280.     word        state;          /* connection state */
  281.  
  282.     longword        acknum;
  283.     longword        seqnum;         /* data ack'd and sequence num */
  284.     long            timeout;        /* timeout, in milliseconds */
  285.     byte            unhappy;        /* flag, indicates retransmitting segt's */
  286.     byte            recent;         /* 1 if recently transmitted */
  287.     word            flags;          /* tcp flags word for last packet sent */
  288.  
  289.     word        window;        /* other guy's window */
  290.     int         datalen;        /* number of bytes of data to send */
  291.                     /* must be signed */
  292.     int             unacked;        /* unacked data */
  293.  
  294.     byte        cwindow;        /* Van Jacobson's algorithm */
  295.     byte        wwindow;
  296.  
  297.     word        vj_sa;        /* VJ's alg, standard average */
  298.     word        vj_sd;        /* VJ's alg, standard deviation */
  299.     longword        vj_last;        /* last transmit time */
  300.     word        rto;
  301.     byte        karn_count;        /* count of packets */
  302.     byte            tos;            /* priority */
  303.     /* retransmission timeout proceedure */
  304.     /* these are in clock ticks */
  305.     longword        rtt_lasttran;       /* last transmission time */
  306.     longword        rtt_smooth;         /* smoothed round trip time */
  307.     longword        rtt_delay;          /* delay for next transmission */
  308.     longword        rtt_time;           /* time of next transmission */
  309.  
  310.     word            mss;
  311.     longword        inactive_to;           /* for the inactive flag */
  312.     int             sock_delay;
  313.  
  314.     byte            data[tcp_MaxBufSize+1]; /* data to send */
  315. } tcp_Socket;
  316. #else /* __WATTCP_USER */
  317. /*
  318.  * Don't give users access to the fields.
  319.  */
  320. typedef struct {
  321.     byte undoc[ 4300 ];
  322. } tcp_Socket;
  323. #endif /* __WATTCP_USER__ */
  324.  
  325. #if defined(__WATTCP_KERNEL__)
  326. /* sock_type used for socket io */
  327. typedef union {
  328.     udp_Socket udp;
  329.     tcp_Socket tcp;
  330. } sock_type;
  331. #else /* __WATTCP_USER__ */
  332. typedef void sock_type;
  333. #endif /* __WATTCP_USER__ */
  334.  
  335. /* similar to UNIX */
  336. typedef struct sockaddr {
  337.     word        s_type;
  338.     word        s_port;
  339.     longword    s_ip;
  340.     byte        s_spares[6];    /* unused in TCP realm */
  341. };
  342. #define sockaddr_in sockaddr
  343.  
  344.         /*
  345.          * TCP/IP system variables - do not change these since they
  346.          *      are not necessarily the source variables, instead use
  347.          *      ip_Init function
  348.          */
  349. extern longword my_ip_addr;
  350. extern longword sin_mask;       /* eg.  0xfffffe00L */
  351. extern word sock_delay;
  352.  
  353. #if defined(__WATTCP_KERNEL__)
  354. extern eth_address _eth_addr;
  355. extern eth_address _eth_brdcast;
  356. #endif
  357.  
  358.  
  359. #if defined(__WATTCP_KERNEL__)
  360. /*
  361.  * ARP definitions
  362.  */
  363. #define arp_TypeEther  0x100        /* ARP type of Ethernet address */
  364.  
  365. /* arp op codes */
  366. #define ARP_REQUEST 0x0100
  367. #define ARP_REPLY   0x0200
  368.  
  369. /*
  370.  * Arp header
  371.  */
  372. typedef struct {
  373.     word            hwType;
  374.     word            protType;
  375.     word            hwProtAddrLen;  // hw and prot addr len
  376.     word            opcode;
  377.     eth_address     srcEthAddr;
  378.     longword        srcIPAddr;
  379.     eth_address     dstEthAddr;
  380.     longword        dstIPAddr;
  381. } arp_Header;
  382.  
  383. #define ETH_MSS 1400  // MSS for Ethernet
  384.  
  385. byte *fragment( in_Header * ip );
  386. void timeout_frags( void );
  387.  
  388. #endif
  389.  
  390.  
  391. /*
  392.  * Ethernet interface -- pcsed.c
  393.  */
  394. void  _eth_init( void );
  395. byte *_eth_formatpacket( eth_address *eth_dest, word eth_type );
  396. int   _eth_send( word len );
  397. void  _eth_free( void *buf );
  398. byte *_eth_arrived( word *type_ptr );
  399. void  _eth_release( void );
  400. #if defined(__WATTCP_KERNEL__)
  401. extern void *_eth_hardware( byte *p );
  402. #endif
  403.  
  404.  
  405. /*
  406.  * timers -- pctcp.c
  407.  */
  408. void ip_timer_init( sock_type *s, int delayseconds );
  409. int ip_timer_expired( sock_type *s );
  410. longword MsecClock( void );
  411.  
  412.  
  413. /*
  414.  * sock_init()  -- initialize wattcp libraries -- sock_ini.c
  415.  */
  416. void sock_init(void);
  417. void sock_exit( void );   /* normally called via atexit() in sock_init() */
  418.  
  419.  
  420.         /*
  421.          * tcp_init/tcp_shutdown -- pctcp.c
  422.          *      - init/kill all tcp and lower services
  423.          *      - only call if you do not use sock_init
  424.          * (NOT RECOMMENDED)
  425.          */
  426. void tcp_shutdown(void);
  427. void tcp_init(void);
  428.  
  429. /*
  430.  * things you probably won't need to know about
  431.  */
  432.     /*
  433.      * sock_debugdump -- sock_dbu.c
  434.      *    - dump some socket control block parameters
  435.      * used for testing the kernal, not recommended
  436.      */
  437. void sock_debugdump( sock_type *s );
  438.         /*
  439.          * tcp_config - read a configuration file
  440.          *            - if special path desired, call after sock_init()
  441.          *            - null reads path from executable
  442.          * see sock_init();
  443.          */
  444. int tcp_config( char *path );
  445.         /*
  446.          * tcp_tick - called periodically by user application in sock_wait_...
  447.          *          - returns 1 when our socket closes
  448.          */
  449. int tcp_tick( sock_type *s );
  450.         /*
  451.          * Retransmitter - called periodically to perform tcp retransmissions
  452.          *          - normally called from tcp_tick, you have to be pretty
  453.          *            low down to use this one
  454.          */
  455. void tcp_Retransmitter(void);
  456.         /*
  457.          * tcp_set_debug_state - set 1 or reset 0 - depends on what I have done
  458.          */
  459. void tcp_set_debug_state( int x );
  460.  
  461. /*
  462.  * check for bugs -- pctcp.c
  463.  */
  464. int tcp_checkfor( sock_type *t );
  465.  
  466. /*
  467.  * Timeout routines.
  468.  */
  469. unsigned long set_timeout( unsigned int seconds );
  470. unsigned long set_ttimeout( unsigned int ticks );
  471. int chk_timeout( unsigned long timeout );
  472.  
  473. /*
  474.  * socket macros
  475.  */
  476.  
  477. /*
  478.  * sock_wait_established()
  479.  *    - waits then aborts if timeout on s connection
  480.  * sock_wait_input()
  481.  *    - waits for received input on s
  482.  * - may not be valid input for sock_gets... check returned length
  483.  * sock_tick()
  484.  *    - do tick and jump on abort
  485.  * sock_wait_closed();
  486.  *    - discards all received data
  487.  *
  488.  * jump to sock_err with contents of *statusptr set to
  489.  *     1 on closed
  490.  *    -1 on timeout
  491.  *
  492.  */
  493.  
  494. int _ip_delay0( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr );
  495. int _ip_delay1( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr);
  496. int _ip_delay2( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr);
  497.  
  498.  
  499. #if defined(__WATTCP_KERNEL__)
  500. #define set_mstimeout( x ) (set_timeout(0)+ (x / 55))
  501. #endif  /* defined(__WATTCP_KERNEL__) */
  502.  
  503. #define sock_wait_established( s, seconds, fn, statusptr ) \
  504.     if (_ip_delay0( s, seconds, fn, statusptr )) goto sock_err;
  505. #define sock_wait_input( s, seconds, fn , statusptr ) \
  506.     if (_ip_delay1( s, seconds, fn, statusptr )) goto sock_err;
  507. #define sock_tick( s, statusptr ) \
  508.     if ( !tcp_tick(s)) { *statusptr = 1 ; goto sock_err; }
  509. #define sock_wait_closed(s, seconds, fn, statusptr )\
  510.     if (_ip_delay2( s, seconds, fn, statusptr )) goto sock_err;
  511.  
  512. /*
  513.  * TCP or UDP specific stuff, must be used for open's and listens, but
  514.  * sock stuff is used for everything else -- pctcp.c
  515.  */
  516. int tcp_open( tcp_Socket *s, word lport, longword ina, word port, dataHandler_t datahandler );
  517. int udp_open( udp_Socket *s, word lport, longword ina, word port, dataHandler_t datahandler );
  518. int tcp_listen( tcp_Socket *s, word lport, longword ina, word port, dataHandler_t datahandler, word timeout );
  519. int tcp_established( tcp_Socket *s );
  520.  
  521. /*
  522.  * Clean up a string -- pctcp.c
  523.  */
  524. char *rip( char *s);
  525.  
  526. /*
  527.  * Name service / name lookup routines -- udp_dom.c
  528.  */
  529. longword resolve( char *name );
  530. int reverse_addr_lookup( longword ipaddr, char *name );
  531.  
  532. /*
  533.  * less general functions
  534.  */
  535. longword intel( longword x );
  536. word intel16( word x );
  537. longword MsecClock( void );
  538.  
  539. /*
  540.  * Ctrl-break handling -- pc_cbrk.c
  541.  */
  542. void tcp_cbrk( int mode );
  543.  
  544. void outs( char far * string );
  545.  
  546. #if defined(__WATTCP_KERNEL__)
  547. /* icmp handler -- pcicmp.c */
  548. int icmp_handler( in_Header *ip );
  549. #endif
  550.  
  551.  
  552. /*
  553.  * ARP -- pcarp.c
  554.  */
  555. #if defined(__WATTCP_KERNEL__)
  556. void _arp_add_gateway( char *data, longword ip );
  557. int _arp_handler( arp_Header *in );
  558. #endif
  559. void _arp_register( longword use, longword instead_of );
  560. void _arp_tick( longword ip );      /* kernel only? */
  561. int _arp_resolve( longword ina, eth_address *ethap, int nowait );
  562.  
  563.  
  564.  
  565. /*
  566.  * Packet -- pcpkt.c
  567.  *
  568.  * These probably shouldn't be visible to user app code.
  569.  */
  570. eth_address *_pkt_eth_init( void );
  571. int pkt_send( char *buffer, int length );
  572. void pkt_buf_wipe( void );
  573. void pkt_buf_release( char *ptr );
  574. void * pkt_received( void );
  575. void pkt_release( void );
  576.  
  577. #if defined(__WATTCP_KERNEL__)
  578. void _add_server( int *counter, int max, longword *array, longword value );
  579. extern word debug_on;
  580. #endif
  581.  
  582.  
  583. /*
  584.  * pcbsd.c
  585.  */
  586. int _chk_socket( sock_type *s );
  587. char *inet_ntoa( char *s, longword x );
  588. longword inet_addr( char *s );
  589. char *sockerr( sock_type *s );
  590. char *sockstate( sock_type *s );
  591. longword gethostid( void );
  592. longword sethostid( longword ip );
  593. word ntohs( word a );
  594. word htons( word a );
  595. longword ntohl( longword x );
  596. longword htonl( longword x );
  597.  
  598.  
  599. #if defined(__WATTCP_KERNEL__)
  600. void *_tcp_lookup( longword hisip, word hisport, word myport );
  601.  
  602. void _tcp_cancel( in_Header *ip, int code, char *msg, longword dummyip );
  603. void _udp_cancel( in_Header *ip );
  604.  
  605. int _dobootp(void);
  606. #endif
  607.  
  608.  
  609. /*
  610.  * General socket I/O -- pctcp.c
  611.  */
  612. word sock_mode( sock_type *, word);        /* see TCP_MODE_... */
  613. void sock_abort( sock_type *);
  614. void tcp_sendsoon( tcp_Socket *s );
  615. int sock_fastwrite( sock_type *, byte *, int );
  616. int sock_write( sock_type *, byte *, int );
  617. int sock_read( sock_type *, byte *, int );
  618. int sock_fastread( sock_type *, byte *, int );
  619. int sock_gets( sock_type *, byte *, int );
  620. void sock_close( sock_type *s );
  621.  
  622. byte sock_putc( sock_type  *s, byte c );
  623. int sock_getc( sock_type  *s );
  624. int sock_puts( sock_type  *s, byte *dp );
  625. int sock_gets(sock_type *, byte *, int );
  626.  
  627. int sock_setbuf( sock_type *s, byte *dp, int len );
  628.  
  629. int sock_yield( tcp_Socket *s, void (*fn)( void ) );
  630.  
  631.  
  632. /*
  633.  *   s is the pointer to a udp or tcp socket
  634.  */
  635.  
  636.  
  637. /*
  638.  * Socket text output/input routines -- sock_prn.c
  639.  */
  640. int sock_printf( sock_type  *s, char *format, ... );
  641. int sock_scanf( sock_type  *s, char *format, ... );
  642.  
  643.  
  644. /*
  645.  * Misc. socket I/O -- pctcp.c
  646.  */
  647. int sock_setbuf( sock_type *s, byte *dp, int len );
  648. int sock_enqueue( sock_type  *s, byte *dp, int len );
  649. void sock_noflush( sock_type *s );
  650. void sock_flush( sock_type  *s );
  651. void sock_flushnext( sock_type  *s);
  652. int sock_dataready( sock_type  *s );
  653. int sock_established( sock_type *s );
  654. void sock_sturdy( sock_type *s, int level );
  655.  
  656.  
  657. /*
  658.  * Debug output -- pcdbug.c
  659.  */
  660. void db_write( char *msg );
  661. void db_open( void );
  662. void db_close( void );
  663. void dbug_printf( char *, ... );
  664. void dbug_init( void );
  665. void dbug_init( void );
  666.  
  667.  
  668.  
  669. /*
  670.  * Socket Select -- select.c
  671.  */
  672. int sock_sselect( sock_type *s, int waitstate );
  673.  
  674.  
  675.  
  676. /*
  677.  * recv routines -- pcrecv.c
  678.  */
  679. int sock_recv_init( sock_type *s, void *space, word len );
  680. int sock_recv_from( sock_type *s, long *hisip, word *hisport, char *buffer, int len, word flags );
  681. int sock_recv( sock_type *s, char *buffer, int len, word flags );
  682.  
  683.  
  684. /*
  685.  * bsd-similar stuff -- pcbuf.c
  686.  */
  687. int sock_rbsize( sock_type *s );
  688. int sock_rbused( sock_type *s );
  689. int sock_rbleft( sock_type *s );
  690. int sock_tbsize( sock_type *s );
  691. int sock_tbused( sock_type *s );
  692. int sock_tbleft( sock_type *s );
  693. int sock_preread( sock_type *s, byte *dp, int len );
  694.  
  695.  
  696. /*
  697.  * Name conversion stuff -- udp_nds.c
  698.  */
  699. longword aton( char *text );
  700. int isaddr( char *text );
  701.  
  702. /*
  703.  * Configuration -- pcconfig.c
  704.  */
  705. char *_inet_atoeth( char *src, byte *eth );
  706. void _add_server( int *counter, int max, longword *array, longword value );
  707. int tcp_config( char *path );
  708.  
  709.         /*
  710.          * name domain constants
  711.          */
  712.  
  713. extern char *def_domain;
  714. extern longword def_nameservers[ MAX_NAMESERVERS ];
  715.  
  716. extern word wathndlcbrk;
  717. extern word watcbroke;
  718.  
  719. /* user initialization file */
  720. extern void (*usr_init)(char *name, char *value);
  721.  
  722. extern int _survivebootp;
  723.  
  724. extern int _last_cookie;
  725. extern longword _cookie[MAX_COOKIES];
  726.  
  727. extern int _last_nameserver;
  728. extern char *_hostname;
  729.  
  730. /*
  731.  * Elib stuff
  732.  */
  733. int isstring( char *string, unsigned stringlen );     /* isstring.c */
  734.  
  735.  
  736.  
  737. #endif /* ndef _wattcp_wattcp_h */
  738.