X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/343f5b267c4dd5054e5093d131b2cee5aefa381d..5548a02fb5c1a0399f9e8d8d90b4a0370bea6070:/usr/src/sys/netiso/tp_pcb.c diff --git a/usr/src/sys/netiso/tp_pcb.c b/usr/src/sys/netiso/tp_pcb.c index 805fba5077..e864c8c84d 100644 --- a/usr/src/sys/netiso/tp_pcb.c +++ b/usr/src/sys/netiso/tp_pcb.c @@ -4,7 +4,7 @@ * * %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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* ticks are in units of: * 500 nano-fortnights ;-) or @@ -324,6 +325,9 @@ struct nl_protosw nl_protosw[] = { { 0 } }; +u_long tp_sendspace = 1024 * 4; +u_long tp_recvspace = 1024 * 4; + /* * NAME: tp_init() * @@ -616,7 +620,7 @@ tp_attach(so, protocol) 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[]; @@ -632,7 +636,8 @@ tp_attach(so, protocol) 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) @@ -652,6 +657,7 @@ tp_attach(so, protocol) 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 && protocoltp_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); - } 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);