home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 3 / hamradioversion3.0examsandprograms1992.iso / packet / n17jsrc / iface.h < prev    next >
C/C++ Source or Header  |  1991-06-24  |  5KB  |  126 lines

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