xref: /csrg-svn/old/berknet/defs.h (revision 8211)
1*8211Smckusick /*	@(#)defs.h	4.1	(Berkeley)	09/12/82	*/
2*8211Smckusick 
3*8211Smckusick /* sccs id variable */
4*8211Smckusick static char *defs_h_sid = "@(#)defs.h	1.5";
5*8211Smckusick /*
6*8211Smckusick    get all the machine dependencies, standard I/O, and the
7*8211Smckusick    configuration definitions (LOCAL machine, etc.)
8*8211Smckusick */
9*8211Smckusick 
10*8211Smckusick # include <stdio.h>
11*8211Smckusick 
12*8211Smckusick # define min(a,b) (a > b ? b : a)
13*8211Smckusick # define getremote(S) (remtable[(S)-'a'])
14*8211Smckusick 
15*8211Smckusick /* adjustable parameters, may differ per machine */
16*8211Smckusick 
17*8211Smckusick # define MAXBREAD 	3
18*8211Smckusick # define ATIME 		20
19*8211Smckusick # define DBV 		0
20*8211Smckusick # define BLOCKSIZE 	500
21*8211Smckusick # define SIZE 		100
22*8211Smckusick # define INITFILE	"/usr/net/initfile"
23*8211Smckusick # define NSEND 		20
24*8211Smckusick # define SAMPL 		3600		/* 1 hour = 3600 */
25*8211Smckusick # define BIGSAMPL 	64800L		/* 18 hours = 64800L */
26*8211Smckusick # define LINKS		9
27*8211Smckusick # define SUPERUSER 	0
28*8211Smckusick /* the size of routing tables, etc. */
29*8211Smckusick # define MAXINX 	26
30*8211Smckusick 
31*8211Smckusick /* adjustable parameters, must be same on all machines */
32*8211Smckusick 
33*8211Smckusick /* MAXFILELARGE is the file size limit.  If changed on one machine
34*8211Smckusick    but not the others, files bigger than the common minimum will
35*8211Smckusick    be flushed with no guarantee of err msgs. Thus if one link
36*8211Smckusick    is to be of a different limit than the others, make sure the users
37*8211Smckusick    know this.
38*8211Smckusick    MAXDAYFILE is the largest file that will be transmitted across the
39*8211Smckusick    network during the day on CC machines.
40*8211Smckusick */
41*8211Smckusick # define MAXFILELARGE	500000L
42*8211Smckusick # define MAXDAYFILE	200000L
43*8211Smckusick /* the version of the protocol the network speaks */
44*8211Smckusick # define VMAJOR		1
45*8211Smckusick # define VMINOR 	0
46*8211Smckusick /* the time constant added to all time stamps sent around the net */
47*8211Smckusick # define TIMEBASE 	282098011L
48*8211Smckusick /* the number of mail forwarding hops allowed before looping is detected */
49*8211Smckusick # define MAXHOPS	30
50*8211Smckusick /* the buffer size used in prot.c */
51*8211Smckusick # define MAXNBUF 1024
52*8211Smckusick 
53*8211Smckusick /* non-adjustable constants */
54*8211Smckusick 
55*8211Smckusick /* PARMLIST = max size of variable length parm list used in protocol */
56*8211Smckusick # define PARMLIST 2000
57*8211Smckusick /* FNS = max length of file name string */
58*8211Smckusick # define FNS 80
59*8211Smckusick /* NS = length of UNIX user name*/
60*8211Smckusick # define NS 10
61*8211Smckusick /* returned by prot.c */
62*8211Smckusick # define BROKENREAD -2
63*8211Smckusick # define WRITEFAIL -3
64*8211Smckusick # define INCR 040
65*8211Smckusick # define MINSIZE 50
66*8211Smckusick # define TRUE 1
67*8211Smckusick # define FALSE 0
68*8211Smckusick 
69*8211Smckusick /* flags for packet type (pcode) */
70*8211Smckusick # define REQUEST 02
71*8211Smckusick # define ACK 04
72*8211Smckusick # define PURGE 020
73*8211Smckusick 
74*8211Smckusick /* flags for mach type */
75*8211Smckusick # define M_CC 2
76*8211Smckusick # define M_INGRES 4
77*8211Smckusick # define M_OTHER 6
78*8211Smckusick 
79*8211Smckusick /* codes for cflag, powers of two, max (8 bits - 'a'), others may be added */
80*8211Smckusick 
81*8211Smckusick /* F_QUIET means send back only error messages and output of programs,
82*8211Smckusick    don't send back confimation with no data */
83*8211Smckusick /* F_NONOTIFY means don't send back anything, ever,
84*8211Smckusick    even if there are errors (used for responses, etc.) */
85*8211Smckusick 
86*8211Smckusick # define F_QUIET 	02
87*8211Smckusick # define F_NONOTIFY 	04
88*8211Smckusick 
89*8211Smckusick 
90*8211Smckusick /*
91*8211Smckusick    at this point bring in the locally-dependent definitions.
92*8211Smckusick    this way the above parms may be altered.
93*8211Smckusick */
94*8211Smckusick /* strings for the netsend and netrecieve logins */
95*8211Smckusick # define RESP	"hello hello this is a network"
96*8211Smckusick # define RESPSIZE 29
97*8211Smckusick # define QUERY	"This login for network use only"
98*8211Smckusick # define QSIZE 31
99*8211Smckusick # define WHOAREYOU "who are you?"
100*8211Smckusick # define WHOSIZE 12
101*8211Smckusick 
102*8211Smckusick # include "mach.h"
103*8211Smckusick # include "Paths.h"
104*8211Smckusick /* bring in the exit codes */
105*8211Smckusick # include <sysexits.h>
106*8211Smckusick 
107*8211Smckusick /* structure declarations */
108*8211Smckusick struct packet {
109*8211Smckusick 	short seqno;
110*8211Smckusick 	char pcode;
111*8211Smckusick 	short len;
112*8211Smckusick 	char chksum;
113*8211Smckusick 	char data[1];
114*8211Smckusick 	};
115*8211Smckusick 
116*8211Smckusick struct packet *packptr;	/* just used to get the sizeof to work */
117*8211Smckusick # define ACKLENGTH (sizeof *packptr - 1)
118*8211Smckusick /* these are the lengths to be read and writ if using high-speed block dev. */
119*8211Smckusick /* must be bigger than ACKLENGTH */
120*8211Smckusick # define SENDLEN 256
121*8211Smckusick 
122*8211Smckusick /* the chksum is only on a per-perpacket level,
123*8211Smckusick    which is not enough.
124*8211Smckusick    There should be a checksum on the entire file as well.
125*8211Smckusick    */
126*8211Smckusick struct dumpstruc {
127*8211Smckusick 	long longtime, elaptot;				/* in secs */
128*8211Smckusick 	long nbytesent,nbytercv, bytetot;		/* in bytes */
129*8211Smckusick 	long lastndays;					/* in days */
130*8211Smckusick 	long braw, brawtot;				/* raw bytes*/
131*8211Smckusick 	int nretrans, nabnormal, nloop;
132*8211Smckusick 	int ncksum,npacksent,npackrcv;
133*8211Smckusick 	int nnetcp,nnetlpr,nsmail,nnetmail,nresp,nnet;
134*8211Smckusick 	int npass, nsend, nsendfail;
135*8211Smckusick 	};
136*8211Smckusick 
137*8211Smckusick struct bstruct {
138*8211Smckusick 	char *bname;
139*8211Smckusick 	char bmach;
140*8211Smckusick 	};
141*8211Smckusick /* functions */
142*8211Smckusick 
143*8211Smckusick char *calloc(), *crypt(), *ctime(), *getenv(), *longname();
144*8211Smckusick char *comptime(), *getpass(), *handlesp();
145*8211Smckusick FILE *fopen(), *fdopen(), *popen(), *mailopen();
146*8211Smckusick struct passwd *getpwnam(), *getpwuid(), *PwdCurrent(), *getpwent();
147*8211Smckusick struct packet *getpacket();
148*8211Smckusick long atol();
149*8211Smckusick 
150*8211Smckusick /* constant variables */
151*8211Smckusick extern char *sys_errlist[];
152*8211Smckusick char netcmd[],senddir[], resfile[], Bsh[];
153*8211Smckusick char machtype[], remtable[];
154*8211Smckusick char local;
155*8211Smckusick 
156*8211Smckusick /* variables which are modified */
157*8211Smckusick extern errno;
158*8211Smckusick int debugflg;
159*8211Smckusick char remote;		/* must be global, remote is not initialized*/
160*8211Smckusick 
161*8211Smckusick /* various structure types */
162*8211Smckusick 
163*8211Smckusick /* used to pass around info about user */
164*8211Smckusick struct userinfo {
165*8211Smckusick 	char 	login[NS];
166*8211Smckusick 	char 	mpasswd[20];
167*8211Smckusick 	int 	muid;		/* combines uid and gid for FUID */
168*8211Smckusick 	int 	mgid;		/* unused for FUID */
169*8211Smckusick 	char	jobno[10];	/* CC crn, length = 0 if null and not */
170*8211Smckusick 				/*      CC machine (else MAGICCRN ) */
171*8211Smckusick 	char 	dir[FNS];	/* login directory */
172*8211Smckusick 	char 	loginshell[FNS];/* login shell */
173*8211Smckusick 	char 	localname[NS];
174*8211Smckusick 	char 	defcmd[FNS];
175*8211Smckusick 	char 	force;		/* if true, always prompt for login and pass */
176*8211Smckusick 	char 	nonotify;	/* if true, don't send anything back */
177*8211Smckusick 	char 	nowrite;	/* if true, mail rather than write to user */
178*8211Smckusick 	char 	quiet;		/* if true, only send a response back if rc !=0
179*8211Smckusick 				   or if there is stdout or stderr */
180*8211Smckusick 	} ;
181*8211Smckusick 
182*8211Smckusick /* unique message - id sent with requests */
183*8211Smckusick struct messageid {
184*8211Smckusick 	char 	msg_mch;	/* machine it is on */
185*8211Smckusick 	int 	msg_pid;	/* process id */
186*8211Smckusick 	long	msg_ltime;	/* current time */
187*8211Smckusick };
188*8211Smckusick 
189*8211Smckusick /* header which describes information transferred across the link */
190*8211Smckusick struct header {
191*8211Smckusick 	char	hd_mchto;		/* 1-letter code for dest. machine */
192*8211Smckusick 	char	hd_mchfrom;		/* 1-letter code for source machine */
193*8211Smckusick 	char	hd_snto[NS];		/* login name on mchto mach */
194*8211Smckusick 	char	hd_snfrom[NS];		/* login name on mchfrom mach */
195*8211Smckusick 	char    hd_spasswd[20];		/* password for snto */
196*8211Smckusick 	char	hd_code;		/* request code in protocol */
197*8211Smckusick 	char	hd_fnonotify;		/* if true, don't send anything back */
198*8211Smckusick 	char	hd_fquiet;		/* if true, only send back if error */
199*8211Smckusick 	char	hd_vmajor;		/* major version number */
200*8211Smckusick 	char	hd_vminor;		/* minor version number */
201*8211Smckusick 	char 	hd_sttyname[20];	/* tty user is on,e.g. /dev/tty0 */
202*8211Smckusick 	char 	hd_scmdact[BUFSIZ];	/* the actual cmd the net will exec */
203*8211Smckusick 	char 	hd_scmdvirt[BUFSIZ];	/* the cmd the user thinks he is exec */
204*8211Smckusick 	long 	hd_lttytime;		/* the time for tty login in utmp */
205*8211Smckusick 	long 	hd_ltimesent;		/* the time the request was sent */
206*8211Smckusick 	char	hd_srespfile[FNS];	/* response file name, if sepecified */
207*8211Smckusick 	char	hd_sinfile[FNS];	/* remote input file, if sepecified */
208*8211Smckusick 	char	hd_soutfile[FNS];	/* remote output file, if sepecified */
209*8211Smckusick 	/* sent but not computed (always MAGICCRN or 0 length) across the net */
210*8211Smckusick 	char	hd_ijobno[10];		/* CC job number, if applicable */
211*8211Smckusick 	/* computed, not transferred across the net */
212*8211Smckusick 	char	hd_addrto[FNS];		/* address of dest. acct */
213*8211Smckusick 	char	hd_addrfrom[FNS];	/* address of source acct */
214*8211Smckusick 	/* not now being sent over, will be someday, don't use now */
215*8211Smckusick 	char	hd_sencpasswd[20];	/* encrypted passwd with nbs 2way enc */
216*8211Smckusick 	int 	hd_ifilemode;		/* file mode for netcp */
217*8211Smckusick 	char 	hd_sfndefault[FNS];	/* default filename ext, for netcp */
218*8211Smckusick 	int	hd_uidfrom;		/* userid on the from machine */
219*8211Smckusick 	int 	hd_gidfrom;		/* groupid on the from machine */
220*8211Smckusick 	struct messageid hd_mesgid;	/* message id unique to this request */
221*8211Smckusick 	char	hd_fcompressed;		/* if true, data is compressed */
222*8211Smckusick 	char	hd_facctpair;		/* if true, is an accnt pair w/o pwds */
223*8211Smckusick 	char	hd_addrreplyto[FNS];	/* reply to this address */
224*8211Smckusick };
225*8211Smckusick 
226*8211Smckusick /*
227*8211Smckusick 	this structure defines the various parameters the daemon and testing
228*8211Smckusick    	programs use -- most of the info comes from netrc.c
229*8211Smckusick 	NOTE-- this structure is initialized in netrc.c
230*8211Smckusick 	don't add members without changing that structure
231*8211Smckusick */
232*8211Smckusick struct daemonparms {
233*8211Smckusick 	int 	dp_inspeed;	/* for stty, 7=300, 9=1200, 13=9600 baud */
234*8211Smckusick 	int 	dp_outspeed;	/* for stty, 7=300, 9=1200, 13=9600 baud */
235*8211Smckusick 	int 	dp_maxbread;	/* number of read time outs allowed */
236*8211Smckusick 	int 	dp_atime;	/* time to set alarm for timeout */
237*8211Smckusick 	int 	dp_oatime;	/* default time alarm for timeout */
238*8211Smckusick 	char 	dp_device[20];	/* name of the network file, e.g. /dev/net-A*/
239*8211Smckusick 	int 	dp_datasize;	/* length of data part of packet */
240*8211Smckusick 	int	dp_trynetl;	/* try to use netl, -l disables */
241*8211Smckusick 	int 	dp_onlyuid;	/* if non-zero, only send this uid's things */
242*8211Smckusick 	int	dp_linefd;	/* daemon should read and write from this */
243*8211Smckusick 	char	dp_usehispeed;	/* if true, use high-speed link */
244*8211Smckusick 	char	dp_hispeedlink[20];/* device name of high speed link */
245*8211Smckusick 	short	dp_sndorcv;	/* if <0, only send, if > 0, only recieve */
246*8211Smckusick 	int	dp_linedis;	/* line disc we use, normal is 0 */
247*8211Smckusick 	int 	dp_pipesim;	/* simulate with pipes */
248*8211Smckusick 	FILE	*dp_rdfile;	/* if pipesim then should read from this */
249*8211Smckusick 	int	dp_pwritefd;	/* if pipesim then should write from this */
250*8211Smckusick 	int	dp_use8bit;	/* use 8 bit protocol */
251*8211Smckusick 	short	dp_timeout;	/* timeout deamon (dialup) if > 0 */
252*8211Smckusick };
253*8211Smckusick 
254*8211Smckusick /* macro implementation of harg due to bugs in Onyx C compiler */
255*8211Smckusick # define harg(str) {\
256*8211Smckusick 	if (argv[0][2]) \
257*8211Smckusick 		strcpy(str, argv[0]+2); \
258*8211Smckusick 	else \
259*8211Smckusick 		{ strcpy(str, argv[1]); argc--; argv++; } \
260*8211Smckusick 	}
261