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