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