|
|
1.1 ! root 1: /* %M% %I% %E% */ ! 2: ! 3: #include "../h/param.h" ! 4: #include "../h/mbuf.h" ! 5: #include "../h/socket.h" ! 6: #include "../h/protosw.h" ! 7: #include "../h/socketvar.h" ! 8: #include "../h/errno.h" ! 9: ! 10: #include "../net/if.h" ! 11: #include "../net/route.h" ! 12: #include "../net/raw_cb.h" ! 13: ! 14: #include "../netpup/ether.h" ! 15: #include "../vaxif/if_en.h" ! 16: ! 17: /* ! 18: * Raw interface to 3Mb/s Ethernet. ! 19: */ ! 20: ! 21: struct sockaddr etherlink = { AF_ETHERLINK }; ! 22: /* ! 23: * Generate Ethernet header and pass packet to output ! 24: * routine. The user must create a skeletal header ! 25: * in order to message type. Source and destination ! 26: * field are filled in from send parameters. ! 27: */ ! 28: raw_enoutput(m, so) ! 29: register struct mbuf *m; ! 30: struct socket *so; ! 31: { ! 32: register struct en_header *en; ! 33: register struct sockaddr_en *sen; ! 34: register struct rawcb *rp = sotorawcb(so); ! 35: struct ifnet *ifp; ! 36: int error = 0; ! 37: ! 38: /* ! 39: * Verify user has supplied necessary space for the header. ! 40: */ ! 41: if ((m->m_off > MMAXOFF || m->m_len < sizeof (struct en_header)) && ! 42: (m = m_pullup(m, sizeof (struct en_header))) == 0) { ! 43: error = EMSGSIZE; /* XXX */ ! 44: goto bad; ! 45: } ! 46: en = mtod(m, struct en_header *); ! 47: sen = (struct sockaddr_en *)&rp->rcb_faddr; ! 48: en->en_dhost = sen->sen_host; ! 49: if (rp->rcb_route.ro_rt == 0) ! 50: ifp = if_ifonnetof(sen->sen_net); ! 51: else { ! 52: rp->rcb_route.ro_rt->rt_use++; ! 53: ifp = rp->rcb_route.ro_rt->rt_ifp; ! 54: } ! 55: if (ifp == 0) { ! 56: error = ENETUNREACH; ! 57: goto bad; ! 58: } ! 59: en->en_shost = ifp->if_host[0]; ! 60: return ((*ifp->if_output)(ifp, m, ðerlink)); ! 61: bad: ! 62: m_freem(m); ! 63: return (error); ! 64: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.