changed my mind, need ip_stripoptions again
[unix-history] / usr / src / sys / netns / ns_output.c
index c06d3b4..e632f1f 100644 (file)
@@ -1,4 +1,10 @@
-/*      ns_output.c     6.2     85/06/01     */
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)ns_output.c 6.6 (Berkeley) %G%
+ */
 
 #include "param.h"
 #include "mbuf.h"
 
 #include "param.h"
 #include "mbuf.h"
@@ -29,19 +35,18 @@ ns_output(m0, ro, flags)
 {
        register struct idp *idp = mtod(m0, struct idp *);
        register struct ifnet *ifp;
 {
        register struct idp *idp = mtod(m0, struct idp *);
        register struct ifnet *ifp;
-       register struct mbuf *m;
-       int len, rlen, off, error = 0;
+       int error = 0;
        struct route idproute;
        struct sockaddr_ns *dst;
        extern int idpcksum;
 
        struct route idproute;
        struct sockaddr_ns *dst;
        extern int idpcksum;
 
-       if(ns_hold_output) {
-               if(ns_lastout) {
+       if (ns_hold_output) {
+               if (ns_lastout) {
                        m_free(ns_lastout);
                }
                        m_free(ns_lastout);
                }
-               ns_lastout = m_copy(m0, 0, M_COPYALL);
+               ns_lastout = m_copy(m0, 0, (int)M_COPYALL);
        }
        }
-       if(ns_copy_output) {
+       if (ns_copy_output) {
                ns_watch_output(m0);
        }
 
                ns_watch_output(m0);
        }
 
@@ -56,18 +61,30 @@ ns_output(m0, ro, flags)
        if (ro->ro_rt == 0) {
                dst->sns_family = AF_NS;
                dst->sns_addr = idp->idp_dna;
        if (ro->ro_rt == 0) {
                dst->sns_family = AF_NS;
                dst->sns_addr = idp->idp_dna;
+               dst->sns_addr.x_port = 0;
                /*
                 * If routing to interface only,
                 * short circuit routing lookup.
                 */
                if (flags & NS_ROUTETOIF) {
                        struct ns_ifaddr *ia;
                /*
                 * If routing to interface only,
                 * short circuit routing lookup.
                 */
                if (flags & NS_ROUTETOIF) {
                        struct ns_ifaddr *ia;
+                       struct ifaddr *ifa_ifwithdstaddr();
+
                        ia = ns_iaonnetof(idp->idp_dna.x_net);
                        if (ia == 0) {
                                error = ENETUNREACH;
                                goto bad;
                        }
                        ifp = ia->ia_ifp;
                        ia = ns_iaonnetof(idp->idp_dna.x_net);
                        if (ia == 0) {
                                error = ENETUNREACH;
                                goto bad;
                        }
                        ifp = ia->ia_ifp;
+                       if (ifp->if_flags & IFF_POINTOPOINT) {
+                               ia = (struct ns_ifaddr *)
+                                       ifa_ifwithdstaddr(&ro->ro_dst);
+                               if (ia == 0) {
+                                       error = ENETUNREACH;
+                                       goto bad;
+                               }
+                               ifp = ia->ia_ifp;
+                       }
                        goto gotif;
                }
                rtalloc(ro);
                        goto gotif;
                }
                rtalloc(ro);