xref: /original-bsd/sys/vax/if/raw_hy.c (revision 2301fdfb)
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  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  *	@(#)raw_hy.c	7.2 (Berkeley) 08/04/88
21  */
22 
23 /*
24  * 4.3 BSD Unix kernel - NSC HYPERchannel support
25  *
26  * $Header: raw_hy.c,v 3.1 84/02/15 04:27:44 steveg Exp $
27  * $Locker:  $
28  *
29  * Copyright (c) 1984, Tektronix Inc.
30  * All Rights Reserved
31  *
32  */
33 
34 #include "hy.h"
35 #if NHY > 0
36 
37 #include "param.h"
38 #include "mbuf.h"
39 #include "socket.h"
40 #include "protosw.h"
41 #include "socketvar.h"
42 #include "errno.h"
43 
44 #include "../net/if.h"
45 #include "../net/route.h"
46 #include "../net/raw_cb.h"
47 
48 #include "../netinet/in.h"
49 #include "../netinet/in_systm.h"
50 #include "../netinet/in_var.h"
51 #include "if_hy.h"
52 
53 /*
54  * Raw interface to HYPERchannel.
55  */
56 
57 /*
58  * Generate HYPERchannel leader and pass packet to hyoutput.
59  * The user must create a skeletal leader in order to
60  * communicate message type, message subtype, etc.
61  * We don't really check the header supplied by the user.
62  */
63 rhy_output(m, so)
64 	register struct mbuf *m;
65 	struct socket *so;
66 {
67 	int error = 0;
68 	register struct sockaddr_in *sin;
69 	register struct rawcb *rp = sotorawcb(so);
70 	struct in_ifaddr *ia;
71 
72 	/*
73 	 * Verify user has supplied necessary space
74 	 * for the header.
75 	 */
76 	if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct hym_hdr)) &&
77 	    (m = m_pullup(m, sizeof(struct hym_hdr))) == 0) {
78 		error = EMSGSIZE;	/* XXX */
79 		goto bad;
80 	}
81 
82 	sin = (struct sockaddr_in *)&rp->rcb_faddr;
83 	/* no routing here */
84 	ia = in_iaonnetof(in_netof(sin->sin_addr));
85 	if (ia)
86 		return (hyoutput(ia->ia_ifp, m, (struct sockaddr *)sin));
87 	error = ENETUNREACH;
88 bad:
89 	m_freem(m);
90 	return (error);
91 }
92 #endif
93