home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / KA9Q212.ZIP / IFACE.H < prev    next >
C/C++ Source or Header  |  1993-03-07  |  5KB  |  146 lines

  1. #ifndef    _IFACE_H
  2. #define    _IFACE_H
  3.  
  4. #ifndef _CONFIG_H
  5. #include "config.h"
  6. #endif
  7.  
  8. #ifndef _FILTER_H
  9. #include "filter.h"
  10. #endif
  11.  
  12. #ifndef    _GLOBAL_H
  13. #include "global.h"
  14. #endif
  15.  
  16. #ifndef    _MBUF_H
  17. #include "mbuf.h"
  18. #endif
  19.  
  20. #ifndef _PROC_H
  21. #include "proc.h"
  22. #endif
  23.  
  24. /* Interface encapsulation mode table entry. An array of these structures
  25.  * are initialized in config.c with all of the information necessary
  26.  * to attach a device.
  27.  */
  28. struct iftype {
  29.     char *name;        /* Name of encapsulation technique */
  30.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  31.                 /* Routine to send an IP datagram */
  32.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  33.                 /* Routine to send link packet */
  34.     char *(*format) __ARGS((char *,char *));
  35.                 /* Function that formats addresses */
  36.     int (*scan) __ARGS((char *,char *));
  37.                 /* Reverse of format */
  38.     int type;        /* Type field for network process */
  39.     int hwalen;        /* Length of hardware address, if any */
  40. };
  41. #define    NULLIFT    (struct iftype *)0
  42. extern struct iftype Iftypes[];
  43.  
  44.  
  45. /* Interface control structure */
  46. struct iface {
  47.     struct iface *next;    /* Linked list pointer */
  48.     char *name;        /* Ascii string with interface name */
  49.  
  50.     int32 addr;        /* IP address */
  51.     int32 broadcast;    /* Broadcast address */
  52.     int32 netmask;        /* Network mask */
  53.  
  54.     int16 mtu;        /* Maximum transmission unit size */
  55.  
  56.     int16 flags;        /* Configuration flags */
  57. #define    DATAGRAM_MODE    0    /* Send datagrams in raw link frames */
  58. #define    CONNECT_MODE    1    /* Send datagrams in connected mode */
  59.  
  60.     int16 trace;        /* Trace flags */
  61. #define    IF_TRACE_OUT    0x01    /* Output packets */
  62. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  63. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  64. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  65. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  66. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  67.     char *trfile;        /* Trace file name, if any */
  68.     FILE *trfp;        /* Stream to trace to */
  69.  
  70.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  71.  
  72.     struct proc *rxproc;    /* Receiver process, if any */
  73.     struct proc *txproc;    /* Transmitter process, if any */
  74.     struct proc *supv;    /* Supervisory process, if any */
  75.  
  76. #ifdef FILTER
  77.     /* Filter specifications */
  78.     struct filter *infilter;  /* Inbound filter */
  79.     struct filter *outfilter; /* Outbound filter */
  80. #endif
  81.  
  82.     /* Device dependant */
  83.     int dev;        /* Subdevice number to pass to send */
  84.                 /* To device -- control */
  85.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  86.                 /* From device -- when status changes */
  87.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  88.                 /* Call before detaching */
  89.     int (*stop) __ARGS((struct iface *));
  90.     char *hwaddr;        /* Device hardware address, if any */
  91.  
  92.     /* Encapsulation dependant */
  93.     void *edv;        /* Pointer to protocol extension block, if any */
  94.     int type;        /* Link header type for phdr */
  95.     int xdev;        /* Associated Slip or Nrs channel, if any */
  96.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  97.  
  98.             /* Encapsulate an IP datagram */
  99.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  100.             /* Encapsulate any link packet */
  101.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  102.             /* Send raw packet */
  103.     int (*raw)        __ARGS((struct iface *,struct mbuf *));
  104.             /* Display status */
  105.     void (*show)        __ARGS((struct iface *));
  106.  
  107.     int (*discard)        __ARGS((struct iface *,struct mbuf *));
  108.     int (*echo)        __ARGS((struct iface *,struct mbuf *));
  109.  
  110.     /* Counters */
  111.     int32 ipsndcnt;     /* IP datagrams sent */
  112.     int32 rawsndcnt;    /* Raw packets sent */
  113.     int32 iprecvcnt;    /* IP datagrams received */
  114.     int32 rawrecvcnt;    /* Raw packets received */
  115.     int32 lastsent;        /* Clock time of last send */
  116.     int32 lastrecv;        /* Clock time of last receive */
  117.  
  118.     /* Demand dial */
  119.     int    dial_me;        /* !0 means demand dial */
  120. };
  121. #define    NULLIF    (struct iface *)0
  122. extern struct iface *Ifaces;    /* Head of interface list */
  123. extern struct iface  Loopback;    /* Optional loopback interface */
  124. extern struct iface  Encap;    /* IP-in-IP pseudo interface */
  125.  
  126. /* Header put on front of each packet in input queue */
  127. struct phdr {
  128.     struct iface *iface;
  129.     unsigned short type;    /* Use pktdrvr "class" values */
  130. };
  131. extern char Noipaddr[];
  132. extern struct mbuf *Hopper;
  133.  
  134. /* In iface.c: */
  135. struct iface *if_lookup __ARGS((char *name));
  136. struct iface *ismyaddr __ARGS((int32 addr));
  137. int if_detach __ARGS((struct iface *ifp));
  138. int setencap __ARGS((struct iface *ifp,char *mode));
  139. char *if_name __ARGS((struct iface *ifp,char *comment));
  140. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  141.  
  142. /* In config.c: */
  143. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  144.  
  145. #endif    /* _IFACE_H */
  146.