2008-04-28 17:24:38 +04:00
|
|
|
/* $NetBSD: tp_usrreq.c,v 1.36 2008/04/28 13:24:38 ad 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.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-04-09 16:00:07 +04:00
|
|
|
* 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_usrreq.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
|
|
|
/*
|
1993-04-09 16:00:07 +04:00
|
|
|
* tp_usrreq(), the fellow that gets called from most of the socket code.
|
1996-02-14 01:07:57 +03:00
|
|
|
* Pretty straighforward. THe only really awful stuff here is the OOB
|
|
|
|
* processing, which is done wholly here. tp_rcvoob() and tp_sendoob() are
|
|
|
|
* contained here and called by tp_usrreq().
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 03:56:55 +03:00
|
|
|
#include <sys/cdefs.h>
|
2008-04-28 17:24:38 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tp_usrreq.c,v 1.36 2008/04/28 13:24:38 ad Exp $");
|
2001-11-13 03:56:55 +03:00
|
|
|
|
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>
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <sys/proc.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/tp_param.h>
|
2004-04-20 06:13:26 +04:00
|
|
|
#include <netiso/tp_var.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/tp_timer.h>
|
|
|
|
#include <netiso/tp_seq.h>
|
2004-04-20 06:13:26 +04:00
|
|
|
#include <netiso/tp_stat.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/tp_ip.h>
|
|
|
|
#include <netiso/tp_pcb.h>
|
|
|
|
#include <netiso/argo_debug.h>
|
|
|
|
#include <netiso/tp_trace.h>
|
|
|
|
#include <netiso/tp_meas.h>
|
|
|
|
#include <netiso/iso.h>
|
|
|
|
#include <netiso/iso_errno.h>
|
2007-11-10 00:00:05 +03:00
|
|
|
#include <netiso/iso_var.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
int TNew;
|
|
|
|
int TPNagle1, TPNagle2;
|
|
|
|
struct tp_pcb *tp_listeners, *tp_intercepts;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
/*
|
|
|
|
* CALLED FROM:
|
|
|
|
* anywhere you want to debug...
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* print (str) followed by the control info in the mbufs of an mbuf chain (n)
|
|
|
|
*/
|
|
|
|
void
|
2005-05-30 01:27:45 +04:00
|
|
|
dump_mbuf(struct mbuf *n, const char *str)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct mbuf *nextrecord;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("dump %s\n", str);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
2003-08-11 19:17:29 +04:00
|
|
|
if (n == NULL) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("EMPTY:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (n) {
|
2001-10-19 00:17:24 +04:00
|
|
|
nextrecord = n->m_nextpkt;
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("RECORD:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
while (n) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("%p : Len %x Data %p A %p Nx %p Tp %x\n",
|
2001-10-19 00:17:24 +04:00
|
|
|
n, n->m_len, n->m_data, n->m_nextpkt, n->m_next, n->m_type);
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef notdef
|
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
char *p = mtod(n, char *);
|
|
|
|
int i;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("data: ");
|
1993-04-09 16:00:07 +04:00
|
|
|
for (i = 0; i < n->m_len; i++) {
|
1996-02-14 01:07:57 +03:00
|
|
|
if (i % 8 == 0)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\n");
|
|
|
|
printf("0x%x ", *(p + i));
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* notdef */
|
1993-04-09 16:00:07 +04:00
|
|
|
if (n->m_next == n) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("LOOP!\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
n = n->m_next;
|
|
|
|
}
|
|
|
|
n = nextrecord;
|
|
|
|
}
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* ARGO_DEBUG */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_usrreq(), PRU_RCVOOB
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Copy data from the expedited data socket buffer into
|
|
|
|
* the pre-allocated mbuf m.
|
|
|
|
* There is an isomorphism between XPD TPDUs and expedited data TSDUs.
|
|
|
|
* XPD tpdus are limited to 16 bytes of data so they fit in one mbuf.
|
|
|
|
* RETURN VALUE:
|
|
|
|
* EINVAL if debugging is on and a disaster has occurred
|
|
|
|
* ENOTCONN if the socket isn't connected
|
|
|
|
* EWOULDBLOCK if the socket is in non-blocking mode and there's no
|
|
|
|
* xpd data in the buffer
|
|
|
|
* E* whatever is returned from the fsm.
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
tp_rcvoob(struct tp_pcb *tpcb, struct socket *so, struct mbuf *m,
|
2006-11-16 04:32:37 +03:00
|
|
|
int *outflags, int inflags)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct mbuf *n;
|
|
|
|
struct sockbuf *sb = &so->so_rcv;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct tp_event E;
|
1996-02-14 01:07:57 +03:00
|
|
|
int error = 0;
|
2000-03-30 16:51:13 +04:00
|
|
|
struct mbuf **nn;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_XPD]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("PRU_RCVOOB, sostate 0x%x\n", so->so_state);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/* if you use soreceive */
|
2003-08-11 19:17:29 +04:00
|
|
|
if (m == NULL)
|
1993-04-09 16:00:07 +04:00
|
|
|
return ENOBUFS;
|
|
|
|
|
|
|
|
restart:
|
|
|
|
if ((((so->so_state & SS_ISCONNECTED) == 0)
|
1996-02-14 01:07:57 +03:00
|
|
|
|| (so->so_state & SS_ISDISCONNECTING) != 0) &&
|
|
|
|
(so->so_proto->pr_flags & PR_CONNREQUIRED)) {
|
|
|
|
return ENOTCONN;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* Take the first mbuf off the chain. Each XPD TPDU gives you a
|
|
|
|
* complete TSDU so the chains don't get coalesced, but one TSDU may
|
|
|
|
* span several mbufs. Nevertheless, since n should have a most 16
|
|
|
|
* bytes, it will fit into m. (size was checked in tp_input() )
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Code for excision of OOB data should be added to
|
|
|
|
* uipc_socket2.c (like sbappend).
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1994-05-13 10:08:03 +04:00
|
|
|
sblock(sb, M_WAITOK);
|
2001-10-19 00:17:24 +04:00
|
|
|
for (nn = &sb->sb_mb; (n = *nn) != NULL; nn = &n->m_nextpkt)
|
1993-04-09 16:00:07 +04:00
|
|
|
if (n->m_type == MT_OOBDATA)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (n == 0) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_XPD]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("RCVOOB: empty queue!\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
sbunlock(sb);
|
2008-02-07 00:57:53 +03:00
|
|
|
if (so->so_nbio) {
|
1996-02-14 01:07:57 +03:00
|
|
|
return EWOULDBLOCK;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
sbwait(sb);
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
m->m_len = 0;
|
|
|
|
|
|
|
|
/* Assuming at most one xpd tpdu is in the buffer at once */
|
2003-08-11 19:17:29 +04:00
|
|
|
while (n != NULL) {
|
1993-04-09 16:00:07 +04:00
|
|
|
m->m_len += n->m_len;
|
2007-03-04 08:59:00 +03:00
|
|
|
bcopy(mtod(n, void *), mtod(m, void *), (unsigned) n->m_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
m->m_data += n->m_len; /* so mtod() in bcopy() above gives
|
|
|
|
* right addr */
|
1993-04-09 16:00:07 +04:00
|
|
|
n = n->m_next;
|
|
|
|
}
|
|
|
|
m->m_data = m->m_dat;
|
|
|
|
m->m_flags |= M_EOR;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_XPD]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("tp_rcvoob: xpdlen 0x%x\n", m->m_len);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(so->so_rcv.sb_mb, "RCVOOB: Rcv socketbuf");
|
|
|
|
dump_mbuf(sb->sb_mb, "RCVOOB: Xrcv socketbuf");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if ((inflags & MSG_PEEK) == 0) {
|
|
|
|
n = *nn;
|
2001-10-19 00:17:24 +04:00
|
|
|
*nn = n->m_nextpkt;
|
1996-02-14 01:07:57 +03:00
|
|
|
for (; n; n = m_free(n))
|
1994-05-13 10:08:03 +04:00
|
|
|
sbfree(sb, n);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
sbunlock(sb);
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_XPD]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
tptraceTPCB(TPPTmisc, "PRU_RCVOOB @ release sb_cc m_len",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_Xrcv.sb_cc, m->m_len, 0, 0);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (error == 0)
|
1996-02-14 01:07:57 +03:00
|
|
|
error = DoEvent(T_USR_Xrcvd);
|
1993-04-09 16:00:07 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_usrreq(), PRU_SENDOOB
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Send what's in the mbuf chain (m) as an XPD TPDU.
|
2001-11-21 22:14:19 +03:00
|
|
|
* The mbuf may not contain more than 16 bytes of data.
|
1993-04-09 16:00:07 +04:00
|
|
|
* XPD TSDUs aren't segmented, so they translate into
|
|
|
|
* exactly one XPD TPDU, with EOT bit set.
|
|
|
|
* RETURN VALUE:
|
|
|
|
* EWOULDBLOCK if socket is in non-blocking mode and the previous
|
|
|
|
* xpd data haven't been acked yet.
|
|
|
|
* EMSGSIZE if trying to send > max-xpd bytes (16)
|
|
|
|
* ENOBUFS if ran out of mbufs
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
tp_sendoob(struct tp_pcb *tpcb, struct socket *so, struct mbuf *xdata,
|
2006-11-16 04:32:37 +03:00
|
|
|
int *outflags)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Each mbuf chain represents a sequence # in the XPD seq space.
|
|
|
|
* The first one in the queue has sequence # tp_Xuna.
|
|
|
|
* When we add to the XPD queue, we stuff a zero-length
|
|
|
|
* mbuf (mark) into the DATA queue, with its sequence number in m_next
|
|
|
|
* to be assigned to this XPD tpdu, so data xfer can stop
|
|
|
|
* when it reaches the zero-length mbuf if this XPD TPDU hasn't
|
1996-02-14 01:07:57 +03:00
|
|
|
* yet been acknowledged.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
2000-03-30 16:51:13 +04:00
|
|
|
struct sockbuf *sb = &(tpcb->tp_Xsnd);
|
|
|
|
struct mbuf *xmark;
|
|
|
|
int len = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct tp_event E;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_XPD]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("tp_sendoob:");
|
1993-04-09 16:00:07 +04:00
|
|
|
if (xdata)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("xdata len 0x%x\n", xdata->m_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* DO NOT LOCK the Xsnd buffer!!!! You can have at MOST one socket
|
|
|
|
* buf locked at any time!!! (otherwise you might sleep() in sblock()
|
|
|
|
* w/ a signal pending and cause the system call to be aborted w/ a
|
|
|
|
* locked socketbuf, which is a problem. So the so_snd buffer lock
|
1993-04-09 16:00:07 +04:00
|
|
|
* (done in sosend()) serves as the lock for Xpd.
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
if (sb->sb_mb) { /* Anything already in eXpedited data
|
|
|
|
* sockbuf? */
|
2008-02-07 00:57:53 +03:00
|
|
|
if (so->so_nbio) {
|
1993-04-09 16:00:07 +04:00
|
|
|
return EWOULDBLOCK;
|
|
|
|
}
|
|
|
|
while (sb->sb_mb) {
|
1996-02-14 01:07:57 +03:00
|
|
|
sbunlock(&so->so_snd); /* already locked by sosend */
|
1993-04-09 16:00:07 +04:00
|
|
|
sbwait(&so->so_snd);
|
1996-02-14 01:07:57 +03:00
|
|
|
sblock(&so->so_snd, M_WAITOK); /* sosend will unlock on
|
|
|
|
* return */
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if (xdata == (struct mbuf *) 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
/* empty xpd packet */
|
2003-02-26 09:31:08 +03:00
|
|
|
xdata = m_gethdr(M_WAIT, MT_OOBDATA);
|
1993-04-09 16:00:07 +04:00
|
|
|
xdata->m_len = 0;
|
|
|
|
xdata->m_pkthdr.len = 0;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_XPD]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("tp_sendoob 1:");
|
1993-04-09 16:00:07 +04:00
|
|
|
if (xdata)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("xdata len 0x%x\n", xdata->m_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
xmark = xdata; /* temporary use of variable xmark */
|
1993-04-09 16:00:07 +04:00
|
|
|
while (xmark) {
|
|
|
|
len += xmark->m_len;
|
|
|
|
xmark = xmark->m_next;
|
|
|
|
}
|
|
|
|
if (len > TP_MAX_XPD_DATA) {
|
|
|
|
return EMSGSIZE;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_XPD]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("tp_sendoob 2:");
|
1993-04-09 16:00:07 +04:00
|
|
|
if (xdata)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("xdata len 0x%x\n", len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_XPD]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
tptraceTPCB(TPPTmisc, "XPD mark m_next ", xdata->m_next, 0, 0, 0);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
sbappendrecord(sb, xdata);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_XPD]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("tp_sendoob len 0x%x\n", len);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(so->so_snd.sb_mb, "XPD request Regular sndbuf:");
|
|
|
|
dump_mbuf(tpcb->tp_Xsnd.sb_mb, "XPD request Xsndbuf:");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return DoEvent(T_XPD_req);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CALLED FROM:
|
|
|
|
* the socket routines
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Handles all "user requests" except the [gs]ockopts() requests.
|
1996-02-14 01:07:57 +03:00
|
|
|
* The argument (req) is the request type (PRU*),
|
1993-04-09 16:00:07 +04:00
|
|
|
* (m) is an mbuf chain, generally used for send and
|
|
|
|
* receive type requests only.
|
|
|
|
* (nam) is used for addresses usually, in particular for the bind request.
|
1996-02-14 01:07:57 +03:00
|
|
|
*
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
/* ARGSUSED */
|
1994-05-13 10:08:03 +04:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
tp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
|
2005-12-11 15:16:03 +03:00
|
|
|
struct mbuf *control, struct lwp *l)
|
1996-02-14 01:07:57 +03:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct tp_pcb *tpcb;
|
1996-02-14 01:07:57 +03:00
|
|
|
int error = 0;
|
|
|
|
int flags, *outflags = &flags;
|
|
|
|
u_long eotsdu = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct tp_event E;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("usrreq(%p,%d,%p,%p,%p)\n", so, req, m, nam, outflags);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (so->so_error)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("WARNING!!! so->so_error is 0x%x\n", so->so_error);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_REQUEST]) {
|
|
|
|
tptraceTPCB(TPPTusrreq, "req so m state [", req, so, m,
|
|
|
|
tpcb ? tpcb->tp_state : 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-09-08 18:28:08 +04:00
|
|
|
if (req == PRU_CONTROL)
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
|
|
|
|
tpcb = sototpcb(so);
|
|
|
|
if (tpcb == 0 && req != PRU_ATTACH) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_REQUEST]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
tptraceTPCB(TPPTusrreq, "req failed NO TPCB[", 0, 0, 0, 0);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1996-09-08 18:28:08 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto release;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-09-08 18:28:08 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
switch (req) {
|
|
|
|
|
|
|
|
case PRU_ATTACH:
|
2008-04-28 17:24:38 +04:00
|
|
|
sosetlock(so);
|
1996-09-08 18:28:08 +04:00
|
|
|
if (tpcb != 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EISCONN;
|
1996-09-08 18:28:08 +04:00
|
|
|
break;
|
|
|
|
}
|
2004-04-19 09:16:45 +04:00
|
|
|
error = tp_attach(so, (int)(long)nam);
|
1996-09-08 18:28:08 +04:00
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
tpcb = sototpcb(so);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case PRU_DETACH: /* called from close() */
|
1993-04-09 16:00:07 +04:00
|
|
|
/* called only after disconnect was called */
|
|
|
|
error = DoEvent(T_DETACH);
|
|
|
|
if (tpcb->tp_state == TP_CLOSED) {
|
1994-05-13 10:08:03 +04:00
|
|
|
if (tpcb->tp_notdetached) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("PRU_DETACH: not detached\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
tp_detach(tpcb);
|
|
|
|
}
|
2007-03-04 08:59:00 +03:00
|
|
|
free((void *) tpcb, M_PCB);
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_BIND:
|
2006-07-24 02:06:03 +04:00
|
|
|
error = tp_pcbbind(tpcb, nam, l);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_LISTEN:
|
1994-05-13 10:08:03 +04:00
|
|
|
if (tpcb->tp_state != TP_CLOSED || tpcb->tp_lsuffixlen == 0 ||
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_next == 0)
|
1994-05-13 10:08:03 +04:00
|
|
|
error = EINVAL;
|
|
|
|
else {
|
2000-03-30 16:51:13 +04:00
|
|
|
struct tp_pcb **tt;
|
2007-11-10 00:00:05 +03:00
|
|
|
iso_remque(tpcb);
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb->tp_next = tpcb->tp_prev = tpcb;
|
1994-05-13 10:08:03 +04:00
|
|
|
for (tt = &tp_listeners; *tt; tt = &((*tt)->tp_nextlisten))
|
|
|
|
if ((*tt)->tp_lsuffixlen)
|
|
|
|
break;
|
|
|
|
tpcb->tp_nextlisten = *tt;
|
|
|
|
*tt = tpcb;
|
|
|
|
error = DoEvent(T_LISTEN_req);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_CONNECT:
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_CONN]) {
|
|
|
|
tptraceTPCB(TPPTmisc,
|
|
|
|
"PRU_CONNECT: so 0x%x *SHORT_LSUFXP(tpcb) 0x%x lsuflen 0x%x, class 0x%x",
|
|
|
|
tpcb->tp_sock, *SHORT_LSUFXP(tpcb), tpcb->tp_lsuffixlen,
|
|
|
|
tpcb->tp_class);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("PRU_CONNECT: so %p *SHORT_LSUFXP(tpcb) 0x%x lsuflen 0x%x, class 0x%x",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_sock, *SHORT_LSUFXP(tpcb), tpcb->tp_lsuffixlen,
|
|
|
|
tpcb->tp_class);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (tpcb->tp_lsuffixlen == 0) {
|
1996-05-22 17:54:55 +04:00
|
|
|
error = tp_pcbbind(tpcb, (struct mbuf *)0,
|
2006-07-24 02:06:03 +04:00
|
|
|
(struct lwp *)0);
|
1996-05-22 17:54:55 +04:00
|
|
|
if (error) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("pcbbind returns error 0x%x\n", error);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("isop %p isop->isop_socket offset 12 :\n", tpcb->tp_npcb);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(tpcb->tp_npcb, 16);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if ((error = tp_route_to(nam, tpcb, /* channel */ 0)) != 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-03-17 02:13:45 +03:00
|
|
|
"PRU_CONNECT after tpcb %p so %p npcb %p flags 0x%x\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb, so, tpcb->tp_npcb, tpcb->tp_flags);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("isop %p isop->isop_socket offset 12 :\n", tpcb->tp_npcb);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(tpcb->tp_npcb, 16);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (tpcb->tp_fsuffixlen == 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
/* didn't set peer extended suffix */
|
1996-02-14 01:07:57 +03:00
|
|
|
(tpcb->tp_nlproto->nlp_getsufx) (tpcb->tp_npcb,
|
|
|
|
&tpcb->tp_fsuffixlen,
|
|
|
|
tpcb->tp_fsuffix, TP_FOREIGN);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
if (tpcb->tp_state == TP_CLOSED) {
|
1996-02-14 01:07:57 +03:00
|
|
|
soisconnecting(so);
|
1993-04-09 16:00:07 +04:00
|
|
|
error = DoEvent(T_CONN_req);
|
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
(tpcb->tp_nlproto->nlp_pcbdisc) (tpcb->tp_npcb);
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EISCONN;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TP_PERF_MEAS
|
|
|
|
if (DOPERF(tpcb)) {
|
|
|
|
u_int lsufx, fsufx;
|
2006-06-08 02:33:33 +04:00
|
|
|
struct timeval now;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
lsufx = *(u_short *) (tpcb->tp_lsuffix);
|
|
|
|
fsufx = *(u_short *) (tpcb->tp_fsuffix);
|
|
|
|
|
2006-06-08 02:33:33 +04:00
|
|
|
getmicrotime(&now);
|
1996-02-14 01:07:57 +03:00
|
|
|
tpmeas(tpcb->tp_lref,
|
|
|
|
TPtime_open | (tpcb->tp_xtd_format << 4),
|
2006-06-08 02:33:33 +04:00
|
|
|
&now, lsufx, fsufx, tpcb->tp_fref);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
1996-09-08 18:28:08 +04:00
|
|
|
case PRU_CONNECT2:
|
|
|
|
error = EOPNOTSUPP; /* for unix domain sockets */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_DISCONNECT:
|
|
|
|
E.TPDU_ATTR(REQ).e_reason = E_TP_NORMAL_DISC ^ TP_ERROR_MASK;
|
|
|
|
error = DoEvent(T_DISC_req);
|
|
|
|
break;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case PRU_ACCEPT:
|
|
|
|
(tpcb->tp_nlproto->nlp_getnetaddr) (tpcb->tp_npcb, nam, TP_FOREIGN);
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("ACCEPT PEERADDDR:");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(mtod(nam, char *), nam->m_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef TP_PERF_MEAS
|
|
|
|
if (DOPERF(tpcb)) {
|
|
|
|
u_int lsufx, fsufx;
|
2006-06-08 02:33:33 +04:00
|
|
|
struct timeval now;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
lsufx = *(u_short *) (tpcb->tp_lsuffix);
|
|
|
|
fsufx = *(u_short *) (tpcb->tp_fsuffix);
|
|
|
|
|
2006-06-08 02:33:33 +04:00
|
|
|
getmicrotime(&now);
|
1996-02-14 01:07:57 +03:00
|
|
|
tpmeas(tpcb->tp_lref, TPtime_open,
|
|
|
|
&time, lsufx, fsufx, tpcb->tp_fref);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
1996-09-08 18:28:08 +04:00
|
|
|
case PRU_SHUTDOWN:
|
|
|
|
/*
|
|
|
|
* recv end may have been released; local credit might be
|
|
|
|
* zero
|
|
|
|
*/
|
|
|
|
E.TPDU_ATTR(REQ).e_reason = E_TP_NORMAL_DISC ^ TP_ERROR_MASK;
|
|
|
|
error = DoEvent(T_DISC_req);
|
|
|
|
break;
|
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
case PRU_RCVD:
|
|
|
|
if (so->so_state & SS_ISCONFIRMING) {
|
|
|
|
if (tpcb->tp_state == TP_CONFIRMING)
|
|
|
|
error = tp_confirm(tpcb);
|
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_DATA]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
tptraceTPCB(TPPTmisc,
|
1996-02-14 01:07:57 +03:00
|
|
|
"RCVD BF: lcredit sent_lcdt cc hiwat \n",
|
|
|
|
tpcb->tp_lcredit, tpcb->tp_sent_lcdt,
|
|
|
|
so->so_rcv.sb_cc, so->so_rcv.sb_hiwat);
|
1993-04-09 16:00:07 +04:00
|
|
|
LOCAL_CREDIT(tpcb);
|
1996-02-14 01:07:57 +03:00
|
|
|
tptraceTPCB(TPPTmisc,
|
|
|
|
"PRU_RCVD AF sbspace lcredit hiwat cc",
|
|
|
|
sbspace(&so->so_rcv), tpcb->tp_lcredit,
|
|
|
|
so->so_rcv.sb_cc, so->so_rcv.sb_hiwat);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("RCVD: cc %ld space %ld hiwat %ld\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
so->so_rcv.sb_cc, sbspace(&so->so_rcv),
|
|
|
|
so->so_rcv.sb_hiwat);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (((long) nam) & MSG_OOB)
|
|
|
|
error = DoEvent(T_USR_Xrcvd);
|
|
|
|
else
|
|
|
|
error = DoEvent(T_USR_rcvd);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_RCVOOB:
|
|
|
|
if ((so->so_state & SS_ISCONNECTED) == 0) {
|
|
|
|
error = ENOTCONN;
|
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if (!tpcb->tp_xpd_service) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* kludge - nam is really flags here */
|
1996-02-14 01:07:57 +03:00
|
|
|
error = tp_rcvoob(tpcb, so, m, outflags, (long) nam);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_SEND:
|
|
|
|
case PRU_SENDOOB:
|
1996-05-22 17:54:55 +04:00
|
|
|
if (control) {
|
|
|
|
error = tp_snd_control(control, so, &m);
|
|
|
|
control = NULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((so->so_state & SS_ISCONFIRMING) &&
|
|
|
|
(tpcb->tp_state == TP_CONFIRMING) &&
|
|
|
|
(error = tp_confirm(tpcb)))
|
1996-02-14 01:07:57 +03:00
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (req == PRU_SENDOOB) {
|
|
|
|
error = (tpcb->tp_xpd_service == 0) ?
|
1996-02-14 01:07:57 +03:00
|
|
|
EOPNOTSUPP : tp_sendoob(tpcb, so, m, outflags);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (m == 0)
|
|
|
|
break;
|
|
|
|
if (m->m_flags & M_EOR) {
|
|
|
|
eotsdu = 1;
|
|
|
|
m->m_flags &= ~M_EOR;
|
|
|
|
}
|
|
|
|
if (eotsdu == 0 && m->m_pkthdr.len == 0)
|
|
|
|
break;
|
|
|
|
if (tpcb->tp_state != TP_AKWAIT && tpcb->tp_state != TP_OPEN) {
|
|
|
|
error = ENOTCONN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The protocol machine copies mbuf chains,
|
|
|
|
* prepends headers, assigns seq numbers, and
|
|
|
|
* puts the packets on the device.
|
|
|
|
* When they are acked they are removed from the socket buf.
|
|
|
|
*
|
|
|
|
* sosend calls this up until sbspace goes negative.
|
|
|
|
* Sbspace may be made negative by appending this mbuf chain,
|
|
|
|
* possibly by a whole cluster.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Could have eotsdu and no data.(presently MUST have
|
1996-02-14 01:07:57 +03:00
|
|
|
* an mbuf though, even if its length == 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int totlen = m->m_pkthdr.len;
|
1994-05-13 10:08:03 +04:00
|
|
|
struct sockbuf *sb = &so->so_snd;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TP_PERF_MEAS
|
|
|
|
if (DOPERF(tpcb)) {
|
|
|
|
PStat(tpcb, Nb_from_sess) += totlen;
|
|
|
|
tpmeas(tpcb->tp_lref, TPtime_from_session, 0, 0,
|
|
|
|
PStat(tpcb, Nb_from_sess), totlen);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SYSCALL]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-03-17 02:13:45 +03:00
|
|
|
"PRU_SEND: eot %ld before sbappend %p len 0x%x to sb @ %p\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
eotsdu, m, totlen, sb);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(sb->sb_mb, "so_snd.sb_mb");
|
|
|
|
dump_mbuf(m, "m : to be added");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
tp_packetize(tpcb, m, eotsdu);
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SYSCALL]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("PRU_SEND: eot %ld after sbappend %p\n", eotsdu, m);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(sb->sb_mb, "so_snd.sb_mb");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (tpcb->tp_state == TP_OPEN)
|
1996-02-14 01:07:57 +03:00
|
|
|
error = DoEvent(T_DATA_req);
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SYSCALL]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("PRU_SEND: after driver error 0x%x \n", error);
|
|
|
|
printf("so_snd %p cc 0t%ld mbcnt 0t%ld\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
sb, sb->sb_cc, sb->sb_mbcnt);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(sb->sb_mb, "so_snd.sb_mb after driver");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-09-08 18:28:08 +04:00
|
|
|
case PRU_ABORT: /* called from close() */
|
|
|
|
/*
|
|
|
|
* called for each incoming connect queued on the parent
|
|
|
|
* (accepting) socket
|
|
|
|
*/
|
|
|
|
if (tpcb->tp_state == TP_OPEN || tpcb->tp_state == TP_CONFIRMING) {
|
|
|
|
E.TPDU_ATTR(REQ).e_reason = E_TP_NO_SESSION ^ TP_ERROR_MASK;
|
|
|
|
error = DoEvent(T_DISC_req); /* pretend it was a
|
|
|
|
* close() */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_SENSE:
|
|
|
|
/*
|
|
|
|
* stat: don't bother with a blocksize.
|
|
|
|
*/
|
|
|
|
return (0);
|
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
case PRU_SOCKADDR:
|
1996-02-14 01:07:57 +03:00
|
|
|
(tpcb->tp_nlproto->nlp_getnetaddr) (tpcb->tp_npcb, nam, TP_LOCAL);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_PEERADDR:
|
1996-02-14 01:07:57 +03:00
|
|
|
(tpcb->tp_nlproto->nlp_getnetaddr) (tpcb->tp_npcb, nam, TP_FOREIGN);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
#ifdef ARGO_DEBUG
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("tp_usrreq UNKNOWN PRU %d\n", req);
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* ARGO_DEBUG */
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("%s, so %p, tpcb %p, error %d, state %d\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
"returning from tp_usrreq", so, tpcb, error,
|
|
|
|
tpcb ? tpcb->tp_state : 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_REQUEST]) {
|
|
|
|
tptraceTPCB(TPPTusrreq, "END req so m state [", req, so, m,
|
|
|
|
tpcb ? tpcb->tp_state : 0);
|
|
|
|
}
|
|
|
|
#endif
|
1996-09-08 18:28:08 +04:00
|
|
|
release:
|
1993-04-09 16:00:07 +04:00
|
|
|
return error;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
|
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
tp_ltrace(struct socket *so, struct uio *uio)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_DATA]) {
|
2000-03-30 16:51:13 +04:00
|
|
|
struct tp_pcb *tpcb = sototpcb(so);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (tpcb) {
|
|
|
|
tptraceTPCB(TPPTmisc, "sosend so resid iovcnt", so,
|
1996-02-14 01:07:57 +03:00
|
|
|
uio->uio_resid, uio->uio_iovcnt, 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
tp_confirm(struct tp_pcb *tpcb)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
struct tp_event E;
|
|
|
|
if (tpcb->tp_state == TP_CONFIRMING)
|
1996-02-14 01:07:57 +03:00
|
|
|
return DoEvent(T_ACPT_req);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("Tp confirm called when not confirming; tpcb %p, state 0x%x\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb, tpcb->tp_state);
|
1993-04-09 16:00:07 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process control data sent with sendmsg()
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
tp_snd_control(struct mbuf *m, struct socket *so, struct mbuf **data)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct cmsghdr *ch;
|
1996-02-14 01:07:57 +03:00
|
|
|
int error = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (m && m->m_len) {
|
|
|
|
ch = mtod(m, struct cmsghdr *);
|
1996-02-14 01:07:57 +03:00
|
|
|
m->m_len -= sizeof(*ch);
|
|
|
|
m->m_data += sizeof(*ch);
|
1993-04-09 16:00:07 +04:00
|
|
|
error = tp_ctloutput(PRCO_SETOPT,
|
1996-02-14 01:07:57 +03:00
|
|
|
so, ch->cmsg_level, ch->cmsg_type, &m);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ch->cmsg_type == TPOPT_DISC_DATA) {
|
|
|
|
if (data && *data) {
|
|
|
|
m_freem(*data);
|
|
|
|
*data = 0;
|
|
|
|
}
|
1996-05-22 17:54:55 +04:00
|
|
|
error = tp_usrreq(so, PRU_DISCONNECT, (struct mbuf *)0,
|
|
|
|
(struct mbuf *)0, (struct mbuf *)0,
|
2005-12-11 15:16:03 +03:00
|
|
|
(struct lwp *)0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m)
|
|
|
|
m_freem(m);
|
|
|
|
return error;
|
|
|
|
}
|