make kernel includes standard
[unix-history] / usr / src / sys / netiso / tp_pcb.c
index 805fba5..e864c8c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tp_pcb.c    7.20 (Berkeley) %G%
+ *     @(#)tp_pcb.c    7.25 (Berkeley) %G%
  */
 
 /***********************************************************
  */
 
 /***********************************************************
@@ -52,26 +52,27 @@ SOFTWARE.
  *
  */
 
  *
  */
 
-#include "param.h"
-#include "systm.h"
-#include "mbuf.h"
-#include "socket.h"
-#include "socketvar.h"
-#include "domain.h"
-#include "protosw.h"
-#include "errno.h"
-#include "time.h"
-#include "argo_debug.h"
-#include "tp_param.h"
-#include "tp_timer.h"
-#include "tp_ip.h"
-#include "tp_stat.h"
-#include "tp_pcb.h"
-#include "tp_tpdu.h"
-#include "tp_trace.h"
-#include "tp_meas.h"
-#include "tp_seq.h"
-#include "tp_clnp.h"
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/domain.h>
+#include <sys/protosw.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+
+#include <netiso/argo_debug.h>
+#include <netiso/tp_param.h>
+#include <netiso/tp_timer.h>
+#include <netiso/tp_ip.h>
+#include <netiso/tp_stat.h>
+#include <netiso/tp_pcb.h>
+#include <netiso/tp_tpdu.h>
+#include <netiso/tp_trace.h>
+#include <netiso/tp_meas.h>
+#include <netiso/tp_seq.h>
+#include <netiso/tp_clnp.h>
 
 /* ticks are in units of: 
  * 500 nano-fortnights ;-) or
 
 /* ticks are in units of: 
  * 500 nano-fortnights ;-) or
@@ -324,6 +325,9 @@ struct nl_protosw nl_protosw[] = {
        { 0 }
 };
 
        { 0 }
 };
 
+u_long tp_sendspace = 1024 * 4;
+u_long tp_recvspace = 1024 * 4;
+
 /*
  * NAME:  tp_init()
  *
 /*
  * NAME:  tp_init()
  *
@@ -616,7 +620,7 @@ tp_attach(so, protocol)
        int                                     protocol;
 {
        register struct tp_pcb  *tpcb;
        int                                     protocol;
 {
        register struct tp_pcb  *tpcb;
-       int                                     error;
+       int                                     error = 0;
        int                                     dom = so->so_proto->pr_domain->dom_family;
        u_long                                  lref;
        extern struct tp_conn_param tp_conn_param[];
        int                                     dom = so->so_proto->pr_domain->dom_family;
        u_long                                  lref;
        extern struct tp_conn_param tp_conn_param[];
@@ -632,7 +636,8 @@ tp_attach(so, protocol)
                return EISCONN; /* socket already part of a connection*/
        }
 
                return EISCONN; /* socket already part of a connection*/
        }
 
-       error = soreserve(so, 2 * TP_SOCKBUFSIZE, TP_SOCKBUFSIZE);
+       if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0)
+               error = soreserve(so, tp_sendspace, tp_recvspace);
                /* later an ioctl will allow reallocation IF still in closed state */
 
        if (error)
                /* later an ioctl will allow reallocation IF still in closed state */
 
        if (error)
@@ -652,6 +657,7 @@ tp_attach(so, protocol)
        tpcb->tp_lref = lref;
        tpcb->tp_sock =  so;
        tpcb->tp_domain = dom;
        tpcb->tp_lref = lref;
        tpcb->tp_sock =  so;
        tpcb->tp_domain = dom;
+       tpcb->tp_rhiwat = so->so_rcv.sb_hiwat;
        /* tpcb->tp_proto = protocol; someday maybe? */
        if (protocol && protocol<ISOPROTO_TP4) {
                tpcb->tp_netservice = ISO_CONS;
        /* tpcb->tp_proto = protocol; someday maybe? */
        if (protocol && protocol<ISOPROTO_TP4) {
                tpcb->tp_netservice = ISO_CONS;
@@ -928,15 +934,30 @@ register struct mbuf *nam;
                        if (tp_tselinuse(tlen, tsel, siso,
                                                                tpcb->tp_sock->so_options & SO_REUSEADDR))
                                return (EINVAL);
                        if (tp_tselinuse(tlen, tsel, siso,
                                                                tpcb->tp_sock->so_options & SO_REUSEADDR))
                                return (EINVAL);
-               } else for (tsel = (caddr_t)&tp_unique, tlen = 2;;){
-                       if (tp_unique++ < ISO_PORT_RESERVED ||
-                               tp_unique > ISO_PORT_USERRESERVED) {
-                                       if (wrapped++)
-                                               return ESRCH;
-                                       tp_unique = ISO_PORT_RESERVED;
+               } else {
+                       for (tsel = (caddr_t)&tutil, tlen = 2;;){
+                               if (tp_unique++ < ISO_PORT_RESERVED ||
+                                       tp_unique > ISO_PORT_USERRESERVED) {
+                                               if (wrapped++)
+                                                       return ESRCH;
+                                               tp_unique = ISO_PORT_RESERVED;
+                               }
+                               tutil = htons(tp_unique);
+                               if (tp_tselinuse(tlen, tsel, siso, 0) == 0)
+                                       break;
                        }
                        }
-                       if (tp_tselinuse(tlen, tsel, siso, 0) == 0)
-                               break;
+                       if (siso) switch (siso->siso_family) {
+#ifdef ISO
+                               case AF_ISO:
+                                       bcopy(tsel, TSEL(siso), tlen);
+                                       siso->siso_tlen = tlen;
+                                       break;
+#endif
+#ifdef INET
+                               case AF_INET:
+                                       ((struct sockaddr_in *)siso)->sin_port = tutil;
+#endif
+                               }
                }
                bcopy(tsel, tpcb->tp_lsuffix, (tpcb->tp_lsuffixlen = tlen));
                insque(tpcb, &tp_bound_pcbs);
                }
                bcopy(tsel, tpcb->tp_lsuffix, (tpcb->tp_lsuffixlen = tlen));
                insque(tpcb, &tp_bound_pcbs);