* Copyright (c) 1991 The Regents of the University of California.
* %sccs.include.redist.c%
* @(#)tp_cons.c 7.12 (Berkeley) %G%
/***********************************************************
Copyright IBM Corporation 1987
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of IBM not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
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
******************************************************************/
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
* $Header: tp_cons.c,v 5.6 88/11/18 17:27:13 nhall Exp $
* $Source: /usr/argo/sys/netiso/RCS/tp_cons.c,v $
* Here is where you find the iso- and cons-dependent code. We've tried
* keep all net-level and (primarily) address-family-dependent stuff
* out of the tp source, and everthing here is reached indirectly
* through a switch table (struct nl_protosw *) tpcb->tp_nlproto
* tpcons_input: pullup and call tp_input w/ correct arguments
* tpcons_output: package a pkt for cons given an isopcb & some data
* cons_chan_to_tpcb: find a tpcb based on the channel #
#include <netiso/tp_param.h>
#include <netiso/argo_debug.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/iso_errno.h>
#include <netiso/iso_pcb.h>
#include <netiso/tp_seq.h>
#include <netccitt/x25.h>
#include <netccitt/pk_var.h>
#include <netiso/if_cons.c>
* tp_route_to() for PRU_CONNECT
* FUNCTION, ARGUMENTS, SIDE EFFECTS and RETURN VALUE:
* version of the previous procedure for X.25
tpcons_pcbconnect(isop
, nam
)
register struct mbuf
*nam
;
if (error
= iso_pcbconnect(isop
, nam
))
if ((isop
->isop_chan
= (caddr_t
) pk_attach((struct socket
*)0)) == 0) {
printf("tpcons_pcbconnect: no pklcd; returns 0x%x\n", error
);
if (error
= cons_connect(isop
)) { /* if it doesn't work */
/* oh, dear, throw packet away */
pk_disconnect((struct pklcd
*)isop
->isop_chan
);
* FUNCTION and ARGUMENTS:
* THIS MAYBE BELONGS IN SOME OTHER PLACE??? but i think not -
tpcons_ctlinput(cmd
, siso
, isop
)
struct sockaddr_iso
*siso
;
register struct tp_pcb
*tpcb
= 0;
tpcb
= (struct tp_pcb
*)isop
->isop_socket
->so_pcb
;
if (tpcb
->tp_class
== TP_CLASS_0
) {
/* only if class is exactly class zero, not
* still in class negotiation
register SeqNum seq
= SEQ_ADD(tpcb
, tpcb
->tp_snduna
, 1);
tptrace(TPPTmisc
, "FAKE ACK seq cdt 1",
printf("FAKE ACK seq 0x%x cdt 1\n", seq
);
E
.ATTR(AK_TPDU
).e_cdt
= 1;
E
.ATTR(AK_TPDU
).e_seq
= seq
;
E
.ATTR(AK_TPDU
).e_subseq
= 0;
E
.ATTR(AK_TPDU
).e_fcc_present
= 0;
error
= DoEvent(AK_TPDU
);
tpcb
->tp_sock
->so_error
= error
;
if (tpcb
&& tpcb
->tp_class
== TP_CLASS_0
) {
} /* else drop through */
(void) tpclnp_ctlinput(cmd
, siso
);
* FUNCTION and ARGUMENTS:
* Take a packet (m) from cons, pullup m as required by tp,
* ignore the socket argument, and call tp_input.
tpcons_input(m
, faddr
, laddr
, channel
)
struct sockaddr_iso
*faddr
, *laddr
;
m
= (struct mbuf
*)tp_inputprep(m
);
printf("tpcons_input before tp_input(m 0x%x)\n", m
);
dump_buf( m
, 12+ m
->m_len
);
tp_input(m
, faddr
, laddr
, channel
, tpcons_output
, 0);
* FUNCTION and ARGUMENTS:
* Take a packet(m0) from tp and package it so that cons will accept it.
* This means filling in a few of the fields.
* inp is the isopcb structure; datalen is the length of the data in the
* whatever (E*) is returned form the net layer output routine.
tpcons_output(isop
, m0
, datalen
, nochksum
)
register struct mbuf
*m
= m0
;
"tpcons_output(isop 0x%x, m 0x%x, len 0x%x socket 0x%x\n",
isop
, m0
, datalen
, isop
->isop_socket
);
if ((m
->m_flags
& M_PKTHDR
) == 0) {
MGETHDR(m
, M_DONTWAIT
, MT_DATA
);
m
->m_pkthdr
.len
= datalen
;
if (isop
->isop_chan
== 0) {
/* got a restart maybe? */
if ((isop
->isop_chan
= (caddr_t
) pk_attach((struct socket
*)0)) == 0) {
printf("tpcons_output: no pklcd\n");
if (error
= cons_connect(isop
)) {
pk_disconnect((struct pklcd
*)isop
->isop_chan
);
printf("tpcons_output: can't reconnect\n");
error
= pk_send(isop
->isop_chan
, m
);
* FUNCTION and ARGUMENTS:
* Take a packet(m0) from tp and package it so that cons will accept it.
* chan is the cons channel to use; datalen is the length of the data in the
* whatever (E*) is returned form the net layer output routine.
tpcons_dg_output(chan
, m0
, datalen
)
return tpcons_output(((struct pklcd
*)chan
)->lcd_upnext
, m0
, datalen
, 0);