/*
- * @(#)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
*/
/*
* 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 *);
}
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.
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;
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);
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;
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;
#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;