home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / s920603.zip / CONFIG.C < prev    next >
C/C++ Source or Header  |  1992-06-01  |  24KB  |  1,041 lines

  1. /* A collection of stuff heavily dependent on the configuration info
  2.  * in config.h. The idea is that configuration-dependent tables should
  3.  * be located here to avoid having to pepper lots of .c files with #ifdefs,
  4.  * requiring them to include config.h and be recompiled each time config.h
  5.  * is modified.
  6.  *
  7.  * Copyright 1991 Phil Karn, KA9Q
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include <dos.h>
  12. #include "global.h"
  13. #include "config.h"
  14. #include "mbuf.h"
  15. #include "timer.h"
  16. #include "proc.h"
  17. #include "iface.h"
  18. #include "ip.h"
  19. #include "tcp.h"
  20. #include "udp.h"
  21. #ifdef    ARCNET
  22. #include "arcnet.h"
  23. #endif
  24. #include "lapb.h"
  25. #include "ax25.h"
  26. #include "enet.h"
  27. #include "kiss.h"
  28. #include "nr4.h"
  29. #include "nrs.h"
  30. #include "netrom.h"
  31. #include "pktdrvr.h"
  32. #include "ppp.h"
  33. #include "slip.h"
  34. #include "arp.h"
  35. #include "icmp.h"
  36. #include "hardware.h"    /***/
  37. #include "usock.h"
  38. #include "cmdparse.h"
  39. #include "commands.h"
  40. #include "mailbox.h"
  41. #include "ax25mail.h"
  42. #include "nr4mail.h"
  43. #include "tipmail.h"
  44. #include "daemon.h"
  45. #include "bootp.h"
  46. #include "asy.h"
  47. #include "trace.h"
  48. #ifdef    QTSO
  49. #include "qtso.h"
  50. #endif
  51.  
  52. int dotest __ARGS((int argc,char *argv[],void *p));    /**/
  53. static int dostart __ARGS((int argc,char *argv[],void *p));
  54. static int dostop __ARGS((int argc,char *argv[],void *p));
  55.  
  56. #ifdef    AX25
  57. static void axip __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  58.     char *dest,struct mbuf *bp,int mcast));
  59. static void axarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  60.     char *dest,struct mbuf *bp,int mcast));
  61. static void axnr __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  62.     char *dest,struct mbuf *bp,int mcast));
  63. #endif    /* AX25 */
  64.  
  65. struct mbuf *Hopper;        /* Queue of incoming packets */
  66. unsigned Nsessions = NSESSIONS;
  67. unsigned Nsock = DEFNSOCK;        /* Number of socket entries */
  68.  
  69. /* Free memory threshold, below which things start to happen to conserve
  70.  * memory, like garbage collection, source quenching and refusing connects
  71.  */
  72. int32 Memthresh = MTHRESH;
  73.  
  74. int Nibufs = NIBUFS;        /* Number of interrupt buffers */
  75. unsigned Ibufsize = IBUFSIZE;    /* Size of each interrupt buffer */
  76. unsigned Nfiles = DEFNFILES;
  77.  
  78. /* Command lookup and branch tables */
  79. struct cmds Cmds[] = {
  80.     /* The "go" command must be first */
  81.     "",        go,        0, 0, NULLCHAR,
  82. #ifndef    AMIGA
  83.     "!",        doshell,    0, 0, NULLCHAR,
  84. #endif
  85.     "abort",    doabort,    0, 0, NULLCHAR,
  86. #ifdef    AMIGA
  87.     "amiga",    doamiga,    0, 0, NULLCHAR,
  88. #endif
  89. #if    (defined(MAC) && defined(APPLETALK))
  90.     "applestat",    doatstat,    0,    0, NULLCHAR,
  91. #endif
  92. #if    (defined(AX25) || defined(ETHER) || defined(APPLETALK))
  93.     "arp",        doarp,        0, 0, NULLCHAR,
  94. #endif
  95. #ifdef    ASY
  96.     "asystat",    doasystat,    0, 0, NULLCHAR,
  97. #endif
  98.     "attach",    doattach,    0, 2,
  99.         "attach <hardware> <hw specific options>",
  100. #ifdef    AX25
  101.     "ax25",        doax25,        0, 0, NULLCHAR,
  102. #endif
  103. #ifdef    BOOTP
  104.     "bootp",    dobootp,    0, 0, NULLCHAR,
  105.     "bootpd",    bootpdcmd,    0, 0, NULLCHAR,
  106. #endif
  107. /* This one is out of alpabetical order to allow abbreviation to "c" */
  108. #ifdef    AX25
  109.     "connect",    doconnect,    1024, 3,
  110.     "connect <interface> <callsign>",
  111. #endif
  112. #if    !defined(UNIX) && !defined(AMIGA)
  113.     "cd",        docd,        0, 0, NULLCHAR,
  114. #endif
  115.     "close",    doclose,    0, 0, NULLCHAR,
  116. /* This one is out of alpabetical order to allow abbreviation to "d" */
  117.     "disconnect",    doclose,    0, 0, NULLCHAR,
  118.     "delete",    dodelete,    0, 2, "delete <file>",
  119.     "detach",    dodetach,    0, 2, "detach <interface>",
  120. #ifdef    DIALER
  121.     "dialer",    dodialer,    0, 2,
  122.     "dialer <iface> <timeout> [<raise script> <lower script>]",
  123. #endif
  124. #ifndef    AMIGA
  125.     "dir",        dodir,        512, 0, NULLCHAR, /* note sequence */
  126. #endif
  127.     "domain",    dodomain,    0, 0, NULLCHAR,
  128. #ifdef    DRSI
  129.     "drsistat",    dodrstat,    0, 0, NULLCHAR,
  130. #endif
  131. #ifdef    EAGLE
  132.     "eaglestat",    doegstat,    0, 0, NULLCHAR,
  133. #endif
  134.     "echo",        doecho,        0, 0, NULLCHAR,
  135.     "eol",        doeol,        0, 0, NULLCHAR,
  136. #if    !defined(MSDOS)
  137.     "escape",    doescape,    0, 0, NULLCHAR,
  138. #endif
  139.     "exit",        doexit,        0, 0, NULLCHAR,
  140.     "files",    dofiles,    0, 0, NULLCHAR,
  141.     "finger",    dofinger,    1024, 2, "finger name@host",
  142.     "ftp",        doftp,        2048, 2, "ftp <address>",
  143. #ifdef HAPN
  144.     "hapnstat",    dohapnstat,    0, 0, NULLCHAR,
  145. #endif
  146.     "help",        dohelp,        0, 0, NULLCHAR,
  147. #ifdef    HOPCHECK
  148.     "hop",        dohop,        0, 0, NULLCHAR,
  149. #endif
  150.     "hostname",    dohostname,    0, 0, NULLCHAR,
  151. #ifdef    HS
  152.     "hs",        dohs,        0, 0, NULLCHAR,
  153. #endif
  154.     "icmp",        doicmp,        0, 0, NULLCHAR,
  155.     "ifconfig",    doifconfig,    0, 0, NULLCHAR,
  156.     "ip",        doip,        0, 0, NULLCHAR,
  157. #ifdef    MSDOS
  158.     "isat",        doisat,        0, 0, NULLCHAR,
  159. #endif
  160.     "kick",        dokick,        0, 0, NULLCHAR,
  161.     "log",        dolog,        0, 0, NULLCHAR,
  162. #ifdef    MAILBOX
  163.     "mbox",        dombox,        0, 0, NULLCHAR,
  164. #endif
  165. #ifndef    UNIX
  166.     "memory",    domem,        0, 0, NULLCHAR,
  167. #endif
  168.     "mkdir",    domkd,        0, 2, "mkdir <directory>",
  169. #ifdef    AX25
  170.     "mode",        domode,        0, 2, "mode <interface>",
  171. #endif
  172.     "more",        doview,        0, 2, "more <filename>",
  173. #ifdef    NETROM
  174.     "netrom",    donetrom,    0, 0, NULLCHAR,
  175. #endif    /* NETROM */
  176. #ifdef    NNTP
  177.     "nntp",        donntp,        0, 0, NULLCHAR,
  178. #endif    /* NNTP */
  179. #ifdef    NRS
  180.     "nrstat",    donrstat,    0, 0, NULLCHAR,
  181. #endif    /* NRS */
  182.     "param",    doparam,    0, 2, "param <interface>",
  183.     "ping",        doping,        512, 2,
  184.     "ping <hostid> [<length> [<interval> [incflag]]]",
  185. #ifdef    PI
  186.     "pistatus",    dopistat,    0, 0, NULLCHAR,
  187. #endif
  188. #ifdef POP
  189.     "pop",        dopop,        0, 0, NULLCHAR,
  190. #endif
  191. #ifdef PPP
  192.     "ppp",        doppp_commands,    0, 0, NULLCHAR,
  193. #endif
  194.     "ps",        ps,        0, 0, NULLCHAR,
  195. #if    !defined(UNIX) && !defined(AMIGA)
  196.     "pwd",        docd,        0, 0, NULLCHAR,
  197. #endif
  198.     "record",    dorecord,    0, 0, NULLCHAR,
  199.     "remote",    doremote,    0, 3, "remote [-p port] [-k key] [-a kickaddr] <address> exit|reset|kick",
  200.     "rename",    dorename,    0, 3, "rename <oldfile> <newfile>",
  201.     "reset",    doreset,    0, 0, NULLCHAR,
  202. #ifdef    RIP
  203.     "rip",        dorip,        0, 0, NULLCHAR,
  204. #endif
  205.     "rmdir",    dormd,        0, 2, "rmdir <directory>",
  206.     "route",    doroute,    0, 0, NULLCHAR,
  207.     "session",    dosession,    0, 0, NULLCHAR,
  208. #ifdef    SCC
  209.     "sccstat",    dosccstat,    0, 0, NULLCHAR,
  210. #endif
  211. #if    !defined(AMIGA)
  212.     "shell",    doshell,    0, 0, NULLCHAR,
  213. #endif
  214.     "smtp",        dosmtp,        0, 0, NULLCHAR,
  215.     "socket",    dosock,        0, 0, NULLCHAR,
  216. #ifdef    SERVERS
  217.     "start",    dostart,    0, 2, "start <servername>",
  218.     "stop",        dostop,        0, 2, "stop <servername>",
  219. #endif
  220.     "tcp",        dotcp,        0, 0, NULLCHAR,
  221.     "telnet",    dotelnet,    1024, 2, "telnet <address>",
  222.     "test",        dotest,        1024, 0, NULLCHAR,
  223.     "tip",        dotip,        256, 2, "tip <iface>",
  224. #ifdef    TRACE
  225.     "trace",    dotrace,    512, 0, NULLCHAR,
  226. #endif
  227.     "udp",        doudp,        0, 0, NULLCHAR,
  228.     "upload",    doupload,    0, 0, NULLCHAR,
  229.     "view",        doview,        0, 2, "view <filename>",
  230. #ifdef    MSDOS
  231.     "watch",    doswatch,    0, 0, NULLCHAR,
  232. #endif
  233.     "?",        dohelp,        0, 0, NULLCHAR,
  234.     NULLCHAR,    NULLFP,        0, 0,
  235.         "Unknown command; type \"?\" for list",
  236. };
  237.  
  238. /* List of supported hardware devices */
  239. struct cmds Attab[] = {
  240. #ifdef    ASY
  241.     /* Ordinary PC asynchronous adaptor */
  242.     "asy", asy_attach, 0, 8,
  243. #ifndef    AMIGA
  244.     "attach asy <address> <vector> slip|ax25|nrs|ppp <label> <buffers> <mtu> <speed> [ip_addr]",
  245. #else
  246.     "attach asy <driver> <unit> slip|ax25|nrs|ppp <label> <buffers> <mtu> <speed> [ip_addr]",
  247. #endif    /* AMIGA */
  248. #endif    /* ASY */
  249. #ifdef    PC100
  250.     /* PACCOMM PC-100 8530 HDLC adaptor */
  251.     "pc100", pc_attach, 0, 8,
  252.     "attach pc100 <address> <vector> ax25 <label> <buffers>\
  253.  <mtu> <speed> [ip_addra] [ip_addrb]",
  254. #endif
  255. #ifdef    DRSI
  256.     /* DRSI PCPA card in low speed mode */
  257.     "drsi", dr_attach, 0, 8,
  258.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu>\
  259. <chan a speed> <chan b speed> [ip addr a] [ip addr b]",
  260. #endif
  261. #ifdef    EAGLE
  262.     /* EAGLE RS-232C 8530 HDLC adaptor */
  263.     "eagle", eg_attach, 0, 8,
  264.     "attach eagle <address> <vector> ax25 <label> <buffers>\
  265.  <mtu> <speed> [ip_addra] [ip_addrb]",
  266. #endif
  267. #ifdef    PI
  268.     /* PI 8530 HDLC adaptor */
  269.     "pi", pi_attach, 0, 8,
  270.     "attach pi <address> <vector> <dmachannel> ax25 <label> <buffers>\
  271.  <mtu> <speed> [ip_addra] [ip_addrb]",
  272. #endif
  273. #ifdef    HAPN
  274.     /* Hamilton Area Packet Radio (HAPN) 8273 HDLC adaptor */
  275.     "hapn", hapn_attach, 0, 8,
  276.     "attach hapn <address> <vector> ax25 <label> <rx bufsize>\
  277.  <mtu> csma|full [ip_addr]",
  278. #endif
  279. #ifdef    APPLETALK
  280.     /* Macintosh AppleTalk */
  281.     "0", at_attach, 0, 7,
  282.     "attach 0 <protocol type> <device> arpa <label> <rx bufsize> <mtu> [ip_addr]",
  283. #endif
  284. #ifdef NETROM
  285.     /* fake netrom interface */
  286.     "netrom", nr_attach, 0, 1,
  287.     "attach netrom [ip_addr]",
  288. #endif
  289. #ifdef    PACKET
  290.     /* FTP Software's packet driver spec */
  291.     "packet", pk_attach, 0, 4,
  292.     "attach packet <int#> <label> <buffers> <mtu> [ip_addr]",
  293. #endif
  294. #ifdef    HS
  295.     /* Special high speed driver for DRSI PCPA or Eagle cards */
  296.     "hs", hs_attach, 0, 7,
  297.     "attach hs <address> <vector> ax25 <label> <buffers> <mtu>\
  298.  <txdelay> <persistence> [ip_addra] [ip_addrb]",
  299. #endif
  300. #ifdef SCC
  301.     "scc", scc_attach, 0, 7,
  302.     "attach scc <devices> init <addr> <spacing> <Aoff> <Boff> <Dataoff>\n"
  303.     "   <intack> <vec> [p]<clock> [hdwe] [param]\n"
  304.     "attach scc <chan> slip|kiss|nrs|ax25 <label> <mtu> <speed> <bufsize> [call] ",
  305. #endif
  306.     NULLCHAR,
  307. };
  308.  
  309. #ifdef    SERVERS
  310. /* "start" and "stop" subcommands */
  311. static struct cmds Startcmds[] = {
  312. #if    defined(AX25) && defined(MAILBOX)
  313.     "ax25",        ax25start,    256, 0, NULLCHAR,
  314. #endif
  315.     "discard",    dis1,        256, 0, NULLCHAR,
  316.     "echo",        echo1,        256, 0, NULLCHAR,
  317.     "finger",    finstart,    256, 0, NULLCHAR,
  318.     "ftp",        ftpstart,    256, 0, NULLCHAR,
  319. #if    defined(NETROM) && defined(MAILBOX)
  320.     "netrom",    nr4start,    256, 0, NULLCHAR,
  321. #endif
  322. #ifdef POP
  323.     "pop",        pop1,        256, 0, NULLCHAR,
  324. #endif
  325. #ifdef    RIP
  326.     "rip",        doripinit,    0,   0, NULLCHAR,
  327. #endif
  328.     "smtp",        smtp1,        256, 0, NULLCHAR,
  329. #if    defined(MAILBOX)
  330.     "telnet",    telnet1,    256, 0, NULLCHAR,
  331.     "tip",        tipstart,    256, 2, "start tip <interface>",
  332. #endif
  333.     "ttylink",    ttylstart,    256, 0, NULLCHAR,
  334.     "remote",    rem1,        768, 0, NULLCHAR,
  335.     NULLCHAR,
  336. };
  337.  
  338. static struct cmds Stopcmds[] = {
  339. #if    defined(AX25) && defined(MAILBOX)
  340.     "ax25",        ax250,        0, 0, NULLCHAR,
  341. #endif
  342.     "discard",    dis0,        0, 0, NULLCHAR,
  343.     "echo",        echo0,        0, 0, NULLCHAR,
  344.     "finger",    fin0,        0, 0, NULLCHAR,
  345.     "ftp",        ftp0,        0, 0, NULLCHAR,
  346. #if    defined(NETROM) && defined(MAILBOX)
  347.     "netrom",    nr40,        0, 0, NULLCHAR,
  348. #endif
  349. #ifdef    POP
  350.     "pop",        pop0,        0, 0, NULLCHAR,
  351. #endif
  352. #ifdef    RIP
  353.     "rip",        doripstop,    0, 0, NULLCHAR,
  354. #endif
  355.     "smtp",        smtp0,        0, 0, NULLCHAR,
  356. #ifdef    MAILBOX
  357.     "telnet",    telnet0,    0, 0, NULLCHAR,
  358.     "tip",        tip0,        0, 2, "stop tip <interface>",
  359. #endif
  360.     "ttylink",    ttyl0,        0, 0, NULLCHAR,
  361.     "remote",    rem0,        0, 0, NULLCHAR,
  362.     NULLCHAR,
  363. };
  364. #endif    /* SERVERS */
  365.  
  366. /* Socket-protocol interface table */
  367. struct socklink Socklink[] = {
  368.     /* type,
  369.      * socket,    bind,        listen,        connect,
  370.      * accept,    recv,        send,        qlen,
  371.      * kick,    shut,        close,        check,
  372.      * error,    state,        status,        eol_seq
  373.      */
  374.     TYPE_TCP,
  375.     so_tcp,        NULLFP,        so_tcp_listen,    so_tcp_conn,
  376.     TRUE,        so_tcp_recv,    so_tcp_send,    so_tcp_qlen,
  377.     so_tcp_kick,    so_tcp_shut,    so_tcp_close,    checkipaddr,
  378.     Tcpreasons,    tcpstate,    so_tcp_stat,    Inet_eol,
  379.  
  380.     TYPE_UDP,
  381.     so_udp,        so_udp_bind,    NULLFP,        so_udp_conn,
  382.     FALSE,        so_udp_recv,    so_udp_send,    so_udp_qlen,
  383.     NULLFP,        NULLFP,        so_udp_close,    checkipaddr,
  384.     NULL,        NULLFP,        so_udp_stat,    Inet_eol,
  385.  
  386. #ifdef    AX25
  387.     TYPE_AX25I,
  388.     so_ax_sock,    NULLFP,        so_ax_listen,    so_ax_conn,
  389.     TRUE,        so_ax_recv,    so_ax_send,    so_ax_qlen,
  390.     so_ax_kick,    so_ax_shut,    so_ax_close,    checkaxaddr,
  391.     Axreasons,    axstate,    so_ax_stat,    Ax25_eol,
  392.  
  393.     TYPE_AX25UI,
  394.     so_axui_sock,    so_axui_bind,    NULLFP,        so_axui_conn,
  395.     FALSE,        so_axui_recv,    so_axui_send,    so_axui_qlen,
  396.     NULLFP,        NULLFP,        so_axui_close,    checkaxaddr,
  397.     NULL,        NULLFP,        NULLFP,        Ax25_eol,
  398. #endif    /* AX25 */
  399.  
  400.     TYPE_RAW,
  401.     so_ip_sock,    NULLFP,        NULLFP,        so_ip_conn,
  402.     FALSE,        so_ip_recv,    so_ip_send,    so_ip_qlen,
  403.     NULLFP,        NULLFP,        so_ip_close,    checkipaddr,
  404.     NULL,        NULLFP,        NULLFP,        Inet_eol,
  405.  
  406. #ifdef    NETROM
  407.     TYPE_NETROML3,
  408.     so_n3_sock,    NULLFP,        NULLFP,        so_n3_conn,
  409.     FALSE,        so_n3_recv,    so_n3_send,    so_n3_qlen,
  410.     NULLFP,        NULLFP,        so_n3_close,    checknraddr,
  411.     NULL,        NULLFP,        NULLFP,        Ax25_eol,
  412.  
  413.     TYPE_NETROML4,
  414.     so_n4_sock,    NULLFP,        so_n4_listen,    so_n4_conn,
  415.     TRUE,        so_n4_recv,    so_n4_send,    so_n4_qlen,
  416.     so_n4_kick,    so_n4_shut,    so_n4_close,    checknraddr,
  417.     Nr4reasons,    nrstate,    so_n4_stat,    Ax25_eol,
  418. #endif    /* NETROM */
  419.  
  420. #ifdef    LOCSOCK
  421.     TYPE_LOCAL_STREAM,
  422.     so_los,        NULLFP,        NULLFP,        NULLFP,
  423.     TRUE,        so_lo_recv,    so_los_send,    so_los_qlen,
  424.     NULLFP,        so_loc_shut,    so_loc_close,    NULLFP,
  425.     NULL,        NULLFP,        so_loc_stat,    Eol,
  426.  
  427.     TYPE_LOCAL_DGRAM,
  428.     so_lod,        NULLFP,        NULLFP,        NULLFP,
  429.     FALSE,        so_lo_recv,    so_lod_send,    so_lod_qlen,
  430.     NULLFP,        so_loc_shut,    so_loc_close,    NULLFP,
  431.     NULL,        NULLFP,        so_loc_stat,    Eol,
  432. #endif
  433.  
  434.     -1
  435. };
  436.  
  437. /* Table of functions for printing socket addresses */
  438. char * (*Psock[]) () = {
  439.     ippsocket,
  440. #ifdef    AX25
  441.     axpsocket,
  442. #else
  443.     NULLFP,
  444. #endif
  445. #ifdef    NETROM
  446.     nrpsocket,
  447. #else
  448.     NULLFP,
  449. #endif
  450.     lopsocket,
  451. };
  452.  
  453. /* TCP port numbers to be considered "interactive" by the IP routing
  454.  * code and given priority in queueing
  455.  */
  456. int Tcp_interact[] = {
  457.     IPPORT_FTP,    /* FTP control (not data!) */
  458.     IPPORT_TELNET,    /* Telnet */
  459.     IPPORT_LOGIN,    /* BSD rlogin */
  460.     IPPORT_MTP,    /* Secondary telnet */
  461.     -1
  462. };
  463.  
  464. /* Transport protocols atop IP */
  465. struct iplink Iplink[] = {
  466.     TCP_PTCL,    tcp_input,
  467.     UDP_PTCL,    udp_input,
  468.     ICMP_PTCL,    icmp_input,
  469.     IP_PTCL,    ipip_recv,
  470.     0,        0
  471. };
  472.  
  473. /* Transport protocols atop ICMP */
  474. struct icmplink Icmplink[] = {
  475.     TCP_PTCL,    tcp_icmp,
  476.     0,        0
  477. };
  478.  
  479. #ifdef    AX25
  480. /* Linkage to network protocols atop ax25 */
  481. struct axlink Axlink[] = {
  482.     PID_IP,        axip,
  483.     PID_ARP,    axarp,
  484. #ifdef    NETROM
  485.     PID_NETROM,    axnr,
  486. #endif
  487.     PID_NO_L3,    axnl3,
  488.     0,        NULL,
  489. };
  490. #endif    /* AX25 */
  491.  
  492. /* ARP protocol linkages, indexed by arp's hardware type */
  493. struct arp_type Arp_type[NHWTYPES] = {
  494. #ifdef    NETROM
  495.     AXALEN, 0, 0, 0, NULLCHAR, pax25, setcall,    /* ARP_NETROM */
  496. #else
  497.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  498. #endif
  499.  
  500. #ifdef    ETHER
  501.     EADDR_LEN,IP_TYPE,ARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  502. #else
  503.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  504. #endif
  505.  
  506.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_EETHER */
  507.  
  508. #ifdef    AX25
  509.     AXALEN, PID_IP, PID_ARP, 10, Ax25multi[0], pax25, setcall,
  510. #else
  511.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_AX25 */
  512. #endif
  513.  
  514.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_PRONET */
  515.  
  516.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_CHAOS */
  517.  
  518.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_IEEE802 */
  519.  
  520. #ifdef    ARCNET
  521.     AADDR_LEN, ARC_IP, ARC_ARP, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  522. #else
  523.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  524. #endif
  525.  
  526.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_APPLETALK */
  527. };
  528. /* Get rid of trace references in Iftypes[] if TRACE is turned off */
  529. #ifndef    TRACE
  530. #define    ip_dump        NULLVFP
  531. #define    ax25_dump    NULLVFP
  532. #define    ki_dump        NULLVFP
  533. #define    sl_dump        NULLVFP
  534. #define    ether_dump    NULLVFP
  535. #define    ppp_dump    NULLVFP
  536. #define    arc_dump    NULLVFP
  537. #endif    /* TRACE */
  538.  
  539. /* Table of interface types. Contains most device- and encapsulation-
  540.  * dependent info
  541.  */
  542. struct iftype Iftypes[] = {
  543.     /* This entry must be first, since Loopback refers to it */
  544.     "None",        NULL,        NULL,        NULL,
  545.     NULL,        CL_NONE,    0,        ip_proc,
  546.     NULLFP,        ip_dump,
  547.  
  548. #ifdef    AX25
  549.     "AX25",        ax_send,    ax_output,    pax25,
  550.     setcall,    CL_AX25,    AXALEN,        ax_recv,
  551.     ax_forus,    ax25_dump,
  552. #endif    /* AX25 */
  553.  
  554. #ifdef    KISS
  555.     "KISS",        ax_send,    ax_output,    pax25,
  556.     setcall,    CL_AX25,    AXALEN,        kiss_recv,
  557.     ki_forus,    ki_dump,
  558. #endif    /* KISS */
  559.  
  560. #ifdef    SLIP
  561.     "SLIP",        slip_send,    NULL,        NULL,
  562.     NULL,        CL_NONE,    0,        ip_proc,
  563.     NULLFP,        ip_dump,
  564. #endif    /* SLIP */
  565.  
  566. #ifdef    VJCOMPRESS
  567.     "VJSLIP",    slip_send,    NULL,        NULL,
  568.     NULL,        CL_NONE,    0,        ip_proc,
  569.     NULLFP,        sl_dump,
  570. #endif    /* VJCOMPRESS */
  571.  
  572. #ifdef    ETHER
  573.     /* Note: NULL is specified for the scan function even though
  574.      * gether() exists because the packet drivers don't support
  575.      * address setting.
  576.      */
  577.     "Ethernet",    enet_send,    enet_output,    pether,
  578.     NULL,        CL_ETHERNET,    EADDR_LEN,    eproc,
  579.     ether_forus,    ether_dump,
  580. #endif    /* ETHER */
  581.  
  582. #ifdef    NETROM
  583.     "NETROM",    nr_send,    NULL,        pax25,
  584.     setcall,    CL_NETROM,    AXALEN,        NULLVFP,
  585.     NULLFP,        NULLVFP,
  586. #endif    /* NETROM */
  587.  
  588. #ifdef    SLFP
  589.     "SLFP",        pk_send,    NULL,        NULL,
  590.     NULL,        CL_NONE,    0,        ip_proc,
  591.     NULLFP,        ip_dump,
  592. #endif    /* SLFP */
  593.  
  594. #ifdef    PPP
  595.     "PPP",        ppp_send,    ppp_output,    NULL,
  596.     NULL,        CL_PPP,        0,        ppp_proc,
  597.     NULLFP,        ppp_dump,
  598. #endif    /* PPP */
  599.  
  600. #ifdef    ARCNET
  601.     "Arcnet",    anet_send,    anet_output,    parc,
  602.     garc,        CL_ARCNET,    1,        aproc,
  603.     arc_forus,    arc_dump,
  604. #endif    /* ARCNET */
  605.  
  606. #ifdef    QTSO
  607.     "QTSO",        qtso_send,    qtso_output,    NULL,
  608.     NULL,        CL_NONE,    0,        qtso_proc,
  609.     NULLFP,        NULLVFP,
  610. #endif    /* QTSO */
  611.  
  612.     NULLCHAR,    NULLFP,        NULLFP,        NULL,
  613.     NULL,        -1,        0,        NULLFP,
  614.     NULLFP,        NULLVFP,
  615. };
  616.  
  617. /* Asynchronous interface mode table */
  618. #ifdef    ASY
  619. struct asymode Asymode[] = {
  620. #ifdef    SLIP
  621.     "SLIP",    FR_END,        slip_init,    slip_free,
  622. #endif
  623. #ifdef    KISS
  624.     "AX25",    FR_END,        kiss_init,    kiss_free,
  625.     "KISS",    FR_END,        kiss_init,    kiss_free,
  626. #endif
  627. #ifdef    NRS
  628.     "NRS",    ETX,        nrs_init,    nrs_free,
  629. #endif
  630. #ifdef    PPP
  631.     "PPP",    HDLC_FLAG,    ppp_init,    ppp_free,
  632. #endif
  633. #ifdef    QTSO
  634.     "QTSO",    HDLC_FLAG,    qtso_init,    qtso_free,
  635. #endif
  636.     NULLCHAR
  637. };
  638. #endif    /* ASY */
  639.  
  640.  
  641. /* daemons to be run at startup time */
  642. struct daemon Daemons[] = {
  643.     "killer",    512,    killer,
  644.     "gcollect",    256,    gcollect,
  645.     "timer",    1024,    timerproc,
  646.     "network",    1536,    network,
  647.     "keyboard",    250,    keyboard,
  648.     NULLCHAR,    0,    NULLVFP
  649. };
  650.  
  651. /* Functions to be called on each clock tick */
  652. void (*Cfunc[])() = {
  653.     pctick,    /* Call PC-specific stuff to keep time */
  654.     kbint,    /* Necessary because there's no hardware keyboard interrupt */
  655.     refiq,    /* Replenish interrupt pool */
  656.     sesflush,    /* Flush current session output */
  657. #ifdef    ASY
  658.     asytimer,
  659. #endif
  660. #ifdef    SCC
  661.     scctimer,
  662. #endif
  663.     NULL,
  664. };
  665.  
  666. /* Entry points for garbage collection */
  667. void (*Gcollect[])() = {
  668.     tcp_garbage,
  669.     ip_garbage,
  670.     udp_garbage,
  671.     st_garbage,
  672. #ifdef    AX25
  673.     lapb_garbage,
  674. #endif
  675. #ifdef    NETROM
  676.     nr_garbage,
  677. #endif
  678.     NULL
  679. };
  680.  
  681. /* Functions to be called at shutdown */
  682. void (*Shutdown[])() = {
  683. #ifdef    SCC
  684.     sccstop,
  685. #endif
  686.     uchtimer,    /* Unlink timer handler from timer chain */
  687.     NULLVFP,
  688. };
  689.  
  690. #ifdef    MAILBOX
  691. void (*Listusers) __ARGS((FILE *network)) = listusers;
  692. #else
  693. void (*Listusers) __ARGS((FILE *network)) = NULL;
  694. #endif    /* MAILBOX */
  695.  
  696. #ifndef    BOOTP
  697. int WantBootp = 0;
  698.  
  699. int
  700. bootp_validPacket(ip,bpp)
  701. struct ip *ip;
  702. struct mbuf **bpp;
  703. {
  704.     return 0;
  705. }
  706. #endif    /* BOOTP */
  707.  
  708. /* Packet tracing stuff */
  709. #ifdef    TRACE
  710. #include "trace.h"
  711.  
  712. #else    /* TRACE */
  713.  
  714. /* Stub for packet dump function */
  715. void
  716. dump(iface,direction,type,bp)
  717. struct iface *iface;
  718. int direction;
  719. unsigned type;
  720. struct mbuf *bp;
  721. {
  722. }
  723. void
  724. raw_dump(iface,direction,bp)
  725. struct iface *iface;
  726. int direction;
  727. struct mbuf *bp;
  728. {
  729. }
  730. #endif    /* TRACE */
  731.  
  732. #ifndef    TRACEBACK
  733. void
  734. stktrace()
  735. {
  736. }
  737. #endif
  738.  
  739. #ifndef    LZW
  740. void
  741. lzwfree(up)
  742. struct usock *up;
  743. {
  744. }
  745. #endif
  746.  
  747. #ifdef    AX25
  748. /* Hooks for passing incoming AX.25 data frames to network protocols */
  749. static void
  750. axip(iface,axp,src,dest,bp,mcast)
  751. struct iface *iface;
  752. struct ax25_cb *axp;
  753. char *src;
  754. char *dest;
  755. struct mbuf *bp;
  756. int mcast;
  757. {
  758.     (void)ip_route(iface,bp,mcast);
  759. }
  760.  
  761. static void
  762. axarp(iface,axp,src,dest,bp,mcast)
  763. struct iface *iface;
  764. struct ax25_cb *axp;
  765. char *src;
  766. char *dest;
  767. struct mbuf *bp;
  768. int mcast;
  769. {
  770.     (void)arp_input(iface,bp);
  771. }
  772.  
  773. #ifdef    NETROM
  774. static void
  775. axnr(iface,axp,src,dest,bp,mcast)
  776. struct iface *iface;
  777. struct ax25_cb *axp;
  778. char *src;
  779. char *dest;
  780. struct mbuf *bp;
  781. int mcast;
  782. {
  783.     if(!mcast)
  784.         nr_route(bp,axp);
  785.     else
  786.         nr_nodercv(iface,src,bp);
  787. }
  788.  
  789. #endif    /* NETROM */
  790. #endif    /* AX25 */
  791.  
  792. #ifndef    RIP
  793. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  794. void
  795. rt_timeout(s)
  796. void *s;
  797. {
  798.     struct route *stale = (struct route *)s;
  799.  
  800.     rt_drop(stale->target,stale->bits);
  801. }
  802. #endif
  803.  
  804. /* Stubs for demand dialer */
  805. #ifndef    DIALER
  806. void
  807. dialer_kick(asyp)
  808. struct asy *asyp;
  809. {
  810. }
  811. #endif
  812.  
  813. /* Stubs for Van Jacobsen header compression */
  814. #if !defined(VJCOMPRESS) && defined(ASY)
  815. struct slcompress *
  816. slhc_init(rslots,tslots)
  817. int rslots;
  818. int tslots;
  819. {
  820.     return NULLSLCOMPR;
  821. }
  822. int
  823. slhc_compress(comp, bpp, compress_cid)
  824. struct slcompress *comp;
  825. struct mbuf **bpp;
  826. int compress_cid;
  827. {
  828.     return SL_TYPE_IP;
  829. }
  830. int
  831. slhc_uncompress(comp, bpp)
  832. struct slcompress *comp;
  833. struct mbuf **bpp;
  834. {
  835.     return -1;    /* Can't decompress */
  836. }
  837. void
  838. shlc_i_status(comp)
  839. struct slcompress *comp;
  840. {
  841. }
  842. void
  843. shlc_o_status(comp)
  844. struct slcompress *comp;
  845. {
  846. }
  847. int
  848. slhc_remember(comp, bpp)
  849. struct slcompress *comp;
  850. struct mbuf **bpp;
  851. {
  852.     return -1;
  853. }
  854. #endif /* !defined(VJCOMPRESS) && defined(ASY) */
  855.  
  856. #ifdef    SERVERS
  857. static int
  858. dostart(argc,argv,p)
  859. int argc;
  860. char *argv[];
  861. void *p;
  862. {
  863.     return subcmd(Startcmds,argc,argv,p);
  864. }
  865. static int
  866. dostop(argc,argv,p)
  867. int argc;
  868. char *argv[];
  869. void *p;
  870. {
  871.     return subcmd(Stopcmds,argc,argv,p);
  872. }
  873. #endif    /* SERVERS */
  874.  
  875. #ifdef    notdef
  876. int
  877. dotest(argc,argv,p)
  878. int argc;
  879. char *argv[];
  880. void *p;
  881. {
  882.     long i;
  883.     int32 oldtime = 0;
  884.     int32 newtime;
  885.  
  886.     Current->flowmode = 1;
  887.     for(i=0;i<40000;i++){
  888.         newtime = msclock();
  889.         if(newtime < oldtime){
  890.             printf("Clock slip %ld: %ld - %ld = %ld\n",i,
  891.                 newtime,oldtime,newtime-oldtime);
  892.         } else
  893.             oldtime = newtime;
  894.     }
  895.     pwait(NULL);
  896.     Current->flowmode = 0;
  897.     return 0;
  898. }
  899.  
  900. #endif
  901. #ifdef    notdef
  902. int
  903. dotest(argc,argv,p)
  904. int argc;
  905. char *argv[];
  906. void *p;
  907. {
  908.     struct sockaddr_in fsocket;
  909.     FILE *fp,*fp1;
  910.     int s;
  911.     int c;
  912.     char buf[128];
  913.     struct mbuf *bp;
  914.  
  915. #ifdef    notdef
  916.     fsocket.sin_family = AF_INET;
  917.     if(argc < 3)
  918.         fsocket.sin_port = IPPORT_FINGER;
  919.     else
  920.         fsocket.sin_port = atoi(argv[2]);
  921.  
  922.     printf("Resolving %s... ",argv[1]);
  923.     if((fsocket.sin_addr.s_addr = resolve(argv[1])) == 0){
  924.         printf(Badhost,argv[1]);
  925.         keywait(NULLCHAR,1);
  926.         return 1;
  927.     }
  928.     if((s = socket(AF_INET,SOCK_STREAM,0)) == -1){
  929.         printf("Can't create socket\n");
  930.         keywait(NULLCHAR,1);
  931.         return 1;
  932.     }
  933.     if(connect(s,(char *)&fsocket,sizeof(fsocket)) == -1){
  934.         perror("connect failed");
  935.         return 1;
  936.     }
  937.     printf("connected\n");
  938.     fp = fdopen(s,"r+t");
  939.     fprintf(fp,"karn\n");
  940.     fflush(fp);
  941.     while((c = getc(fp)) != EOF){
  942.         fputc(c,stdout);
  943.     }
  944.     fclose(fp);
  945. #endif
  946.  
  947.     fp = fopen("net.map","rt");
  948.     fp1 = fopen("net.foo","wt");
  949.     while((c = fgetc(fp)) != EOF){
  950.         fputc(c,fp1);
  951.     }
  952.     printf("eof reached\r\n");
  953.     fclose(fp);
  954.     fclose(fp1);
  955.     return 0;
  956. }
  957. #endif
  958. #ifdef    notdef
  959. char imsg[] = { 0x01, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  960.     0,0,0,0,0,0 };
  961.  
  962. int
  963. dotest(argc,argv,p)
  964. int argc;
  965. char *argv[];
  966. void *p;
  967. {
  968.     struct mbuf *bp;
  969.     struct iface *ifp;
  970.     extern qtso_raw();
  971.  
  972.     bp = qdata(imsg,sizeof(imsg));
  973.     ifp = if_lookup("com3");
  974.     (*ifp->raw)(ifp,bp);
  975.     return 0;
  976. }
  977.  
  978. int
  979. dotest(argc,argv,p)
  980. int argc;
  981. char *argv[];
  982. void *p;
  983. {
  984.     void sigsender();
  985.     struct proc *child;
  986.  
  987.     if(SETSIG(666)){
  988.         printf("parent received signal, exiting...\n");
  989.         return;
  990.     }
  991.  
  992.     printf("Hello from parent, my proc is %lx. Spawning sigsender.\n",
  993.         ptol(Curproc));
  994.     child = newproc("sigsender",512,sigsender,0,(void *)Curproc,NULL,0);
  995.     printf("child spawned, proc = %lx\n",ptol(child));
  996.     printf("parent looping.\n");
  997.     for(;;){
  998.         pwait((void *)0x12345678);    /* Not likely to occur */
  999.         printf("parent returned from pwait!!\n");
  1000.     }
  1001.  
  1002. }
  1003. void
  1004. sigsender(a,b,c)
  1005. int a;
  1006. void *b,*c;
  1007. {
  1008.     struct proc *parent;
  1009.  
  1010.     parent = (struct proc *)b;
  1011.     printf("hello, sigsender here. procid is %lx. Parent is %lx. Pausing...\n",
  1012.         ptol(Curproc),ptol(parent));
  1013.     pause(10000L);
  1014.     printf("sigsender: alerting parent\n");
  1015.     alert(parent,666);
  1016.     printf("sigsender: returning\n");
  1017. }
  1018. #endif
  1019. dotest(argc,argv,p)
  1020. int argc;
  1021. char *argv[];
  1022. void *p;
  1023. {
  1024.     int c;
  1025.     struct session *sp;
  1026.  
  1027.     sp = newsession("test",TIP,1);
  1028.     fmode(stdin,STREAM_BINARY);
  1029.     fmode(stdout,STREAM_BINARY);
  1030.     sp->ttystate.edit = 0;
  1031.     sp->ttystate.echo = 0;
  1032.  
  1033.     printf("hello from test\n");
  1034.     while((c = getchar()) != 0x1a)
  1035.         putchar(c);
  1036.     printf("text exiting\n");
  1037.     keywait(NULLCHAR,1);
  1038.     freesession(sp);
  1039.     return 0;
  1040. }
  1041.