t_getinfo.c (7c478bd9) t_getinfo.c (61961e0f)
1/*
2 * CDDL HEADER START
3 *
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
7 * with the License.
8 *

--- 5 unchanged lines hidden (view full) ---

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]
19 *
20 * CDDL HEADER END
21 */
1/*
2 * CDDL HEADER START
3 *
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
7 * with the License.
8 *

--- 5 unchanged lines hidden (view full) ---

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]
19 *
20 * CDDL HEADER END
21 */
22
22/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23/* All Rights Reserved */
24
23/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
24/* All Rights Reserved */
25
25
26/*
26/*
27 * Copyright 1993-2003 Sun Microsystems, Inc. All rights reserved.
27 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
28 * Use is subject to license terms.
29 */
30
31
32#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
33
34#include "mt.h"
31#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
32
33#include "mt.h"
35#include <errno.h>
36#include <sys/types.h>
37#include <unistd.h>
38#include <stdlib.h>
34#include <stdlib.h>
39#include <rpc/trace.h>
35#include <string.h>
36#include <strings.h>
37#include <unistd.h>
38#include <errno.h>
39#include <stropts.h>
40#include <sys/stream.h>
41#define _SUN_TPI_VERSION 2
42#include <sys/tihdr.h>
43#include <sys/timod.h>
40#include <sys/stream.h>
41#define _SUN_TPI_VERSION 2
42#include <sys/tihdr.h>
43#include <sys/timod.h>
44#include <sys/stat.h>
44#include <xti.h>
45#include <xti.h>
46#include <fcntl.h>
45#include <signal.h>
47#include <signal.h>
46#include <stropts.h>
48#include <assert.h>
49#include <syslog.h>
50#include <limits.h>
47#include "tx.h"
48
49int
50_tx_getinfo(int fd, struct t_info *info, int api_semantics)
51{
52 struct T_info_req *inforeqp;
53 struct T_info_ack *infoackp;
54 int retlen;
55 struct _ti_user *tiptr;
56 int retval, sv_errno, didalloc;
57 struct strbuf ctlbuf;
58
51#include "tx.h"
52
53int
54_tx_getinfo(int fd, struct t_info *info, int api_semantics)
55{
56 struct T_info_req *inforeqp;
57 struct T_info_ack *infoackp;
58 int retlen;
59 struct _ti_user *tiptr;
60 int retval, sv_errno, didalloc;
61 struct strbuf ctlbuf;
62
59 trace2(TR_t_getinfo, 0, fd);
60 if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == 0) {
61 sv_errno = errno;
62 trace2(TR_t_getinfo, 1, fd);
63 errno = sv_errno;
63 if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == 0)
64 return (-1);
64 return (-1);
65 }
66 sig_mutex_lock(&tiptr->ti_lock);
67
68 /*
69 * Acquire buffer for use in sending/receiving the message.
70 * Note: assumes (correctly) that ti_ctlsize is large enough
71 * to hold sizeof (struct T_info_req/ack)
72 */
73 if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) {
74 sv_errno = errno;
75 sig_mutex_unlock(&tiptr->ti_lock);
65 sig_mutex_lock(&tiptr->ti_lock);
66
67 /*
68 * Acquire buffer for use in sending/receiving the message.
69 * Note: assumes (correctly) that ti_ctlsize is large enough
70 * to hold sizeof (struct T_info_req/ack)
71 */
72 if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) {
73 sv_errno = errno;
74 sig_mutex_unlock(&tiptr->ti_lock);
76 trace2(TR_t_getinfo, 1, fd);
77 errno = sv_errno;
78 return (-1);
79 }
80
75 errno = sv_errno;
76 return (-1);
77 }
78
79 /* LINTED pointer cast */
81 inforeqp = (struct T_info_req *)ctlbuf.buf;
82 inforeqp->PRIM_type = T_INFO_REQ;
83
84 do {
85 retval = _t_do_ioctl(fd, ctlbuf.buf,
86 (int)sizeof (struct T_info_req), TI_GETINFO, &retlen);
87 } while (retval < 0 && errno == EINTR);
88
89 if (retval < 0)
90 goto err_out;
91
92 if (retlen != (int)sizeof (struct T_info_ack)) {
93 t_errno = TSYSERR;
94 errno = EIO;
95 goto err_out;
96 }
97
80 inforeqp = (struct T_info_req *)ctlbuf.buf;
81 inforeqp->PRIM_type = T_INFO_REQ;
82
83 do {
84 retval = _t_do_ioctl(fd, ctlbuf.buf,
85 (int)sizeof (struct T_info_req), TI_GETINFO, &retlen);
86 } while (retval < 0 && errno == EINTR);
87
88 if (retval < 0)
89 goto err_out;
90
91 if (retlen != (int)sizeof (struct T_info_ack)) {
92 t_errno = TSYSERR;
93 errno = EIO;
94 goto err_out;
95 }
96
97 /* LINTED pointer cast */
98 infoackp = (struct T_info_ack *)ctlbuf.buf;
99
100 info->addr = infoackp->ADDR_size;
101 info->options = infoackp->OPT_size;
102 info->tsdu = infoackp->TSDU_size;
103 info->etsdu = infoackp->ETSDU_size;
104 info->connect = infoackp->CDATA_size;
105 info->discon = infoackp->DDATA_size;

--- 5 unchanged lines hidden (view full) ---

111 if (infoackp->PROVIDER_flag & (SENDZERO|OLD_SENDZERO))
112 info->flags |= T_SENDZERO;
113 }
114 if (didalloc)
115 free(ctlbuf.buf);
116 else
117 tiptr->ti_ctlbuf = ctlbuf.buf;
118 sig_mutex_unlock(&tiptr->ti_lock);
98 infoackp = (struct T_info_ack *)ctlbuf.buf;
99
100 info->addr = infoackp->ADDR_size;
101 info->options = infoackp->OPT_size;
102 info->tsdu = infoackp->TSDU_size;
103 info->etsdu = infoackp->ETSDU_size;
104 info->connect = infoackp->CDATA_size;
105 info->discon = infoackp->DDATA_size;

--- 5 unchanged lines hidden (view full) ---

111 if (infoackp->PROVIDER_flag & (SENDZERO|OLD_SENDZERO))
112 info->flags |= T_SENDZERO;
113 }
114 if (didalloc)
115 free(ctlbuf.buf);
116 else
117 tiptr->ti_ctlbuf = ctlbuf.buf;
118 sig_mutex_unlock(&tiptr->ti_lock);
119 trace2(TR_t_getinfo, 1, fd);
120 return (0);
121
122err_out:
123 sv_errno = errno;
124 if (didalloc)
125 free(ctlbuf.buf);
126 else
127 tiptr->ti_ctlbuf = ctlbuf.buf;
128 sig_mutex_unlock(&tiptr->ti_lock);
119 return (0);
120
121err_out:
122 sv_errno = errno;
123 if (didalloc)
124 free(ctlbuf.buf);
125 else
126 tiptr->ti_ctlbuf = ctlbuf.buf;
127 sig_mutex_unlock(&tiptr->ti_lock);
129 trace2(TR_t_getinfo, 1, fd);
130 errno = sv_errno;
131 return (-1);
132}
128 errno = sv_errno;
129 return (-1);
130}