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