Lines Matching +full:boot +full:- +full:up

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
12 * to css-dist@cs.utah.edu any improvements that they make and grant
56 ** ProcessPacket -- determine packet type and do what's required.
58 ** An RMP BOOT packet has been received. Look at the type field
59 ** and process Boot Requests, Read Requests, and Boot Complete
63 ** rconn - the new connection
64 ** client - list of files available to this host
70 ** - If this is a valid boot request, it will be added to
72 ** - If this is a valid boot complete, its associated
74 ** - Also, unless we run out of memory, a reply will be
83 rmp = &rconn->rmp; /* cache pointer to RMP packet */ in ProcessPacket()
85 switch(rmp->r_type) { /* do what we came here to do */ in ProcessPacket()
86 case RMP_BOOT_REQ: /* boot request */ in ProcessPacket()
99 * If this is an actual boot request, open the file in ProcessPacket()
105 if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) { in ProcessPacket()
106 if (WORDZE(rmp->r_brq.rmp_seqno)) in ProcessPacket()
110 client? client->files: in ProcessPacket()
115 client? client->files: BootFiles)) in ProcessPacket()
122 case RMP_BOOT_REPL: /* boot reply (not valid) */ in ProcessPacket()
123 syslog(LOG_WARNING, "%s: sent a boot reply", in ProcessPacket()
129 * Send a portion of the boot file. in ProcessPacket()
139 case RMP_BOOT_DONE: /* boot complete */ in ProcessPacket()
149 EnetStr(rconn), rmp->r_type); in ProcessPacket()
154 ** SendServerID -- send our host name to who ever requested it.
157 ** rconn - the reply packet to be formatted.
172 rpl = &rconn->rmp; /* cache ptr to RMP packet */ in SendServerID()
175 * Set up assorted fields in reply packet. in SendServerID()
177 rpl->r_brpl.rmp_type = RMP_BOOT_REPL; in SendServerID()
178 rpl->r_brpl.rmp_retcode = RMP_E_OKAY; in SendServerID()
179 ZEROWORD(rpl->r_brpl.rmp_seqno); in SendServerID()
180 rpl->r_brpl.rmp_session = 0; in SendServerID()
181 rpl->r_brpl.rmp_version = htons(RMP_VERSION); in SendServerID()
183 size = &rpl->r_brpl.rmp_flnmsize; /* ptr to length of host name */ in SendServerID()
190 dst = (char *) &rpl->r_brpl.rmp_flnm; in SendServerID()
197 rconn->rmplen = RMPBOOTSIZE(*size); /* set packet length */ in SendServerID()
203 ** SendFileNo -- send the name of a bootable file to the requester.
206 ** req - RMP BOOT packet containing the request.
207 ** rconn - the reply packet to be formatted.
208 ** filelist - list of files available to the requester.
224 GETWORD(req->r_brpl.rmp_seqno, i); /* SeqNo is really FileNo */ in SendFileNo()
225 rpl = &rconn->rmp; /* cache ptr to RMP packet */ in SendFileNo()
228 * Set up assorted fields in reply packet. in SendFileNo()
230 rpl->r_brpl.rmp_type = RMP_BOOT_REPL; in SendFileNo()
231 PUTWORD(i, rpl->r_brpl.rmp_seqno); in SendFileNo()
232 i--; in SendFileNo()
233 rpl->r_brpl.rmp_session = 0; in SendFileNo()
234 rpl->r_brpl.rmp_version = htons(RMP_VERSION); in SendFileNo()
236 size = &rpl->r_brpl.rmp_flnmsize; /* ptr to length of filename */ in SendFileNo()
247 dst = (char *)&rpl->r_brpl.rmp_flnm; in SendFileNo()
253 rpl->r_brpl.rmp_retcode = RMP_E_OKAY; in SendFileNo()
255 rpl->r_brpl.rmp_retcode = RMP_E_NODFLT; in SendFileNo()
257 rconn->rmplen = RMPBOOTSIZE(*size); /* set packet length */ in SendFileNo()
263 ** SendBootRepl -- open boot file and respond to boot request.
266 ** req - RMP BOOT packet containing the request.
267 ** rconn - the reply packet to be formatted.
268 ** filelist - list of files available to the requester.
296 rpl = &rconn->rmp; /* cache ptr to RMP packet */ in SendBootRepl()
299 * Set up assorted fields in reply packet. in SendBootRepl()
301 rpl->r_brpl.rmp_type = RMP_BOOT_REPL; in SendBootRepl()
302 COPYWORD(req->r_brq.rmp_seqno, rpl->r_brpl.rmp_seqno); in SendBootRepl()
303 rpl->r_brpl.rmp_session = htons(GenSessID()); in SendBootRepl()
304 rpl->r_brpl.rmp_version = htons(RMP_VERSION); in SendBootRepl()
305 rpl->r_brpl.rmp_flnmsize = req->r_brq.rmp_flnmsize; in SendBootRepl()
310 src = &req->r_brq.rmp_flnm; in SendBootRepl()
312 dst2 = &rpl->r_brpl.rmp_flnm; in SendBootRepl()
313 for (i = 0; i < req->r_brq.rmp_flnmsize; i++) in SendBootRepl()
318 * If we are booting HP-UX machines, their secondary loader will in SendBootRepl()
319 * ask for files like "/hp-ux". As a security measure, we do not in SendBootRepl()
320 * allow boot files to lay outside the boot directory (unless they in SendBootRepl()
321 * are purposely link'd out. So, make `filename' become the path- in SendBootRepl()
329 * Check that this is a valid boot file name. in SendBootRepl()
336 * Invalid boot file name, set error and send reply packet. in SendBootRepl()
338 rpl->r_brpl.rmp_retcode = RMP_E_NOFILE; in SendBootRepl()
344 * This is a valid boot file. Open the file and save the file in SendBootRepl()
347 * "no such file or dir" - RMP_E_NOFILE in SendBootRepl()
348 * "file table overflow" - RMP_E_BUSY in SendBootRepl()
349 * "too many open files" - RMP_E_BUSY in SendBootRepl()
350 * anything else - RMP_E_OPENFILE in SendBootRepl()
352 if ((rconn->bootfd = open(filename, O_RDONLY, 0600)) < 0) { in SendBootRepl()
353 rpl->r_brpl.rmp_retcode = (errno == ENOENT)? RMP_E_NOFILE: in SendBootRepl()
358 rpl->r_brpl.rmp_retcode = RMP_E_OKAY; in SendBootRepl()
363 syslog(LOG_INFO, "%s: request to boot %s (%s)", in SendBootRepl()
366 rconn->rmplen = RMPBOOTSIZE(rpl->r_brpl.rmp_flnmsize); in SendBootRepl()
372 ** SendReadRepl -- send a portion of the boot file to the requester.
375 ** rconn - the reply packet to be formatted.
404 req = &rconn->rmp; /* cache ptr to request packet */ in SendReadRepl()
405 rpl = &oldconn->rmp; /* cache ptr to reply packet */ in SendReadRepl()
408 rpl->r_rrpl.rmp_retcode = RMP_E_ABORT; in SendReadRepl()
416 if (ntohs(req->r_rrq.rmp_session) != in SendReadRepl()
417 ((rpl->r_type == RMP_BOOT_REPL)? ntohs(rpl->r_brpl.rmp_session): in SendReadRepl()
418 ntohs(rpl->r_rrpl.rmp_session))) { in SendReadRepl()
421 rpl->r_rrpl.rmp_retcode = RMP_E_BADSID; in SendReadRepl()
434 if (ntohs(req->r_rrq.rmp_size) > RMPREADDATA) in SendReadRepl()
435 req->r_rrq.rmp_size = htons(RMPREADDATA); in SendReadRepl()
440 GETWORD(req->r_rrq.rmp_offset, size); in SendReadRepl()
441 if (lseek(oldconn->bootfd, (off_t)size, SEEK_SET) < 0) { in SendReadRepl()
444 rpl->r_rrpl.rmp_retcode = RMP_E_ABORT; in SendReadRepl()
452 if ((size = read(oldconn->bootfd, &rpl->r_rrpl.rmp_data, in SendReadRepl()
453 (int) ntohs(req->r_rrq.rmp_size))) <= 0) { in SendReadRepl()
457 rpl->r_rrpl.rmp_retcode = RMP_E_ABORT; in SendReadRepl()
459 rpl->r_rrpl.rmp_retcode = RMP_E_EOF; in SendReadRepl()
468 rpl->r_rrpl.rmp_retcode = RMP_E_OKAY; in SendReadRepl()
472 * Set up assorted fields in reply packet. in SendReadRepl()
474 rpl->r_rrpl.rmp_type = RMP_READ_REPL; in SendReadRepl()
475 COPYWORD(req->r_rrq.rmp_offset, rpl->r_rrpl.rmp_offset); in SendReadRepl()
476 rpl->r_rrpl.rmp_session = req->r_rrq.rmp_session; in SendReadRepl()
478 oldconn->rmplen = RMPREADSIZE(size); /* set size of packet */ in SendReadRepl()
482 if (madeconn) /* clean up after ourself */ in SendReadRepl()
489 ** BootDone -- free up memory allocated for a connection.
492 ** rconn - incoming boot complete packet.
515 rpl = &oldconn->rmp; /* cache ptr to RMP packet */ in BootDone()
520 if (ntohs(rconn->rmp.r_rrq.rmp_session) != in BootDone()
521 ((rpl->r_type == RMP_BOOT_REPL)? ntohs(rpl->r_brpl.rmp_session): in BootDone()
522 ntohs(rpl->r_rrpl.rmp_session))) { in BootDone()
530 syslog(LOG_INFO, "%s: boot complete", EnetStr(rconn)); in BootDone()
536 ** SendPacket -- send an RMP packet to a remote host.
539 ** rconn - packet to be sent.
554 memmove((char *)&rconn->rmp.hp_hdr.daddr[0], in SendPacket()
555 (char *)&rconn->rmp.hp_hdr.saddr[0], RMP_ADDRLEN); in SendPacket()
556 rconn->rmp.hp_hdr.len = htons(rconn->rmplen - sizeof(struct hp_hdr)); in SendPacket()
561 rconn->rmp.hp_llc.dxsap = htons(HPEXT_SXSAP); in SendPacket()
562 rconn->rmp.hp_llc.sxsap = htons(HPEXT_DXSAP); in SendPacket()
567 (void)gettimeofday(&rconn->tstamp, NULL); in SendPacket()