X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/be9760a9307aa6a343496bfc06cd4d0423967450..430f81c3e8403e1b366018124c1bece2685f94b1:/usr/src/sys/netns/idp_usrreq.c diff --git a/usr/src/sys/netns/idp_usrreq.c b/usr/src/sys/netns/idp_usrreq.c index d7556f905c..8cbb8f2f74 100644 --- a/usr/src/sys/netns/idp_usrreq.c +++ b/usr/src/sys/netns/idp_usrreq.c @@ -1,9 +1,15 @@ /* - * Copyright (c) 1982 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. + * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California. + * All rights reserved. * - * @(#)idp_usrreq.c 6.9 (Berkeley) %G% + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + * + * @(#)idp_usrreq.c 7.2 (Berkeley) %G% */ #include "param.h" @@ -49,7 +55,7 @@ idp_input(m, nsp, ifp) * Stuff source address and datagram in user buffer. */ idp_ns.sns_addr = idp->idp_sna; - if (ns_netof(idp->idp_sna)==0) { + if (ns_neteqnn(idp->idp_sna.x_net, ns_zeronet) && ifp) { register struct ifaddr *ia; for (ia = ifp->if_addrlist; ia; ia = ia->ifa_next) { @@ -107,6 +113,7 @@ idp_drop(nsp, errno) soisdisconnected(so); } +int noIdpRoute; idp_output(nsp, m0) struct nspcb *nsp; struct mbuf *m0; @@ -161,7 +168,9 @@ idp_output(nsp, m0) m_freem(m0); return (ENOBUFS); } - m->m_off = MMAXOFF - sizeof (struct idp); + m->m_off = MMAXOFF - sizeof (struct idp) - 2; + /* adjust to start on longword bdry + for NSIP on gould */ m->m_len = sizeof (struct idp); m->m_next = m0; idp = mtod(m, struct idp *); @@ -190,19 +199,47 @@ idp_output(nsp, m0) (so->so_options & SO_BROADCAST) | NS_ROUTETOIF)); /* * Use cached route for previous datagram if - * this is also to the same destination. + * possible. If the previous net was the same + * and the interface was a broadcast medium, or + * if the previous destination was identical, + * then we are ok. * * NB: We don't handle broadcasts because that * would require 3 subroutine calls. */ ro = &nsp->nsp_route; - if (ro->ro_rt && - ((*(long *)&nsp->nsp_lastnet)!=ns_netof(idp->idp_dna)) && - !(ns_hosteq(satons_addr(ro->ro_dst), idp->idp_dna))) { - RTFREE(ro->ro_rt); - ro->ro_rt = (struct rtentry *)0; - nsp->nsp_lastnet = idp->idp_dna.x_net; +#ifdef ancient_history + /* + * I think that this will all be handled in ns_pcbconnect! + */ + if (ro->ro_rt) { + if(ns_neteq(nsp->nsp_lastdst, idp->idp_dna)) { + /* + * This assumes we have no GH type routes + */ + if (ro->ro_rt->rt_flags & RTF_HOST) { + if (!ns_hosteq(nsp->nsp_lastdst, idp->idp_dna)) + goto re_route; + + } + if ((ro->ro_rt->rt_flags & RTF_GATEWAY) == 0) { + register struct ns_addr *dst = + &satons_addr(ro->ro_dst); + dst->x_host = idp->idp_dna.x_host; + } + /* + * Otherwise, we go through the same gateway + * and dst is already set up. + */ + } else { + re_route: + RTFREE(ro->ro_rt); + ro->ro_rt = (struct rtentry *)0; + } } + nsp->nsp_lastdst = idp->idp_dna; +#endif ancient_history + if (noIdpRoute) ro = 0; return (ns_output(m, ro, so->so_options & SO_BROADCAST)); } /* ARGSUSED */ @@ -264,6 +301,10 @@ idp_ctloutput(req, so, level, name, value) m->m_len = sizeof(long); m->m_off = MMAXOFF - sizeof(long); *mtod(m, long *) = ns_pexseq++; + break; + + default: + error = EINVAL; } *value = m; break; @@ -298,12 +339,15 @@ idp_ctloutput(req, so, level, name, value) = mtod(*value, struct idp *); nsp->nsp_dpt = idp->idp_pt; } -#ifdef NSIP break; +#ifdef NSIP case SO_NSIP_ROUTE: error = nsip_route(*value); + break; #endif NSIP + default: + error = EINVAL; } if (value && *value) m_freem(*value);