home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / lan / soss.arj / INCLUDE / NET.H < prev    next >
C/C++ Source or Header  |  1991-04-11  |  5KB  |  134 lines

  1. /* Copyright 1986 by Carnegie Mellon */
  2. /*  Copyright 1983,1984,1985 by the Massachusetts Institute of Technology  */
  3. /*  define's for levels of tracing and for success and failure
  4.     added, January 1984.     <J. H. Saltzer>
  5.     8/12/84 - added the custom structure for each net, and RARP
  6.                     <John Romkey>
  7.     10/3/84 - changed the Q to a queue * to make structure
  8.         initialization simpler.    <John Romkey>
  9.     8/9/85    - added ip_snd_handler and int_swtch calls; also added
  10.         pointer to per-net interface info. Punted unused n_open
  11.         call.
  12.                     <John Romkey>
  13. */
  14.  
  15. #ifndef NET_H                /* DDP */
  16. #define NET_H    1            /* DDP */
  17.  
  18. /* need to define this before dragging in custom.h */
  19. typedef long in_name;
  20.  
  21. /*
  22. #include <task.h>
  23. #include <netq.h>
  24. #include <custom.h>
  25. */
  26.  
  27. /* This is the net structure. This idea is based somewhat on Noel's C
  28.     Gateway. For the IBM's, we need an easy way to make up a net
  29.     program that can use any of the three potential nets that the
  30.     IBM can be interfaced to: the Serial Line net w/PC Gateway, the
  31.     10 Mb Ethernet or a Packet Radio setup.
  32.        The code for each net has to supply a routine to send packets
  33.     over the net, a routine to receive packets and a routine to
  34.     do net initialization. The init routine finds the IBM's address
  35.     on that net. All addresses are internet addresses; any local
  36.     addresses can be kept in statics by the net drivers.
  37.        To use this, the user creates a C program which just consists
  38.     of the global structure called nets which is an array of net structs.
  39.     The netinit routine will do the right thing with all the info provided
  40.     when called, and will call each net's initialization routines.
  41.     The user must include a variable, int Nnet, in this file with the
  42.     statement:
  43.         int Nnet = sizeof(nets)/sizeof(struct net);
  44.     This provides a way for netinit to tell how many nets there are.
  45.  */
  46.  
  47.  
  48. #define    IP    0
  49. #define    CHAOS    1
  50. #define    PUP    2
  51. #define    SLP    3
  52. #define    ARP    4    /* Address Resolution Protocol */
  53. #define    RARP    5    /* reverse address resolution protocol */
  54.  
  55. /* The NET struct has all the actual interface characteristics which are
  56.     visible at the internet level and has pointers to the interface
  57.     handling routines.
  58. */
  59.  
  60. struct net {
  61.     char    *n_name;    /* 00 the net's name in ascii */
  62.     int    (*n_init)();    /* 02 the net initialization routine */
  63.     int    (*n_send)();    /* 04 the packet xmit routine */
  64.     int    (*n_swtch)();    /* 06 interrupt vector swap routine */
  65.     int    (*n_close)();    /* 08 the protocol close routine */
  66.     int    (*n_ip_send)();    /* 0a internet packet send handler */
  67.     int    (*n_stats)();    /* ... per net statistics */
  68.     task    *n_demux;    /* 22 packet demultiplexing task to protocol */
  69.     queue    *n_inputq;    /* 24 the queue of received packets */
  70.     unsigned n_initp1;    /* 30 initialization parameter one */
  71.     unsigned n_initp2;    /* 32    "         "        two */
  72.     int    n_stksiz;    /* 34 net task initial stack size */
  73.     int    n_lnh;        /* 36 the net's local net header  size */
  74.     int    n_lnt;        /* 38 the net's local net trailer size */
  75.     /* we could get our ip address and default gateway out of the
  76.         custom structure too.
  77.     */
  78.     in_name    ip_addr;    /* 3A the interface's internet address */
  79.     in_name n_defgw;    /* the default gateway for this net */
  80.     in_name n_netbr;    /* DDP - our network broadcast address */
  81.     in_name n_netbr42;    /* DDP - our (4.2BSD) network broadcast  */
  82.     in_name n_subnetbr;    /* DDP - our subnetwork broadcast address */
  83.     struct custom    *n_custom;    /* net's custom structure */
  84.     unsigned char n_hal;    /* DDP - Hardware address length (for bootp) */
  85.     unsigned char n_htype;    /* DDP - Hardware type (for bootp) */
  86.     char    *n_haddr;    /* DDP - Pointer to hardware address, size= n_hal */
  87.     char    *n_per_net;    /* per-net interface info */
  88.     };
  89.  
  90.  
  91. typedef struct net NET;
  92.  
  93. /* Here are the debugging things. DEBUG is a global variable whose value
  94.     determines what sort of debugging messages will be displayed by
  95.     the system. */
  96.  
  97. extern unsigned NDEBUG;        /* Debugging options */
  98. extern int MaxLnh;        /* Largest local net header size */
  99. extern unsigned version;    /* program version number */
  100.  
  101. #define    BUGHALT        1    /* BUGHALT on a gross applications level error
  102.                     that is detected in the network code */
  103.  
  104. #define    DUMP        2    /* Works in conjuction with other options:
  105.                    BUGHALT:  Dump all arriving packets
  106.                    PROTERR:  Dump header for level of error
  107.                           NETTRACE, etc.:  Dump headers at trace
  108.                                          level */
  109.  
  110. #define    INFOMSG        4    /* Print informational messages such as packet
  111.                     received, etc. */
  112.  
  113. #define    NETERR        8    /* Display net interface error messages */
  114.  
  115. #define    PROTERR        16    /* Display protocol level error messages */
  116.  
  117. #define    TMO        64    /* Print message on timeout */
  118.  
  119. #define NETRACE        32    /* Trace packet in link level net layer */
  120.  
  121. #define IPTRACE        512    /* Trace packet in internet layer  */
  122.  
  123. #define TPTRACE        256    /* Transport protocol (UDP/TCP/RVD) trace */
  124.  
  125. #define APTRACE        128    /* Trace packet through application */
  126.  
  127. /*  The following two definitions provide a standard way for one net level
  128. to tell the next that things worked out as hoped or that they didn't.  */
  129.  
  130. #define SUCCESS        1
  131.  
  132. #define FAILURE        -1
  133. #endif                /* DDP */
  134.