trailing comment after #else or #endif
[unix-history] / usr / src / sys / netiso / tp_iso.c
index d0fbce3..ce93b6d 100644 (file)
@@ -1,3 +1,12 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)tp_iso.c    7.16 (Berkeley) %G%
+ */
+
 /***********************************************************
                Copyright IBM Corporation 1987
 
 /***********************************************************
                Copyright IBM Corporation 1987
 
@@ -28,7 +37,6 @@ SOFTWARE.
  * ARGO TP
  * $Header: /var/src/sys/netiso/RCS/tp_iso.c,v 5.1 89/02/09 16:20:51 hagens Exp $
  * $Source: /var/src/sys/netiso/RCS/tp_iso.c,v $
  * ARGO TP
  * $Header: /var/src/sys/netiso/RCS/tp_iso.c,v 5.1 89/02/09 16:20:51 hagens Exp $
  * $Source: /var/src/sys/netiso/RCS/tp_iso.c,v $
- *     @(#)tp_iso.c    7.10 (Berkeley) %G%
  *
  * Here is where you find the iso-dependent code.  We've tried
  * keep all net-level and (primarily) address-family-dependent stuff
  *
  * Here is where you find the iso-dependent code.  We've tried
  * keep all net-level and (primarily) address-family-dependent stuff
@@ -50,34 +58,30 @@ SOFTWARE.
  *             tpclnp_output: package a pkt for clnp given an isopcb & some data
  */
 
  *             tpclnp_output: package a pkt for clnp given an isopcb & some data
  */
 
-#ifndef lint
-static char *rcsid = "$Header: /var/src/sys/netiso/RCS/tp_iso.c,v 5.1 89/02/09 16:20:51 hagens Exp $";
-#endif lint
-
 #ifdef ISO
 
 #ifdef ISO
 
-#include "param.h"
-#include "socket.h"
-#include "socketvar.h"
-#include "domain.h"
-#include "malloc.h"
-#include "mbuf.h"
-#include "errno.h"
-#include "time.h"
-#include "protosw.h"
-
-#include "../net/if.h"
-#include "../net/route.h"
-
-#include "argo_debug.h"
-#include "tp_param.h"
-#include "tp_stat.h"
-#include "tp_pcb.h"
-#include "tp_trace.h"
-#include "tp_stat.h"
-#include "tp_tpdu.h"
-#include "tp_clnp.h"
-#include "cltp_var.h"
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/domain.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/protosw.h>
+
+#include <net/if.h>
+#include <net/route.h>
+
+#include <netiso/argo_debug.h>
+#include <netiso/tp_param.h>
+#include <netiso/tp_stat.h>
+#include <netiso/tp_pcb.h>
+#include <netiso/tp_trace.h>
+#include <netiso/tp_stat.h>
+#include <netiso/tp_tpdu.h>
+#include <netiso/tp_clnp.h>
+#include <netiso/cltp_var.h>
 
 /*
  * CALLED FROM:
 
 /*
  * CALLED FROM:
@@ -283,103 +287,41 @@ iso_getnetaddr( isop, name, which)
        else
                name->m_len = 0;
 }
        else
                name->m_len = 0;
 }
-
 /*
 /*
+ * NAME:       tpclnp_mtu()
+ *
  * CALLED FROM:
  * CALLED FROM:
- *  tp_input() on incoming CR, CC, and pr_usrreq() for PRU_CONNECT
- * FUNCTION, ARGUMENTS, SIDE EFFECTS and RETURN VALUE:
- * Determine the proper maximum transmission unit, i.e., MTU, to use, given
- * a) the header size for the network protocol and the max transmission
- *       unit on the subnet interface, determined from the information in (isop),
- * b) the max size negotiated so far (negot)
- * c) the window size used by the tp connection (found in so),
+ *  tp_route_to() on incoming CR, CC, and pr_usrreq() for PRU_CONNECT
  *
  *
- * The result is put in the integer *size in its integer form and in
- * *negot in its logarithmic form.  
+ * FUNCTION, ARGUMENTS, and RETURN VALUE:
+ *
+ * Perform subnetwork dependent part of determining MTU information.
+ * It appears that setting a double pointer to the rtentry associated with
+ * the destination, and returning the header size for the network protocol
+ * suffices.
  * 
  * 
- * The rules are:
- * a) can only negotiate down from the value found in *negot.
- * b) the MTU must be < the windowsize,
- * c) If src and dest are on the same net,
- *       we will negotiate the closest size larger than  MTU but really USE 
- *    the actual device mtu - ll hdr sizes.
- *   otherwise we negotiate the closest size smaller than MTU - ll hdr sizes.
+ * SIDE EFFECTS:
+ * Sets tp_routep pointer in pcb.
+ *
+ * NOTES:
  */
  */
-
-void
-tpclnp_mtu(so, isop, size, negot )
-       struct socket *so;
-       struct isopcb *isop;
-       int *size;
-       u_char *negot;
+tpclnp_mtu(tpcb)
+register struct tp_pcb *tpcb;
 {
 {
-       struct ifnet *ifp = 0;
-       struct iso_ifaddr *ia = 0;
-       register int i;
-       int windowsize = so->so_rcv.sb_hiwat;
-       int clnp_size, mtu;
-       int sizeismtu = 0;
-       register struct rtentry *rt = isop->isop_route.ro_rt;
+       struct isopcb                   *isop = (struct isopcb *)tpcb->tp_npcb;
 
        IFDEBUG(D_CONN)
 
        IFDEBUG(D_CONN)
-               printf("tpclnp_mtu(0x%x,0x%x,0x%x,0x%x)\n", so, isop, size, negot);
+               printf("tpclnp_mtu(tpcb)\n", tpcb);
        ENDDEBUG
        ENDDEBUG
-       IFTRACE(D_CONN)
-               tptrace(TPPTmisc, "ENTER GET MTU: size negot \n",*size, *negot, 0, 0);
-       ENDTRACE
-
-       *size = 1 << *negot;
-
-       if( *size > windowsize ) {
-               *size = windowsize;
-       }
-
-       if (rt == 0 || (rt->rt_flags & RTF_UP == 0) ||
-               (ia = (struct iso_ifaddr *)rt->rt_ifa) == 0 ||
-           (ifp = ia->ia_ifp) == 0) {
-               IFDEBUG(D_CONN)
-                       printf("tpclnp_mtu routing abort rt=0x%x ia=0x%x ifp=0x%x\n",
-                                       rt, ia, ifp)
-               ENDDEBUG
-               return;
-       }
-
-
-
-       /* TODO - make this indirect off the socket structure to the
-        * network layer to get headersize
-        */
-       clnp_size = sizeof(struct clnp_fixed) + sizeof(struct clnp_segment) +
-                       2 * sizeof(struct iso_addr);
-       mtu = SN_MTU(ifp, rt) - clnp_size;
-       if(*size > mtu) {
-               *size = mtu;
-               sizeismtu = 1;
-       }
-       /* have to transform size to the log2 of size */
-       for(i=TP_MIN_TPDUSIZE; (i<=TP_MAX_TPDUSIZE && ((1<<i) <= *size)) ; i++)
-               ;
-       i--;
-
-       IFTRACE(D_CONN)
-               tptrace(TPPTmisc, "GET MTU MID: tpcb size negot i \n",
-               *size, *negot, i, 0);
-       ENDTRACE
-
-       *size = 1<<i;
-       *negot = i;
+       tpcb->tp_routep = &(isop->isop_route.ro_rt);
+       if (tpcb->tp_netservice == ISO_CONS)
+               return 0;
+       else
+               return (sizeof(struct clnp_fixed) + sizeof(struct clnp_segment) +
+                       2 * sizeof(struct iso_addr));
 
 
-       IFDEBUG(D_CONN)
-               printf("GET MTU RETURNS: ifp %s size 0x%x negot 0x%x\n",
-               ifp->if_name,   *size, *negot);
-       ENDDEBUG
-       IFTRACE(D_CONN)
-               tptrace(TPPTmisc, "EXIT GET MTU: tpcb size negot \n",
-               *size, *negot, 0, 0);
-       ENDTRACE
 }
 
 }
 
-
 /*
  * CALLED FROM:
  *  tp_emit()
 /*
  * CALLED FROM:
  *  tp_emit()
@@ -387,7 +329,7 @@ tpclnp_mtu(so, isop, size, negot )
  *  Take a packet(m0) from tp and package it so that clnp will accept it.
  *  This means prepending space for the clnp header and filling in a few
  *  of the fields.
  *  Take a packet(m0) from tp and package it so that clnp will accept it.
  *  This means prepending space for the clnp header and filling in a few
  *  of the fields.
- *  inp is the isopcb structure; datalen is the length of the data in the
+ *  isop is the isopcb structure; datalen is the length of the data in the
  *  mbuf string m0.
  * RETURN VALUE:
  *  whatever (E*) is returned form the net layer output routine.
  *  mbuf string m0.
  * RETURN VALUE:
  *  whatever (E*) is returned form the net layer output routine.
@@ -497,7 +439,6 @@ tpclnp_input(m, src, dst, clnp_len, ce_bit)
        struct sockaddr_iso *src, *dst;
        int clnp_len, ce_bit;
 {
        struct sockaddr_iso *src, *dst;
        int clnp_len, ce_bit;
 {
-       int s = splnet();
        struct mbuf *tp_inputprep();
        int tp_input(), cltp_input(), (*input)() = tp_input;
 
        struct mbuf *tp_inputprep();
        int tp_input(), cltp_input(), (*input)() = tp_input;
 
@@ -513,10 +454,21 @@ tpclnp_input(m, src, dst, clnp_len, ce_bit)
         * First, strip off the Clnp header. leave the mbuf there for the
         * pullup that follows.
         */
         * First, strip off the Clnp header. leave the mbuf there for the
         * pullup that follows.
         */
-
        m->m_len -= clnp_len;
        m->m_data += clnp_len;
        m->m_len -= clnp_len;
        m->m_data += clnp_len;
-
+       m->m_pkthdr.len -= clnp_len;
+       /* XXXX: should probably be in clnp_input */
+       switch (dst->siso_data[dst->siso_nlen - 1]) {
+#ifdef TUBA
+       case ISOPROTO_TCP:
+               return (tuba_tcpinput(m, src, dst));
+#endif
+       case 0:
+               if (m->m_len == 0 && (m = m_pullup(m, 1)) == 0)
+                       return 0;
+               if (*(mtod(m, u_char *)) == ISO10747_IDRP)
+                       return (idrp_input(m, src, dst));
+       }
        m = tp_inputprep(m);
        if (m == 0)
                return 0;
        m = tp_inputprep(m);
        if (m == 0)
                return 0;
@@ -552,7 +504,6 @@ tpclnp_input(m, src, dst, clnp_len, ce_bit)
                }
        ENDDEBUG
 
                }
        ENDDEBUG
 
-       splx(s);
        return 0;
 }
 
        return 0;
 }
 
@@ -572,7 +523,7 @@ void
 tpiso_decbit(isop)
        struct isopcb *isop;
 {
 tpiso_decbit(isop)
        struct isopcb *isop;
 {
-       tp_quench((struct tp_pcb *)isop->isop_socket->so_tpcb, PRC_QUENCH2);
+       tp_quench((struct tp_pcb *)isop->isop_socket->so_pcb, PRC_QUENCH2);
 }
 /*
  * CALLED FROM:
 }
 /*
  * CALLED FROM:
@@ -584,7 +535,7 @@ void
 tpiso_quench(isop)
        struct isopcb *isop;
 {
 tpiso_quench(isop)
        struct isopcb *isop;
 {
-       tp_quench((struct tp_pcb *)isop->isop_socket->so_tpcb, PRC_QUENCH);
+       tp_quench((struct tp_pcb *)isop->isop_socket->so_pcb, PRC_QUENCH);
 }
 
 /*
 }
 
 /*
@@ -699,7 +650,7 @@ tpiso_abort(isop)
        ENDDEBUG
        e.ev_number = ER_TPDU;
        e.ATTR(ER_TPDU).e_reason = ECONNABORTED;
        ENDDEBUG
        e.ev_number = ER_TPDU;
        e.ATTR(ER_TPDU).e_reason = ECONNABORTED;
-       return  tp_driver((struct tp_pcb *)isop->isop_socket->so_tpcb, &e);
+       return  tp_driver((struct tp_pcb *)isop->isop_socket->so_pcb, &e);
 }
 
 ProtoHook
 }
 
 ProtoHook
@@ -709,8 +660,8 @@ tpiso_reset(isop)
        struct tp_event e;
 
        e.ev_number = T_NETRESET;
        struct tp_event e;
 
        e.ev_number = T_NETRESET;
-       return tp_driver((struct tp_pcb *)isop->isop_socket->so_tpcb, &e);
+       return tp_driver((struct tp_pcb *)isop->isop_socket->so_pcb, &e);
 
 }
 
 
 }
 
-#endif ISO
+#endif /* ISO */