home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / NETWORK / TEL23SRC.ZIP / INCLUDE / LTALK.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-29  |  15.3 KB  |  462 lines

  1. /*
  2.  * National Center for Supercomputing Applications (NCSA) Telnet source code
  3.  * 
  4.  * February 10, 1989
  5.  * (C) Copyright 1989 Planning Research Corporation
  6.  *
  7.  * Permission is granted to any individual or institution to use, copy,
  8.  * modify, or redistribute this software and its documentation provided this
  9.  * notice and the copyright notices are retained.  This software may not be
  10.  * distributed for profit, either in original form or in derivative works.
  11.  * Planning Research Corporation makes no representations about the
  12.  * suitability of this software for any purpose.
  13.  * 
  14.  * PLANNING RESEARCH CORPORATION GIVES NO WARRANTY, EITHER EXPRESS OR IMPLIED,
  15.  * FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT
  16.  * LIMITATION, WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A
  17.  * PARTICULAR PURPOSE.
  18.  */
  19.  
  20. /*
  21.  * LTalk.h - Typedef's and equates for the PC AppleTalk driver.  
  22.  * 
  23.  * Copied from Appendix A of "AppleTalk PC Card and Driver Preliminary Note",
  24.  * Final Draft 3 August, 1987, ADPA #KMB014, with corrections from the body of
  25.  * the document.
  26.  */
  27.  
  28. /*
  29.  * Revision History:
  30.  * 
  31.  * Date        Initials    Comment
  32.  * ----        --------    -------
  33.  * 02-10-89    JGN@PRC        Initial version.
  34.  * 
  35.  * Initials    Name        Organization
  36.  * --------    ----        ------------
  37.  * JGN@PRC    Jim Noble    Planning Research Corporation
  38.  */
  39.  
  40. #ifndef LTALK_H
  41. #define LTALK_H
  42.  
  43. typedef    int        (*CPTR)();
  44. typedef char  *DPTR;
  45.  
  46. #define AsyncMask        0x8000
  47.  
  48. typedef struct AddrBlk {
  49.     unsigned int    network;    /* network number */
  50.     unsigned char    nodeid;        /* node number */
  51.     unsigned char    socket;        /* socket number */
  52. } AddrBlk;
  53.  
  54. /*
  55.  * Equates/typedefs for ATGetNetInfo/ATInit/ATKill
  56.  */
  57.  
  58. typedef struct InfoParams {
  59.     int            atd_command;    /* command code */
  60.     int            atd_status;    /* status word/error return */
  61.     CPTR        atd_compfun;    /* completion routine or zero */
  62.     int            inf_network;    /* network number or zero */
  63.     unsigned char    inf_nodeid;    /* current node number or zero */
  64.     unsigned char    inf_abridge;    /* node number of a bridge or zero */
  65.     int            inf_config;    /* configuration mask for driver */
  66.     DPTR        inf_bptr;    /* segment:offset of buffer for error */
  67.                     /* info */
  68.     int            inf_buffsize;    /* size of buffer */
  69. } InfoParams;
  70.  
  71. typedef struct ATErrorStatus {
  72.     int            bufflen;    /* number of valid bytes in buffer */
  73.     long        packets;    /* number of packets received */
  74.     long        crcerrs;    /* number of CRC errors detected */
  75.     long        overruns;    /* number of overruns detected */
  76.     long        deferrals;    /* number of deferrals detected */
  77.     long        collisions;    /* number of collisions detected */
  78.     long        tossed;        /* number of packets tossed */
  79.     long        mem_free;    /* number of Bytes of Free Memory */
  80.     long        largest_mem;    /* Largest contiguous chunk of memory */
  81.                     /* available */
  82.     long        int_bytes;    /* number of bytes used by driver */
  83.     long        ext_bytes;    /* number of bytes used by external aps */
  84. } ATErrorStatus;
  85.  
  86. #define ATInit            1
  87. #define ATKill            2
  88. #define ATGetNetInfo        3
  89.  
  90. /*
  91.  * Equates/typedefs for Timer Calls
  92.  */
  93.  
  94. typedef struct TimerParams {
  95.     int            atd_command;    /* command code */
  96.     int            atd_status;    /* status word/error return */
  97.     CPTR        atd_compfun;    /* completion (timer) routine or zero */
  98.     long        tmr_ticks;    /* timer ticks (since init.) */
  99.     int            tmr_time;    /* number of 1/3 seconds to wait */
  100.     struct TimerParams  *
  101.             tmr_params;    /* address of another parameter block */
  102. } TimerParams;
  103.  
  104. #define ATGetClockTicks        4
  105. #define ATStartTimer        5
  106. #define ATResetTimer        6
  107. #define ATCancelTimer        7
  108.  
  109. /*
  110.  * Equates/typedefs for LAP Protocol
  111.  */
  112.  
  113. typedef struct LAPParams {
  114.     int            atd_command;    /* command code */
  115.     int            atd_status;    /* status word/error return */
  116.     CPTR        atd_compfun;    /* completion routine or zero */
  117.     int            lap_fl1;    /* filler word */
  118.     unsigned char    lap_destnode;    /* destination node number */
  119.     int            lap_fl2;    /* filler word */
  120.     unsigned char    lap_type;    /* LAP type for header */
  121.     DPTR        lap_bptr;    /* segment:offset of buffer area or */
  122.                     /* protocol handler (LAPInstall) */
  123.     int            lap_buffsize;    /* size of buffer area */
  124. } LAPParams;
  125.  
  126. #define LAPInstall        0x10
  127. #define LAPRemove        0x11
  128. #define LAPWrite        0x12
  129. #define LAPRead            0x13
  130. #define LAPCancel        0x14
  131.  
  132. /*
  133.  * Equates/typedefs for DDP Protocol
  134.  */
  135.  
  136. typedef struct DDPParams {
  137.     int            atd_command;    /* command code */
  138.     int            atd_status;    /* status word/error return */
  139.     CPTR        atd_compfun;    /* completion routine or zero */
  140.     AddrBlk        ddp_addr;    /* destination address of packet */
  141.     unsigned char    ddp_socket;    /* socket for command */
  142.     unsigned char    ddp_type;    /* DDP type for header */
  143.     DPTR        ddp_bptr;    /* segment:offset of buffer area or */
  144.                     /* socket listener (DDPOpenSocket) */
  145.     int            ddp_buffsize;    /* size of buffer area */
  146.     unsigned char    ddp_chksum;    /* checksum flag */
  147. } DDPParams;
  148.  
  149. #define DDPOpenSocket        0x20
  150. #define DDPCloseSocket        0x21
  151. #define DDPWrite        0x22
  152. #define DDPRead            0x23
  153. #define DDPCancel        0x24
  154.  
  155. /*
  156.  * Equates/typedefs for NBP Protocol
  157.  */
  158.  
  159. typedef struct NBPTuple {
  160.     AddrBlk        tup_address;
  161.     char        tup_enum;
  162.     char        tup_entname[99];
  163. } NBPTuple;
  164.  
  165. typedef struct NBPTabEntry {
  166.     struct NBPTabEntry
  167.         *tab_nxtentry;
  168.     NBPTuple
  169.         tab_tuple;
  170. } NBPTabEntry;
  171.  
  172. typedef struct NBPParams {
  173.     int            atd_command;    /* command code */
  174.     int            atd_status;    /* status word/error return */
  175.     CPTR        atd_compfun;    /* completion routine or zero */
  176.     AddrBlk        nbp_addr;    /* for confirm, original address */
  177.     int            nbp_toget;    /* number of matches to get/were found */
  178.     DPTR        nbp_bptr;    /* segment:offset of buffer area */
  179.     int            nbp_buffsize;    /* size of buffer area */
  180.     unsigned char    nbp_interval;    /* interval (seconds) between retries */
  181.     unsigned char    nbp_retry;    /* number of tries */
  182.     DPTR        nbp_entptr;    /* segment:offset of entity name */
  183. } NBPParams;
  184.  
  185. #define NBPRegister        0x30
  186. #define NBPRemove        0x31
  187. #define NBPLookup        0x32
  188. #define NBPConfirm        0x33
  189. #define NBPCancel        0x34
  190.  
  191. /*
  192.  * Equates/typedefs for ZIP Protocol
  193.  */
  194.  
  195. typedef struct ZIPParams {
  196.     int            atd_command;    /* command code */
  197.     int            atd_status;    /* status word/error return */
  198.     CPTR        atd_compfun;    /* completion routine or zero */
  199.     long        zip_fl;    /* filler dword */
  200.     int            zip_zones;    /* number of zone names in returned list */
  201.     DPTR        zip_bptr;    /* segment:offset of buffer area */
  202.     int            zip_buffsize;    /* size of buffer area */
  203. } ZIPParams;
  204.  
  205. #define ZIPGetZoneList        0x35
  206. #define ZIPGetMyZone        0x36
  207.  
  208. /*
  209.  * Equates/typedefs for ATP Protocol
  210.  */
  211.  
  212. typedef struct BDSElement {
  213.     DPTR        bds_bptr;    /* segment:offset of data buffer */
  214.     int            bds_buffsize;    /* size of data buffer in bytes */
  215.     int            bds_datasize;    /* amount of data put in header */
  216.     char        bds_usrbytes[4];/* four bytes for ATP header */
  217. } BDSElement;
  218.  
  219. typedef struct ATPParams {
  220.     int            atd_command;    /* command code */
  221.     int            atd_status;    /* status word/error return */
  222.     CPTR        atd_compfun;    /* completion routine or zero */
  223.     AddrBlk        atp_addr;    /* embedded address block */
  224.     char        atp_socket;    /* socket associated with this transaction */
  225.     char        atp_fl;    /* filler byte */
  226.     DPTR        atp_bptr;    /* segment:offset of request data buffer */
  227.     int            atp_buffsize;    /* amount of data at above address */
  228.     char        atp_interval;    /* interval (seconds) between tries */
  229.     char        atp_retry;    /* number of times to try request */
  230.     char        atp_flags;    /* control info  (XO, etc.) */
  231.                     /* (NoRelease = 02H) */
  232.     char        atp_seqbit;    /* bitmap, sequence info */
  233.     int            atp_tranid;    /* transaction ID */
  234.     char        atp_userbytes[4];/* four user bytes for ATP header */
  235.     char        atp_bdsbuffs;    /* number of BDSElements at atp_bdsptr */
  236.     char        atp_bdsresps;    /* number of responses at atp_bdsptr */
  237.     struct BDSElement *
  238.             atp_bdsptr;    /* segment:offset of BDS for responses */
  239. } ATPParams;
  240.  
  241. #define ChkSum            0x01
  242. #define STSbit            0x08
  243. #define EOMbit            0x10
  244. #define XObit            0x20
  245.  
  246. #define ATPOpenSocket        0x40
  247. #define ATPCloseSocket        0x41
  248. #define ATPSndRequest        0x42
  249. #define ATPGetRequest        0x43
  250. #define ATPSendResponse        0x44
  251. #define ATPAddResponse        0x45
  252. #define ATPCanTrans        0x46
  253. #define ATPCanResponse    0x47
  254. #define ATPCnRequest    0x48
  255. #define ATPRespond        0x49
  256.  
  257. /*
  258.  * Equates/typedefs for PAP Protocol
  259.  */
  260.  
  261. typedef struct PAPStatusRec {
  262.     long        psr_system;    /* internal PAP information */
  263.     char        psr_status[256];/* printer-dependent status string */
  264. } PAPStatusRec;
  265.  
  266. typedef struct PAPParams {
  267.     int            atd_command;    /* command code */
  268.     int            atd_status;    /* status word/error return */
  269.     CPTR        atd_compfun;    /* completion routine or zero */
  270.     AddrBlk        pap_addr;    /* address for status, open calls */
  271.     int            pap_refnum;    /* reference number for connection */
  272.     DPTR        pap_bptr;    /* segment:offset of buffer area */
  273.     int            pap_buffsize;    /* size of buffer area */
  274.     unsigned char    pap_eof;    /* end-of-file indicator */
  275.     unsigned char    pap_srefnum;    /* server reference number */
  276.     DPTR        pap_entptr;    /* segment:offset of entity name */
  277. } PAPParams;
  278.  
  279. #define PAPOpen            0x70
  280. #define PAPClose        0x71
  281. #define PAPRead            0x72
  282. #define PAPWrite        0x73
  283. #define PAPStatus        0x74
  284. #define    PAPRegName        0x75
  285. #define PAPRemName        0x76
  286. #define PAPInit            0x77
  287. #define PAPNewStatus        0x78
  288. #define PAPGetNextJob        0x79
  289. #define PAPKill            0x7a
  290. #define PAPCancel        0x7b
  291. #define PAPXStatus        0x7c
  292.  
  293. /*
  294.  * Equates/typedefs for ASP Protocol
  295.  */
  296.  
  297. typedef struct ASPParams {
  298.     int            atd_command;    /* command code */
  299.     int            atd_status;    /* status word/error return */
  300.     CPTR        atd_compfun;    /* completion routine or zero */
  301.     int            asp_maxcmdsize;    /* maximum size of command block */
  302.     int            asp_quantum;    /* maximum data for reply or write */
  303. } ASPParams;
  304.  
  305. typedef struct ASPWksParams {
  306.     int            atd_command;    /* command code */
  307.     int            atd_status;    /* status word/error return */
  308.     CPTR        atd_compfun;    /* completion routine or zero */
  309.     long        aspw_cresult;    /* result code from server */
  310.     int            aspw_sesrefnum;    /* reference number for session */
  311.     unsigned char    aspw_interval;    /* period of interval timer */
  312.     unsigned char    aspw_retry;    /* number of retries to be made */
  313.     DPTR        aspw_cmdblock;    /* command buffer pointer */
  314.     int            aspw_cblocksize;/* size of command block */
  315.     DPTR        aspw_breply;    /* address of reply buffer */
  316.     int            aspw_replysize;    /* size of reply buffer */
  317.     int            aspw_actreply;    /* actual size of reply data */
  318.     DPTR        aspw_bwrite;    /* address of write buffer */
  319.     int            aspw_writesize;    /* size of write buffer */
  320.     int            aspw_byteswritten;/* actual number of bytes written */
  321. } ASPWksParams;
  322.  
  323. #define ASPGetParms        0x50
  324. #define ASPCloseSession        0x51
  325. #define ASPCancel        0x52
  326.  
  327. #define ASPGetStatus        0x5d
  328. #define ASPOpenSession        0x5e
  329. #define ASPCommand        0x5f
  330. #define ASPWrite        0x60
  331. #define ASPGetAttention        0x61
  332.  
  333. /*
  334.  * Equates for Error Codes
  335.  */
  336.  
  337. #define NOERR            0    /* No errors yet encountered */
  338. #define MAXCOLISERR        -1    /* Too many collisions detected */
  339. #define MAXDEFERERR        -2    /* 32 deferrals encountered (ALAP) */
  340.  
  341. #define LAP_LENERR        -30    /* LAP data too long */
  342. #define LAP_TYPERR        -31    /* Bad LAP type */
  343. #define TABFULLERR        -32    /* No more LAP protocols available */
  344. #define LAP_NOTFND        -33    /* LAP type not found in internal */
  345.                         /* protocol table */
  346. #define LAP_CANCELLED        -34    /* LAP command has been cancelled */
  347. #define DDP_SKTERR        -40    /* Used unopen socket */
  348. #define DDP_LENERR        -41    /* DDP data too long */
  349. #define NOBRDGERR        -42    /* No bridge found */
  350. #define DDP_CANCELLED        -43    /* DDP transaction cancelled */
  351.  
  352. #define ATP_REQFAILED        -100    /* No response received */
  353. #define ATP_NOSENDRESP        -101    /* Original socket not found */
  354. #define ATP_BADSOCKET        -102    /* ATP socket not found */
  355. #define ATP_NORELEASE        -103    /* No release received on ATP request */
  356. #define ATP_OVERFLOW        -104    /* Too much response data */
  357. #define ATP_CANCELLED        -105    /* Transaction cancelled */
  358. #define ATP_NO_IDS        -106    /* No more transaction IDs for ATP */
  359.  
  360. #define NO_MEM_ERROR        -120    /* Not enough memory to perform */
  361.                         /* requested operation */
  362. #define BAD_PARAMETER        -121    /* Illegal parameter or parameters */
  363. #define STACKERROR        -122    /* Too many levels of nesting to */
  364.                         /* complete call */
  365. #define ATNOTINITIALIZED    -123    /* Driver not initialized */
  366. #define CALLNOTSUPPORTED    -124    /* Requested call not supported */
  367. #define HARDWARE_ERROR        -125    /* Unrecoverable hardware error */
  368. #define SOFTWARE_ERROR        -126    /* Internal software error. */
  369.                         /* Reinitialize driver */
  370. #define MEMORY_CORRUPTED    -127    /* Internal memory pool corrupted. */
  371.                         /* Reload driver */
  372. #define BAD_SYNC_CALL        -128    /* Synchronous command was called at */
  373.                         /* a time when the driver cannot */
  374.                         /* handle it */
  375.  
  376. #define NBP_NEWSOCKET        -200    /* New entity address on confinn */
  377. #define NBP_NOCONFIRM        -201    /* Entity not found on confirm */
  378. #define NAME_IN_USE        -202    /* Name already in use */
  379. #define NBP_NO_ROOM        -203    /* Buffer overflow */
  380. #define BAD_NAME        -204    /* Illegal entity name */
  381. #define NBP_NOTFOUND        -205    /* Name not found */
  382. #define NBP_CANCELLED        -206    /* NBP comrnand cancelled */
  383. #define NBP_NO_IDS        -207    /* No more IDs for NBP */
  384.  
  385. #define TMR_NOTFOUND        -215    /* Timer structure not found */
  386. #define TMR_CANCELLED        -216    /* Timer command cancelled */
  387.  
  388. #define PAP_BADCONNID        -300    /* Invalid connection reference */
  389.                         /* number */
  390. #define PAP_NOCONNIDS        -301    /* No more connections available */
  391. #define PAP_DIED        -302    /* Connection died */
  392. #define PAP_LENERR        -303    /* Data length too large */
  393. #define PAP_WRITE_ACTIVE    -310    /* Write already active on stream */
  394. #define PAP_READ_ACIIVE        -311    /* Read already active on stream */
  395.  
  396. #define ASP_DIED        -401    /* ASP session tickle timer expired */
  397. #define ASP_CANCELLED        -402    /* ASP command was cancelled */
  398. #define ASP_BADCONNID        -403    /* ASP session reference number does */
  399.                         /* not exist */
  400.  
  401.  
  402. /***************************************/
  403. /*  ARP packet structure for telnet
  404. */
  405.  
  406. /*
  407.  * atalk.h - AppleTalk conversion structures.....
  408.  */
  409.  
  410. #define ATADDLEN    4
  411. #define ATHTYPE        3            /* AppleTalk type */
  412.  
  413. /*
  414.  * AppleTalk Listener Interface structure
  415.  */
  416.  
  417. #define    AIP        22
  418. #define AARP    23
  419.  
  420. struct aTalk {
  421.     short    count;
  422.     unsigned char
  423.             dest[ATADDLEN],    /* where the packet is going */
  424.              me[ATADDLEN],
  425.             type, paddingchars[3];        /* Give an even length so we will be at even */
  426.     };
  427.  
  428. typedef struct aTalk ATdlayer;
  429.  
  430.  
  431. /*
  432.  * Here is the ARP packet structure  -  ATplummer
  433.  */
  434.  
  435. struct ATplummer {
  436.     ATdlayer d;                 /* data link layer packet header */
  437.  
  438.     unsigned short hrd,            /* hardware type, Ethernet = 1 */
  439.             pro;            /* protocol type to resolve for */
  440.     unsigned char    
  441.             hln,            /* byte length of hardware addr = 6 for ETNET */
  442.             pln;            /* byte length of protocol = 4 for IP */
  443.     unsigned short op;            /* opcode, request = 1, reply = 2, RARP = 3,4 */
  444.     unsigned char
  445.             sha[ATADDLEN],
  446.             spa[4],
  447.             tha[ATADDLEN],
  448.             tpa[4];
  449. /*
  450. *   the final four fields (contained in 'rest') are:
  451. *      sender hardware address:   sha       hln bytes
  452. *      sender protocol address:   spa       pln bytes
  453. *      target hardware address:   tha       hln bytes
  454. *      target protocol address:   tpa       pln bytes
  455. */
  456.         char dummy[8];                /* for overrun */
  457. };
  458.  
  459. typedef struct ATplummer ATARPKT;
  460.  
  461. #endif
  462.