home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / s920603.zip / IFACE.H < prev    next >
C/C++ Source or Header  |  1992-05-05  |  5KB  |  140 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));
  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.     void (*rcvf) __ARGS((struct iface *,struct mbuf *));
  33.     int (*addrtest) __ARGS((struct iface *,struct mbuf *));
  34.     void (*trace) __ARGS((FILE *,struct mbuf **,int));
  35. };
  36. #define    NULLIFT    (struct iftype *)0
  37. extern struct iftype Iftypes[];
  38.  
  39.  
  40. /* Interface control structure */
  41. struct iface {
  42.     struct iface *next;    /* Linked list pointer */
  43.     char *name;        /* Ascii string with interface name */
  44.  
  45.     int32 addr;        /* IP address */
  46.     int32 broadcast;    /* Broadcast address */
  47.     int32 netmask;        /* Network mask */
  48.  
  49.     int16 mtu;        /* Maximum transmission unit size */
  50.  
  51.     int16 flags;        /* Configuration flags */
  52. #define    DATAGRAM_MODE    0    /* Send datagrams in raw link frames */
  53. #define    CONNECT_MODE    1    /* Send datagrams in connected mode */
  54.     int16 trace;        /* Trace flags */
  55. #define    IF_TRACE_OUT    0x01    /* Output packets */
  56. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  57. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  58. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  59. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  60. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  61.     FILE *trfp;        /* Stream to trace to */
  62.  
  63.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  64.  
  65.     struct proc *rxproc;    /* Receiver process, if any */
  66.     struct proc *txproc;    /* IP send process */
  67.     struct proc *supv;    /* Supervisory process, if any */
  68.  
  69.     struct mbuf *outq;    /* IP datagram transmission queue */
  70.  
  71.     /* Device dependent */
  72.     int dev;        /* Subdevice number to pass to send */
  73.                 /* To device -- control */
  74.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  75.                 /* From device -- when status changes */
  76.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  77.                 /* Call before detaching */
  78.     int (*stop) __ARGS((struct iface *));
  79.     char *hwaddr;        /* Device hardware address, if any */
  80.  
  81.     /* Encapsulation dependent */
  82.     void *edv;        /* Pointer to protocol extension block, if any */
  83.     int xdev;        /* Associated Slip or Nrs channel, if any */
  84.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  85.  
  86.                 /* Routine to send an IP datagram */
  87.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int));
  88.             /* Encapsulate any link packet */
  89.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  90.             /* Send raw packet */
  91.     int (*raw)        __ARGS((struct iface *,struct mbuf *));
  92.             /* Display status */
  93.     void (*show)        __ARGS((struct iface *));
  94.  
  95.     int (*discard)        __ARGS((struct iface *,struct mbuf *));
  96.     int (*echo)        __ARGS((struct iface *,struct mbuf *));
  97.  
  98.     /* Counters */
  99.     int32 ipsndcnt;     /* IP datagrams sent */
  100.     int32 rawsndcnt;    /* Raw packets sent */
  101.     int32 iprecvcnt;    /* IP datagrams received */
  102.     int32 rawrecvcnt;    /* Raw packets received */
  103.     int32 lastsent;        /* Clock time of last send */
  104.     int32 lastrecv;        /* Clock time of last receive */
  105. };
  106. #define    NULLIF    (struct iface *)0
  107. extern struct iface *Ifaces;    /* Head of interface list */
  108. extern struct iface  Loopback;    /* Optional loopback interface */
  109. extern struct iface  Encap;    /* IP-in-IP pseudo interface */
  110.  
  111. /* Header put on front of each packet sent to an interface */
  112. struct qhdr {
  113.     char tos;
  114.     int32 gateway;
  115. };
  116. /* List of link-level receive functions, initialized in config.c */
  117. struct rfunc {
  118.     int class;
  119.     void (*rcvf) __ARGS((struct iface *,struct mbuf *));
  120. };
  121. extern struct rfunc Rfunc[];
  122.  
  123. extern char Noipaddr[];
  124. extern struct mbuf *Hopper;
  125.  
  126. /* In iface.c: */
  127. struct iface *if_lookup __ARGS((char *name));
  128. struct iface *ismyaddr __ARGS((int32 addr));
  129. int if_detach __ARGS((struct iface *ifp));
  130. int setencap __ARGS((struct iface *ifp,char *mode));
  131. char *if_name __ARGS((struct iface *ifp,char *comment));
  132. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  133. void if_tx __ARGS((int dev,void *arg1,void *unused));
  134. void network __ARGS((int i,void *v1,void *v2));
  135.  
  136. /* In config.c: */
  137. int net_route __ARGS((struct iface *ifp,struct mbuf *bp));
  138.  
  139. #endif    /* _IFACE_H */
  140.