home *** CD-ROM | disk | FTP | other *** search
/ Supremacy 1 / Supremacy-1.iso / UTILS / S-T / STING.ZIP / STING / DEV-KIT / HEADER / PORT.H < prev    next >
C/C++ Source or Header  |  1997-05-03  |  6KB  |  143 lines

  1. /*
  2.  *      port.h              (c) Peter Rottengatter  1996
  3.  *                              perot@pallas.amp.uni-hannover.de
  4.  *
  5.  *      Include this file to provide port interfacing to STinG
  6.  */
  7.  
  8. #ifndef STING_PORT_H
  9. #define STING_PORT_H
  10.  
  11. #ifndef MODULE_DRIVER
  12. #define MODULE_DRIVER    "MODULE_LAYER"
  13. #endif
  14.  
  15.  
  16.  
  17. /*--------------------------------------------------------------------------*/
  18.  
  19.  
  20. /*
  21.  *   Internal port descriptor.
  22.  */
  23.  
  24. typedef  struct port_desc {
  25.     char      *name;            /* Name of port                             */
  26.     int16     type;             /* Type of port                             */
  27.     int16     active;           /* Flag for port active or not              */
  28.     uint32    flags;            /* Type dependent operational flags         */
  29.     uint32    ip_addr;          /* IP address of this network adapter       */
  30.     uint32    sub_mask;         /* Subnet mask of attached network          */
  31.     int16     mtu;              /* Maximum packet size to go through        */
  32.     int16     max_mtu;          /* Maximum allowed value for mtu            */
  33.     int32     stat_sd_data;     /* Statistics of sent data                  */
  34.     IP_DGRAM  *send;            /* Link to first entry in send queue        */
  35.     int32     stat_rcv_data;    /* Statistics of received data              */
  36.     IP_DGRAM  *receive;         /* Link to first entry in receive queue     */
  37.     int16     stat_dropped;     /* Statistics of dropped datagrams          */
  38.     struct drv_desc   *driver;  /* Driver program to handle this port       */
  39.     struct port_desc  *next;    /* Next port in port chain                  */
  40.  } PORT;
  41.  
  42.  
  43. /*
  44.  *   Port driver descriptor.
  45.  */
  46.  
  47. typedef  struct drv_desc {
  48.     int16 cdecl  (* set_state) (PORT *, int16);  /* Setup and shutdown port */
  49.     void  cdecl  (* send) (PORT *);              /* Send pending packets    */
  50.     void  cdecl  (* receive) (PORT *);           /* Receive pending packets */
  51.     char             *name;     /* Name of driver                           */
  52.     char             *version;  /* Version of driver in "xx.yy" format      */
  53.     uint16           date;      /* Compile date in GEMDOS format            */
  54.     char             *author;   /* Name of programmer                       */
  55.     struct drv_desc  *next;     /* Next driver in driver chain              */
  56.  } DRIVER;
  57.  
  58.  
  59.  
  60. /*--------------------------------------------------------------------------*/
  61.  
  62.  
  63. /*
  64.  *   Link Type Definitions
  65.  */
  66.  
  67. #define  L_SER_PTP    1           /*   Serial point to point type link      */
  68. #define  L_PAR_PTP    2           /* Parallel point to point type link      */
  69. #define  L_SER_BUS    3           /*   Serial            bus type link      */
  70. #define  L_PAR_BUS    4           /* Parallel            bus type link      */
  71. #define  L_SER_RING   5           /*   Serial           ring type link      */
  72. #define  L_PAR_RING   6           /* Parallel           ring type link      */
  73.  
  74.  
  75.  
  76. /*--------------------------------------------------------------------------*/
  77.  
  78.  
  79. /*
  80.  *   Module driver structure / functions
  81.  */
  82.  
  83. #ifndef MOD_DRIVER
  84. #define MOD_DRIVER
  85.  
  86. typedef  struct stx {
  87.     char *     module;      /* Specific string that can be searched for     */
  88.     char *     author;      /* Any string                                   */
  89.     char *     version;     /* Format `00.00' Version:Revision              */
  90.     void       cdecl  (* set_dgram_ttl) (IP_DGRAM *);
  91.     int16      cdecl  (* check_dgram_ttl) (IP_DGRAM *);
  92.     int16      cdecl  (* load_routing_table) (void);
  93.     int32      cdecl  (* set_sysvars) (int16, int16);
  94.     void       cdecl  (* query_chains) (void **, void **, void **);
  95.     int16      cdecl  (* IP_send) (uint32, uint32, uint8, uint16, uint8, uint8, uint16,
  96.                                    void *, uint16, void *, uint16);
  97.     IP_DGRAM * cdecl  (* IP_fetch) (int16);
  98.     int16      cdecl  (* IP_handler) (int16, int16 cdecl (*) (IP_DGRAM *), int16);
  99.     void       cdecl  (* IP_discard) (IP_DGRAM *, int16);
  100.     int16      cdecl  (* PRTCL_announce) (int16);
  101.     int16      cdecl  (* PRTCL_get_parameters) (uint32, uint32 *, int16 *, uint16 *);
  102.     int16      cdecl  (* PRTCL_request) (void *, void *);
  103.     void       cdecl  (* PRTCL_release) (int16);
  104.     void *     cdecl  (* PRTCL_lookup) (int16, void *);
  105.     int16      cdecl  (* TIMER_call) (void cdecl (*) (void), int16);
  106.     int32      cdecl  (* TIMER_now) (void);
  107.     int32      cdecl  (* TIMER_elapsed) (int32);
  108.  } STX;
  109.  
  110. extern STX *stx;
  111.  
  112.  
  113. /*
  114.  *   Definitions of module driver functions for direct use
  115.  */
  116.  
  117. #define set_dgram_ttl(x)                 (*stx->set_dgram_ttl)(x)
  118. #define check_dgram_ttl(x)               (*stx->check_dgram_ttl)(x)
  119. #define load_routing_table()             (*stx->load_routing_table)()
  120. #define set_sysvars(x,y)                 (*stx->set_sysvars)(x,y)
  121. #define query_chains(x,y,z)              (*stx->query_chains)(x,y,z)
  122. #define IP_send(a,b,c,d,e,f,g,h,i,j,k)   (*stx->IP_send)(a,b,c,d,e,f,g,h,i,j,k)
  123. #define IP_fetch(x)                      (*stx->IP_fetch)(x)
  124. #define IP_handler(x,y,z)                (*stx->IP_handler)(x,y,z)
  125. #define IP_discard(x,y)                  (*stx->IP_discard)(x,y)
  126. #define PRTCL_announce(x)                (*stx->PRTCL_announce)(x)
  127. #define PRTCL_get_parameters(w,x,y,z)    (*stx->PRTCL_get_parameters)(w,x,y,z)
  128. #define PRTCL_request(x,y)               (*stx->PRTCL_request)(x,y)
  129. #define PRTCL_release(x)                 (*stx->PRTCL_release)(x)
  130. #define PRTCL_lookup(x,y)                (*stx->PRTCL_lookup)(x,y)
  131. #define TIMER_call(x,y)                  (*stx->TIMER_call)(x,y)
  132. #define TIMER_now()                      (*stx->TIMER_now)()
  133. #define TIMER_elapsed(x)                 (*stx->TIMER_elapsed)(x)
  134.  
  135. #endif /* MOD_DRIVER */
  136.  
  137.  
  138.  
  139. /*--------------------------------------------------------------------------*/
  140.  
  141.  
  142. #endif /* STING_PORT_H */
  143.