xref: /csrg-svn/sys/vax/if/raw_hy.c (revision 35322)
123743Skarels /*
2*35322Sbostic  * Copyright (c) 1988 Regents of the University of California.
3*35322Sbostic  * All rights reserved.
423743Skarels  *
5*35322Sbostic  * This code is derived from software contributed to Berkeley by
6*35322Sbostic  * Tektronix Inc.
7*35322Sbostic  *
8*35322Sbostic  * Redistribution and use in source and binary forms are permitted
9*35322Sbostic  * provided that the above copyright notice and this paragraph are
10*35322Sbostic  * duplicated in all such forms and that any documentation,
11*35322Sbostic  * advertising materials, and other materials related to such
12*35322Sbostic  * distribution and use acknowledge that the software was developed
13*35322Sbostic  * by the University of California, Berkeley.  The name of the
14*35322Sbostic  * University may not be used to endorse or promote products derived
15*35322Sbostic  * from this software without specific prior written permission.
16*35322Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17*35322Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18*35322Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19*35322Sbostic  *
20*35322Sbostic  *	@(#)raw_hy.c	7.2 (Berkeley) 08/04/88
21*35322Sbostic  */
22*35322Sbostic 
23*35322Sbostic /*
2424798Skarels  * 4.3 BSD Unix kernel - NSC HYPERchannel support
2523743Skarels  *
2623743Skarels  * $Header: raw_hy.c,v 3.1 84/02/15 04:27:44 steveg Exp $
2723743Skarels  * $Locker:  $
2823743Skarels  *
2923743Skarels  * Copyright (c) 1984, Tektronix Inc.
3023743Skarels  * All Rights Reserved
3123743Skarels  *
3223743Skarels  */
3323743Skarels 
3425276Sbloom #include "hy.h"
3525276Sbloom #if NHY > 0
3623743Skarels 
3723743Skarels #include "param.h"
3823743Skarels #include "mbuf.h"
3923743Skarels #include "socket.h"
4023743Skarels #include "protosw.h"
4123743Skarels #include "socketvar.h"
4223743Skarels #include "errno.h"
4323743Skarels 
4423743Skarels #include "../net/if.h"
4523743Skarels #include "../net/route.h"
4623743Skarels #include "../net/raw_cb.h"
4723743Skarels 
4823743Skarels #include "../netinet/in.h"
4923743Skarels #include "../netinet/in_systm.h"
5024798Skarels #include "../netinet/in_var.h"
5123743Skarels #include "if_hy.h"
5223743Skarels 
5323743Skarels /*
5423743Skarels  * Raw interface to HYPERchannel.
5523743Skarels  */
5623743Skarels 
5723743Skarels /*
5823743Skarels  * Generate HYPERchannel leader and pass packet to hyoutput.
5923743Skarels  * The user must create a skeletal leader in order to
6023743Skarels  * communicate message type, message subtype, etc.
6123743Skarels  * We don't really check the header supplied by the user.
6223743Skarels  */
6323743Skarels rhy_output(m, so)
6423743Skarels 	register struct mbuf *m;
6523743Skarels 	struct socket *so;
6623743Skarels {
6723743Skarels 	int error = 0;
6823743Skarels 	register struct sockaddr_in *sin;
6923743Skarels 	register struct rawcb *rp = sotorawcb(so);
7024798Skarels 	struct in_ifaddr *ia;
7123743Skarels 
7223743Skarels 	/*
7323743Skarels 	 * Verify user has supplied necessary space
7423743Skarels 	 * for the header.
7523743Skarels 	 */
7623743Skarels 	if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct hym_hdr)) &&
7723743Skarels 	    (m = m_pullup(m, sizeof(struct hym_hdr))) == 0) {
7823743Skarels 		error = EMSGSIZE;	/* XXX */
7923743Skarels 		goto bad;
8023743Skarels 	}
8123743Skarels 
8223743Skarels 	sin = (struct sockaddr_in *)&rp->rcb_faddr;
8323743Skarels 	/* no routing here */
8424798Skarels 	ia = in_iaonnetof(in_netof(sin->sin_addr));
8524798Skarels 	if (ia)
8624798Skarels 		return (hyoutput(ia->ia_ifp, m, (struct sockaddr *)sin));
8723743Skarels 	error = ENETUNREACH;
8823743Skarels bad:
8923743Skarels 	m_freem(m);
9023743Skarels 	return (error);
9123743Skarels }
9225276Sbloom #endif
93