diff options
Diffstat (limited to 'libexec/rbootd/rmpproto.c')
-rw-r--r-- | libexec/rbootd/rmpproto.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/libexec/rbootd/rmpproto.c b/libexec/rbootd/rmpproto.c index d0a8d4a..12a6f5c 100644 --- a/libexec/rbootd/rmpproto.c +++ b/libexec/rbootd/rmpproto.c @@ -1,3 +1,5 @@ +/* $NetBSD: rmpproto.c,v 1.7 1996/02/01 21:27:46 mycroft Exp $ */ + /* * Copyright (c) 1988, 1992 The University of Utah and the Center * for Software Science (CSS). @@ -38,14 +40,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)rmpproto.c 8.1 (Berkeley) 6/4/93 + * from: @(#)rmpproto.c 8.1 (Berkeley) 6/4/93 * - * Utah $Hdr: rmpproto.c 3.1 92/07/06$ + * From: Utah Hdr: rmpproto.c 3.1 92/07/06 * Author: Jeff Forys, University of Utah CSS */ #ifndef lint -static char sccsid[] = "@(#)rmpproto.c 8.1 (Berkeley) 6/4/93"; +/*static char sccsid[] = "@(#)rmpproto.c 8.1 (Berkeley) 6/4/93";*/ +static char rcsid[] = "$NetBSD: rmpproto.c,v 1.7 1996/02/01 21:27:46 mycroft Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -111,7 +114,7 @@ ProcessPacket(rconn, client) * of active connections, otherwise delete it since * an error was encountered. */ - if (rmp->r_brq.rmp_session == RMP_PROBESID) { + if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) { if (WORDZE(rmp->r_brq.rmp_seqno)) (void) SendServerID(rconnout); else @@ -177,7 +180,7 @@ SendServerID(rconn) { register struct rmp_packet *rpl; register char *src, *dst; - register u_char *size; + register u_int8_t *size; rpl = &rconn->rmp; /* cache ptr to RMP packet */ @@ -188,7 +191,7 @@ SendServerID(rconn) rpl->r_brpl.rmp_retcode = RMP_E_OKAY; ZEROWORD(rpl->r_brpl.rmp_seqno); rpl->r_brpl.rmp_session = 0; - rpl->r_brpl.rmp_version = RMP_VERSION; + rpl->r_brpl.rmp_version = htons(RMP_VERSION); size = &rpl->r_brpl.rmp_flnmsize; /* ptr to length of host name */ @@ -231,7 +234,8 @@ SendFileNo(req, rconn, filelist) { register struct rmp_packet *rpl; register char *src, *dst; - register u_char *size, i; + register u_int8_t *size; + register int i; GETWORD(req->r_brpl.rmp_seqno, i); /* SeqNo is really FileNo */ rpl = &rconn->rmp; /* cache ptr to RMP packet */ @@ -243,7 +247,7 @@ SendFileNo(req, rconn, filelist) PUTWORD(i, rpl->r_brpl.rmp_seqno); i--; rpl->r_brpl.rmp_session = 0; - rpl->r_brpl.rmp_version = RMP_VERSION; + rpl->r_brpl.rmp_version = htons(RMP_VERSION); size = &rpl->r_brpl.rmp_flnmsize; /* ptr to length of filename */ *size = 0; /* init length to zero */ @@ -296,7 +300,7 @@ SendBootRepl(req, rconn, filelist) RMPCONN *oldconn; register struct rmp_packet *rpl; register char *src, *dst1, *dst2; - register u_char i; + register u_int8_t i; /* * If another connection already exists, delete it since we @@ -315,8 +319,8 @@ SendBootRepl(req, rconn, filelist) */ rpl->r_brpl.rmp_type = RMP_BOOT_REPL; COPYWORD(req->r_brq.rmp_seqno, rpl->r_brpl.rmp_seqno); - rpl->r_brpl.rmp_session = GenSessID(); - rpl->r_brpl.rmp_version = RMP_VERSION; + rpl->r_brpl.rmp_session = htons(GenSessID()); + rpl->r_brpl.rmp_version = htons(RMP_VERSION); rpl->r_brpl.rmp_flnmsize = req->r_brq.rmp_flnmsize; /* @@ -398,7 +402,7 @@ int SendReadRepl(rconn) RMPCONN *rconn; { - int retval; + int retval = 0; RMPCONN *oldconn; register struct rmp_packet *rpl, *req; register int size = 0; @@ -428,9 +432,9 @@ SendReadRepl(rconn) /* * Make sure Session ID's match. */ - if (req->r_rrq.rmp_session != - ((rpl->r_type == RMP_BOOT_REPL)? rpl->r_brpl.rmp_session: - rpl->r_rrpl.rmp_session)) { + if (ntohs(req->r_rrq.rmp_session) != + ((rpl->r_type == RMP_BOOT_REPL)? ntohs(rpl->r_brpl.rmp_session): + ntohs(rpl->r_rrpl.rmp_session))) { syslog(LOG_ERR, "SendReadRepl: bad session id (%s)", EnetStr(rconn)); rpl->r_rrpl.rmp_retcode = RMP_E_BADSID; @@ -446,8 +450,8 @@ SendReadRepl(rconn) * to work. This is necessary for bpfwrite() on machines * with MCLBYTES less than 1514. */ - if (req->r_rrq.rmp_size > RMPREADDATA) - req->r_rrq.rmp_size = RMPREADDATA; + if (ntohs(req->r_rrq.rmp_size) > RMPREADDATA) + req->r_rrq.rmp_size = htons(RMPREADDATA); /* * Position read head on file according to info in request packet. @@ -465,7 +469,7 @@ SendReadRepl(rconn) * Read data directly into reply packet. */ if ((size = read(oldconn->bootfd, &rpl->r_rrpl.rmp_data, - (int) req->r_rrq.rmp_size)) <= 0) { + (int) ntohs(req->r_rrq.rmp_size))) <= 0) { if (size < 0) { syslog(LOG_ERR, "SendReadRepl: read: %m (%s)", EnetStr(rconn)); @@ -533,9 +537,9 @@ BootDone(rconn) /* * Make sure Session ID's match. */ - if (rconn->rmp.r_rrq.rmp_session != - ((rpl->r_type == RMP_BOOT_REPL)? rpl->r_brpl.rmp_session: - rpl->r_rrpl.rmp_session)) { + if (ntohs(rconn->rmp.r_rrq.rmp_session) != + ((rpl->r_type == RMP_BOOT_REPL)? ntohs(rpl->r_brpl.rmp_session): + ntohs(rpl->r_rrpl.rmp_session))) { syslog(LOG_ERR, "BootDone: bad session id (%s)", EnetStr(rconn)); return(0); @@ -570,13 +574,18 @@ SendPacket(rconn) */ bcopy((char *)&rconn->rmp.hp_hdr.saddr[0], (char *)&rconn->rmp.hp_hdr.daddr[0], RMP_ADDRLEN); +#ifdef __FreeBSD__ + /* BPF (incorrectly) wants this in host order. */ rconn->rmp.hp_hdr.len = rconn->rmplen - sizeof(struct hp_hdr); +#else + rconn->rmp.hp_hdr.len = htons(rconn->rmplen - sizeof(struct hp_hdr)); +#endif /* * Reverse 802.2/HP Extended Source & Destination Access Pts. */ - rconn->rmp.hp_llc.dxsap = HPEXT_SXSAP; - rconn->rmp.hp_llc.sxsap = HPEXT_DXSAP; + rconn->rmp.hp_llc.dxsap = htons(HPEXT_SXSAP); + rconn->rmp.hp_llc.sxsap = htons(HPEXT_DXSAP); /* * Last time this connection was active. |