Lines Matching refs:connection

63  * The ndmp connection version can be set through command line. If command line
99 static int ndmp_recv_msg(ndmp_connection_t *connection);
100 static int ndmp_process_messages(ndmp_connection_t *connection,
102 static ndmp_msg_handler_t *ndmp_get_handler(ndmp_connection_t *connection,
121 * Allocate and initialize a connection structure.
128 * connection pointer
131 * The returned connection should be destroyed using
137 ndmp_connection_t *connection;
139 connection = ndmp_malloc(sizeof (ndmp_connection_t));
140 if (connection == NULL)
143 connection->conn_sock = -1;
144 connection->conn_my_sequence = 0;
145 connection->conn_authorized = FALSE;
146 connection->conn_eof = FALSE;
147 connection->conn_msginfo.mi_body = 0;
148 connection->conn_version = ndmp_ver;
149 connection->conn_client_data = 0;
150 (void) mutex_init(&connection->conn_lock, 0, NULL);
151 connection->conn_xdrs.x_ops = 0;
153 xdrrec_create(&connection->conn_xdrs, 0, 0, (caddr_t)connection,
156 if (connection->conn_xdrs.x_ops == 0) {
158 (void) mutex_destroy(&connection->conn_lock);
159 (void) close(connection->conn_sock);
160 free(connection);
163 return ((ndmp_connection_t *)connection);
169 * Shutdown a connection and release allocated resources.
172 * connection_handle (Input) - connection handle.
180 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
182 if (connection->conn_sock >= 0) {
183 (void) mutex_destroy(&connection->conn_lock);
184 (void) close(connection->conn_sock);
185 connection->conn_sock = -1;
187 xdr_destroy(&connection->conn_xdrs);
188 free(connection);
195 * Close a connection.
198 * connection_handle (Input) - connection handle.
206 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
208 ndmpd_audit_disconnect(connection);
209 if (connection->conn_sock >= 0) {
210 (void) mutex_destroy(&connection->conn_lock);
211 (void) close(connection->conn_sock);
212 connection->conn_sock = -1;
214 connection->conn_eof = TRUE;
217 * We should close all the tapes that are used by this connection.
219 * tape and closes the connection.
247 * Accepts connections and passes each connection to the connection
256 * handler (input) - connection handler function.
306 NDMP_LOG(LOG_DEBUG, "connection fd: %d", ns);
325 * 0 - successful connection.
332 ndmp_connection_t *connection;
341 if ((connection = ndmp_create_connection()) == NULL) {
348 if (adt_start_session(&connection->conn_ah, NULL, 0) != 0) {
353 ((ndmp_connection_t *)connection)->conn_sock = sock;
354 (*argp->nw_con_handler_func)(connection);
355 (void) adt_end_session(connection->conn_ah);
356 ndmp_destroy_connection(connection);
370 * connection_handle (input) - connection handle.
374 * -1 - error; connection no longer established.
380 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
382 (void) mutex_lock(&connection->conn_lock);
384 if (ndmp_process_messages(connection, FALSE) < 0)
387 (void) mutex_unlock(&connection->conn_lock);
398 * connection_handle (input) - connection pointer.
417 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
424 if (!(handler = ndmp_get_handler(connection, message))) {
431 header.sequence = ++(connection->conn_my_sequence);
438 connection->conn_xdrs.x_op = XDR_ENCODE;
439 if (!xdr_ndmp_header(&connection->conn_xdrs, &header)) {
442 (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
446 if (!(*handler->mh_xdr_request)(&connection->conn_xdrs,
451 (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
455 (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
467 r = ndmp_process_messages(connection, TRUE);
469 /* connection error? */
480 connection->conn_msginfo.mi_hdr.message) {
483 connection->conn_msginfo.mi_hdr.message);
488 *reply = connection->conn_msginfo.mi_body;
492 return (connection->conn_msginfo.mi_hdr.error);
507 * connection_handle (input) - connection pointer.
527 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
529 (void) mutex_lock(&connection->conn_lock);
533 (void) mutex_unlock(&connection->conn_lock);
544 * connection_handle (input) - connection pointer.
559 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
565 header.sequence = ++(connection->conn_my_sequence);
568 header.message = connection->conn_msginfo.mi_hdr.message;
569 header.reply_sequence = connection->conn_msginfo.mi_hdr.sequence;
572 connection->conn_xdrs.x_op = XDR_ENCODE;
573 if (!xdr_ndmp_header(&connection->conn_xdrs, &header)) {
577 (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
581 connection->conn_msginfo.mi_handler->mh_xdr_reply &&
583 if (!(*connection->conn_msginfo.mi_handler->mh_xdr_reply)(
584 &connection->conn_xdrs, reply)) {
588 (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
592 (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
602 * connection_handle (input) - connection pointer.
611 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
613 if (connection->conn_msginfo.mi_handler == NULL ||
614 connection->conn_msginfo.mi_body == NULL)
617 connection->conn_xdrs.x_op = XDR_FREE;
618 if (connection->conn_msginfo.mi_hdr.message_type ==
620 if (connection->conn_msginfo.mi_handler->mh_xdr_request)
621 (*connection->conn_msginfo.mi_handler->mh_xdr_request)(
622 &connection->conn_xdrs,
623 connection->conn_msginfo.mi_body);
625 if (connection->conn_msginfo.mi_handler->mh_xdr_reply)
626 (*connection->conn_msginfo.mi_handler->mh_xdr_reply)(
627 &connection->conn_xdrs,
628 connection->conn_msginfo.mi_body);
631 (void) free(connection->conn_msginfo.mi_body);
632 connection->conn_msginfo.mi_body = 0;
638 * Returns the connection file descriptor.
641 * connection_handle (input) - connection handle
645 * -1 - connection not open.
662 * connection_handle (input) - connection handle.
684 * connection_handle (input) - connection handle.
699 * Sets the NDMP protocol version to be used on the connection.
702 * connection_handle (input) - connection handle.
718 * Gets the NDMP protocol version in use on the connection.
721 * connection_handle (input) - connection handle.
737 * Mark the connection as either having been authorized or not.
740 * connection_handle (input) - connection handle.
793 * NDMP connection handler.
794 * Waits for, reads, and processes NDMP requests on a connection.
797 * connection (input) - connection handle.
803 connection_handler(ndmp_connection_t *connection)
811 session.ns_connection = connection;
853 ndmp_set_client_data(connection, (void *)&session);
859 if (ndmp_send_request_lock(connection, NDMP_NOTIFY_CONNECTION_STATUS,
864 connection_fd = ndmp_get_fd(connection);
869 * Add the handler function for the connection to the DMA.
878 * Register the connection in the list of active connections.
880 if (ndmp_connect_list_add(connection, &conn_id) != 0) {
916 (void) ndmp_connect_list_del(connection);
925 * NDMP connection.
929 * fd (input) - connection file descriptor.
954 * connection (input) - connection pointer.
965 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
967 len = read(connection->conn_sock, buf, len);
970 connection->conn_eof = TRUE;
982 * connection (input) - connection pointer.
993 ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
998 if ((n = write(connection->conn_sock, buf, cnt)) < 0) {
999 connection->conn_eof = TRUE;
1014 * connection (input) - connection pointer.
1023 ndmp_recv_msg(ndmp_connection_t *connection)
1028 connection->conn_xdrs.x_op = XDR_DECODE;
1029 (void) xdrrec_skiprecord(&connection->conn_xdrs);
1030 if (!xdr_ndmp_header(&connection->conn_xdrs,
1031 &connection->conn_msginfo.mi_hdr))
1035 if ((connection->conn_msginfo.mi_handler = ndmp_get_handler(connection,
1036 connection->conn_msginfo.mi_hdr.message)) == 0) {
1038 connection->conn_msginfo.mi_hdr.message);
1041 connection->conn_msginfo.mi_body = 0;
1043 if (connection->conn_msginfo.mi_hdr.error != NDMP_NO_ERR)
1047 if (connection->conn_msginfo.mi_hdr.message_type ==
1050 connection->conn_msginfo.mi_hdr.message) &&
1051 !connection->conn_authorized) {
1053 "Processing request 0x%x:connection not authorized",
1054 connection->conn_msginfo.mi_hdr.message);
1057 if (connection->conn_msginfo.mi_handler->mh_sizeof_request >
1060 connection->conn_msginfo.mi_handler->mh_xdr_request;
1065 connection->conn_msginfo.mi_hdr.message);
1068 connection->conn_msginfo.mi_body = ndmp_malloc(
1069 connection->conn_msginfo.mi_handler->
1071 if (connection->conn_msginfo.mi_body == NULL)
1074 (void) memset(connection->conn_msginfo.mi_body, 0,
1075 connection->conn_msginfo.mi_handler->
1079 if (connection->conn_msginfo.mi_handler->mh_sizeof_reply > 0) {
1081 connection->conn_msginfo.mi_handler->mh_xdr_reply;
1086 connection->conn_msginfo.mi_hdr.message);
1089 connection->conn_msginfo.mi_body = ndmp_malloc(
1090 connection->conn_msginfo.mi_handler->
1092 if (connection->conn_msginfo.mi_body == NULL)
1095 (void) memset(connection->conn_msginfo.mi_body, 0,
1096 connection->conn_msginfo.mi_handler->
1103 if (!(*xdr_func)(&connection->conn_xdrs,
1104 connection->conn_msginfo.mi_body)) {
1107 connection->conn_msginfo.mi_hdr.message);
1108 free(connection->conn_msginfo.mi_body);
1109 connection->conn_msginfo.mi_body = 0;
1132 * A reply message, if received, is placed in connection->conn_msginfo
1138 * connection (input) - connection pointer.
1151 * NDMP_PROC_REP_ERR - error; connection no longer established.
1164 ndmp_process_messages(ndmp_connection_t *connection, boolean_t reply_expected)
1177 (void) memset((void *)&connection->conn_msginfo, 0,
1180 if ((err = ndmp_recv_msg(connection)) != NDMP_NO_ERR) {
1181 if (connection->conn_eof) {
1205 if (connection->conn_msginfo.mi_hdr.message_type
1208 connection->conn_msginfo.mi_hdr.message);
1214 connection->conn_msginfo.mi_hdr.
1218 connection);
1227 connection->conn_msginfo.mi_hdr.message);
1230 connection, err, NULL);
1231 ndmp_free_message((ndmp_connection_t *)connection);
1234 if (connection->conn_msginfo.mi_hdr.message_type
1237 connection->conn_msginfo.mi_hdr.message);
1242 connection->conn_msginfo.mi_hdr.message);
1244 connection);
1248 reply_msginfo = connection->conn_msginfo;
1252 connection->conn_msginfo.mi_hdr.message);
1259 if (connection->conn_msginfo.mi_handler->mh_func == NULL) {
1261 connection->conn_msginfo.mi_hdr.message);
1264 connection, NDMP_NOT_SUPPORTED_ERR, NULL);
1265 ndmp_free_message((ndmp_connection_t *)connection);
1272 (*connection->conn_msginfo.mi_handler->mh_func) (connection,
1273 connection->conn_msginfo.mi_body);
1275 ndmp_free_message((ndmp_connection_t *)connection);
1277 } while (xdrrec_eof(&connection->conn_xdrs) == FALSE &&
1278 connection->conn_eof == FALSE);
1282 if (connection->conn_eof == TRUE) {
1293 connection->conn_msginfo = reply_msginfo;
1334 * connection (input) - connection pointer.
1342 ndmp_get_handler(ndmp_connection_t *connection, ndmp_message message)
1347 int ver = connection->conn_version;
1358 * Check if the connection needs to be authenticated before
1387 * inaddr_p (output) - the IP address of peer connection
1390 * socket for the accepted connection
1416 * Get the peer IP address for a connection
1420 * inaddr_p (output) - the IP address of peer connection
1421 * port_p (output) - the port number of peer connection
1424 * socket for the accepted connection