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