2 * Copyright (c) 1998,1999,2000
3 * Traakan, Inc., Los Altos, CA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice unmodified, this list of conditions, and the following
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include "ndmagents.h"
41 #ifndef NDMOS_OPTION_NO_DATA_AGENT
45 * DATA Agent originated calls
46 ****************************************************************
50 ndma_notify_data_halted (struct ndm_session *sess)
52 struct ndmconn * conn = sess->plumb.control;
53 struct ndm_data_agent * da = &sess->data_acb;
55 assert (da->data_state.state == NDMP9_DATA_STATE_HALTED);
56 assert (da->data_state.halt_reason != NDMP9_DATA_HALT_NA);
58 NDMC_WITH_NO_REPLY(ndmp9_notify_data_halted, NDMP9VER)
59 request->reason = da->data_state.halt_reason;
60 ndma_send_to_control (sess, xa, sess->plumb.data);
67 ndma_notify_data_read (struct ndm_session *sess,
68 unsigned long long offset, unsigned long long length)
70 struct ndmconn * conn = sess->plumb.control;
72 NDMC_WITH_NO_REPLY(ndmp9_notify_data_read, NDMP9VER)
73 request->offset = offset;
74 request->length = length;
75 ndma_send_to_control (sess, xa, sess->plumb.data);
81 #endif /* !NDMOS_OPTION_NO_DATA_AGENT */
84 #ifndef NDMOS_OPTION_NO_TAPE_AGENT
87 ndma_notify_mover_halted (struct ndm_session *sess)
89 struct ndmconn * conn = sess->plumb.control;
90 struct ndm_tape_agent * ta = &sess->tape_acb;
92 assert (ta->mover_state.state == NDMP9_MOVER_STATE_HALTED);
93 assert (ta->mover_state.halt_reason != NDMP9_MOVER_HALT_NA);
95 NDMC_WITH_NO_REPLY(ndmp9_notify_mover_halted, NDMP9VER)
96 request->reason = ta->mover_state.halt_reason;
97 ndma_send_to_control (sess, xa, sess->plumb.tape);
104 ndma_notify_mover_paused (struct ndm_session *sess)
106 struct ndmconn * conn = sess->plumb.control;
107 struct ndm_tape_agent * ta = &sess->tape_acb;
109 assert (ta->mover_state.state == NDMP9_MOVER_STATE_PAUSED);
110 assert (ta->mover_state.pause_reason != NDMP9_MOVER_PAUSE_NA);
112 NDMC_WITH_NO_REPLY(ndmp9_notify_mover_paused, NDMP9VER)
113 request->reason = ta->mover_state.pause_reason;
114 request->seek_position = ta->mover_want_pos;
115 ndma_send_to_control (sess, xa, sess->plumb.tape);
121 #endif /* !NDMOS_OPTION_NO_TAPE_AGENT */
124 #ifndef NDMOS_EFFECT_NO_SERVER_AGENTS
127 ndma_send_logmsg (struct ndm_session *sess, ndmp9_log_type ltype,
128 struct ndmconn *from_conn,
131 struct ndmconn * conn = from_conn;
136 vsnprintf (buf, sizeof(buf), fmt, ap);
139 switch (from_conn->protocol_version) {
140 #ifndef NDMOS_OPTION_NO_NDMP2
144 case NDMP9_LOG_NORMAL:
145 case NDMP9_LOG_ERROR:
146 case NDMP9_LOG_WARNING:
147 NDMC_WITH_NO_REPLY(ndmp2_log_log, NDMP2VER)
148 request->entry = buf;
149 ndma_send_to_control (sess, xa, from_conn);
153 case NDMP9_LOG_DEBUG:
154 NDMC_WITH_NO_REPLY(ndmp2_log_debug, NDMP2VER)
155 request->level = NDMP2_DBG_USER_INFO;
156 request->message = buf;
157 ndma_send_to_control (sess, xa, from_conn);
162 #endif /* !NDMOS_OPTION_NO_NDMP2 */
163 #ifndef NDMOS_OPTION_NO_NDMP3
165 NDMC_WITH_NO_REPLY(ndmp3_log_message, NDMP3VER)
168 case NDMP9_LOG_NORMAL:
169 request->log_type = NDMP3_LOG_NORMAL;
172 case NDMP9_LOG_DEBUG:
173 request->log_type = NDMP3_LOG_DEBUG;
176 case NDMP9_LOG_ERROR:
177 request->log_type = NDMP3_LOG_ERROR;
180 case NDMP9_LOG_WARNING:
181 request->log_type = NDMP3_LOG_WARNING;
184 request->message_id = time(0);
185 request->entry = buf;
186 ndma_send_to_control (sess, xa, from_conn);
189 #endif /* !NDMOS_OPTION_NO_NDMP3 */
190 #ifndef NDMOS_OPTION_NO_NDMP4
192 NDMC_WITH_POST(ndmp4_log_message, NDMP4VER)
195 case NDMP9_LOG_NORMAL:
196 request->log_type = NDMP4_LOG_NORMAL;
199 case NDMP9_LOG_DEBUG:
200 request->log_type = NDMP4_LOG_DEBUG;
203 case NDMP9_LOG_ERROR:
204 request->log_type = NDMP4_LOG_ERROR;
207 case NDMP9_LOG_WARNING:
208 request->log_type = NDMP4_LOG_WARNING;
211 request->message_id = time(0);
212 request->entry = buf;
213 ndma_send_to_control (sess, xa, from_conn);
216 #endif /* !NDMOS_OPTION_NO_NDMP4 */
224 #endif /* !NDMOS_EFFECT_NO_SERVER_AGENTS */