home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / comm / amitcp-3.0ß2.lha / AmiTCP / src / devs / agnet / agnet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-08  |  6.4 KB  |  209 lines

  1. RCS_ID agnet_h_id[]="$Id: agnet.h,v 3.1 93/10/07 19:24:17 ppessi Exp $";
  2. /*
  3.  * agnet.h --- agnet.device C definitions
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright (c) 1993 OHT-AmiTCP/IP Group,
  8.  *                    Helsinki University of Technology, Finland.
  9.  *                    All rights reserved.
  10.  *
  11.  * Created      : Thu Jan 21 17:36:36 1993 ppessi
  12.  * Last modified: Thu Oct  7 18:53:59 1993 ppessi
  13.  *
  14.  * $Log:    agnet.h,v $
  15.  * Revision 3.1  93/10/07  19:24:17  ppessi
  16.  * Release 2.1 version
  17.  * 
  18.  * Revision 2.1  93/05/14  16:48:01  ppessi
  19.  * Release version
  20.  * 
  21.  */
  22.  
  23. #include <exec/types.h>
  24. #include <exec/devices.h>
  25. #include <exec/ports.h>
  26. #include <exec/semaphores.h>
  27. #include <exec/memory.h>
  28. #include <exec/execbase.h>
  29.  
  30. #include <devices/sana2.h>
  31.  
  32. #include "lrandom.h"
  33.  
  34. /* Minimum Stacksize and Priority of agnet.device Process */
  35. #define AGNET_STACKSIZE 4000
  36. #define AGNET_PRI       3    /* We are running an ARexx Port */
  37. #define AGNET_DEV_PRI   5    /* for device node */
  38.  
  39. #define AD_MAXUNITS 16        /* Max # of Units allowed */
  40.  
  41. /* Maximum address size in bytes */
  42. #define MAX_ADDR_BYTES 8
  43.  
  44. /* A non-standard wiretype */
  45. #define S2WireType_LoopBack  0 
  46.  
  47. /* 
  48.  *   Agnet Device Data Structure 
  49.  */
  50. struct AgnetDevice
  51. {
  52.   struct Library     ad_Device;
  53. #define ad_Dev_Flags     ad_Device.lib_Flags
  54. #define ad_Dev_pad       ad_Device.lib_pad
  55. #define ad_Dev_NegSize   ad_Device.lib_NegSize        /* number of bytes before library */
  56. #define ad_Dev_PosSize   ad_Device.lib_PosSize        /* number of bytes after library */
  57. #define ad_Dev_Version   ad_Device.lib_Version        /* major */
  58. #define ad_Dev_Revision  ad_Device.lib_Revision        /* minor */
  59. #define ad_Dev_IdString  ad_Device.lib_IdString        /* ASCII identification */
  60. #define ad_Dev_Sum       ad_Device.lib_Sum        /* the checksum itself */
  61. #define ad_Dev_OpenCnt   ad_Device.lib_OpenCnt        /* number of current opens */
  62.  
  63.   struct SignalSemaphore ad_Lock;
  64.   UBYTE                 ad_Flags;
  65.   UBYTE                 ad_Pad1;
  66.   struct AgnetDevUnit   *ad_Units[AD_MAXUNITS];
  67.   struct Task           *ad_Task;
  68.   struct ExecBase    *ad_SysBase;
  69.   struct Library    *ad_DOSBase;
  70.   struct Library    *ad_IntuitionBase;
  71.   struct timerequest     ad_Timer;
  72.   struct MsgPort         ad_MsgPort;
  73. };
  74.  
  75. /* Typedef's for the SANA-II callback functions. */
  76.  
  77. typedef BOOL (*SANA2_CFB)(APTR to, APTR from, LONG length);
  78. typedef BOOL (*SANA2_CTB)(APTR to, APTR from, LONG length);
  79.  
  80. struct BufferManagement
  81. {
  82.     struct MinNode    bm_Node;
  83.     SANA2_CFB        bm_CopyFromBuffer;
  84.     SANA2_CTB        bm_CopyToBuffer;
  85. };
  86.  
  87. struct SuperS2PTStats
  88. {
  89.   struct MinNode          ss_Node;
  90.   ULONG                  ss_PType;
  91.   struct Sana2PacketTypeStats ss_Stats;
  92. };
  93.  
  94. /* 
  95.  * Structure for our internal delayed transfer
  96.  */
  97. struct DelayRequest {
  98.   struct IORequest    tr_node;
  99.   struct timeval      tr_time;
  100.   struct AgnetDevUnit*dr_Unit;
  101.   ULONG               dr_HardwareType;
  102.   ULONG               dr_PacketType;
  103.   UWORD                  dr_Cmd;
  104.   LONG                dr_PPUnit;
  105.   UBYTE               dr_SrcAddr[MAX_ADDR_BYTES];
  106.   UBYTE               dr_DstAddr[MAX_ADDR_BYTES];
  107.   UWORD               dr_DataLen; /* Length of Data */
  108.   UWORD               dr_Len;     /* Length of Data Field */
  109.   UBYTE               dr_Data[0]; /* Actually at least MTU */
  110. };
  111.  
  112. #define MAX_TXED 4
  113.  
  114. /* 
  115.  * Unit Data Structure 
  116.  */
  117. struct AgnetDevUnit
  118. {
  119.     struct Unit            adu_Unit;        /* Standard Unit Structure           */
  120. #define adu_Unit_MsgPort    adu_Unit.unit_MsgPort  /* queue for unprocessed messages */
  121. #define adu_Unit_flags      adu_Unit.unit_flags
  122. #define adu_Unit_OpenCnt    adu_Unit.unit_OpenCnt          /* number of active opens */
  123.     UBYTE            adu_UnitNum;    /* Unit number                       */
  124.     UBYTE            adu_State;        /* State bits                        */
  125.     struct Device       *adu_Device;        /* Pointer to our device node        */
  126.     UBYTE            adu_Addr[MAX_ADDR_BYTES];      /* Our "hardware" address */
  127.     UWORD            adu_AddrFieldSize;    /* address size in bits              */
  128.     LONG            adu_PPUnit;        /* Destination of p-to-p connection  */
  129.     ULONG            adu_MaxTU;        /* Maximum Transfer Unit             */
  130.     ULONG            adu_HardwareType;
  131.     ULONG            adu_BPS;        /* line rate (bits/second)           */
  132.     ULONG            adu_MinTU;        /* Minumum Transfer Unit             */
  133.     ULONG            adu_Delay;        /* Delay for outgoing packets in ms  */
  134.     ULONG            adu_Deviation;    /* Deviation in delay in ms          */
  135.     ULONG            adu_Errors;        /* Packet bit-error probabilty       */
  136.     ULONG            adu_Loss;        /* Packet loss probabilty            */
  137.     struct SignalSemaphore  adu_Lock;            /* A Semaphore for all queues.       */
  138.     struct DelayRequest    *adu_TxEd[MAX_TXED]; /* Transfer buffers                  */
  139.     struct MinList          adu_FreeToTx;       /* Free Transfer buffer              */
  140.     struct MinList        adu_Rx;        /* Pending CMD_READ's                */
  141.     struct MinList        adu_RxOrph;        /* Pending CMD_READORPHAN's          */
  142.     struct MinList        adu_Tx;        /* Pending CMD_WRITE's               */
  143.     struct MinList        adu_Events;        /* Pending S2_ONEVENT's              */
  144.     struct MinList        adu_Track;        /* List of tracked packet types      */
  145.     struct MinList        adu_BuffMgmt;    /* List of Callback routines         */
  146.     struct Sana2DeviceStats adu_Stats;        /* Global device statistics          */
  147. };
  148.  
  149. /*
  150.  * Parameters for bit errors and packet loss
  151.  */
  152. #define ERRORS_MAX 1000000000
  153. #define LOSS_MAX   1000000
  154.  
  155. /*
  156.  * State bits for adu_State
  157.  */
  158. #define AGUB_CONFIG 0
  159. #define AGUB_ONLINE 1
  160. #define AGUB_SETCONFIG 2
  161.  
  162. #define AGUF_CONFIG        (1<<AGUB_CONFIG)
  163. #define AGUF_ONLINE        (1<<AGUB_ONLINE)
  164. #define AGUF_SETCONFIG            (1<<AGUB_SETCONFIG)
  165.  
  166. /*
  167.  * Device Name
  168.  */
  169.  
  170. #define AGNETDEVNAME "agnet.device"
  171.  
  172. #define ASM           __asm
  173. #define REG(x)        register __ ## x
  174.  
  175. #define TAILP(x) (!(struct Node *)x->ln_Succ)
  176. #define HEADP(x) (!(struct Node *)x->ln_Pred)
  177.  
  178. /*
  179.  * Unit access control
  180.  */
  181. #define LockUnit(adu)   ObtainSemaphore(&adu->adu_Lock)
  182. #define UnlockUnit(adu) ReleaseSemaphore(&adu->adu_Lock)
  183.  
  184. #ifndef NOINLINE
  185. #define RemHead execRemHead
  186. /* 
  187.  * List init routine 
  188.  */
  189. static __inline VOID 
  190. NewList(register struct List *list)
  191. {
  192.   list->lh_Head = (struct Node *)&list->lh_Tail;
  193.   list->lh_Tail = NULL;
  194.   list->lh_TailPred = (struct Node *)list;
  195. }
  196. /*
  197.  * List handling routines
  198.  */
  199. static __inline struct Node *
  200. RemHead(register struct List *list)
  201. {
  202.   register struct Node * head = list->lh_Head;
  203.   
  204.   if (TAILP(head)) return NULL;
  205.   (list->lh_Head = head->ln_Succ)->ln_Pred = (struct Node *)list;
  206.   return head;
  207. }
  208. #endif
  209.