home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / IFACE.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  7KB  |  185 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. #ifndef _TCP_H
  17. #include "tcp.h"
  18. #endif
  19.   
  20. #ifdef AX25
  21. #ifndef _AX25_H
  22. #include "ax25.h"
  23. #endif
  24. #endif
  25.   
  26. /* Interface encapsulation mode table entry. An array of these structures
  27.  * are initialized in config.c with all of the information necessary
  28.  * to attach a device.
  29.  */
  30.   
  31. #ifdef __GNUC__
  32. struct iface;         /* forward declaration for gcc */
  33. #endif
  34.   
  35. #ifdef LINUX
  36. #ifndef send
  37. /* ugly hack to avoid both libc collisions and jnos misconnections */
  38. #include "socket.h"
  39. #endif
  40. #endif
  41.   
  42. struct iftype {
  43.     char *name;     /* Name of encapsulation technique */
  44.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  45.                 /* Routine to send an IP datagram */
  46.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  47.                 /* Routine to send link packet */
  48.     char *(*format) __ARGS((char *,char *));
  49.                 /* Function that formats addresses */
  50.     int (*scan) __ARGS((char *,char *));
  51.                 /* Reverse of format */
  52.     int type;       /* Type field for network process */
  53.     int hwalen;     /* Length of hardware address, if any */
  54. };
  55. #define NULLIFT (struct iftype *)0
  56. extern struct iftype Iftypes[];
  57.   
  58.   
  59. /* Interface control structure */
  60. struct iface {
  61.     struct iface *next; /* Linked list pointer */
  62.     char *name;     /* Ascii string with interface name */
  63.     char *descr;    /* Description of interface */
  64.   
  65.     int32 addr;     /* IP address */
  66.     int32 broadcast;    /* Broadcast address */
  67.     int32 netmask;      /* Network mask */
  68.   
  69.     int16 mtu;      /* Maximum transmission unit size */
  70.   
  71.     int32 flags;        /* Configuration flags */
  72. #define DATAGRAM_MODE   0L   /* Send datagrams in raw link frames */
  73. #define CONNECT_MODE    1L   /* Send datagrams in connected mode */
  74. #define IS_NR_IFACE     2L   /* Activated for NET/ROM - WG7J */
  75. #define NR_VERBOSE      4L   /* NET/ROM broadcast is verbose - WG7J */
  76. #define IS_CONV_IFACE   8L   /* Activated for conference call access - WG7J */
  77. #define AX25_BEACON     16L  /* Broadcast AX.25 beacons */
  78. #define MAIL_BEACON     32L  /* Send MAIL beacons */
  79. #define HIDE_PORT       64L  /* Don't show port in mbox P command */
  80. #define AX25_DIGI       128L /* Allow digipeating */
  81. #define ARP_EAVESDROP   256L /* Listen to ARP replies */
  82. #define ARP_KEEPALIVE   512L /* Keep arp entries alive after timeout */
  83. #define LOG_AXHEARD    1024L /* Do ax.25 heard logging on this interface */
  84. #define LOG_IPHEARD    2048L /* Do IP heard logging on this interface */
  85. #define NO_AX25        4096L /* No ax.25 mbox connections on this port */
  86. #define BBS_ONLY       8192L /* BBS's only in mbox via this port */
  87. #define USERS_ONLY     16384L /* Users only on this port */
  88. #define SYSOP_ONLY     32768L /* Sysops only on this port */
  89.   
  90. #ifdef NETROM
  91.     int quality;            /* Netrom interface quality */
  92.     int nr_autofloor;       /* Netrom minimum route quality for broadcast */
  93. #endif
  94.   
  95.     int16 trace;        /* Trace flags */
  96. #define IF_TRACE_OUT    0x01    /* Output packets */
  97. #define IF_TRACE_IN 0x10    /* Packets to me except broadcast */
  98. #define IF_TRACE_ASCII  0x100   /* Dump packets in ascii */
  99. #define IF_TRACE_HEX    0x200   /* Dump packets in hex/ascii */
  100. #define IF_TRACE_NOBC   0x1000  /* Suppress broadcasts */
  101. #define IF_TRACE_RAW    0x2000  /* Raw dump, if supported */
  102.     char *trfile;       /* Trace file name, if any */
  103.     FILE *trfp;     /* Stream to trace to */
  104.   
  105.     struct iface *forw; /* Forwarding interface for output, if rx only */
  106.   
  107.     struct proc *rxproc;    /* Receiver process, if any */
  108.     struct proc *txproc;    /* Transmitter process, if any */
  109.     struct proc *supv;  /* Supervisory process, if any */
  110.   
  111.     /* Device dependant */
  112.     int dev;        /* Subdevice number to pass to send */
  113.                 /* To device -- control */
  114.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  115.                 /* From device -- when status changes */
  116.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  117.                 /* Call before detaching */
  118.     int (*stop) __ARGS((struct iface *));
  119.     char *hwaddr;       /* Device hardware address, if any */
  120.   
  121.     /* Encapsulation dependant */
  122. #ifdef AX25
  123.     struct ifax25 *ax25;    /* Pointer to ax.25 protocol structure */
  124. #endif
  125.     struct iftcp *tcp;      /* Tcp protocol variables */
  126.     void *edv;      /* Pointer to protocol extension block, if any */
  127.     int type;       /* Link header type for phdr */
  128.     int xdev;       /* Associated Slip or Nrs channel, if any */
  129.     int port;       /* Sub port for multy port kiss */
  130.     struct iftype *iftype;  /* Pointer to appropriate iftype entry */
  131.   
  132.             /* Encapsulate an IP datagram */
  133.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  134.             /* Encapsulate any link packet */
  135.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  136.             /* Send raw packet */
  137.     int (*raw)      __ARGS((struct iface *,struct mbuf *));
  138.             /* Display status */
  139.     void (*show)        __ARGS((struct iface *));
  140.   
  141.     int (*discard)      __ARGS((struct iface *,struct mbuf *));
  142.     int (*echo)     __ARGS((struct iface *,struct mbuf *));
  143.   
  144.     /* Counters */
  145.     int32 ipsndcnt;     /* IP datagrams sent */
  146.     int32 rawsndcnt;    /* Raw packets sent */
  147.     int32 iprecvcnt;    /* IP datagrams received */
  148.     int32 rawrecvcnt;   /* Raw packets received */
  149.     int32 lastsent;     /* Clock time of last send */
  150.     int32 lastrecv;     /* Clock time of last receive */
  151. };
  152. #define NULLIF  (struct iface *)0
  153. extern struct iface *Ifaces;    /* Head of interface list */
  154. extern struct iface  Loopback;  /* Optional loopback interface */
  155. extern struct iface  Encap; /* IP-in-IP pseudo interface */
  156.   
  157. /* Header put on front of each packet in input queue */
  158. struct phdr {
  159.     struct iface *iface;
  160.     unsigned short type;    /* Use pktdrvr "class" values */
  161. };
  162.   
  163. /* Header put on front of each packet sent to an interface */
  164. struct qhdr {
  165.     char tos;
  166.     int32 gateway;
  167. };
  168.   
  169. extern char Noipaddr[];
  170. extern struct mbuf *Hopper;
  171.   
  172. /* In iface.c: */
  173. struct iface *if_lookup __ARGS((char *name));
  174. struct iface *ismyaddr __ARGS((int32 addr));
  175. int if_detach __ARGS((struct iface *ifp));
  176. int setencap __ARGS((struct iface *ifp,char *mode));
  177. char *if_name __ARGS((struct iface *ifp,char *comment));
  178. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  179. int mask2width __ARGS((int32 mask));         /* Added N0POY, for rip code */
  180.   
  181. /* In config.c: */
  182. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  183.   
  184. #endif  /* _IFACE_H */
  185.