home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
internet
/
tcpipsrc
/
h
/
if
/
Main
/
c
/
main
< prev
next >
Wrap
Text File
|
1995-02-05
|
27KB
|
1,065 lines
/* Main network program - provides both client and server functions */
#define HOSTNAMELEN 32 /* changed from 16 by Bdale 860812 */
#define ESC 29
extern char config[]; /* File to read setup from */
extern char startup[]; /* File to read startup commands from */
extern char alternate[]; /* Directory for alternate startup commands */
extern char scripts[]; /* Directory for command files for source command */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include <ctype.h>
#include "wimp.h"
#include "wimpt.h"
#include "visdelay.h"
#include "config.h"
#include "global.h"
#include "mbuf.h"
#include "netuser.h"
#include "timer.h"
#include "icmp.h"
#include "iface.h"
#include "ip.h"
#include "tcp.h"
#include "ax25.h"
#include "netrom.h"
#include "remote.h"
#include "ftp.h"
#include "telnet.h"
#include "session.h"
#include "cmdparse.h"
#include "asy.h"
#include "chat.h"
#include "slip.h"
#include "nrs.h"
#include "trace.h"
#include "mem.h"
#include "arp.h"
#include "ax_mbx.h"
#include "finger.h"
#include "ident.h"
#include "dns.h"
#include "internet.h"
#include "kiss.h"
#include "lapb.h"
#include "nr4.h"
#include "ping.h"
#include "pop.h"
#include "nntp.h"
#include "smtp.h"
#include "NetTime.h"
#include "udp.h"
#include "misc.h"
#include "domain.h"
#include "arc.h"
#include "driver.h"
#include "pppdriver.h"
#include "alarm.h"
#include "var.h"
extern varlist global_vars;
extern int (*driver_load(char*))(int,...);
/* Dummy structure for loopback tracing */
struct interface loopback = {
NULLIF, "loopback" };
extern struct interface *ifaces;
extern char version[];
extern struct mbuf *loopq;
extern Terminal *MWin;
int mode;
char badhost[] = "Unknown host %s\r\n";
char hostname[HOSTNAMELEN];
unsigned nsessions = NSESSIONS;
int16 lport = 1001;
char *prompt = "net> ";
char nospace[] = "No space!!\r\n"; /* Generic malloc fail message */
int attended = 1;
int ttyflow = 1; /* tty flow control */
int initialisation_completed = FALSE;
static char *ttybuf;
static int quiet = FALSE; /* Echo startup files */
extern int doresolve(int, char **);
extern int dotransfer(int, char **);
static int doexit(int, char **);
static int doattach(int, char **);
static int doecho(int, char **);
static int doeol(int, char **);
static int dohostname(int, char **);
static int dolog(int, char **);
static int dohelp(int, char **);
static int domode(int, char **);
static int doparam(int, char **);
static int doremote(int, char **);
static int dostart(int, char **);
static int dostop(int, char **);
static int dotrace(int, char **);
static int dosource(int, char **);
static int dounattend(int, char **);
static int dofiler(int, char **);
static int filer_open(int, char **);
static int filer_run(int, char **);
extern int docredits(int argc, char **argv);
extern int doterm(int argc, char **argv);
extern int doslipstat(int argc, char **argv);
extern int dosetvar(int argc, char **argv); /* In command parse */
extern int dosetosvar(int argc, char **argv); /* In command parse */
extern int doshowvar(int argc, char **argv); /* In command parse */
extern int doident(int argc, char **argv);
static void showtrace(struct interface *);
static int asy_attach(int, char **);
extern int ether_attach(int argc, char **argv);
struct cmds cmds[] = {
/* The "go" command must be first */
"", go, 0, NULLCHAR, NULLCHAR,
"arp", doarp, 0, NULLCHAR, NULLCHAR,
"asystat", doasystat, 0, NULLCHAR, NULLCHAR,
"ax25", doax25, 0, NULLCHAR, NULLCHAR,
"attach", doattach, 2, "attach <hardware> <hw specific options>", NULLCHAR,
/* This one is out of alpabetical order to allow abbreviation to "c" */
"connect", doconnect, 3,"connect <interface> <callsign> [digipeaters]",
NULLCHAR,
"chat", dochat, 0, "chat <interface> <error-send> [expect-send pairs]", NULLCHAR,
"chattrace", chat_trace, 0, NULLCHAR, NULLCHAR,
"close", doclose, 0, NULLCHAR, NULLCHAR,
"credits", docredits, 0, NULLCHAR, NULLCHAR,
"disconnect", doclose, 0, NULLCHAR, NULLCHAR,
"domain", dodomain, 0, NULLCHAR, NULLCHAR,
"echo", doecho, 0, NULLCHAR, "echo [refuse|accept]",
"eol", doeol, 0, NULLCHAR, "eol options: unix, standard",
"exit", doexit, 0, NULLCHAR, NULLCHAR,
"finger", dofinger, 0, NULLCHAR, NULLCHAR,
"filer", dofiler, 1, "open|run <file>", NULLCHAR,
"forward", doforward, 0, NULLCHAR, NULLCHAR,
"ftp", doftp, 2, "ftp <address> [ \\ <switches>[ \\ <chat strings>]]", NULLCHAR,
"help", dohelp, 0, NULLCHAR, NULLCHAR,
"hop", dohop, 0, NULLCHAR, NULLCHAR,
"hostname", dohostname, 0, NULLCHAR, NULLCHAR,
"kick", dokick, 0, NULLCHAR, NULLCHAR,
"log", dolog, 0, NULLCHAR, NULLCHAR,
"ip", doip, 0, NULLCHAR, NULLCHAR,
"ident", doident, 1, NULLCHAR, NULLCHAR,
"mbox", dombox, 0, NULLCHAR, NULLCHAR,
"mem", domem, 0, NULLCHAR, NULLCHAR,
"mode", domode, 2, "mode <interface>", NULLCHAR,
"netrom", donetrom, 0, NULLCHAR, NULLCHAR,
"nntp", donntp, 0, NULLCHAR, NULLCHAR,
/* "nntp2", donntp2, 0, NULLCHAR, NULLCHAR, */
"nrstat", donrstat, 0, NULLCHAR, NULLCHAR,
"nsquery", dodns, 0, "nsquery <options> [<namesever>] [<name>] [<type>]", NULLCHAR,
"param", doparam, 2, "param <interface>", NULLCHAR,
"ping", doping, 0, NULLCHAR, NULLCHAR,
"pop", dopop, 0, NULLCHAR, NULLCHAR,
"quit", doexit, 0, NULLCHAR, NULLCHAR,
"record", dorecord, 0, NULLCHAR, NULLCHAR,
"remote", doremote, 4, "remote <address> <port> <command>", NULLCHAR,
"reset", doreset, 0, NULLCHAR, NULLCHAR,
"resolve", doresolve, 0, NULLCHAR, NULLCHAR,
"route", doroute, 0, NULLCHAR, NULLCHAR,
"session", dosession, 0, NULLCHAR, NULLCHAR,
"setvar", dosetvar, 3, "setvar <variable> <value_string>", NULLCHAR,
"setosvar", dosetosvar, 3, "setvar <variable> <os variable name>", NULLCHAR,
"showvar", doshowvar, 0, "showvar [<variable>]", NULLCHAR,
"smtp", dosmtp, 0, NULLCHAR, NULLCHAR,
"slipstat", doslipstat, 2, "slipstat <interface>", NULLCHAR,
"source", dosource, 2, "source <filename>", NULLCHAR,
"start", dostart, 2, "start <servername>",NULLCHAR,
"stop", dostop, 2, "stop <servername>", NULLCHAR,
"tcp", dotcp, 0, NULLCHAR, NULLCHAR,
"telnet", dotelnet, 2, "telnet <address> [<port>] [ \\ <switches>[ \\ <chat strings>]]", NULLCHAR,
"time", dotime, 1, NULLCHAR, NULLCHAR,
"trace", dotrace, 0, NULLCHAR, NULLCHAR,
"trf", dotransfer, 4, "trf <site> <port> <command>", NULLCHAR,
"udp", doudp, 0, NULLCHAR, NULLCHAR,
"unattended", dounattend, 0, NULLCHAR, NULLCHAR,
"upload", doupload, 0, NULLCHAR, NULLCHAR,
"window", dowin, 0, NULLCHAR, NULLCHAR,
"terminal", doterm, 1, "terminal [*] <switches>[ \\ <chat strings>]", NULLCHAR,
"?", dohelp, 0, NULLCHAR, NULLCHAR,
NULLCHAR, NULLFP, 0,
"Unknown command; type \"?\" for list", NULLCHAR,
};
/* "start" and "stop" subcommands */
static struct cmds startcmds[] = {
"discard", dis1, 0, NULLCHAR, NULLCHAR,
"echo", echo1, 0, NULLCHAR, NULLCHAR,
"finger", finger1, 0, NULLCHAR, NULLCHAR,
"ftp", ftp1, 0, NULLCHAR, NULLCHAR,
"smtp", smtp1, 0, NULLCHAR, NUL