4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #pragma ident "%Z%%M% %I% %E% SMI"
38 #include <netinet/tcp.h>
44 __td_setnodelay(int fd
)
47 static mutex_t td_opt_lock
= DEFAULTMUTEX
;
48 static struct t_optmgmt t_optreq
, t_optret
;
52 /* VARIABLES PROTECTED BY td_opt_lock: t_optreq, t_optret */
54 if ((state
= t_getstate(fd
)) == -1)
57 (void) mutex_lock(&td_opt_lock
);
58 if ((state
== T_IDLE
) && (t_optreq
.flags
!= T_NEGOTIATE
)) {
62 t_optreq
.flags
= T_NEGOTIATE
;
63 t_optreq
.opt
.maxlen
= MAXOPTSIZE
;
64 t_optreq
.opt
.buf
= malloc(MAXOPTSIZE
);
65 if (t_optreq
.opt
.buf
== NULL
) {
66 (void) mutex_unlock(&td_opt_lock
);
70 /* LINTED pointer cast */
71 opt
= (struct opthdr
*)(t_optreq
.opt
.buf
);
72 opt
->name
= TCP_NODELAY
;
74 opt
->level
= IPPROTO_TCP
;
75 (void) memcpy((caddr_t
)(t_optreq
.opt
.buf
+
76 sizeof (struct opthdr
)), &i
, sizeof (int));
77 t_optreq
.opt
.len
= (int)(sizeof (struct opthdr
) +
80 t_optret
.opt
.maxlen
= MAXOPTSIZE
;
82 t_optret
.opt
.buf
= malloc(MAXOPTSIZE
);
83 if (t_optret
.opt
.buf
== NULL
) {
84 (void) mutex_unlock(&td_opt_lock
);
85 free(t_optreq
.opt
.buf
);
92 rval
= t_optmgmt(fd
, &t_optreq
, &t_optret
);
94 (void) mutex_unlock(&td_opt_lock
);