home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / misc / tcpipsrc / iface.h < prev    next >
C/C++ Source or Header  |  1990-11-10  |  4KB  |  102 lines

  1. #ifndef    _IFACE_H
  2. #define    _IFACE_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef _PROC_H
  13. #include "proc.h"
  14. #endif
  15.  
  16. /* Interface control structure */
  17. struct iface {
  18.     struct iface *next;    /* Linked list pointer */
  19.     char *name;        /* Ascii string with interface name */
  20.     int type;        /* Link header type for phdr */
  21.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  22.     int32 addr;        /* IP address */
  23.     int32 broadcast;    /* Broadcast address */
  24.     int32 netmask;        /* Network mask */
  25.     int (*ioctl) __ARGS((struct iface *,int,char **));
  26.                 /* Function to handle device control */
  27.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  28.                 /* Routine to send an IP datagram */
  29.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  30.                 /* Routine to send link packet */
  31.     int (*raw) __ARGS((struct iface *,struct mbuf *));
  32.                 /* Routine to call to send raw packet */
  33.     int (*stop) __ARGS((struct iface *));
  34.                 /* Routine to call before detaching */
  35.     int16 mtu;        /* Maximum transmission unit size */
  36.     int dev;        /* Subdevice number to pass to send */
  37.     int xdev;        /* Associated Slip or Nrs channel, if any */
  38.     int16 flags;        /* Configuration flags */
  39. #define    DATAGRAM_MODE    0    /* Send datagrams in raw link frames */
  40. #define    CONNECT_MODE    1    /* Send datagrams in connected mode */
  41.     int16 trace;        /* Trace flags */
  42. #define    IF_TRACE_OUT    0x01    /* Output packets */
  43. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  44. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  45. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  46. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  47. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  48.     char *trfile;        /* Trace file name, if any */
  49.     FILE *trfp;        /* Stream to trace to */
  50.     char *hwaddr;        /* Device hardware address, if any */
  51.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  52.     int32 ipsndcnt;        /* IP datagrams sent */
  53.     int32 rawsndcnt;    /* Raw packets sent */
  54.     int32 iprecvcnt;    /* IP datagrams received */
  55.     int32 rawrecvcnt;    /* Raw packets received */
  56.     int32 lastsent;        /* Clock time of last send */
  57.     int32 lastrecv;        /* Clock time of last receive */
  58.     struct proc *rxproc;    /* Receiver process, if any */
  59.     struct proc *txproc;    /* Transmitter process, if any */
  60.     struct proc *supv;    /* Supervisory process, if any */
  61. };
  62. #define    NULLIF    (struct iface *)0
  63. extern struct iface *Ifaces;    /* Head of interface list */
  64. extern struct iface Loopback;    /* Optional loopback interface */
  65.  
  66. /* Header put on front of each packet in input queue */
  67. struct phdr {
  68.     struct iface *iface;
  69.     unsigned short type;    /* Use pktdrvr "class" values */
  70. };
  71. extern char Noipaddr[];
  72. extern struct mbuf *Hopper;
  73.  
  74. /* Interface encapsulation mode table entry. An array of these strctures
  75.  * are initialized in config.c with all of the information necessary
  76.  * to attach a device.
  77.  */
  78. struct iftype {
  79.     char *name;        /* Name of encapsulation technique */
  80.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  81.                 /* Routine to send an IP datagram */
  82.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  83.                 /* Routine to send link packet */
  84.     char *(*format) __ARGS((char *,char *));
  85.                 /* Function that formats addresses */
  86.     int (*scan) __ARGS((char *,char *));
  87.                 /* Reverse of format */
  88.     int type;        /* Type field for network process */
  89.     int hwalen;        /* Length of hardware address, if any */
  90. };
  91. #define    NULLIFT    (struct iftype *)0
  92. extern struct iftype Iftypes[];
  93.  
  94. /* In iface.c: */
  95. struct iface *if_lookup __ARGS((char *name));
  96. struct iface *ismyaddr __ARGS((int32 addr));
  97. int if_detach __ARGS((struct iface *ifp));
  98. int setencap __ARGS((struct iface *ifp,char *mode));
  99. int dumppkt __ARGS((struct iface *ifp,struct mbuf *bp));
  100.  
  101. #endif    /* _IFACE_H */
  102.