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