home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / KA9QTCPP / NNTP4NOS.ZIP / CONFIG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-30  |  14.7 KB  |  634 lines

  1. /* Stuff heavily dependent on the configuration info in config.h */
  2.  
  3. #include <stdio.h>
  4. #include <dos.h>
  5. #include "global.h"
  6. #include "mbuf.h"
  7. #include "proc.h"
  8. #include "cmdparse.h"
  9. #include "config.h"
  10. #include "daemon.h"
  11. #include "timer.h"
  12. #include "iface.h"
  13. #include "pktdrvr.h"
  14. #include "slip.h"
  15. #include "usock.h"
  16. #include "kiss.h"
  17. #include "enet.h"
  18. #include "ax25.h"
  19. #include "netrom.h"
  20. #include "arp.h"
  21. #include "ip.h"
  22. #include "icmp.h"
  23. #include "tcp.h"
  24. #include "udp.h"
  25. #include "commands.h"
  26.  
  27. static int dostart __ARGS((int argc,char *argv[],void *p));
  28. static int dostop __ARGS((int argc,char *argv[],void *p));
  29.  
  30. static void axip __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  31.     char *dest,struct mbuf *bp,int mcast));
  32. static void axarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  33.     char *dest,struct mbuf *bp,int mcast));
  34. static void axnr __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  35.     char *dest,struct mbuf *bp,int mcast));
  36.  
  37. struct mbuf *Hopper;
  38. unsigned Nsessions = NSESSIONS;
  39. int32 Heapsize = HEAPSIZE * (long)1024;
  40.  
  41. /* Free memory threshold, below which things start to happen to conserve
  42.  * memory, like issuing source quenches and refusing connects
  43.  */
  44. int32 Memthresh = MTHRESH;
  45.  
  46. /* Transport protocols atop IP */
  47. struct iplink Iplink[] = {
  48.     TCP_PTCL,    tcp_input,
  49.     UDP_PTCL,    udp_input,
  50.     ICMP_PTCL,    icmp_input,
  51.     0,        0
  52. };
  53.  
  54. /* Transport protocols atop ICMP */
  55. struct icmplink Icmplink[] = {
  56.     TCP_PTCL,    tcp_icmp,
  57.     0,        0
  58. };
  59.  
  60. /* ARP protocol linkages */
  61. struct arp_type Arp_type[NHWTYPES] = {
  62. #ifdef    NETROM
  63.     AXALEN, 0, 0, 0, NULLCHAR, pax25, setcall,    /* ARP_NETROM */
  64. #else
  65.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  66. #endif
  67.  
  68. #ifdef    ETHER
  69.     EADDR_LEN,IP_TYPE,ARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  70. #else
  71.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  72. #endif
  73.  
  74.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_EETHER */
  75.  
  76. #ifdef    AX25
  77.     AXALEN, PID_IP, PID_ARP, 10, Ax25_bdcst, pax25, setcall,
  78. #else
  79.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_AX25 */
  80. #endif
  81.  
  82.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_PRONET */
  83.  
  84.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_CHAOS */
  85.  
  86.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_IEEE802 */
  87.  
  88. #ifdef    ARCNET
  89.     AADDR_LEN, ARC_IP, ARC_ARP, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  90. #else
  91.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  92. #endif
  93.  
  94.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_APPLETALK */
  95. };
  96.  
  97. #ifdef    AX25
  98. /* Linkage to network protocols atop ax25 */
  99. struct axlink Axlink[] = {
  100.     PID_IP,        axip,
  101.     PID_ARP,    axarp,
  102. #ifdef    NETROM
  103.     PID_NETROM,    axnr,
  104. #endif
  105.     PID_NO_L3,    axnl3,
  106.     0,        NULL,
  107. };
  108.  
  109. /* List of AX.25 multicast addresses */
  110. char *Axmulti[] = {
  111.     Ax25_bdcst,
  112. #ifdef    NETROM
  113.     Nr_nodebc,
  114. #endif
  115.     NULLCHAR,
  116. };
  117. #endif
  118.  
  119. /* daemons to be run at startup time */
  120. struct daemon Daemons[] = {
  121.     "killer",    200,    killer,
  122.     "timer",    1024,    timerproc,
  123.     "network",    1536,    network,
  124.     "keyboard",    250,    keyboard,
  125.     NULLCHAR,    0,    NULLVFP
  126. };
  127.  
  128. struct iftype Iftypes[] = {
  129.     /* This entry must be first, since Loopback refers to it */
  130.     "None",        NULL,        NULL,        NULL,
  131.     NULL,        CL_NONE,    0,
  132.  
  133. #ifdef    AX25
  134.     "AX25",        ax_send,    ax_output,    pax25,
  135.     setcall,    CL_AX25,    AXALEN,
  136. #endif
  137.  
  138. #ifdef    SLIP
  139.     "SLIP",        slip_send,    NULL,        NULL,
  140.     NULL,        CL_NONE,    0,
  141. #endif
  142.  
  143. #ifdef    ETHER
  144.     /* Note: NULL is specified for the scan function even though
  145.      * gether() exists because the packet drivers don't support
  146.      * address setting.
  147.      */
  148.     "Ethernet",    enet_send,    enet_output,    pether,
  149.     NULL,        CL_ETHERNET,    EADDR_LEN,
  150. #endif
  151.  
  152. #ifdef    NETROM
  153.     "NETROM",    nr_send,    NULL,        pax25,
  154.     setcall,    CL_NETROM,    AXALEN,
  155. #endif
  156.  
  157. #ifdef    SLFP
  158.     "SLFP",        pk_send,    NULL,        NULL,
  159.     NULL,        CL_NONE,    0,
  160. #endif
  161.  
  162.     NULLCHAR
  163. };
  164.  
  165. /* Command lookup and branch tables */
  166. struct cmds Cmds[] = {
  167.     /* The "go" command must be first */
  168.     "",        go,        0, 0, NULLCHAR,
  169. #ifndef    AMIGA
  170.     "!",        doshell,    0, 0, NULLCHAR,
  171. #endif
  172.     "abort",    doabort,    0, 0, NULLCHAR,
  173. #ifdef    AMIGA
  174.     "amiga",    doamiga,    0, 0, NULLCHAR,
  175. #endif
  176. #if    (defined(MAC) && defined(APPLETALK))
  177.     "applestat",    doatstat,    0,    0, NULLCHAR,
  178. #endif
  179. #if    (defined(AX25) || defined(ETHER) || defined(APPLETALK))
  180.     "arp",        doarp,        0, 0, NULLCHAR,
  181. #endif
  182. #ifdef    ASY
  183.     "asystat",    doasystat,    0, 0, NULLCHAR,
  184. #endif
  185. #ifdef    AX25
  186.     "ax25",        doax25,        0, 0, NULLCHAR,
  187. #endif    
  188.     "attach",    doattach,    0, 2,
  189.         "attach <hardware> <hw specific options>",
  190. /* This one is out of alpabetical order to allow abbreviation to "c" */
  191. #ifdef    AX25
  192.     "connect",    doconnect,    1024, 3,"connect <interface> <callsign>",
  193. #endif
  194. #if    !defined(UNIX) && !defined(AMIGA)
  195.     "cd",        docd,        0, 0, NULLCHAR,
  196. #endif
  197.     "close",    doclose,    0, 0, NULLCHAR,
  198.     "disconnect",    doclose,    0, 0, NULLCHAR,
  199. #ifndef    AMIGA
  200.     "dir",        dodir,        512, 0, NULLCHAR, /* note sequence */
  201. #endif
  202.     "delete",    dodelete,    0, 2, "delete <file>",
  203.     "detach",    dodetach,    0, 2, "detach <interface>",
  204.     "domain",    dodomain,    0, 0, NULLCHAR,
  205. #ifdef    DRSI
  206.     "drsistat",    dodrstat,    0, 0, NULLCHAR,
  207. #endif
  208. #ifdef    HOPCHECK
  209.     "hopcheck",    dohop,        0, 0, NULLCHAR,
  210. #endif
  211. #ifdef    HS
  212.     "hs",        dohs,        0, 0, NULLCHAR,
  213. #endif
  214. #ifdef    EAGLE
  215.     "eaglestat",    doegstat,    0, 0, NULLCHAR,
  216. #endif
  217.     "echo",        doecho,        0, 0, NULLCHAR,
  218.     "eol",        doeol,        0, 0, NULLCHAR,
  219. #if    !defined(MSDOS)
  220.     "escape",    doescape,    0, 0, NULLCHAR,
  221. #endif
  222. #ifdef    PC_EC
  223.     "etherstat",    doetherstat,    0, 0, NULLCHAR,
  224. #endif
  225.     "exit",        doexit,        0, 0, NULLCHAR,
  226.     "finger",    dofinger,    1024, 2, "finger name@host",
  227.     "ftp",        doftp,        2048, 2, "ftp <address>",
  228. #ifdef HAPN
  229.     "hapnstat",    dohapnstat,    0, 0, NULLCHAR,
  230. #endif
  231.     "help",        dohelp,        0, 0, NULLCHAR,
  232.     "hostname",    dohostname,    0, 0, NULLCHAR,
  233.     "icmp",        doicmp,        0, 0, NULLCHAR,
  234.     "ifconfig",    doifconfig,    0, 0, NULLCHAR,
  235.     "ip",        doip,        0, 0, NULLCHAR,
  236.     "kick",        dokick,        0, 0, NULLCHAR,
  237.     "log",        dolog,        0, 0, NULLCHAR,
  238. #ifdef    MAILBOX
  239.     "mbox",        dombox,        0, 0, NULLCHAR,
  240. #endif
  241.     "mem",        domem,        0, 0, NULLCHAR,
  242. #ifdef    AX25
  243.     "mode",        domode,        0, 2, "mode <interface>",
  244. #endif
  245.     "more",        domore,        512, 2, "more <filename>",
  246. #ifdef    NETROM
  247.     "netrom",    donetrom,    0, 0, NULLCHAR,
  248. #endif  /* NETROM */
  249.     "nntp",        donntp,        0, 0, NULLCHAR,
  250. #ifdef  NETROM
  251. #ifdef    NRS
  252.     "nrstat",    donrstat,    0, 0, NULLCHAR,
  253. #endif    /* NRS */
  254. #endif    /* NETROM */
  255.     "param",    doparam,    0, 2, "param <interface>",
  256.     "ping",        doping,        512, 2, "ping <host> [<length> [<interval> [incflag]]]",
  257.     "ps",        ps,        0, 0, NULLCHAR,
  258. #if    !defined(UNIX) && !defined(AMIGA)
  259.     "pwd",        docd,        0, 0, NULLCHAR,
  260. #endif
  261.     "record",    dorecord,    0, 0, NULLCHAR,
  262.     "remote",    doremote,    0, 3, "remote [-p port] [-k key] [-a kickaddr] <address> exit|reset|kick",
  263.     "rename",    dorename,    0, 3, "rename <oldfile> <newfile>",
  264.     "reset",    doreset,    0, 0, NULLCHAR,
  265. #ifdef    RIP
  266.     "rip",        dorip,        0, 0, NULLCHAR,
  267. #endif
  268.     "route",    doroute,    0, 0, NULLCHAR,
  269.     "session",    dosession,    0, 0, NULLCHAR,
  270. #ifdef    SCC
  271.     "sccstat",    dosccstat,    0, 0, NULLCHAR,
  272. #endif
  273. #if    !defined(AMIGA)
  274.     "shell",    doshell,    0, 0, NULLCHAR,
  275. #endif
  276.     "smtp",        dosmtp,        0, 0, NULLCHAR,
  277.     "socket",    dosock,        0, 0, NULLCHAR,
  278. #ifdef    SERVERS
  279.     "start",    dostart,    0, 2, "start <servername>",
  280.     "stop",        dostop,        0, 2, "stop <servername>",
  281. #endif
  282.     "tcp",        dotcp,        0, 0, NULLCHAR,
  283.     "telnet",    dotelnet,    1024, 2, "telnet <address>",
  284. #ifdef    TRACE
  285.     "trace",    dotrace,    0, 0, NULLCHAR,
  286. #endif
  287.     "udp",        doudp,        0, 0, NULLCHAR,
  288.     "upload",    doupload,    0, 0, NULLCHAR,
  289. #ifdef    MSDOS
  290.     "watch",    doswatch,    0, 0, NULLCHAR,
  291. #endif
  292.     "?",        dohelp,        0, 0, NULLCHAR,
  293.     NULLCHAR,    NULLFP,        0, 0,
  294.         "Unknown command; type \"?\" for list",
  295. };
  296.  
  297. /* List of supported hardware devices */
  298. struct cmds Attab[] = {
  299. #ifdef    PC_EC
  300.     /* 3-Com Ethernet interface */
  301.     "3c500", ec_attach, 0, 7, 
  302.     "attach 3c500 <address> <vector> arpa <label> <buffers> <mtu> [ip_addr]",
  303. #endif
  304. #ifdef    ASY
  305.     /* Ordinary PC asynchronous adaptor */
  306.     "asy", asy_attach, 0, 8, 
  307. #ifndef    AMIGA
  308.     "attach asy <address> <vector> slip|ax25|nrs <label> <buffers> <mtu> <speed> [ip_addr]",
  309. #else
  310.      "attach asy <driver> <unit> slip|ax25|nrs <label> <buffers> <mtu> <speed> [ip_addr]",
  311. #endif    /* AMIGA */
  312. #endif    /* ASY */
  313. #ifdef    PC100
  314.     /* PACCOMM PC-100 8530 HDLC adaptor */
  315.     "pc100", pc_attach, 0, 8, 
  316.     "attach pc100 <address> <vector> ax25 <label> <buffers>\
  317.  <mtu> <speed> [ip_addra] [ip_addrb]",
  318. #endif
  319. #ifdef    DRSI
  320.     /* DRSI PCPA card in low speed mode */
  321.     "drsi", dr_attach, 0, 8,
  322.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu>\
  323. <chan a speed> <chan b speed> [ip addr a] [ip addr b]",
  324. #endif
  325. #ifdef    EAGLE
  326.     /* EAGLE RS-232C 8530 HDLC adaptor */
  327.     "eagle", eg_attach, 0, 8,
  328.     "attach eagle <address> <vector> ax25 <label> <buffers>\
  329.  <mtu> <speed> [ip_addra] [ip_addrb]",
  330. #endif
  331. #ifdef    HAPN
  332.     /* Hamilton Area Packet Radio (HAPN) 8273 HDLC adaptor */
  333.     "hapn", hapn_attach, 0, 8,
  334.     "attach hapn <address> <vector> ax25 <label> <rx bufsize>\
  335.  <mtu> csma|full [ip_addr]",
  336. #endif
  337. #ifdef    APPLETALK
  338.     /* Macintosh AppleTalk */
  339.     "0", at_attach, 0, 7,
  340.     "attach 0 <protocol type> <device> arpa <label> <rx bufsize> <mtu> [ip_addr]",
  341. #endif
  342. #ifdef NETROM
  343.     /* fake netrom interface */
  344.     "netrom", nr_attach, 0, 1,
  345.     "attach netrom [ip_addr]",
  346. #endif
  347. #ifdef    PACKET
  348.     /* FTP Software's packet driver spec */
  349.     "packet", pk_attach, 0, 4,
  350.     "attach packet <int#> <label> <buffers> <mtu> [ip_addr]",
  351. #endif
  352. #ifdef    HS
  353.     /* Special high speed driver for DRSI PCPA or Eagle cards */
  354.     "hs", hs_attach, 0, 7,
  355.     "attach hs <address> <vector> ax25 <label> <buffers> <mtu>\
  356.  <txdelay> <persistence> [ip_addra] [ip_addrb]",
  357. #endif
  358. #ifdef SCC
  359.     "scc", scc_attach, 0, 7,
  360.      "\nattach scc <devices> init <addr> <spacing> <Aoff> <Boff> <Dataoff>\
  361. \n   <intack> <vec> [p]<clock> [hdwe] [param]\
  362. \nattach scc <chan> slip|kiss|nrs|ax25 <label> <mtu> <speed> <bufsiz> [call] ",
  363.   #endif
  364.     NULLCHAR,
  365. };
  366.  
  367. /* Packet tracing stuff */
  368. #ifdef    TRACE
  369. #include "trace.h"
  370.  
  371. /* Protocol tracing function pointers. Matches list of class definitions
  372.  * in pktdrvr.h.
  373.  */
  374. struct trace Tracef[] = {
  375.     NULLFP,        ip_dump,    /* CL_NONE */
  376.  
  377. #ifdef    ETHER                /* CL_ETHERNET */
  378.     ether_forus,    ether_dump,
  379. #else
  380.     NULLFP,        NULLVFP,
  381. #endif    /* ETHER */
  382.  
  383.     NULLFP,        NULLVFP,    /* CL_PRONET_10 */
  384.     NULLFP,        NULLVFP,    /* CL_IEEE8025 */
  385.     NULLFP,        NULLVFP,    /* CL_OMNINET */
  386.  
  387. #ifdef    APPLETALK
  388.     at_forus,    at_dump,    /* CL_APPLETALK */
  389. #else
  390.     NULLFP,        NULLVFP,
  391. #endif    /* APPLETALK */
  392.  
  393.     NULLFP,        ip_dump,    /* CL_SERIAL_LINE */
  394.     NULLFP,        NULLVFP,    /* CL_STARLAN */
  395.  
  396. #ifdef    ARCNET
  397.     arc_forus,    arc_dump,    /* CL_ARCNET */
  398. #else
  399.     NULLFP,        NULLVFP,
  400. #endif    /* ARCNET */
  401.  
  402. #ifdef    AX25
  403.     ax_forus,    ax25_dump,    /* CL_AX25 */
  404. #else
  405.     NULLFP,        NULLVFP,
  406. #endif    /* AX25 */
  407.  
  408. #ifdef    KISS                /* CL_KISS */
  409.     ki_forus,    ki_dump,
  410. #else
  411.     NULLFP,        NULLVFP,
  412. #endif    /* KISS */
  413.  
  414.     NULLFP,        NULLVFP,    /* CL_IEEE8023 */
  415.     NULLFP,        NULLVFP,    /* CL_FDDI */
  416.     NULLFP,        NULLVFP,    /* CL_INTERNET_X25 */
  417.     NULLFP,        NULLVFP,    /* CL_LANSTAR */
  418.     NULLFP,        ip_dump,    /* CL_SLFP */
  419.  
  420. #ifdef    NETROM                /* CL_NETROM */
  421.     NULLFP,        ip_dump,
  422. #else
  423.     NULLFP,        NULLVFP,
  424. #endif
  425.  
  426. };
  427. #else    /* TRACE */
  428.  
  429. /* Stub for packet dump function */
  430. void
  431. dump(iface,direction,type,bp)
  432. struct iface *iface;
  433. int direction;
  434. unsigned type;
  435. struct mbuf *bp;
  436. {
  437. }
  438. #endif    /* TRACE */
  439.  
  440.  
  441. #ifdef    AX25
  442. /* Hooks for passing incoming AX.25 data frames to network protocols */
  443. static void
  444. axip(iface,axp,src,dest,bp,mcast)
  445. struct iface *iface;
  446. struct ax25_cb *axp;
  447. char *src;
  448. char *dest;
  449. struct mbuf *bp;
  450. int mcast;
  451. {
  452.     (void)ip_route(iface,bp,mcast);
  453. }
  454.  
  455. static void
  456. axarp(iface,axp,src,dest,bp,mcast)
  457. struct iface *iface;
  458. struct ax25_cb *axp;
  459. char *src;
  460. char *dest;
  461. struct mbuf *bp;
  462. int mcast;
  463. {
  464.     (void)arp_input(iface,bp);
  465. }
  466.  
  467. #ifdef    NETROM
  468. static void
  469. axnr(iface,axp,src,dest,bp,mcast)
  470. struct iface *iface;
  471. struct ax25_cb *axp;
  472. char *src;
  473. char *dest;
  474. struct mbuf *bp;
  475. int mcast;
  476. {
  477.     if(!mcast)
  478.         nr_route(bp,axp);
  479.     else
  480.         nr_nodercv(iface,src,bp);
  481. }
  482.  
  483. #endif    /* NETROM */
  484. #endif    /* AX25 */
  485.  
  486. #ifndef    RIP
  487. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  488. void
  489. rt_timeout(s)
  490. void *s;
  491. {
  492.     struct route *stale = (struct route *)s;
  493.  
  494.     rt_drop(stale->target,stale->bits);
  495. }
  496. #endif
  497.  
  498. #ifdef    SERVERS
  499. /* "start" and "stop" subcommands */
  500. static struct cmds Startcmds[] = {
  501. #if    defined(AX25) && defined(MAILBOX)
  502.     "ax25",        ax25start,    256, 0, NULLCHAR,
  503. #endif
  504.     "discard",    dis1,        256, 0, NULLCHAR,
  505.     "echo",        echo1,        256, 0, NULLCHAR,
  506.     "finger",    finstart,    256, 0, NULLCHAR,
  507.     "ftp",        ftpstart,    256, 0, NULLCHAR,
  508. #if    defined(NETROM) && defined(MAILBOX)
  509.     "netrom",    nr4start,    256, 0, NULLCHAR,
  510. #endif
  511. #ifdef    RIP
  512.     "rip",        doripinit,    0,   0, NULLCHAR,
  513. #endif
  514.     "smtp",        smtp1,        256, 0, NULLCHAR,
  515. #if    defined(MAILBOX)
  516.     "telnet",    telnet1,    256, 0, NULLCHAR,
  517. #endif
  518.     "ttylink",    ttylstart,    256, 0, NULLCHAR,
  519.     "remote",    rem1,        256, 0, NULLCHAR,
  520.     NULLCHAR,
  521. };
  522. static struct cmds Stopcmds[] = {
  523. #if    defined(AX25) && defined(MAILBOX)
  524.     "ax25",        ax250,        0, 0, NULLCHAR,
  525. #endif
  526.     "discard",    dis0,        0, 0, NULLCHAR,
  527.     "echo",        echo0,        0, 0, NULLCHAR,
  528.     "finger",    fin0,        0, 0, NULLCHAR,
  529.     "ftp",        ftp0,        0, 0, NULLCHAR,
  530. #if    defined(NETROM) && defined(MAILBOX)
  531.     "netrom",    nr40,        0, 0, NULLCHAR,
  532. #endif
  533. #ifdef    RIP
  534.     "rip",        doripstop,    0, 0, NULLCHAR,
  535. #endif
  536.     "smtp",        smtp0,        0, 0, NULLCHAR,
  537. #ifdef    MAILBOX
  538.     "telnet",    telnet0,    0, 0, NULLCHAR,
  539. #endif
  540.     "ttylink",    ttyl0,        0, 0, NULLCHAR,
  541.     "remote",    rem0,        0, 0, NULLCHAR,
  542.     NULLCHAR,
  543.  
  544. };
  545. static int
  546. dostart(argc,argv,p)
  547. int argc;
  548. char *argv[];
  549. void *p;
  550. {
  551.     return subcmd(Startcmds,argc,argv,p);
  552. }
  553. static int
  554. dostop(argc,argv,p)
  555. int argc;
  556. char *argv[];
  557. void *p;
  558. {
  559.     return subcmd(Stopcmds,argc,argv,p);
  560. }
  561. #endif    /* SERVERS */
  562.  
  563. /* Various configuration-dependent functions */
  564.  
  565. /* Process packets in the Hopper */
  566. static void
  567. network(i,v1,v2)
  568. int i;
  569. void *v1;
  570. void *v2;
  571. {
  572.     struct mbuf *bp;
  573.     struct phdr phdr;
  574.     char i_state;
  575.  
  576. loop:
  577.     refiq();    /* Replenish interrupt buffer pool */
  578.  
  579.     i_state = dirps();
  580.     while(Hopper == NULLBUF)
  581.         pwait(&Hopper);
  582.     restore(i_state);
  583.  
  584.     /* Process the input packet */
  585.     bp = dequeue(&Hopper);
  586.     pullup(&bp,(char *)&phdr,sizeof(phdr));
  587.     if(phdr.iface != NULLIF)
  588.         phdr.iface->rawrecvcnt++;
  589.     dump(phdr.iface,IF_TRACE_IN,phdr.type,bp);
  590.     switch(phdr.type){
  591. #ifdef    KISS
  592.     case CL_KISS:
  593.         kiss_recv(phdr.iface,bp);
  594.         break;
  595. #endif
  596. #ifdef    AX25
  597.     case CL_AX25:
  598.         ax_recv(phdr.iface,bp);
  599.         break;
  600. #endif
  601. #ifdef    ETHER
  602.     case CL_ETHERNET:
  603.         eproc(phdr.iface,bp);
  604.         break;
  605. #endif
  606. #ifdef ARCNET
  607.     case CL_ARCNET:
  608.         aproc(phdr.iface,bp);
  609.         break;
  610. #endif
  611.     /* These types have no link layer protocol at the point when they're
  612.      * put in the hopper, so they can be handed directly to IP. The
  613.      * separate types are just for user convenience when running the
  614.      * "iface" command.
  615.      */
  616.     case CL_NONE:
  617.     case CL_SERIAL_LINE:
  618.     case CL_SLFP:
  619.         ip_route(phdr.iface,bp,0);
  620.         break;
  621.     default:
  622.         free_p(bp);
  623.         break;
  624.     }
  625.     /* Let everything else run - this keeps the system from wedging
  626.      * when we're hit by a big burst of packets
  627.      */
  628.     pwait(NULL);
  629.     goto loop;
  630. }
  631.  
  632.  
  633.  
  634.