+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ * @(#)tp_subr2.c 7.14 (Berkeley) %G%
+ */
+
/***********************************************************
Copyright IBM Corporation 1987
*
* $Header: tp_subr2.c,v 5.5 88/11/18 17:28:55 nhall Exp $
* $Source: /usr/argo/sys/netiso/RCS/tp_subr2.c,v $
- * @(#)tp_subr2.c 7.7 (Berkeley) %G%
*
* 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.
+ * 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.
*/
-#ifndef lint
-static char *rcsid = "$Header: tp_subr2.c,v 5.5 88/11/18 17:28:55 nhall Exp $";
-#endif lint
-
/* this def'n is to cause the expansion of this macro in the
* routine tp_local_credit :
*/
#define LOCAL_CREDIT_EXPAND
#include "param.h"
+#include "systm.h"
#include "mbuf.h"
#include "socket.h"
#include "socketvar.h"
#include "cons.h"
#include "../net/if.h"
+#include "../net/if_types.h"
#ifdef TRUE
#undef FALSE
#undef TRUE
tpcb->tp_seqhalf = tpcb->tp_seqbit >> 1;
tpcb->tp_dt_ticks =
MAX(tpcb->tp_dt_ticks, (tpcb->tp_peer_acktime + 2));
-
+ (void) tp_rsyset(tpcb);
+
}
/*
ENDDEBUG
switch(cmd) {
case PRC_QUENCH:
- tpcb->tp_cong_win = 1;
+ tpcb->tp_cong_win = tpcb->tp_l_tpdusize;
IncStat(ts_quench);
break;
case PRC_QUENCH2:
- tpcb->tp_cong_win = 1; /* might as well quench source also */
+ tpcb->tp_cong_win = tpcb->tp_l_tpdusize; /* might as well quench source also */
tpcb->tp_decbit = TP_DECBIT_CLEAR_COUNT;
IncStat(ts_rcvdecbit);
break;
case CONN_CLOSE:
case CONN_REFUSE:
- if (isop->isop_refcnt == 1)
+ if (isop->isop_refcnt == 1) {
+ /* 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. */
+ lcp->lcd_upper = 0;
+ lcp->lcd_upnext = 0;
pk_disconnect(lcp);
- isop->isop_chan = 0;
- isop->isop_refcnt = 0;
+ isop->isop_chan = 0;
+ isop->isop_refcnt = 0;
+ }
break;
default:
{
register struct sockaddr_iso *siso; /* NOTE: this may be a sockaddr_in */
extern struct tp_conn_param tp_conn_param[];
- struct pklcd *lcp = (struct pklcd *)channel;
- int error = 0;
+ int error = 0, save_netservice = tpcb->tp_netservice;
+ register struct rtentry *rt = 0;
siso = mtod(m, struct sockaddr_iso *);
IFTRACE(D_CONN)
printf("m->mlen x%x, m->m_data:\n", m->m_len);
dump_buf(mtod(m, caddr_t), m->m_len);
ENDDEBUG
- if (siso->siso_family != tpcb->tp_domain) {
- error = EAFNOSUPPORT;
- goto done;
- }
- IFDEBUG(D_CONN)
- printf("tp_route_to calling nlp_pcbconn, netserv %d\n",
- tpcb->tp_netservice);
- ENDDEBUG
+ if (channel) {
#ifdef TPCONS
- if (lcp) {
+ struct pklcd *lcp = (struct pklcd *)channel;
struct isopcb *isop = (struct isopcb *)lcp->lcd_upnext,
- *isop_new = (struct isopcb *)tpcb->tp_sock->so_pcb;
+ *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 */
remque(isop_new);
free(isop_new, M_PCB);
- tpcb->tp_sock->so_pcb = (caddr_t)isop;
- if (isop->isop_refcnt == 0) {
- extern struct isopcb tp_isopcb;
- remque(isop);
- insque(isop, &tp_isopcb);
- isop->isop_head = &tp_isopcb;
+ tpcb->tp_npcb = (caddr_t)isop;
+ tpcb->tp_netservice = ISO_CONS;
+ tpcb->tp_nlproto = nl_protosw + ISO_CONS;
+ isop->isop_socket = tpcb->tp_sock;
+ if (isop->isop_refcnt == 0)
iso_putsufx(isop, tpcb->tp_lsuffix, tpcb->tp_lsuffixlen, TP_LOCAL);
- }
- /* else there are already connections sharing this */
+ else
+ /* there are already connections sharing this */;
isop->isop_refcnt++;
- } else
#endif
- error = (tpcb->tp_nlproto->nlp_pcbconn)(tpcb->tp_sock->so_pcb, m);
+ } else {
+ switch (siso->siso_family) {
+ default:
+ error = EAFNOSUPPORT;
+ goto done;
+#ifdef ISO
+ case AF_ISO:
+ tpcb->tp_netservice = ISO_CLNS;
+ if (rt = rtalloc1((struct sockaddr *)siso, 0)) {
+ rt->rt_refcnt--;
+ if (rt->rt_flags & RTF_PROTO1)
+ tpcb->tp_netservice = ISO_CONS;
+ }
+ break;
+#endif
+#ifdef INET
+ case AF_INET:
+ tpcb->tp_netservice = IN_CLNS;
+ }
+#endif
+ if (tpcb->tp_nlproto->nlp_afamily != siso->siso_family) {
+ IFDEBUG(D_CONN)
+ printf("tp_route_to( CHANGING nlproto old 0x%x new 0x%x)\n",
+ save_netservice, tpcb->tp_netservice);
+ ENDDEBUG
+ if (error = tp_set_npcb(tpcb))
+ goto done;
+ }
+ IFDEBUG(D_CONN)
+ printf("tp_route_to calling nlp_pcbconn, netserv %d\n",
+ tpcb->tp_netservice);
+ ENDDEBUG
+ tpcb->tp_nlproto = nl_protosw + tpcb->tp_netservice;
+ error = (tpcb->tp_nlproto->nlp_pcbconn)(tpcb->tp_npcb, m);
+ }
if( error )
goto done;
{
- register int save_netservice = tpcb->tp_netservice;
-
switch(tpcb->tp_netservice) {
case ISO_COSNS:
case ISO_CLNS:
* can get long enough timers. sigh.
if( siso->siso_addr.osinet_idi[1] == (u_char)IDI_OSINET )
*/
-#define IDI_OSINET 0x0004 /* bcd of "0004" */
- if( siso->siso_addr.isoa_genaddr[2] == (char)IDI_OSINET ) {
+ if (rt && rt->rt_ifp && rt->rt_ifp->if_type == IFT_X25) {
if( tpcb->tp_dont_change_params == 0) {
copyQOSparms( &tp_conn_param[ISO_COSNS],
&tpcb->_tp_param);
case IN_CLNS:
if (iso_localifa(siso))
tpcb->tp_flags |= TPF_PEER_ON_SAMENET;
- if( (tpcb->tp_class & TP_CLASS_4)==0 ) {
+ if((tpcb->tp_class & TP_CLASS_4) == 0) {
error = EPROTOTYPE;
break;
}
}
tpcb->tp_rx_strat = TPRX_USE_CW;
- if( (tpcb->tp_nlproto != &nl_protosw[ISO_CONS]) ) {
- IFDEBUG(D_CONN)
- printf(
- "tp_route_to( CHANGING nlproto old 0x%x new 0x%x)\n",
- tpcb->tp_nlproto , &nl_protosw[ISO_CONS]);
- ENDDEBUG
- tpcb->tp_nlproto = &nl_protosw[ISO_CONS];
- }
/* class 4 doesn't need to open a vc now - may use one already
* opened or may open one only when it sends a pkt.
*/
error = EPROTOTYPE;
}
- ASSERT( save_netservice == tpcb->tp_netservice);
}
if (error) {
tp_netcmd( tpcb, CONN_CLOSE);
int len;
{
int i,j;
-
+#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) {
- printf("%x/%d\t", buf[i+j]&0xff, buf[i+j]);
+ printf("%x/%d\t", Buf[i+j], Buf[i+j]);
} else {
printf(" ");
}
for (j = 0; j < MAX_COLUMNS; j++) {
if (i + j < len) {
- if (((buf[i+j]) > 31) && ((buf[i+j]) < 128))
- printf("%c", buf[i+j]&0xff);
+ if (((Buf[i+j]) > 31) && ((Buf[i+j]) < 128))
+ printf("%c", Buf[i+j]);
else
printf(".");
}