1996-05-22 17:54:55 +04:00
|
|
|
/* $NetBSD: tp_output.c,v 1.13 1996/05/22 13:56:03 mycroft 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_output.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
|
|
|
* In here is tp_ctloutput(), the guy called by [sg]etsockopt(),
|
|
|
|
*/
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/kernel.h>
|
1996-05-22 17:54:55 +04:00
|
|
|
#include <sys/proc.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
|
|
|
|
#include <netiso/tp_param.h>
|
|
|
|
#include <netiso/tp_user.h>
|
|
|
|
#include <netiso/tp_stat.h>
|
|
|
|
#include <netiso/tp_ip.h>
|
|
|
|
#include <netiso/tp_clnp.h>
|
|
|
|
#include <netiso/tp_timer.h>
|
|
|
|
#include <netiso/argo_debug.h>
|
|
|
|
#include <netiso/tp_pcb.h>
|
|
|
|
#include <netiso/tp_trace.h>
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <netiso/tp_var.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
#define TPDUSIZESHIFT 24
|
|
|
|
#define CLASSHIFT 16
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: tp_consistency()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
|
|
|
* tp_ctloutput(), tp_input()
|
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Checks the consistency of options and tpdusize with class,
|
|
|
|
* using the parameters passed in via (param).
|
|
|
|
* (cmd) may be TP_STRICT or TP_FORCE or both.
|
|
|
|
* Force means it will set all the values in (tpcb) to those in
|
|
|
|
* the input arguements iff no errors were encountered.
|
|
|
|
* Strict means that no inconsistency will be tolerated. If it's
|
|
|
|
* not used, checksum and tpdusize inconsistencies will be tolerated.
|
1996-02-14 01:07:57 +03:00
|
|
|
* The reason for this is that in some cases, when we're negotiating down
|
|
|
|
* from class 4, these options should be changed but should not
|
1993-04-09 16:00:07 +04:00
|
|
|
* cause negotiation to fail.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* E* or EOK
|
|
|
|
* E* if the various parms aren't ok for a given class
|
|
|
|
* EOK if they are ok for a given class
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
1996-02-14 01:07:57 +03:00
|
|
|
tp_consistency(tpcb, cmd, param)
|
|
|
|
u_int cmd;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct tp_conn_param *param;
|
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
|
|
|
register int error = EOK;
|
|
|
|
int class_to_use = tp_mask_to_num(param->p_class);
|
|
|
|
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_SETPARAMS]) {
|
|
|
|
tptrace(TPPTmisc,
|
|
|
|
"tp_consist enter class_to_use dontchange param.class cmd",
|
|
|
|
class_to_use, param->p_dont_change_params, param->p_class, cmd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
|
|
|
printf("tp_consistency %s %s\n",
|
|
|
|
cmd & TP_FORCE ? "TP_FORCE" : "",
|
|
|
|
cmd & TP_STRICT ? "TP_STRICT" : "");
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((cmd & TP_FORCE) && (param->p_dont_change_params)) {
|
|
|
|
cmd &= ~TP_FORCE;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* can switch net services within a domain, but cannot switch domains
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
switch (param->p_netservice) {
|
1993-04-09 16:00:07 +04:00
|
|
|
case ISO_CONS:
|
|
|
|
case ISO_CLNS:
|
|
|
|
case ISO_COSNS:
|
|
|
|
/* param->p_netservice in ISO DOMAIN */
|
1996-02-14 01:07:57 +03:00
|
|
|
if (tpcb->tp_domain != AF_ISO) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IN_CLNS:
|
|
|
|
/* param->p_netservice in INET DOMAIN */
|
1996-02-14 01:07:57 +03:00
|
|
|
if (tpcb->tp_domain != AF_INET) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* no others not possible-> netservice is a 2-bit field! */
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
|
|
|
printf("p_class 0x%x, class_to_use 0x%x\n", param->p_class,
|
|
|
|
class_to_use);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if ((param->p_netservice > TP_MAX_NETSERVICES)) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if ((param->p_class & TP_CLASSES_IMPLEMENTED) == 0) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
|
|
|
printf("Nretrans 0x%x\n", param->p_Nretrans);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif
|
|
|
|
if ((param->p_Nretrans < 1) ||
|
|
|
|
(param->p_cr_ticks < 1) || (param->p_cc_ticks < 1)) {
|
|
|
|
/*
|
|
|
|
* bad for any class because negot has to be done a la class
|
|
|
|
* 4
|
|
|
|
*/
|
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
|
|
|
printf("use_csum 0x%x\n", param->p_use_checksum);
|
|
|
|
printf("xtd_format 0x%x\n", param->p_xtd_format);
|
|
|
|
printf("xpd_service 0x%x\n", param->p_xpd_service);
|
|
|
|
printf("tpdusize 0x%x\n", param->p_tpdusize);
|
|
|
|
printf("tpcb->flags 0x%x\n", tpcb->tp_flags);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
switch (class_to_use) {
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
case 0:
|
|
|
|
/* do not use checksums, xtd format, or XPD */
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
if (param->p_use_checksum | param->p_xtd_format | param->p_xpd_service) {
|
|
|
|
if (cmd & TP_STRICT) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
param->p_use_checksum = 0;
|
|
|
|
param->p_xtd_format = 0;
|
|
|
|
param->p_xpd_service = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (param->p_tpdusize < TP_MIN_TPDUSIZE) {
|
1996-02-14 01:07:57 +03:00
|
|
|
if (cmd & TP_STRICT) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
param->p_tpdusize = TP_MIN_TPDUSIZE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if (param->p_tpdusize > TP0_TPDUSIZE) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if (cmd & TP_STRICT) {
|
1996-02-14 01:07:57 +03:00
|
|
|
error = EINVAL;
|
1993-04-09 16:00:07 +04:00
|
|
|
} else {
|
|
|
|
param->p_tpdusize = TP0_TPDUSIZE;
|
|
|
|
}
|
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
/* connect/disc data not allowed for class 0 */
|
|
|
|
if (tpcb->tp_ucddata) {
|
1996-02-14 01:07:57 +03:00
|
|
|
if (cmd & TP_STRICT) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
1996-02-14 01:07:57 +03:00
|
|
|
} else if (cmd & TP_FORCE) {
|
1993-04-09 16:00:07 +04:00
|
|
|
m_freem(tpcb->tp_ucddata);
|
|
|
|
tpcb->tp_ucddata = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
case 4:
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
|
|
|
printf("dt_ticks 0x%x\n", param->p_dt_ticks);
|
|
|
|
printf("x_ticks 0x%x\n", param->p_x_ticks);
|
|
|
|
printf("dr_ticks 0x%x\n", param->p_dr_ticks);
|
|
|
|
printf("keepalive 0x%x\n", param->p_keepalive_ticks);
|
|
|
|
printf("sendack 0x%x\n", param->p_sendack_ticks);
|
|
|
|
printf("inact 0x%x\n", param->p_inact_ticks);
|
|
|
|
printf("ref 0x%x\n", param->p_ref_ticks);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if ((param->p_class & TP_CLASS_4) && (
|
|
|
|
(param->p_dt_ticks < 1) || (param->p_dr_ticks < 1) ||
|
|
|
|
(param->p_x_ticks < 1) || (param->p_keepalive_ticks < 1) ||
|
|
|
|
(param->p_sendack_ticks < 1) || (param->p_ref_ticks < 1) ||
|
|
|
|
(param->p_inact_ticks < 1))) {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
|
|
|
printf("rx_strat 0x%x\n", param->p_rx_strat);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (param->p_rx_strat >
|
|
|
|
(TPRX_USE_CW | TPRX_EACH | TPRX_FASTSTART)) {
|
|
|
|
if (cmd & TP_STRICT) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
1996-02-14 01:07:57 +03:00
|
|
|
} else {
|
|
|
|
param->p_rx_strat = TPRX_USE_CW;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
|
|
|
printf("ack_strat 0x%x\n", param->p_ack_strat);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if ((param->p_ack_strat != 0) && (param->p_ack_strat != 1)) {
|
|
|
|
if (cmd & TP_STRICT) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
param->p_ack_strat = TPACK_WINDOW;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (param->p_tpdusize < TP_MIN_TPDUSIZE) {
|
1996-02-14 01:07:57 +03:00
|
|
|
if (cmd & TP_STRICT) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
param->p_tpdusize = TP_MIN_TPDUSIZE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if (param->p_tpdusize > TP_TPDUSIZE) {
|
|
|
|
if (cmd & TP_STRICT) {
|
|
|
|
error = EINVAL;
|
1993-04-09 16:00:07 +04:00
|
|
|
} else {
|
|
|
|
param->p_tpdusize = TP_TPDUSIZE;
|
|
|
|
}
|
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((error == 0) && (cmd & TP_FORCE)) {
|
|
|
|
long dusize = ((long) param->p_ptpdusize) << 7;
|
1993-04-09 16:00:07 +04:00
|
|
|
/* Enforce Negotation rules below */
|
|
|
|
tpcb->tp_class = param->p_class;
|
|
|
|
if (tpcb->tp_use_checksum || param->p_use_checksum)
|
|
|
|
tpcb->tp_use_checksum = 1;
|
|
|
|
if (!tpcb->tp_xpd_service || !param->p_xpd_service)
|
|
|
|
tpcb->tp_xpd_service = 0;
|
|
|
|
if (!tpcb->tp_xtd_format || !param->p_xtd_format)
|
|
|
|
tpcb->tp_xtd_format = 0;
|
1994-05-13 10:08:03 +04:00
|
|
|
if (dusize) {
|
|
|
|
if (tpcb->tp_l_tpdusize > dusize)
|
|
|
|
tpcb->tp_l_tpdusize = dusize;
|
|
|
|
if (tpcb->tp_ptpdusize == 0 ||
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_ptpdusize > param->p_ptpdusize)
|
1994-05-13 10:08:03 +04:00
|
|
|
tpcb->tp_ptpdusize = param->p_ptpdusize;
|
|
|
|
} else {
|
|
|
|
if (param->p_tpdusize != 0 &&
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->tp_tpdusize > param->p_tpdusize)
|
1994-05-13 10:08:03 +04:00
|
|
|
tpcb->tp_tpdusize = param->p_tpdusize;
|
|
|
|
tpcb->tp_l_tpdusize = 1 << tpcb->tp_tpdusize;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
done:
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_CONN]) {
|
|
|
|
tptrace(TPPTmisc, "tp_consist returns class xtdfmt cmd",
|
1993-04-09 16:00:07 +04:00
|
|
|
error, tpcb->tp_class, tpcb->tp_xtd_format, cmd);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_CONN]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf(
|
1996-02-14 01:07:57 +03:00
|
|
|
"tp_consist rtns 0x%x class 0x%x xtd_fmt 0x%x cmd 0x%x\n",
|
|
|
|
error, tpcb->tp_class, tpcb->tp_xtd_format, cmd);
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: tp_ctloutput()
|
|
|
|
*
|
|
|
|
* CALLED FROM:
|
1996-02-14 01:07:57 +03:00
|
|
|
* [sg]etsockopt(), via so[sg]etopt().
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* FUNCTION and ARGUMENTS:
|
|
|
|
* Implements the socket options at transport level.
|
|
|
|
* (cmd) is either PRCO_SETOPT or PRCO_GETOPT (see ../sys/protosw.h).
|
|
|
|
* (so) is the socket.
|
|
|
|
* (level) is SOL_TRANSPORT (see ../sys/socket.h)
|
|
|
|
* (optname) is the particular command or option to be set.
|
1996-02-14 01:07:57 +03:00
|
|
|
* (**mp) is an mbuf structure.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* RETURN VALUE:
|
|
|
|
* ENOTSOCK if the socket hasn't got an associated tpcb
|
1996-02-14 01:07:57 +03:00
|
|
|
* EINVAL if
|
1993-04-09 16:00:07 +04:00
|
|
|
* trying to set window too big
|
1996-02-14 01:07:57 +03:00
|
|
|
* trying to set illegal max tpdu size
|
1993-04-09 16:00:07 +04:00
|
|
|
* trying to set illegal credit fraction
|
|
|
|
* trying to use unknown or unimplemented class of TP
|
|
|
|
* structure passed to set timer values is wrong size
|
1996-02-14 01:07:57 +03:00
|
|
|
* illegal combination of command/GET-SET option,
|
|
|
|
* e.g., GET w/ TPOPT_CDDATA_CLEAR:
|
1993-04-09 16:00:07 +04:00
|
|
|
* EOPNOTSUPP if the level isn't transport, or command is neither GET nor SET
|
|
|
|
* or if the transport-specific command is not implemented
|
|
|
|
* EISCONN if trying a command that isn't allowed after a connection
|
|
|
|
* is established
|
|
|
|
* ENOTCONN if trying a command that is allowed only if a connection is
|
|
|
|
* established
|
|
|
|
* EMSGSIZE if trying to give too much data on connect/disconnect
|
|
|
|
*
|
|
|
|
* SIDE EFFECTS:
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
tp_ctloutput(cmd, so, level, optname, mp)
|
1996-02-14 01:07:57 +03:00
|
|
|
int cmd, level, optname;
|
|
|
|
struct socket *so;
|
|
|
|
struct mbuf **mp;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-05-22 17:54:55 +04:00
|
|
|
struct proc *p = curproc; /* XXX */
|
1996-02-14 01:07:57 +03:00
|
|
|
struct tp_pcb *tpcb = sototpcb(so);
|
|
|
|
int s = splsoftnet();
|
|
|
|
caddr_t value;
|
|
|
|
unsigned val_len;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_REQUEST]) {
|
|
|
|
tptrace(TPPTmisc, "tp_ctloutput cmd so optname mp",
|
1993-04-09 16:00:07 +04:00
|
|
|
cmd, so, optname, mp);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
printf(
|
1996-03-17 02:13:45 +03:00
|
|
|
"tp_ctloutput so %p cmd 0x%x optname 0x%x, mp %p *mp %p tpcb %p\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
so, cmd, optname, mp, mp ? *mp : 0, tpcb);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (tpcb == (struct tp_pcb *) 0) {
|
|
|
|
error = ENOTSOCK;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if (*mp == MNULL) {
|
1993-04-09 16:00:07 +04:00
|
|
|
register struct mbuf *m;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
MGET(m, M_DONTWAIT, TPMT_SONAME); /* does off, type, next */
|
1993-04-09 16:00:07 +04:00
|
|
|
if (m == NULL) {
|
|
|
|
splx(s);
|
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
m->m_len = 0;
|
|
|
|
m->m_act = 0;
|
|
|
|
*mp = m;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Hook so one can set network options via a tp socket.
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
if (level == SOL_NETWORK) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((tpcb->tp_nlproto == NULL) || (tpcb->tp_npcb == NULL))
|
|
|
|
error = ENOTSOCK;
|
|
|
|
else if (tpcb->tp_nlproto->nlp_ctloutput == NULL)
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
else
|
1996-02-14 01:07:57 +03:00
|
|
|
return ((tpcb->tp_nlproto->nlp_ctloutput) (cmd, optname,
|
|
|
|
tpcb->tp_npcb, *mp));
|
1994-05-13 10:08:03 +04:00
|
|
|
goto done;
|
1996-02-14 01:07:57 +03:00
|
|
|
} else if (level == SOL_SOCKET) {
|
1994-05-13 10:08:03 +04:00
|
|
|
if (optname == SO_RCVBUF && cmd == PRCO_SETOPT) {
|
1996-02-14 01:07:57 +03:00
|
|
|
u_long old_credit = tpcb->tp_maxlcredit;
|
1994-05-13 10:08:03 +04:00
|
|
|
tp_rsyset(tpcb);
|
|
|
|
if (tpcb->tp_rhiwat != so->so_rcv.sb_hiwat &&
|
|
|
|
tpcb->tp_state == TP_OPEN &&
|
|
|
|
(old_credit < tpcb->tp_maxlcredit))
|
|
|
|
tp_emit(AK_TPDU_type, tpcb,
|
|
|
|
tpcb->tp_rcvnxt, 0, MNULL);
|
|
|
|
tpcb->tp_rhiwat = so->so_rcv.sb_hiwat;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
goto done;
|
1996-02-14 01:07:57 +03:00
|
|
|
} else if (level != SOL_TRANSPORT) {
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
goto done;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
if (cmd != PRCO_GETOPT && cmd != PRCO_SETOPT) {
|
1996-02-14 01:07:57 +03:00
|
|
|
error = EOPNOTSUPP;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if (so->so_error) {
|
|
|
|
error = so->so_error;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The only options allowed after connection is established are GET
|
|
|
|
* (anything) and SET DISC DATA and SET PERF MEAS
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
if (((so->so_state & SS_ISCONNECTING) || (so->so_state & SS_ISCONNECTED))
|
|
|
|
&&
|
|
|
|
(cmd == PRCO_SETOPT &&
|
|
|
|
optname != TPOPT_DISC_DATA &&
|
|
|
|
optname != TPOPT_CFRM_DATA &&
|
|
|
|
optname != TPOPT_PERF_MEAS &&
|
|
|
|
optname != TPOPT_CDDATA_CLEAR)) {
|
|
|
|
error = EISCONN;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The only options allowed after disconnection are GET DISC DATA,
|
|
|
|
* and TPOPT_PSTATISTICS and they're not allowed if the ref timer has
|
|
|
|
* gone off, because the tpcb is gone
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((so->so_state & (SS_ISCONNECTED | SS_ISCONFIRMING)) == 0) {
|
|
|
|
if (so->so_pcb == 0) {
|
|
|
|
error = ENOTCONN;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((tpcb->tp_state == TP_REFWAIT || tpcb->tp_state == TP_CLOSING) &&
|
|
|
|
(optname != TPOPT_DISC_DATA && optname != TPOPT_PSTATISTICS)) {
|
|
|
|
error = ENOTCONN;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
value = mtod(*mp, caddr_t); /* it's aligned, don't worry, but
|
|
|
|
* lint complains about it */
|
1993-04-09 16:00:07 +04:00
|
|
|
val_len = (*mp)->m_len;
|
|
|
|
|
|
|
|
switch (optname) {
|
|
|
|
|
|
|
|
case TPOPT_INTERCEPT:
|
1994-05-13 10:08:03 +04:00
|
|
|
#define INA(t) (((struct inpcb *)(t->tp_npcb))->inp_laddr.s_addr)
|
|
|
|
#define ISOA(t) (((struct isopcb *)(t->tp_npcb))->isop_laddr->siso_addr)
|
|
|
|
|
1996-05-22 17:54:55 +04:00
|
|
|
if (p == 0 || (error = suser(p->p_ucred, &p->p_acflag))) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EPERM;
|
1994-05-13 10:08:03 +04:00
|
|
|
} else if (cmd != PRCO_SETOPT || tpcb->tp_state != TP_CLOSED ||
|
1996-02-14 01:07:57 +03:00
|
|
|
(tpcb->tp_flags & TPF_GENERAL_ADDR) ||
|
|
|
|
tpcb->tp_next == 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
else {
|
1994-05-13 10:08:03 +04:00
|
|
|
register struct tp_pcb *t;
|
|
|
|
error = EADDRINUSE;
|
|
|
|
for (t = tp_listeners; t; t = t->tp_nextlisten)
|
|
|
|
if ((t->tp_flags & TPF_GENERAL_ADDR) == 0 &&
|
1996-02-14 01:07:57 +03:00
|
|
|
t->tp_domain == tpcb->tp_domain)
|
1994-05-13 10:08:03 +04:00
|
|
|
switch (tpcb->tp_domain) {
|
|
|
|
default:
|
|
|
|
goto done;
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
if (INA(t) == INA(tpcb))
|
|
|
|
goto done;
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
#ifdef ISO
|
|
|
|
case AF_ISO:
|
|
|
|
if (bcmp(ISOA(t).isoa_genaddr, ISOA(tpcb).isoa_genaddr,
|
1996-02-14 01:07:57 +03:00
|
|
|
ISOA(t).isoa_len) == 0)
|
1994-05-13 10:08:03 +04:00
|
|
|
goto done;
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
tpcb->tp_lsuffixlen = 0;
|
|
|
|
tpcb->tp_state = TP_LISTENING;
|
|
|
|
error = 0;
|
|
|
|
remque(tpcb);
|
|
|
|
tpcb->tp_next = tpcb->tp_prev = tpcb;
|
|
|
|
tpcb->tp_nextlisten = tp_listeners;
|
|
|
|
tp_listeners = tpcb;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TPOPT_MY_TSEL:
|
1996-02-14 01:07:57 +03:00
|
|
|
if (cmd == PRCO_GETOPT) {
|
|
|
|
ASSERT(tpcb->tp_lsuffixlen <= MAX_TSAP_SEL_LEN);
|
|
|
|
bcopy((caddr_t) tpcb->tp_lsuffix, value, tpcb->tp_lsuffixlen);
|
1993-04-09 16:00:07 +04:00
|
|
|
(*mp)->m_len = tpcb->tp_lsuffixlen;
|
1996-02-14 01:07:57 +03:00
|
|
|
} else { /* cmd == PRCO_SETOPT */
|
|
|
|
if ((val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0)) {
|
1996-03-17 02:13:45 +03:00
|
|
|
printf("val_len 0x%x (*mp)->m_len %p\n",
|
|
|
|
val_len, (*mp));
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy(value, (caddr_t) tpcb->tp_lsuffix, val_len);
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb->tp_lsuffixlen = val_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TPOPT_PEER_TSEL:
|
1996-02-14 01:07:57 +03:00
|
|
|
if (cmd == PRCO_GETOPT) {
|
|
|
|
ASSERT(tpcb->tp_fsuffixlen <= MAX_TSAP_SEL_LEN);
|
|
|
|
bcopy((caddr_t) tpcb->tp_fsuffix, value, tpcb->tp_fsuffixlen);
|
1993-04-09 16:00:07 +04:00
|
|
|
(*mp)->m_len = tpcb->tp_fsuffixlen;
|
1996-02-14 01:07:57 +03:00
|
|
|
} else { /* cmd == PRCO_SETOPT */
|
|
|
|
if ((val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0)) {
|
1996-03-17 02:13:45 +03:00
|
|
|
printf("val_len 0x%x (*mp)->m_len %p\n",
|
|
|
|
val_len, (*mp));
|
1996-02-14 01:07:57 +03:00
|
|
|
error = EINVAL;
|
1993-04-09 16:00:07 +04:00
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy(value, (caddr_t) tpcb->tp_fsuffix, val_len);
|
1993-04-09 16:00:07 +04:00
|
|
|
tpcb->tp_fsuffixlen = val_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TPOPT_FLAGS:
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1996-03-17 02:13:45 +03:00
|
|
|
printf("%s TPOPT_FLAGS value %p *value 0x%x, flags 0x%x \n",
|
1996-02-14 01:07:57 +03:00
|
|
|
cmd == PRCO_GETOPT ? "GET" : "SET",
|
|
|
|
value,
|
|
|
|
*value,
|
|
|
|
tpcb->tp_flags);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (cmd == PRCO_GETOPT) {
|
|
|
|
*(int *) value = (int) tpcb->tp_flags;
|
1993-04-09 16:00:07 +04:00
|
|
|
(*mp)->m_len = sizeof(u_int);
|
1996-02-14 01:07:57 +03:00
|
|
|
} else { /* cmd == PRCO_SETOPT */
|
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TPOPT_PARAMS:
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* This handles: timer values, class, use of transport
|
|
|
|
* expedited data, max tpdu size, checksum, xtd format and
|
|
|
|
* disconnect indications, and may get rid of connect/disc
|
|
|
|
* data
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SETPARAMS]) {
|
1996-03-17 02:13:45 +03:00
|
|
|
printf("TPOPT_PARAMS value %p, cmd %s \n", value,
|
1996-02-14 01:07:57 +03:00
|
|
|
cmd == PRCO_GETOPT ? "GET" : "SET");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1996-03-17 02:13:45 +03:00
|
|
|
printf("TPOPT_PARAMS value %p, cmd %s \n", value,
|
1996-02-14 01:07:57 +03:00
|
|
|
cmd == PRCO_GETOPT ? "GET" : "SET");
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
if (cmd == PRCO_GETOPT) {
|
|
|
|
*(struct tp_conn_param *) value = tpcb->_tp_param;
|
1993-04-09 16:00:07 +04:00
|
|
|
(*mp)->m_len = sizeof(tpcb->_tp_param);
|
1996-02-14 01:07:57 +03:00
|
|
|
} else { /* cmd == PRCO_SETOPT */
|
|
|
|
if ((error =
|
|
|
|
tp_consistency(tpcb, TP_STRICT | TP_FORCE,
|
|
|
|
(struct tp_conn_param *) value)) == 0) {
|
|
|
|
/*
|
|
|
|
* tp_consistency doesn't copy the whole set
|
|
|
|
* of params
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
tpcb->_tp_param = *(struct tp_conn_param *) value;
|
1993-04-09 16:00:07 +04:00
|
|
|
(*mp)->m_len = sizeof(tpcb->_tp_param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case TPOPT_PSTATISTICS:
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef TP_PERF_MEAS
|
|
|
|
if (cmd == PRCO_SETOPT) {
|
1996-02-14 01:07:57 +03:00
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (tpcb->tp_perf_on) {
|
1995-08-16 04:38:53 +04:00
|
|
|
MCLGET(*mp, M_WAITOK);
|
|
|
|
if (((*mp)->m_flags & M_EXT) == 0) {
|
|
|
|
error = ENOBUFS; goto done;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1995-08-16 04:38:53 +04:00
|
|
|
(*mp)->m_len = sizeof(struct tp_pmeas);
|
|
|
|
bcopy(tpcb->tp_p_meas, mtod(*mp), sizeof(struct tp_pmeas));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
else {
|
1996-02-14 01:07:57 +03:00
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
#else
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
goto done;
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* TP_PERF_MEAS */
|
|
|
|
|
|
|
|
case TPOPT_CDDATA_CLEAR:
|
1993-04-09 16:00:07 +04:00
|
|
|
if (cmd == PRCO_GETOPT) {
|
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
if (tpcb->tp_ucddata) {
|
|
|
|
m_freem(tpcb->tp_ucddata);
|
|
|
|
tpcb->tp_ucddata = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TPOPT_CFRM_DATA:
|
1996-02-14 01:07:57 +03:00
|
|
|
case TPOPT_DISC_DATA:
|
|
|
|
case TPOPT_CONN_DATA:
|
|
|
|
if (tpcb->tp_class == TP_CLASS_0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
|
|
|
printf("%s\n", optname == TPOPT_DISC_DATA ? "DISC data" : "CONN data");
|
1996-03-17 02:13:45 +03:00
|
|
|
printf("m_len 0x%x, vallen 0x%x so_snd.cc 0x%lx\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
(*mp)->m_len, val_len, so->so_snd.sb_cc);
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(so->so_snd.sb_mb, "tp_ctloutput: sosnd ");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (cmd == PRCO_SETOPT) {
|
1996-02-14 01:07:57 +03:00
|
|
|
int len = tpcb->tp_ucddata ? tpcb->tp_ucddata->m_len : 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
/* can append connect data in several calls */
|
1996-02-14 01:07:57 +03:00
|
|
|
if (len + val_len >
|
|
|
|
(optname == TPOPT_CONN_DATA ? TP_MAX_CR_DATA : TP_MAX_DR_DATA)) {
|
|
|
|
error = EMSGSIZE;
|
|
|
|
goto done;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
(*mp)->m_next = MNULL;
|
|
|
|
(*mp)->m_act = 0;
|
|
|
|
if (tpcb->tp_ucddata)
|
|
|
|
m_cat(tpcb->tp_ucddata, *mp);
|
|
|
|
else
|
|
|
|
tpcb->tp_ucddata = *mp;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(tpcb->tp_ucddata, "tp_ctloutput after CONN_DATA");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef TPPT
|
|
|
|
if (tp_traceflags[D_REQUEST]) {
|
|
|
|
tptrace(TPPTmisc, "C/D DATA: flags snd.sbcc val_len",
|
|
|
|
tpcb->tp_flags, so->so_snd.sb_cc, val_len, 0);
|
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
*mp = MNULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (optname == TPOPT_CFRM_DATA && (so->so_state & SS_ISCONFIRMING))
|
|
|
|
(void) tp_confirm(tpcb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case TPOPT_PERF_MEAS:
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef TP_PERF_MEAS
|
|
|
|
if (cmd == PRCO_GETOPT) {
|
1996-02-14 01:07:57 +03:00
|
|
|
*value = (u_int) tpcb->tp_perf_on;
|
1993-04-09 16:00:07 +04:00
|
|
|
(*mp)->m_len = sizeof(u_int);
|
|
|
|
} else if (cmd == PRCO_SETOPT) {
|
|
|
|
(*mp)->m_len = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((*value) != 0 && (*value) != 1)
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
1996-02-14 01:07:57 +03:00
|
|
|
else
|
|
|
|
tpcb->tp_perf_on = (*value);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if (tpcb->tp_perf_on)
|
1993-04-09 16:00:07 +04:00
|
|
|
error = tp_setup_perf(tpcb);
|
1996-02-14 01:07:57 +03:00
|
|
|
#else /* TP_PERF_MEAS */
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EOPNOTSUPP;
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* TP_PERF_MEAS */
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
done:
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_mbuf(so->so_snd.sb_mb, "tp_ctloutput sosnd at end");
|
|
|
|
dump_mbuf(*mp, "tp_ctloutput *mp");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* sigh: getsockopt looks only at m_len : all output data must reside
|
|
|
|
* in the first mbuf
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
if (*mp) {
|
|
|
|
if (cmd == PRCO_SETOPT) {
|
|
|
|
m_freem(*mp);
|
|
|
|
*mp = MNULL;
|
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
ASSERT(m_compress(*mp, mp) <= MLEN);
|
1994-05-13 10:08:03 +04:00
|
|
|
if (error)
|
|
|
|
(*mp)->m_len = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_REQUEST]) {
|
1994-05-13 10:08:03 +04:00
|
|
|
dump_mbuf(*mp, "tp_ctloutput *mp after compress");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return error;
|
|
|
|
}
|