home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / sys / h / dcistructs < prev    next >
Encoding:
Text File  |  1995-10-11  |  9.1 KB  |  321 lines

  1. /* -*-C-*-
  2.  *
  3.  * $Header: /ax/networking:include/sys/dcistructs.h:networking  1.11  $
  4.  * $Source: /ax/networking:include/sys/dcistructs.h: $
  5.  *
  6.  * dcistructs.h - data structures used in the DCI interface
  7.  *
  8.  * Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
  9.  *
  10.  * $Log:    dcistructs.h,v $
  11.  * Revision 1.11  95/10/11  12:17:56  pwain
  12.  * Removed st_net_error from the stats structure.
  13.  * This should have been removed a while back
  14.  * according to Borris.
  15.  *
  16.  * Revision 1.10  95/09/18  13:24:06  kwelton
  17.  * Added definitions for st_link_status (in stats structure) bits.
  18.  *
  19.  * Revision 1.9  95/09/07  13:00:16  kwelton
  20.  * Added two new flags for virtual interfaces.
  21.  *
  22.  * Revision 1.8  95/03/21  14:10:46  kwelton
  23.  * Added copy of Inquire flags to struct dib.  DCI version is now 4.03.
  24.  *
  25.  * Revision 1.7  95/03/16  14:19:39  kwelton
  26.  * Added details of new InternetStatus service call.
  27.  *
  28.  * Revision 1.6  95/03/14  14:44:19  kwelton
  29.  * DCI version is now 4.02
  30.  *
  31.  * Revision 1.5  95/03/01  12:12:31  kwelton
  32.  * A few minor changes, plus the definition of the "standard" stats.
  33.  * structure.
  34.  *
  35.  * Revision 1.4  95/02/03  15:27:47  kwelton
  36.  * Added a new error number: INETERR_FILTERGONE, used by the Filter SWI
  37.  * when a given frame type has already been claimed.
  38.  *
  39.  * Revision 1.3  95/01/24  16:32:26  kwelton
  40.  * Fixed the definition of GETDCI4ERRNO, which should now cope with all
  41.  * errors returned from a SWI.
  42.  *
  43.  * Revision 1.2  95/01/12  21:53:53  kwelton
  44.  * The original scheme of returning UNIX style errors numbers as
  45.  * an offset within an error block broke any application that was
  46.  * looking for specific errors which effectively used to be offset
  47.  * from zero.
  48.  *
  49.  * Revision 1.1  95/01/11  10:19:03  kwelton
  50.  * Initial revision
  51.  *
  52.  */
  53.  
  54. #if !defined(__sys_dcistructs_h)
  55. #define __sys_dcistructs_h
  56.  
  57. #define DCIVERSION    403
  58.  
  59. /*
  60.  * DCI 4 service calls
  61.  */
  62. #define Service_EnumerateNetworkDrivers    0x9b
  63. #define Service_DCIDriverStatus        0x9d
  64. #define Service_DCIFrameTypeFree    0x9e
  65. #define Service_DCIProtocolStatus    0x9f
  66.  
  67. /*
  68.  * Internet specific service calls and reason codes
  69.  */
  70. #define Service_InternetStatus        0xb0
  71. #define InternetStatus_AddressChanged    0x00
  72.  
  73. #ifndef Service_PreReset
  74. # define Service_PreReset        0x45
  75. #endif
  76.  
  77. #ifndef Service_MessageFileClosed
  78. # define Service_MessageFileClosed    0x5e
  79. #endif
  80.  
  81. /*
  82.  * official DCI4 error block.
  83.  *
  84.  * the bottom 128 bytes are used to hold UNIX style error
  85.  * numbers, e.g. 12 = ENOMEM, 65 = EHOSTUNREACH.  the top
  86.  * 128 bytes hold various special error numbers
  87.  *
  88.  * 950112 KWelton
  89.  *
  90.  * Of course, the problem with this scheme is that applications
  91.  * are used to the old (pre-DI4) internet modules which returned
  92.  * a limited set of error numbers, offset from zero.  For the time
  93.  * being, SETDCI4ERRNO should also offset numbers from zero,
  94.  * GETDCI4ERRNO can already cope with both offsets.
  95.  *
  96.  * In addition, GETDCI4ERRNO should not convert Internet specific
  97.  * errors to UNIX style error numbers.
  98.  */
  99. #define DCI4ERRORBLOCK        (0x20e00)
  100. #define SPECIFICOFFSET        (0x80)
  101. #define SPECIFICERRORBASE    (DCI4ERRORBLOCK + SPECIFICOFFSET)
  102.  
  103. #if 0
  104. # define SETDCI4ERRNO(x, y)    ((x) = DCI4ERRORBLOCK + ((y) & 0x7f))
  105. # define REALLYSETDCI4ERRNO(x, y) ((x) = DCI4ERRORBLOCK + ((y) & 0x7f))
  106. #else
  107. # define SETDCI4ERRNO(x, y)    ((x) = ((y) & 0x7f))
  108. # define REALLYSETDCI4ERRNO(x, y) ((x) = DCI4ERRORBLOCK + ((y) & 0x7f))
  109. #endif
  110.  
  111. #define GETDCI4ERRNO(x)        ((((x) & ~0xff) != DCI4ERRORBLOCK) ? \
  112.                  (x) : \
  113.                  (((x) & 0xff) < SPECIFICOFFSET) ? \
  114.                  ((x) & 0x7f) : (x))
  115.  
  116. /*
  117.  * define Internet specific errors
  118.  */
  119. #define INETERR_IFBAD        (SPECIFICERRORBASE + 0)
  120. #define INETERR_MMBAD        (SPECIFICERRORBASE + 1)
  121. #define INETERR_NOMM        (SPECIFICERRORBASE + 2)
  122. #define INETERR_PANICED        (SPECIFICERRORBASE + 3)
  123. #define INETERR_BADCLI        (SPECIFICERRORBASE + 4)
  124. #define INETERR_MLCFAIL        (SPECIFICERRORBASE + 5)
  125. #define INETERR_TXBLOCKED    (SPECIFICERRORBASE + 6)
  126. #define INETERR_FILTERGONE    (SPECIFICERRORBASE + 7)
  127. #define INETERR_INVALIDSWI    (SPECIFICERRORBASE + 8)
  128.  
  129. /*
  130.  * offsets into driver's SWI chunk
  131.  */
  132. #define DCI4Version        0
  133. #define DCI4Inquire        1
  134. #define DCI4GetNetworkMTU    2
  135. #define DCI4SetNetworkMTU    3
  136. #define DCI4Transmit        4
  137. #define DCI4Filter        5
  138. #define DCI4Stats        6
  139.  
  140. /*
  141.  * network slot for Service_FindNetworkDriver
  142.  */
  143. typedef struct slot
  144. {
  145.     unsigned int sl_slotid:8,
  146.          sl_minor:8,
  147.          sl_pcmciaslot:5,
  148.          sl_mbz:11;
  149. } Slot, *SlotRef;
  150.  
  151. /*
  152.  * Driver Information Block
  153.  */
  154. typedef struct dib
  155. {
  156.     unsigned int   dib_swibase;        /* base of driver's SWI chunk */
  157.     unsigned char *dib_name;        /* pointer to name of driver */
  158.     unsigned int   dib_unit;        /* unit number */
  159.     unsigned char *dib_address;        /* interface's h/w address */
  160.     unsigned char *dib_module;        /* title of driver module */
  161.     unsigned char *dib_location;    /* description of interface position */
  162.     Slot           dib_slot;        /* physical location of interface */
  163.     unsigned int   dib_inquire;        /* copy of flags from Inquire SWI */
  164. } Dib, *DibRef;
  165.  
  166. /*
  167.  * struct to chain Driver Information Blocks
  168.  */
  169. typedef struct chaindib
  170. {
  171.     struct chaindib *chd_next;
  172.     struct dib      *chd_dib;
  173. } ChDib, *ChDibRef;
  174.  
  175. /*
  176.  * structure of header passed into Rx frame handler
  177.  */
  178. typedef struct
  179. {
  180.     void          *rx_ptr;
  181.     unsigned int   rx_tag;
  182.     unsigned char  rx_src_addr[6], _spad[2];
  183.     unsigned char  rx_dst_addr[6], _dpad[2];
  184.     unsigned int   rx_frame_type;
  185.     unsigned int   rx_error_level;
  186. } RxHdr, *RxHdrRef;
  187.  
  188. /*
  189.  * returned flag bits for Inquire SWI
  190.  */
  191. #define INQ_MULTICAST    (1 << 0)    /* multicast reception supported */
  192. #define INQ_PROMISCUOUS    (1 << 1)    /* promiscuous reception supported */
  193. #define INQ_CANREFLECT    (1 << 2)    /* i/f receives its own packets */
  194. #define INQ_STATIONNO    (1 << 3)    /* station number is required */
  195. #define INQ_RXERRORS    (1 << 4)    /* i/f can receive erroneous packets */
  196. #define INQ_HWADDRVALID    (1 << 5)    /* i/f has a hardware address */
  197. #define INQ_SOFTHWADDR    (1 << 6)    /* i/f can alter hardware address */
  198. #define INQ_POINTOPOINT (1 << 7)    /* i/f is a point to point link */
  199. #define INQ_HASSTATS    (1 << 8)    /* i/f supplys standard statistics */
  200. #define INQ_HASESTATS    (1 << 9)    /* i/f supplys extended statistics */
  201. #define INQ_VIRTUAL    (1 << 10)    /* this is a virtual i/f */
  202. #define INQ_SWVIRTUAL    (1 << 11)    /* this is a software virtual i/f */
  203.  
  204. /*
  205.  * flags for Transmit SWI
  206.  */
  207. #define TX_OWNSOURCE    (0 << 0)    /* use default MAC address */
  208. #define TX_FAKESOURCE    (1 << 0)    /* use user supplied MAC address */
  209. #define TX_DRIVERSDATA    (0 << 1)    /* driver gains ownership of mbufs */
  210. #define TX_PROTOSDATA    (1 << 1)    /* protocol retains mbuf ownership */
  211. #define TX_1STRESERVED    (2 << 1)    /* 1st reserved flag bit */
  212.  
  213. /*
  214.  * levels for Filter SWI
  215.  */
  216. #define FRMLVL_E2SPECIFIC    1
  217. #define FRMLVL_E2SINK        2
  218. #define FRMLVL_E2MONITOR    3
  219. #define FRMLVL_IEEE        4
  220.  
  221. #define ADDRLVL_SPECIFIC    0
  222. #define ADDRLVL_NORMAL        1
  223. #define ADDRLVL_MULTICAST    2
  224. #define ADDRLVL_PROMISCUOUS    3
  225.  
  226. #define ERRLVL_NO_ERRORS    0
  227. #define ERRLVL_ERRORS        1
  228.  
  229. /*
  230.  * macros for manipulating subfields within frame type
  231.  */
  232. #define GET_FRAMETYPE(x)    ((x) & 0xffff)
  233. #define SET_FRAMETYPE(x, y)    ((x) = ((x) & 0xffff0000) | ((y) & 0xffff))
  234. #define GET_FRAMELEVEL(x)    (((unsigned int)(x)) >> 16)
  235. #define SET_FRAMELEVEL(x, y)    ((x) = ((x) & 0x0000ffff) | ((y) << 16))
  236.  
  237. /*
  238.  * flags for Filter SWI
  239.  */
  240. #define FILTER_CLAIM        (0 << 0)
  241. #define FILTER_RELEASE        (1 << 0)
  242. #define FILTER_UNSAFE_OK    (0 << 1)
  243. #define FILTER_NO_UNSAFE    (1 << 1)
  244. #define FILTER_1STRESERVED    (2 << 1)
  245.  
  246. /*
  247.  * definitions for stats interface types
  248.  */
  249. #define ST_TYPE_10BASE5            1
  250. #define ST_TYPE_10BASE2            2
  251. #define ST_TYPE_10BASET            3
  252. #define ST_TYPE_10BASE5N2        4
  253. #define ST_TYPE_10BASE2NT        5
  254. #define ST_TYPE_RSQUELCH10BASET        6
  255. #define ST_TYPE_ACORNECONET        7
  256. #define ST_TYPE_SERIAL            8
  257. #define ST_TYPE_PARALLEL        9
  258. #define ST_TYPE_10BASE5N2NT        10
  259.  
  260. /*
  261.  * stats. link status bits
  262.  */
  263. #define ST_STATUS_OK            (1 << 0)
  264. #define ST_STATUS_ACTIVE        (1 << 1)
  265. #define ST_STATUS_RXMASK        (3 << 2)
  266. #define ST_STATUS_DIRECT        (0 << 2)
  267. #define ST_STATUS_BROADCAST        (1 << 2)
  268. #define ST_STATUS_MULTICAST        (2 << 2)
  269. #define ST_STATUS_PROMISCUOUS        (3 << 2)
  270.  
  271. /*
  272.  * structure for returning device driver statistics
  273.  */
  274. struct stats
  275. {
  276.     /*
  277.      * general information
  278.      */
  279.     unsigned char st_interface_type;
  280.     unsigned char st_link_status;
  281.     unsigned char st_link_polarity;
  282.     unsigned char st_blank1;
  283.     unsigned long st_link_failures;
  284.     unsigned long st_network_collisions;
  285.  
  286.     /*
  287.      * transmit statistics
  288.      */
  289.     unsigned long st_collisions;
  290.     unsigned long st_excess_collisions;
  291.     unsigned long st_heartbeat_failures;
  292.     unsigned long st_not_listening;
  293. #if 0
  294.     unsigned long st_net_error;
  295. #endif
  296.     unsigned long st_tx_frames;
  297.     unsigned long st_tx_bytes;
  298.     unsigned long st_tx_general_errors;
  299.     unsigned char st_last_dest_addr[8];
  300.  
  301.     /*
  302.      * receive statistics
  303.      */
  304.     unsigned long st_crc_failures;
  305.     unsigned long st_frame_alignment_errors;
  306.     unsigned long st_dropped_frames;
  307.     unsigned long st_runt_frames;
  308.     unsigned long st_overlong_frames;
  309.     unsigned long st_jabbers;
  310.     unsigned long st_late_events;
  311.     unsigned long st_unwanted_frames;
  312.     unsigned long st_rx_frames;
  313.     unsigned long st_rx_bytes;
  314.     unsigned long st_rx_general_errors;
  315.     unsigned char st_last_src_addr[8];
  316. };
  317.  
  318. #endif /* !defined(__sys_dci4structs_h) */
  319.  
  320. /* EOF dcistructs.h */
  321.