1996-02-14 01:07:57 +03:00
|
|
|
/* $NetBSD: tp_subr2.c,v 1.9 1996/02/13 22:12:04 christos Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*-
|
1994-05-13 10:08:03 +04:00
|
|
|
* Copyright (c) 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-06-29 10:39:25 +04:00
|
|
|
* @(#)tp_subr2.c 8.1 (Berkeley) 6/10/93
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/***********************************************************
|
|
|
|
Copyright IBM Corporation 1987
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
1993-04-09 16:00:07 +04:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
1996-02-14 01:07:57 +03:00
|
|
|
both that copyright notice and this permission notice appear in
|
1993-04-09 16:00:07 +04:00
|
|
|
supporting documentation, and that the name of IBM not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
1996-02-14 01:07:57 +03:00
|
|
|
software without specific, written prior permission.
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* Some auxiliary routines: tp_protocol_error: required by xebec- called when
|
|
|
|
* a combo of state, event, predicate isn't covered for by the transition
|
|
|
|
* file. tp_indicate: gives indications(signals) to the user process
|
|
|
|
* tp_getoptions: initializes variables that are affected by the options
|
|
|
|
* chosen.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* this def'n is to cause the expansion of this macro in the routine
|
|
|
|
* tp_local_credit :
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
#define LOCAL_CREDIT_EXPAND
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#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 <sys/kernel.h>
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <sys/queue.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
|
|
|
|
#include <netiso/argo_debug.h>
|
|
|
|
#include <netiso/tp_param.h>
|
|
|
|
#include <netiso/tp_ip.h>
|
|
|
|
#include <netiso/iso.h>
|
|
|
|
#include <netiso/iso_errno.h>
|
|
|
|
#include <netiso/iso_pcb.h>
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <netiso/iso_var.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/tp_timer.h>
|
|
|
|
#include <netiso/tp_stat.h>
|
|
|
|
#include <netiso/tp_tpdu.h>
|
|
|
|
#include <netiso/tp_pcb.h>
|
|
|
|
#include <netiso/tp_seq.h>
|
|
|
|
#include <netiso/tp_trace.h>
|
|
|
|
#include <netiso/tp_user.h>
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <netiso/tp_var.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/cons.h>
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <netiso/clnp.h>
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef TRUE
|
1996-02-14 01:07:57 +03:00
|
|
|
#undef MNULL
|
1993-04-09 16:00:07 +04:00
|
|
|
#undef FALSE
|
|
|
|
#undef TRUE
|
|
|
|
#endif
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netccitt/x25.h>
|
|
|
|
#include <netccitt/pk.h>
|
|
|
|
#include <netccitt/pk_var.h>
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <netccitt/pk_extern.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#if 0
|
|
|
|
static void copyQOSparms __P((struct tp_conn_param *, struct tp_conn_param *));
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
static void pk_flowcontrol __P((struct pklcd *, int, int));
|
|
|
|
#endif
|
1993-09-06 22:08:02 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* NAME: tp_local_credit()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_emit(), tp_usrreq()
|
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Computes the local credit and stashes it in tpcb->tp_lcredit.
|
|
|
|
* It's a macro in the production system rather than a procdure.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* SIDE EFFECTS:
|
|
|
|
*
|
|
|
|
* NOTES:
|
1996-02-14 01:07:57 +03:00
|
|
|
* This doesn't actually get called in a production system -
|
1993-04-09 16:00:07 +04:00
|
|
|
* the macro gets expanded instead in place of calls to this proc.
|
|
|
|
* But for debugging, we call this and that allows us to add
|
|
|
|
* debugging messages easily here.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tp_local_credit(tpcb)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct tp_pcb *tpcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
LOCAL_CREDIT(tpcb);
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CREDIT]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("ref 0x%x lcdt 0x%x l_tpdusize 0x%x decbit 0x%x\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_lref,
|
|
|
|
tpcb->tp_lcredit,
|
|
|
|
tpcb->tp_l_tpdusize,
|
|
|
|
tpcb->tp_decbit,
|
|
|
|
tpcb->tp_cong_win
|
1993-04-09 16:00:07 +04:00
|
|
|
);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_CREDIT]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
tptraceTPCB(TPPTmisc,
|
1996-02-14 01:07:57 +03:00
|
|
|
"lcdt tpdusz \n",
|
|
|
|
tpcb->tp_lcredit, tpcb->tp_l_tpdusize, 0, 0);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: tp_protocol_error()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_driver(), when it doesn't know what to do with
|
|
|
|
* a combo of event, state, predicate
|
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
1996-02-14 01:07:57 +03:00
|
|
|
* print error mesg
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* RETURN VALUE:
|
|
|
|
* EIO - always
|
|
|
|
*
|
|
|
|
* SIDE EFFECTS:
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
*/
|
|
|
|
int
|
1996-02-14 01:07:57 +03:00
|
|
|
tp_protocol_error(e, tpcb)
|
|
|
|
struct tp_event *e;
|
|
|
|
struct tp_pcb *tpcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
printf("TP PROTOCOL ERROR! tpcb 0x%x event 0x%x, state 0x%x\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb, e->ev_number, tpcb->tp_state);
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_DRIVER]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
tptraceTPCB(TPPTmisc, "PROTOCOL ERROR tpcb event state",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb, e->ev_number, tpcb->tp_state, 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return EIO; /* for lack of anything better */
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Not used at the moment */
|
1994-05-13 10:08:03 +04:00
|
|
|
void
|
1993-04-09 16:00:07 +04:00
|
|
|
tp_drain()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: tp_indicate()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp.trans when XPD arrive, when a connection is being disconnected by
|
|
|
|
* the arrival of a DR or ER, and when a connection times out.
|
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* (ind) is the type of indication : T_DISCONNECT, T_XPD
|
|
|
|
* (error) is an E* value that will be put in the socket structure
|
|
|
|
* to be passed along to the user later.
|
|
|
|
* Gives a SIGURG to the user process or group indicated by the socket
|
|
|
|
* attached to the tpcb.
|
|
|
|
*
|
|
|
|
* RETURNS: Rien
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
* SIDE EFFECTS:
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tp_indicate(ind, tpcb, error)
|
1996-02-14 01:07:57 +03:00
|
|
|
int ind;
|
|
|
|
u_short error;
|
|
|
|
register struct tp_pcb *tpcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
register struct socket *so = tpcb->tp_sock;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_INDICATION]) {
|
|
|
|
tptraceTPCB(TPPTindicate, ind, *(u_short *) (tpcb->tp_lsuffix),
|
|
|
|
*(u_short *) (tpcb->tp_fsuffix), error, so->so_pgid);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_INDICATION]) {
|
|
|
|
char *ls, *fs;
|
|
|
|
ls = tpcb->tp_lsuffix,
|
|
|
|
fs = tpcb->tp_fsuffix,
|
|
|
|
|
|
|
|
printf(
|
|
|
|
"indicate 0x%x lsuf 0x%02x%02x fsuf 0x%02x%02x err 0x%x noind 0x%x ref 0x%x\n",
|
|
|
|
ind,
|
|
|
|
*ls, *(ls + 1), *fs, *(fs + 1),
|
|
|
|
error, /* so->so_pgrp, */
|
|
|
|
tpcb->tp_no_disc_indications,
|
|
|
|
tpcb->tp_lref);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (ind == ER_TPDU) {
|
|
|
|
register struct mbuf *m;
|
|
|
|
struct tp_disc_reason x;
|
|
|
|
|
|
|
|
if ((so->so_state & SS_CANTRCVMORE) == 0 &&
|
1996-02-14 01:07:57 +03:00
|
|
|
(m = m_get(M_DONTWAIT, MT_OOBDATA)) != 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
x.dr_hdr.cmsg_len = m->m_len = sizeof(x);
|
|
|
|
x.dr_hdr.cmsg_level = SOL_TRANSPORT;
|
1996-02-14 01:07:57 +03:00
|
|
|
x.dr_hdr.cmsg_type = TPOPT_DISC_REASON;
|
1993-04-09 16:00:07 +04:00
|
|
|
x.dr_reason = error;
|
|
|
|
*mtod(m, struct tp_disc_reason *) = x;
|
|
|
|
sbappendrecord(&tpcb->tp_Xrcv, m);
|
|
|
|
error = 0;
|
|
|
|
} else
|
|
|
|
error = ECONNRESET;
|
|
|
|
}
|
|
|
|
so->so_error = error;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
if (ind == T_DISCONNECT) {
|
1994-05-13 10:08:03 +04:00
|
|
|
if (error == 0)
|
|
|
|
so->so_error = ENOTCONN;
|
1996-02-14 01:07:57 +03:00
|
|
|
if (tpcb->tp_no_disc_indications)
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_INDICATION]) {
|
|
|
|
tptraceTPCB(TPPTmisc, "doing sohasoutofband(so)", so, 0, 0, 0);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
sohasoutofband(so);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME : tp_getoptions()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
1996-02-14 01:07:57 +03:00
|
|
|
* tp.trans whenever we go into OPEN state
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* sets the proper flags and values in the tpcb, to control
|
|
|
|
* the appropriate actions for the given class, options,
|
|
|
|
* sequence space, etc, etc.
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
* RETURNS: Nada
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
* SIDE EFFECTS:
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tp_getoptions(tpcb)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct tp_pcb *tpcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_seqmask =
|
|
|
|
tpcb->tp_xtd_format ? TP_XTD_FMT_MASK : TP_NML_FMT_MASK;
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb->tp_seqbit =
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_xtd_format ? TP_XTD_FMT_BIT : TP_NML_FMT_BIT;
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb->tp_seqhalf = tpcb->tp_seqbit >> 1;
|
|
|
|
tpcb->tp_dt_ticks =
|
1994-05-13 10:08:03 +04:00
|
|
|
max(tpcb->tp_dt_ticks, (tpcb->tp_peer_acktime + 2));
|
|
|
|
tp_rsyset(tpcb);
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: tp_recycle_tsuffix()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
|
|
|
* Called when a ref is frozen.
|
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
1996-02-14 01:07:57 +03:00
|
|
|
* allows the suffix to be reused.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* RETURNS: zilch
|
|
|
|
*
|
|
|
|
* SIDE EFFECTS:
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
*/
|
|
|
|
void
|
1996-02-14 01:07:57 +03:00
|
|
|
tp_recycle_tsuffix(v)
|
|
|
|
void *v;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct tp_pcb *tpcb = v;
|
|
|
|
bzero((caddr_t) tpcb->tp_lsuffix, sizeof(tpcb->tp_lsuffix));
|
|
|
|
bzero((caddr_t) tpcb->tp_fsuffix, sizeof(tpcb->tp_fsuffix));
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb->tp_fsuffixlen = tpcb->tp_lsuffixlen = 0;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
(tpcb->tp_nlproto->nlp_recycle_suffix) (tpcb->tp_npcb);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: tp_quench()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp{af}_quench() when ICMP source quench or similar thing arrives.
|
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Drop the congestion window back to 1.
|
|
|
|
* Congestion window scheme:
|
|
|
|
* Initial value is 1. ("slow start" as Nagle, et. al. call it)
|
|
|
|
* For each good ack that arrives, the congestion window is increased
|
1996-02-14 01:07:57 +03:00
|
|
|
* by 1 (up to max size of logical infinity, which is to say,
|
1993-04-09 16:00:07 +04:00
|
|
|
* it doesn't wrap around).
|
|
|
|
* Source quench causes it to drop back to 1.
|
1996-02-14 01:07:57 +03:00
|
|
|
* tp_send() uses the smaller of (regular window, congestion window).
|
|
|
|
* One retransmission strategy option is to have any retransmission
|
1993-04-09 16:00:07 +04:00
|
|
|
* cause reset the congestion window back to 1.
|
|
|
|
*
|
|
|
|
* (cmd) is either PRC_QUENCH: source quench, or
|
|
|
|
* PRC_QUENCH2: dest. quench (dec bit)
|
|
|
|
*
|
|
|
|
* RETURNS:
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
* SIDE EFFECTS:
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
* NOTES:
|
|
|
|
*/
|
|
|
|
void
|
1996-02-14 01:07:57 +03:00
|
|
|
tp_quench(ipcb, cmd)
|
|
|
|
struct inpcb *ipcb;
|
|
|
|
int cmd;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct tp_pcb *tpcb = (struct tp_pcb *) ipcb;
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_QUENCH]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("tp_quench tpcb 0x%x ref 0x%x sufx 0x%x\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb, tpcb->tp_lref, *(u_short *) (tpcb->tp_lsuffix));
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("cong_win 0x%x decbit 0x%x \n",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_cong_win, tpcb->tp_decbit);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
switch (cmd) {
|
|
|
|
case PRC_QUENCH:
|
|
|
|
tpcb->tp_cong_win = tpcb->tp_l_tpdusize;
|
|
|
|
IncStat(ts_quench);
|
|
|
|
break;
|
|
|
|
case PRC_QUENCH2:
|
|
|
|
/* might as well quench source also */
|
|
|
|
tpcb->tp_cong_win = tpcb->tp_l_tpdusize;
|
|
|
|
tpcb->tp_decbit = TP_DECBIT_CLEAR_COUNT;
|
|
|
|
IncStat(ts_rcvdecbit);
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: tp_netcmd()
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* CALLED FROM:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* FUNCTION and ARGUMENTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES:
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
|
|
|
tp_netcmd(tpcb, cmd)
|
|
|
|
struct tp_pcb *tpcb;
|
|
|
|
int cmd;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
#ifdef TPCONS
|
1996-02-14 01:07:57 +03:00
|
|
|
struct isopcb *isop;
|
|
|
|
struct pklcd *lcp;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (tpcb->tp_netservice != ISO_CONS)
|
|
|
|
return;
|
1996-02-14 01:07:57 +03:00
|
|
|
isop = (struct isopcb *) tpcb->tp_npcb;
|
|
|
|
lcp = (struct pklcd *) isop->isop_chan;
|
1993-04-09 16:00:07 +04:00
|
|
|
switch (cmd) {
|
|
|
|
|
|
|
|
case CONN_CLOSE:
|
|
|
|
case CONN_REFUSE:
|
1994-05-13 10:08:03 +04:00
|
|
|
if (isop->isop_refcnt == 1) {
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* This is really superfluous, since it would happen
|
|
|
|
* anyway in iso_pcbdetach, although it is a courtesy
|
|
|
|
* to free up the x.25 channel before the refwait
|
|
|
|
* timer expires.
|
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
lcp->lcd_upper = 0;
|
|
|
|
lcp->lcd_upnext = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
pk_disconnect(lcp);
|
1994-05-13 10:08:03 +04:00
|
|
|
isop->isop_chan = 0;
|
|
|
|
isop->isop_refcnt = 0;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("tp_netcmd(0x%x, 0x%x) NOT IMPLEMENTED\n", tpcb, cmd);
|
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#else /* TPCONS */
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("tp_netcmd(): X25 NOT CONFIGURED!!\n");
|
|
|
|
#endif
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_ctloutput() and tp_emit()
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Convert a class mask to the highest numeric value it represents.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
tp_mask_to_num(x)
|
1996-02-14 01:07:57 +03:00
|
|
|
u_char x;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
register int j;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
for (j = 4; j >= 0; j--) {
|
|
|
|
if (x & (1 << j))
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
ASSERT((j == 4) || (j == 0)); /* for now */
|
|
|
|
if ((j != 4) && (j != 0)) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("ASSERTION ERROR: tp_mask_to_num: x 0x%x j %d\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
x, j);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_TPINPUT]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
tptrace(TPPTmisc, "tp_mask_to_num(x) returns j", x, j, 0, 0);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_TPINPUT]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("tp_mask_to_num(0x%x) returns 0x%x\n", x, j);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#if 0
|
|
|
|
static void
|
1993-04-09 16:00:07 +04:00
|
|
|
copyQOSparms(src, dst)
|
|
|
|
struct tp_conn_param *src, *dst;
|
|
|
|
{
|
|
|
|
/* copy all but the bits stuff at the end */
|
|
|
|
#define COPYSIZE (12 * sizeof(short))
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy((caddr_t) src, (caddr_t) dst, COPYSIZE);
|
1993-04-09 16:00:07 +04:00
|
|
|
dst->p_tpdusize = src->p_tpdusize;
|
|
|
|
dst->p_ack_strat = src->p_ack_strat;
|
|
|
|
dst->p_rx_strat = src->p_rx_strat;
|
|
|
|
#undef COPYSIZE
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif
|
|
|
|
|
1994-05-13 10:08:03 +04:00
|
|
|
/*
|
|
|
|
* Determine a reasonable value for maxseg size.
|
|
|
|
* If the route is known, check route for mtu.
|
|
|
|
* We also initialize the congestion/slow start
|
|
|
|
* window to be a single segment if the destination isn't local.
|
|
|
|
* While looking at the routing entry, we also initialize other path-dependent
|
|
|
|
* parameters from pre-set or cached values in the routing entry.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tp_mss(tpcb, nhdr_size)
|
|
|
|
register struct tp_pcb *tpcb;
|
1996-02-14 01:07:57 +03:00
|
|
|
int nhdr_size;
|
1994-05-13 10:08:03 +04:00
|
|
|
{
|
|
|
|
register struct rtentry *rt;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifnet *ifp;
|
|
|
|
register int rtt, mss;
|
|
|
|
u_long bufsize;
|
|
|
|
int i, ssthresh = 0, rt_mss;
|
|
|
|
struct socket *so;
|
1994-05-13 10:08:03 +04:00
|
|
|
|
|
|
|
if (tpcb->tp_ptpdusize)
|
|
|
|
mss = tpcb->tp_ptpdusize << 7;
|
|
|
|
else
|
|
|
|
mss = 1 << tpcb->tp_tpdusize;
|
|
|
|
so = tpcb->tp_sock;
|
|
|
|
if ((rt = *(tpcb->tp_routep)) == 0) {
|
|
|
|
bufsize = so->so_rcv.sb_hiwat;
|
|
|
|
goto punt_route;
|
|
|
|
}
|
|
|
|
ifp = rt->rt_ifp;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef RTV_MTU /* if route characteristics exist ... */
|
1994-05-13 10:08:03 +04:00
|
|
|
/*
|
|
|
|
* While we're here, check if there's an initial rtt
|
|
|
|
* or rttvar. Convert from the route-table units
|
|
|
|
* to hz ticks for the smoothed timers and slow-timeout units
|
|
|
|
* for other inital variables.
|
|
|
|
*/
|
|
|
|
if (tpcb->tp_rtt == 0 && (rtt = rt->rt_rmx.rmx_rtt)) {
|
|
|
|
tpcb->tp_rtt = rtt * hz / RTM_RTTUNIT;
|
|
|
|
if (rt->rt_rmx.rmx_rttvar)
|
|
|
|
tpcb->tp_rtv = rt->rt_rmx.rmx_rttvar
|
1996-02-14 01:07:57 +03:00
|
|
|
* hz / RTM_RTTUNIT;
|
1994-05-13 10:08:03 +04:00
|
|
|
else
|
|
|
|
tpcb->tp_rtv = tpcb->tp_rtt;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* if there's an mtu associated with the route, use it
|
|
|
|
*/
|
|
|
|
if (rt->rt_rmx.rmx_mtu)
|
|
|
|
rt_mss = rt->rt_rmx.rmx_mtu - nhdr_size;
|
|
|
|
else
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* RTV_MTU */
|
1994-05-13 10:08:03 +04:00
|
|
|
rt_mss = (ifp->if_mtu - nhdr_size);
|
1996-02-14 01:07:57 +03:00
|
|
|
if (tpcb->tp_ptpdusize == 0 || /* assume application doesn't care */
|
|
|
|
mss > rt_mss /* network won't support what was asked for */ )
|
1994-05-13 10:08:03 +04:00
|
|
|
mss = rt_mss;
|
|
|
|
/* can propose mtu which are multiples of 128 */
|
|
|
|
mss &= ~0x7f;
|
|
|
|
/*
|
|
|
|
* If there's a pipesize, change the socket buffer
|
|
|
|
* to that size.
|
|
|
|
*/
|
|
|
|
#ifdef RTV_SPIPE
|
|
|
|
if ((bufsize = rt->rt_rmx.rmx_sendpipe) > 0) {
|
|
|
|
#endif
|
|
|
|
bufsize = min(bufsize, so->so_snd.sb_hiwat);
|
|
|
|
(void) sbreserve(&so->so_snd, bufsize);
|
|
|
|
}
|
|
|
|
#ifdef RTV_SPIPE
|
|
|
|
if ((bufsize = rt->rt_rmx.rmx_recvpipe) > 0) {
|
|
|
|
#endif
|
|
|
|
bufsize = min(bufsize, so->so_rcv.sb_hiwat);
|
|
|
|
(void) sbreserve(&so->so_rcv, bufsize);
|
|
|
|
} else
|
|
|
|
bufsize = so->so_rcv.sb_hiwat;
|
|
|
|
#ifdef RTV_SSTHRESH
|
|
|
|
/*
|
|
|
|
* There's some sort of gateway or interface
|
|
|
|
* buffer limit on the path. Use this to set
|
|
|
|
* the slow start threshhold, but set the
|
|
|
|
* threshold to no less than 2*mss.
|
|
|
|
*/
|
|
|
|
ssthresh = rt->rt_rmx.rmx_ssthresh;
|
|
|
|
punt_route:
|
|
|
|
/*
|
|
|
|
* The current mss is initialized to the default value.
|
|
|
|
* If we compute a smaller value, reduce the current mss.
|
|
|
|
* If we compute a larger value, return it for use in sending
|
|
|
|
* a max seg size option.
|
|
|
|
* If we received an offer, don't exceed it.
|
|
|
|
* However, do not accept offers under 128 bytes.
|
|
|
|
*/
|
|
|
|
if (tpcb->tp_l_tpdusize)
|
|
|
|
mss = min(mss, tpcb->tp_l_tpdusize);
|
|
|
|
/*
|
|
|
|
* We want a minimum recv window of 4 packets to
|
|
|
|
* signal packet loss by duplicate acks.
|
|
|
|
*/
|
|
|
|
mss = min(mss, bufsize >> 2) & ~0x7f;
|
1996-02-14 01:07:57 +03:00
|
|
|
mss = max(mss, 128); /* sanity */
|
1994-05-13 10:08:03 +04:00
|
|
|
tpcb->tp_cong_win =
|
|
|
|
(rt == 0 || (rt->rt_flags & RTF_GATEWAY)) ? mss : bufsize;
|
|
|
|
tpcb->tp_l_tpdusize = mss;
|
|
|
|
tp_rsyset(tpcb);
|
|
|
|
tpcb->tp_ssthresh = max(2 * mss, ssthresh);
|
|
|
|
/* Calculate log2 of mss */
|
|
|
|
for (i = TP_MIN_TPDUSIZE + 1; i <= TP_MAX_TPDUSIZE; i++)
|
|
|
|
if ((1 << i) > mss)
|
|
|
|
break;
|
|
|
|
i--;
|
|
|
|
tpcb->tp_tpdusize = i;
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* RTV_MTU */
|
1994-05-13 10:08:03 +04:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_usrreq on PRU_CONNECT and tp_input on receipt of CR
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
* FUNCTION and ARGUMENTS:
|
1994-05-13 10:08:03 +04:00
|
|
|
* -- An mbuf containing the peer's network address.
|
|
|
|
* -- Our control block, which will be modified
|
|
|
|
* -- In the case of cons, a control block for that layer.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
* RETURNS:
|
1996-02-14 01:07:57 +03:00
|
|
|
* errno value :
|
1993-04-09 16:00:07 +04:00
|
|
|
* EAFNOSUPPORT if can't find an nl_protosw for x.25 (really could panic)
|
|
|
|
* ECONNREFUSED if trying to run TP0 with non-type 37 address
|
|
|
|
* possibly other E* returned from cons_netcmd()
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
|
|
|
* SIDE EFFECTS:
|
|
|
|
* Determines recommended tpdusize, buffering and intial delays
|
|
|
|
* based on information cached on the route.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
int
|
1996-02-14 01:07:57 +03:00
|
|
|
tp_route_to(m, tpcb, channel)
|
|
|
|
struct mbuf *m;
|
|
|
|
register struct tp_pcb *tpcb;
|
|
|
|
caddr_t channel;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct sockaddr_iso *siso; /* NOTE: this may be a
|
|
|
|
* sockaddr_in */
|
|
|
|
int error = 0, save_netservice = tpcb->tp_netservice;
|
1994-05-13 10:08:03 +04:00
|
|
|
register struct rtentry *rt = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
int nhdr_size;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
siso = mtod(m, struct sockaddr_iso *);
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_CONN]) {
|
|
|
|
tptraceTPCB(TPPTmisc,
|
|
|
|
"route_to: so afi netservice class",
|
|
|
|
tpcb->tp_sock, siso->siso_addr.isoa_genaddr[0], tpcb->tp_netservice,
|
|
|
|
tpcb->tp_class);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
|
|
|
printf("tp_route_to( m x%x, channel 0x%x, tpcb 0x%x netserv 0x%x)\n",
|
|
|
|
m, channel, tpcb, tpcb->tp_netservice);
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("m->mlen x%x, m->m_data:\n", m->m_len);
|
|
|
|
dump_buf(mtod(m, caddr_t), m->m_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
if (channel) {
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef TPCONS
|
1996-02-14 01:07:57 +03:00
|
|
|
struct pklcd *lcp = (struct pklcd *) channel;
|
|
|
|
struct isopcb *isop = (struct isopcb *) lcp->lcd_upnext,
|
|
|
|
*isop_new = (struct isopcb *) tpcb->tp_npcb;
|
|
|
|
/*
|
|
|
|
* The next 2 lines believe that you haven't set any network
|
|
|
|
* level options or done a pcbconnect and XXXXXXX'edly apply
|
|
|
|
* to both inpcb's and isopcb's
|
|
|
|
*/
|
1993-04-09 16:00:07 +04:00
|
|
|
remque(isop_new);
|
|
|
|
free(isop_new, M_PCB);
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_npcb = (caddr_t) isop;
|
1994-05-13 10:08:03 +04:00
|
|
|
tpcb->tp_netservice = ISO_CONS;
|
|
|
|
tpcb->tp_nlproto = nl_protosw + ISO_CONS;
|
|
|
|
if (isop->isop_refcnt++ == 0) {
|
1996-02-14 01:07:57 +03:00
|
|
|
iso_putsufx(isop, tpcb->tp_lsuffix,
|
|
|
|
tpcb->tp_lsuffixlen, TP_LOCAL);
|
1994-05-13 10:08:03 +04:00
|
|
|
isop->isop_socket = tpcb->tp_sock;
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
} else {
|
|
|
|
switch (siso->siso_family) {
|
1993-04-09 16:00:07 +04:00
|
|
|
default:
|
1994-05-13 10:08:03 +04:00
|
|
|
error = EAFNOSUPPORT;
|
|
|
|
goto done;
|
|
|
|
#ifdef ISO
|
|
|
|
case AF_ISO:
|
1996-02-14 01:07:57 +03:00
|
|
|
{
|
|
|
|
struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb;
|
|
|
|
int flags = tpcb->tp_sock->so_options & SO_DONTROUTE;
|
|
|
|
tpcb->tp_netservice = ISO_CLNS;
|
|
|
|
if (clnp_route(&siso->siso_addr, &isop->isop_route,
|
|
|
|
flags, NULL, NULL) == 0) {
|
|
|
|
rt = isop->isop_route.ro_rt;
|
|
|
|
if (rt && rt->rt_flags & RTF_PROTO1)
|
|
|
|
tpcb->tp_netservice = ISO_CONS;
|
|
|
|
}
|
|
|
|
} break;
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
tpcb->tp_netservice = IN_CLNS;
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
if (tpcb->tp_nlproto->nlp_afamily != siso->siso_family) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
|
|
|
printf("tp_route_to( CHANGING nlproto old 0x%x new 0x%x)\n",
|
|
|
|
save_netservice, tpcb->tp_netservice);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if ((error = tp_set_npcb(tpcb)) != 0)
|
1994-05-13 10:08:03 +04:00
|
|
|
goto done;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1994-05-13 10:08:03 +04:00
|
|
|
printf("tp_route_to calling nlp_pcbconn, netserv %d\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_netservice);
|
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
tpcb->tp_nlproto = nl_protosw + tpcb->tp_netservice;
|
1996-02-14 01:07:57 +03:00
|
|
|
error = (*tpcb->tp_nlproto->nlp_pcbconn) (tpcb->tp_npcb, m);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
if (error)
|
1993-04-09 16:00:07 +04:00
|
|
|
goto done;
|
1996-02-14 01:07:57 +03:00
|
|
|
/* only gets common info */
|
|
|
|
nhdr_size = (*tpcb->tp_nlproto->nlp_mtu)(tpcb);
|
1994-05-13 10:08:03 +04:00
|
|
|
tp_mss(tpcb, nhdr_size);
|
1993-04-09 16:00:07 +04:00
|
|
|
done:
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf("tp_route_to returns 0x%x\n", error);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_CONN]) {
|
|
|
|
tptraceTPCB(TPPTmisc, "route_to: returns: error netserv class", error,
|
|
|
|
tpcb->tp_netservice, tpcb->tp_class, 0);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#if 0
|
1994-05-13 10:08:03 +04:00
|
|
|
static
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
|
|
|
pk_flowcontrol(lcp, foo, bar)
|
|
|
|
struct pklcd *lcp;
|
|
|
|
int foo, bar;
|
|
|
|
{
|
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/* class zero version */
|
|
|
|
void
|
1996-02-14 01:07:57 +03:00
|
|
|
tp0_stash(tpcb, e)
|
|
|
|
register struct tp_pcb *tpcb;
|
|
|
|
register struct tp_event *e;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
#define E e->TPDU_ATTR(DT)
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
register struct sockbuf *sb = &tpcb->tp_sock->so_rcv;
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TP_PERF_MEAS
|
|
|
|
if (DOPERF(tpcb)) {
|
1993-04-09 16:00:07 +04:00
|
|
|
PStat(tpcb, Nb_from_ll) += E.e_datalen;
|
1996-02-14 01:07:57 +03:00
|
|
|
tpmeas(tpcb->tp_lref, TPtime_from_ll, &e->e_time,
|
|
|
|
E.e_seq, PStat(tpcb, Nb_from_ll), E.e_datalen);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_STASH]) {
|
|
|
|
printf("stash EQ: seq 0x%x datalen 0x%x eot 0x%x",
|
|
|
|
E.e_seq, E.e_datalen, E.e_eot);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_STASH]) {
|
|
|
|
tptraceTPCB(TPPTmisc, "stash EQ: seq len eot",
|
|
|
|
E.e_seq, E.e_datalen, E.e_eot, 0);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
if (E.e_eot) {
|
1993-04-09 16:00:07 +04:00
|
|
|
register struct mbuf *n = E.e_data;
|
|
|
|
n->m_flags |= M_EOR;
|
1996-02-14 01:07:57 +03:00
|
|
|
n->m_act = NULL; /* set on tp_input */
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
sbappend(sb, E.e_data);
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_STASH]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(sb->sb_mb, "stash 0: so_rcv after appending");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (tpcb->tp_netservice != ISO_CONS)
|
|
|
|
printf("tp0_stash: tp running over something wierd\n");
|
|
|
|
else {
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct pklcd *lcp = (struct pklcd *) isop->isop_chan;
|
1993-04-09 16:00:07 +04:00
|
|
|
pk_flowcontrol(lcp, sbspace(sb) <= 0, 1);
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
tp0_openflow(tpcb)
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct tp_pcb *tpcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (tpcb->tp_netservice != ISO_CONS)
|
|
|
|
printf("tp0_openflow: tp running over something wierd\n");
|
|
|
|
else {
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct pklcd *lcp = (struct pklcd *) isop->isop_chan;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (lcp->lcd_rxrnr_condition)
|
|
|
|
pk_flowcontrol(lcp, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TP_PERF_MEAS
|
|
|
|
/*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_ctloutput() when the user sets TPOPT_PERF_MEAS on
|
1996-02-14 01:07:57 +03:00
|
|
|
* and tp_newsocket() when a new connection is made from
|
1993-04-09 16:00:07 +04:00
|
|
|
* a listening socket with tp_perf_on == true.
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* (tpcb) is the usual; this procedure gets a clear cluster mbuf for
|
|
|
|
* a tp_pmeas structure, and makes tpcb->tp_p_meas point to it.
|
|
|
|
* RETURN VALUE:
|
|
|
|
* ENOBUFS if it cannot get a cluster mbuf.
|
|
|
|
*/
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
tp_setup_perf(tpcb)
|
|
|
|
register struct tp_pcb *tpcb;
|
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
if (tpcb->tp_p_meas == 0) {
|
1995-08-16 04:38:53 +04:00
|
|
|
tpcb->tp_p_meas = malloc(sizeof(struct tp_pmeas), M_PCB, M_WAITOK);
|
|
|
|
bzero((caddr_t)tpcb->tp_p_meas, sizeof(struct tp_pmeas));
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_PERF_MEAS]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf(
|
1996-02-14 01:07:57 +03:00
|
|
|
"tpcb 0x%x so 0x%x ref 0x%x tp_p_meas 0x%x tp_perf_on 0x%x\n",
|
|
|
|
tpcb, tpcb->tp_sock, tpcb->tp_lref,
|
|
|
|
tpcb->tp_p_meas, tpcb->tp_perf_on);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb->tp_perf_on = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* TP_PERF_MEAS */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
#ifdef ARGO_DEBUG
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
|
|
|
dump_addr(addr)
|
1993-04-09 16:00:07 +04:00
|
|
|
register struct sockaddr *addr;
|
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
switch (addr->sa_family) {
|
|
|
|
case AF_INET:
|
|
|
|
dump_inaddr(satosin(addr));
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef ISO
|
1996-02-14 01:07:57 +03:00
|
|
|
case AF_ISO:
|
|
|
|
dump_isoaddr(satosiso(addr));
|
|
|
|
break;
|
|
|
|
#endif /* ISO */
|
|
|
|
default:
|
|
|
|
printf("BAD AF: 0x%x\n", addr->sa_family);
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_COLUMNS 8
|
|
|
|
/*
|
|
|
|
* Dump the buffer to the screen in a readable format. Format is:
|
|
|
|
*
|
|
|
|
* hex/dec where hex is the hex format, dec is the decimal format.
|
|
|
|
* columns of hex/dec numbers will be printed, followed by the
|
|
|
|
* character representations (if printable).
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
1993-04-09 16:00:07 +04:00
|
|
|
Dump_buf(buf, len)
|
1996-02-14 01:07:57 +03:00
|
|
|
caddr_t buf;
|
|
|
|
int len;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
int i, j;
|
1993-04-09 16:00:07 +04:00
|
|
|
#define Buf ((u_char *)buf)
|
|
|
|
printf("Dump buf 0x%x len 0x%x\n", buf, len);
|
|
|
|
for (i = 0; i < len; i += MAX_COLUMNS) {
|
|
|
|
printf("+%d:\t", i);
|
|
|
|
for (j = 0; j < MAX_COLUMNS; j++) {
|
|
|
|
if (i + j < len) {
|
1996-02-14 01:07:57 +03:00
|
|
|
printf("%x/%d\t", Buf[i + j], Buf[i + j]);
|
1993-04-09 16:00:07 +04:00
|
|
|
} else {
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < MAX_COLUMNS; j++) {
|
|
|
|
if (i + j < len) {
|
1996-02-14 01:07:57 +03:00
|
|
|
if (((Buf[i + j]) > 31) && ((Buf[i + j]) < 128))
|
|
|
|
printf("%c", Buf[i + j]);
|
1993-04-09 16:00:07 +04:00
|
|
|
else
|
|
|
|
printf(".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif /* ARGO_DEBUG */
|