xref: /original-bsd/sys/vax/if/raw_hy.c (revision d11ff5ba)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Tektronix Inc.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)raw_hy.c	7.4 (Berkeley) 12/16/90
11  */
12 
13 /*
14  * 4.3 BSD Unix kernel - NSC HYPERchannel support
15  *
16  * $Header: raw_hy.c,v 3.1 84/02/15 04:27:44 steveg Exp $
17  * $Locker:  $
18  *
19  * Copyright (c) 1984, Tektronix Inc.
20  * All Rights Reserved
21  *
22  */
23 
24 #include "hy.h"
25 #if NHY > 0
26 
27 #include "sys/param.h"
28 #include "sys/mbuf.h"
29 #include "sys/socket.h"
30 #include "sys/protosw.h"
31 #include "sys/socketvar.h"
32 #include "sys/errno.h"
33 
34 #include "net/if.h"
35 #include "net/route.h"
36 #include "net/raw_cb.h"
37 
38 #include "netinet/in.h"
39 #include "netinet/in_systm.h"
40 #include "netinet/in_var.h"
41 #include "if_hy.h"
42 
43 /*
44  * Raw interface to HYPERchannel.
45  */
46 
47 /*
48  * Generate HYPERchannel leader and pass packet to hyoutput.
49  * The user must create a skeletal leader in order to
50  * communicate message type, message subtype, etc.
51  * We don't really check the header supplied by the user.
52  */
53 rhy_output(m, so)
54 	register struct mbuf *m;
55 	struct socket *so;
56 {
57 	int error = 0;
58 	register struct sockaddr_in *sin;
59 	register struct rawcb *rp = sotorawcb(so);
60 	struct in_ifaddr *ia;
61 
62 	/*
63 	 * Verify user has supplied necessary space
64 	 * for the header.
65 	 */
66 	if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct hym_hdr)) &&
67 	    (m = m_pullup(m, sizeof(struct hym_hdr))) == 0) {
68 		error = EMSGSIZE;	/* XXX */
69 		goto bad;
70 	}
71 
72 	sin = (struct sockaddr_in *)&rp->rcb_faddr;
73 	/* no routing here */
74 	ia = in_iaonnetof(in_netof(sin->sin_addr));
75 	if (ia)
76 		return (hyoutput(ia->ia_ifp, m, (struct sockaddr *)sin));
77 	error = ENETUNREACH;
78 bad:
79 	m_freem(m);
80 	return (error);
81 }
82 #endif
83