X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/ca67e7b465996afb3821d6a075c4dc6a7f0f5d52..1c15e88899094343f75aeba04122cd96a96b428e:/usr/src/sys/vaxif/if_hy.c diff --git a/usr/src/sys/vaxif/if_hy.c b/usr/src/sys/vaxif/if_hy.c index 037dc056be..8cd334409f 100644 --- a/usr/src/sys/vaxif/if_hy.c +++ b/usr/src/sys/vaxif/if_hy.c @@ -1,5 +1,26 @@ /* - * @(#)if_hy.c 7.1 (Berkeley) 6/5/86 + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Tektronix Inc. + * + * Redistribution is only permitted until one year after the first shipment + * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and + * binary forms are permitted provided that: (1) source distributions retain + * this entire copyright notice and comment, and (2) distributions including + * binaries display the following acknowledgement: This product includes + * software developed by the University of California, Berkeley and its + * contributors'' in the documentation or other materials provided with the + * distribution and in all advertising materials mentioning features or use + * of this software. Neither the name of the University nor the names of + * its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)if_hy.c 7.6 (Berkeley) 6/28/90 */ /* @@ -583,22 +604,11 @@ hyoutput(ifp, m0, dst) * No extra space for headers is allocated. */ mp = mtod(m, char *); /* save pointer to real message */ - if (m->m_off > MMAXOFF || - MMINOFF + sizeof(struct hym_hdr) > m->m_off) { - m = m_get(M_DONTWAIT, MT_HEADER); - if (m == 0) { - m = m0; - error = ENOBUFS; - goto drop; - } - m->m_next = m0; - m->m_off = MMINOFF; - m->m_len = sizeof(struct hym_hdr); - } else { - m->m_off -= sizeof(struct hym_hdr); - m->m_len += sizeof(struct hym_hdr); + M_PREPEND(m, sizeof(struct hym_hdr), M_DONTWAIT); + if (m == 0) { + error = ENOBUFS; + goto bad; } - dlen += sizeof(struct hym_hdr) - HYM_SWLEN; hym = mtod(m, struct hym_hdr *); @@ -1089,8 +1099,8 @@ endintr: } struct sockproto hypproto = { PF_HYLINK }; -struct sockaddr_in hypdst = { AF_HYLINK }; -struct sockaddr_in hypsrc = { AF_HYLINK }; +struct sockaddr_in hypdst = { sizeof(hypdst), AF_HYLINK }; +struct sockaddr_in hypsrc = { sizeof(hypsrc), AF_HYLINK }; /* * Called from device interrupt when receiving data. @@ -1150,18 +1160,12 @@ hyrecvdata(ui, hym, len) default: rawlinkin: { - struct mbuf *m0; - - MGET(m0, M_DONTWAIT, MT_DATA); - if (m0 == 0) { + M_PREPEND(m, sizeof(struct hym_hdr), M_DONTWAIT); + if (m == 0) { m_freem(m); return; } - m0->m_off = MMINOFF; - m0->m_len = sizeof(struct hym_hdr); - m0->m_next = m; - bcopy((caddr_t)hym, mtod(m0, caddr_t), sizeof(struct hym_hdr)); - m = m0; + bcopy((caddr_t)hym, mtod(m, caddr_t), sizeof(struct hym_hdr)); hypproto.sp_protocol = 0; hypdst.sin_addr = is->hy_addr; hypsrc.sin_addr = is->hy_addr; @@ -1370,7 +1374,7 @@ hyioctl(ifp, cmd, data) switch(cmd) { case SIOCSIFADDR: - if (ifa->ifa_addr.sa_family != AF_INET) + if (ifa->ifa_addr->sa_family != AF_INET) return(EINVAL); if ((ifp->if_flags & IFF_RUNNING) == 0) hyinit(ifp->if_unit); @@ -1381,10 +1385,8 @@ hyioctl(ifp, cmd, data) break; case HYSETROUTE: - if (!suser()) { - error = EPERM; + if (error = suser(u.u_cred, &u.u_acflag)) goto out; - } if (sg->hyrsg_len != sizeof(struct hy_route)) { error = EINVAL; @@ -1423,10 +1425,8 @@ hyioctl(ifp, cmd, data) goto out; } if (sgl->hylsg_cmd) { - if (!suser()) { - error = EPERM; + if (error = suser(u.u_cred, &u.u_acflag)) goto out; - } bzero((caddr_t)hy_elog, sizeof(hy_elog)); } break; @@ -1434,10 +1434,8 @@ hyioctl(ifp, cmd, data) #ifdef HYLOG case HYSETLOG: - if (!suser()) { - error = EPERM; + if (error = suser(u.u_cred, &u.u_acflag)) goto out; - } hy_log.hyl_enable = HYL_DISABLED; hylog(HYL_NOP, 0, (char *)0); /* force log init */ hy_log.hyl_enable = sgl->hylsg_cmd & 0x0f;