Imported Upstream version 3.3.1
[debian/amanda] / perl / Amanda / NDMP.pm
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 2.0.4
3 #
4 # Do not make changes to this file unless you know what you are doing--modify
5 # the SWIG interface file instead.
6
7 package Amanda::NDMP;
8 use base qw(Exporter);
9 use base qw(DynaLoader);
10 package Amanda::NDMPc;
11 bootstrap Amanda::NDMP;
12 package Amanda::NDMP;
13 @EXPORT = qw();
14
15 # ---------- BASE METHODS -------------
16
17 package Amanda::NDMP;
18
19 sub TIEHASH {
20     my ($classname,$obj) = @_;
21     return bless $obj, $classname;
22 }
23
24 sub CLEAR { }
25
26 sub FIRSTKEY { }
27
28 sub NEXTKEY { }
29
30 sub FETCH {
31     my ($self,$field) = @_;
32     my $member_func = "swig_${field}_get";
33     $self->$member_func();
34 }
35
36 sub STORE {
37     my ($self,$field,$newval) = @_;
38     my $member_func = "swig_${field}_set";
39     $self->$member_func($newval);
40 }
41
42 sub this {
43     my $ptr = shift;
44     return tied(%$ptr);
45 }
46
47
48 # ------- FUNCTION WRAPPERS --------
49
50 package Amanda::NDMP;
51
52
53 ############# Class : Amanda::NDMP::NDMPConnection ##############
54
55 package Amanda::NDMP::NDMPConnection;
56 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
57 @ISA = qw( Amanda::NDMP );
58 %OWNER = ();
59 %ITERATORS = ();
60 sub new {
61     my $pkg = shift;
62     my $self = Amanda::NDMPc::new_NDMPConnection(@_);
63     bless $self, $pkg if defined($self);
64 }
65
66 sub DESTROY {
67     return unless $_[0]->isa('HASH');
68     my $self = tied(%{$_[0]});
69     return unless defined $self;
70     delete $ITERATORS{$self};
71     if (exists $OWNER{$self}) {
72         Amanda::NDMPc::delete_NDMPConnection($self);
73         delete $OWNER{$self};
74     }
75 }
76
77 *err_code = *Amanda::NDMPc::NDMPConnection_err_code;
78 *err_msg = *Amanda::NDMPc::NDMPConnection_err_msg;
79 *set_verbose = *Amanda::NDMPc::NDMPConnection_set_verbose;
80 *scsi_open = *Amanda::NDMPc::NDMPConnection_scsi_open;
81 *scsi_close = *Amanda::NDMPc::NDMPConnection_scsi_close;
82 *scsi_execute_cdb_C = *Amanda::NDMPc::NDMPConnection_scsi_execute_cdb_C;
83 *tape_open = *Amanda::NDMPc::NDMPConnection_tape_open;
84 *tape_close = *Amanda::NDMPc::NDMPConnection_tape_close;
85 *tape_mtio = *Amanda::NDMPc::NDMPConnection_tape_mtio;
86 *tape_write = *Amanda::NDMPc::NDMPConnection_tape_write;
87 *tape_read = *Amanda::NDMPc::NDMPConnection_tape_read;
88 *tape_get_state = *Amanda::NDMPc::NDMPConnection_tape_get_state;
89 sub DISOWN {
90     my $self = shift;
91     my $ptr = tied(%$self);
92     delete $OWNER{$ptr};
93 }
94
95 sub ACQUIRE {
96     my $self = shift;
97     my $ptr = tied(%$self);
98     $OWNER{$ptr} = 1;
99 }
100
101
102 # ------- VARIABLE STUBS --------
103
104 package Amanda::NDMP;
105
106 *NDMP9_SCSI_DATA_DIR_NONE = *Amanda::NDMPc::NDMP9_SCSI_DATA_DIR_NONE;
107 *NDMP9_SCSI_DATA_DIR_IN = *Amanda::NDMPc::NDMP9_SCSI_DATA_DIR_IN;
108 *NDMP9_SCSI_DATA_DIR_OUT = *Amanda::NDMPc::NDMP9_SCSI_DATA_DIR_OUT;
109 *NDMP9_TAPE_READ_MODE = *Amanda::NDMPc::NDMP9_TAPE_READ_MODE;
110 *NDMP9_TAPE_RDWR_MODE = *Amanda::NDMPc::NDMP9_TAPE_RDWR_MODE;
111 *NDMP9_TAPE_RAW_MODE = *Amanda::NDMPc::NDMP9_TAPE_RAW_MODE;
112 *NDMP9_MTIO_FSF = *Amanda::NDMPc::NDMP9_MTIO_FSF;
113 *NDMP9_MTIO_BSF = *Amanda::NDMPc::NDMP9_MTIO_BSF;
114 *NDMP9_MTIO_FSR = *Amanda::NDMPc::NDMP9_MTIO_FSR;
115 *NDMP9_MTIO_BSR = *Amanda::NDMPc::NDMP9_MTIO_BSR;
116 *NDMP9_MTIO_REW = *Amanda::NDMPc::NDMP9_MTIO_REW;
117 *NDMP9_MTIO_EOF = *Amanda::NDMPc::NDMP9_MTIO_EOF;
118 *NDMP9_MTIO_OFF = *Amanda::NDMPc::NDMP9_MTIO_OFF;
119 *NDMP9_MOVER_MODE_READ = *Amanda::NDMPc::NDMP9_MOVER_MODE_READ;
120 *NDMP9_MOVER_MODE_WRITE = *Amanda::NDMPc::NDMP9_MOVER_MODE_WRITE;
121 *NDMP9_ADDR_LOCAL = *Amanda::NDMPc::NDMP9_ADDR_LOCAL;
122 *NDMP9_ADDR_TCP = *Amanda::NDMPc::NDMP9_ADDR_TCP;
123 *NDMP9_ADDR_AS_CONNECTED = *Amanda::NDMPc::NDMP9_ADDR_AS_CONNECTED;
124 *NDMP9_MOVER_STATE_IDLE = *Amanda::NDMPc::NDMP9_MOVER_STATE_IDLE;
125 *NDMP9_MOVER_STATE_LISTEN = *Amanda::NDMPc::NDMP9_MOVER_STATE_LISTEN;
126 *NDMP9_MOVER_STATE_ACTIVE = *Amanda::NDMPc::NDMP9_MOVER_STATE_ACTIVE;
127 *NDMP9_MOVER_STATE_PAUSED = *Amanda::NDMPc::NDMP9_MOVER_STATE_PAUSED;
128 *NDMP9_MOVER_STATE_HALTED = *Amanda::NDMPc::NDMP9_MOVER_STATE_HALTED;
129 *NDMP9_MOVER_STATE_STANDBY = *Amanda::NDMPc::NDMP9_MOVER_STATE_STANDBY;
130 *NDMP9_DATA_HALT_NA = *Amanda::NDMPc::NDMP9_DATA_HALT_NA;
131 *NDMP9_DATA_HALT_SUCCESSFUL = *Amanda::NDMPc::NDMP9_DATA_HALT_SUCCESSFUL;
132 *NDMP9_DATA_HALT_ABORTED = *Amanda::NDMPc::NDMP9_DATA_HALT_ABORTED;
133 *NDMP9_DATA_HALT_INTERNAL_ERROR = *Amanda::NDMPc::NDMP9_DATA_HALT_INTERNAL_ERROR;
134 *NDMP9_DATA_HALT_CONNECT_ERROR = *Amanda::NDMPc::NDMP9_DATA_HALT_CONNECT_ERROR;
135 *NDMP9_MOVER_HALT_NA = *Amanda::NDMPc::NDMP9_MOVER_HALT_NA;
136 *NDMP9_MOVER_HALT_CONNECT_CLOSED = *Amanda::NDMPc::NDMP9_MOVER_HALT_CONNECT_CLOSED;
137 *NDMP9_MOVER_HALT_ABORTED = *Amanda::NDMPc::NDMP9_MOVER_HALT_ABORTED;
138 *NDMP9_MOVER_HALT_INTERNAL_ERROR = *Amanda::NDMPc::NDMP9_MOVER_HALT_INTERNAL_ERROR;
139 *NDMP9_MOVER_HALT_CONNECT_ERROR = *Amanda::NDMPc::NDMP9_MOVER_HALT_CONNECT_ERROR;
140 *NDMP9_MOVER_PAUSE_NA = *Amanda::NDMPc::NDMP9_MOVER_PAUSE_NA;
141 *NDMP9_MOVER_PAUSE_EOM = *Amanda::NDMPc::NDMP9_MOVER_PAUSE_EOM;
142 *NDMP9_MOVER_PAUSE_EOF = *Amanda::NDMPc::NDMP9_MOVER_PAUSE_EOF;
143 *NDMP9_MOVER_PAUSE_SEEK = *Amanda::NDMPc::NDMP9_MOVER_PAUSE_SEEK;
144 *NDMP9_MOVER_PAUSE_MEDIA_ERROR = *Amanda::NDMPc::NDMP9_MOVER_PAUSE_MEDIA_ERROR;
145 *NDMP9_MOVER_PAUSE_EOW = *Amanda::NDMPc::NDMP9_MOVER_PAUSE_EOW;
146
147 @EXPORT_OK = ();
148 %EXPORT_TAGS = ();
149
150
151 =head1 NAME
152
153 Amanda::NDMP - communicate via NDMP
154
155 =head1 SYNOPSIS
156
157   use Amanda::NDMP qw( :constants );
158
159   my $conn = Amanda::NDMP::NDMPConnection->new($host, $port, $ident, $username,
160                                                $password, $auth);
161   my ($ok, $blocksize, $file_num, $blockno) = $conn->tape_get_state();
162
163 =head1 DESCRIPTION
164
165 This package interfaces with the C class C<NDMPConnection> class declared in
166 C<ndmp-src/ndmpconnobj.h>.  It is only available in builds that did not specify
167 C<--without-ndmp>.  The C class, in turn, interfaces to the XDR code provided
168 by NDMJOB, which sends and receives NDMP messages on a TCP socket.
169
170 =head2 Constructor
171
172   my $conn = Amanda::NDMP::NDMPConnection->new($host, $port, $ident, $username,
173                                                $password, $auth);
174   if ($conn->err_code()) {
175     # handle error..
176   }
177
178 This gets a new connection object.  This will always return an object, but the
179 result should be checked for errors as described in the "Error Handling"
180 section, below.
181
182 The C<$host> and C<$port> give the NDMP server's host and port, respectively.
183 The C<$auth> parameter defines the authentication mechanism to use: "md5" or
184 "text"; "none" for no authentication; or "void" to not send any authentication
185 packets at all.  For md5 or text modes, C<$username> and C<$password> specify
186 the username and password for the NDMP server; these parameters must always be
187 included, but can be blank for none or void.
188
189 The C<$ident> parameter deserves some explanation.  NDMP scopes many
190 server-side variables to the NDMP connection - for example, the "current" tape
191 and taper state are associated with the NDMP connection.  To facilitate this,
192 the constructor returns the I<same connection> for any constructor invocation
193 with the same host, port, and identifier.  In cases where multiple connections
194 are required (e.g., when two tapes are in use simultaneously), callers should
195 provide different identifiers for each connection.
196
197 =head2 Methods
198
199 Note that not all NDMPConnection methods are available.  All of these methods
200 block until the appropriate reply is received.  The underlying C class provides
201 appropriate locking fundamentals to prevent corrupted on-the-wire messages.
202
203 All methods return a boolean "ok" status, with false indicating an error.
204
205 =head3 Error Handling
206
207   my $code = $conn->err_code();
208   my $msg = $conn->err_msg();
209
210 Get the error code and message from the last method that returned false, or
211 after the constructor is invoked.
212
213   $conn->set_verbose(1);
214
215 This method will enable verbose logging of the NDMP transactions to the Amanda
216 debug logs.
217
218 =head3 SCSI Interface
219
220   my $ok = $conn->scsi_open($device);       # NDMP_SCSI_OPEN
221   my $ok = $conn->scsi_close();             # NDMP_SCSI_CLOSE
222   # NDMP_SCSI_EXECUTE_CDB
223   my $res = $conn->scsi_execute_cdb(
224     flags => $flags,
225     timeout => $timeout,
226     cdb => $cdb,
227     datain_len => $datain_len,      # only if $flags == $NDMP9_SCSI_DATA_DIR_IN
228     dataout => $dataout             # only if $flags == $NDMP9_SCSI_DATA_DIR_OUT
229   )
230
231 The first two methods are clear; the third uses keyword parameters to simplify
232 a complex set of parameters.  The C<flags> argument can be
233 C<$NDMP9_SCSI_DATA_DIR_IN>, to take data I<into> the server from the SCSI
234 device, or C<$NDMP9_SCSI_DATA_DIR_OUT> to send data I<out> to the SCSI device.
235 The C<timeout> is in milliseconds.  The C<cdb> should be a SCSI control block
236 (the C<pack> function is useful here).  If the data direction is in, then
237 C<datain_len> indicates the maximum amount of data to expect; otherwise,
238 C<dataout> is the data to send to the device.
239
240 The result is C<undef> for an error, or a hashref with the following keys:
241
242   status            SCSI status byte
243   ext_sense         SCSI extended sense data
244   datain            data from the device
245   dataout_len       number of bytes actually transmitted to the device
246
247 =head3 Tape Interface
248
249   my $ok = $conn->tape_open($device, $mode);
250   my $ok = $conn->tape_close();
251
252 The first method opens a tape device, using the give mode -
253 C<$NDMP9_TAPE_READ_MODE> or C<$NDMP9_TAPE_RDRW_MODE>.  The second method closes
254 the tape device associated with this connection.
255
256   my ($ok, $resid) = $conn->tape_mtio($op, $count);
257
258 This method sends C<NDMP_TAPE_MTIO> with the given operation and count.
259 Operations have the prefix C<$NDMP9_MTIO_>.  The number of incomplete
260 operations is returned in C<$resid>.
261
262 To read and write blocks, use these methods:
263
264   my ($ok, $actual) = $conn->tape_write($data);
265   my ($ok, $data) = $conn->tape_read($bufsize);
266
267 where C<$actual> and C<$bufsize> are byte counts, and C<$data> is a string of
268 data.  Finally, to get the state of the tape agent, use
269
270   my ($ok, $blocksize, $file_num, $blockno) = $conn->tape_get_state();
271
272 =head2 Constants
273
274 The constants required for the interface exposed here are included in this
275 package.  They all begin with the prefix C<$NDMP9_>, which is an implementation
276 detail of the NDMJOB library.  The constants are available from the export tag
277 C<constants>:
278
279   use Amanda::NDMP qw( :constants );
280
281 =cut
282
283
284
285 package Amanda::NDMP::NDMPConnection;
286
287 sub scsi_execute_cdb {
288     my $self = shift;
289     my %params = @_;
290
291     die "no 'flags' parameter'" unless defined $params{'flags'};
292     die "no 'timeout' parameter'" unless defined $params{'timeout'};
293     die "no 'cdb' parameter'" unless defined $params{'cdb'};
294     if ($params{'flags'} & $Amanda::NDMP::NDMP9_SCSI_DATA_DIR_IN) {
295         die "no 'datain_len' parameter'" unless defined $params{'datain_len'};
296     } else {
297         $params{'datain_len'} = 0;
298     }
299     if ($params{'flags'} & $Amanda::NDMP::NDMP9_SCSI_DATA_DIR_OUT) {
300         die "no 'dataout' parameter'" unless defined $params{'dataout'};
301     } else {
302         $params{'dataout'} = undef;
303     }
304
305     my ($ok, $dataout_len, $datain, $status, $ext_sense) =
306         $self->scsi_execute_cdb_C(
307             $params{'flags'}, $params{'timeout'},
308             $params{'cdb'}, $params{'dataout'},
309             $params{'datain_len'});
310
311     return 0 unless ($ok);
312
313     my %result = (
314         status => $status,
315         ext_sense => $ext_sense);
316     if ($params{'flags'} & $Amanda::NDMP::NDMP9_SCSI_DATA_DIR_IN) {
317         $result{'datain'} = $datain;
318     }
319     if ($params{'flags'} & $Amanda::NDMP::NDMP9_SCSI_DATA_DIR_OUT) {
320         $result{'dataout_len'} = $dataout_len;
321     }
322     return \%result;
323 }
324
325 package Amanda::NDMP;
326
327 push @EXPORT_OK, qw(scsi_data_dir_to_strings);
328 push @{$EXPORT_TAGS{"scsi_data_dir"}}, qw(scsi_data_dir_to_strings);
329
330 my %_scsi_data_dir_VALUES;
331 #Convert a flag value to a list of names for flags that are set.
332 sub scsi_data_dir_to_strings {
333     my ($flags) = @_;
334     my @result = ();
335
336     for my $k (keys %_scsi_data_dir_VALUES) {
337         my $v = $_scsi_data_dir_VALUES{$k};
338
339         #is this a matching flag?
340         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
341             push @result, $k;
342         }
343     }
344
345 #by default, just return the number as a 1-element list
346     if (!@result) {
347         return ($flags);
348     }
349
350     return @result;
351 }
352
353 push @EXPORT_OK, qw($NDMP9_SCSI_DATA_DIR_NONE);
354 push @{$EXPORT_TAGS{"scsi_data_dir"}}, qw($NDMP9_SCSI_DATA_DIR_NONE);
355
356 $_scsi_data_dir_VALUES{"NDMP9_SCSI_DATA_DIR_NONE"} = $NDMP9_SCSI_DATA_DIR_NONE;
357
358 push @EXPORT_OK, qw($NDMP9_SCSI_DATA_DIR_IN);
359 push @{$EXPORT_TAGS{"scsi_data_dir"}}, qw($NDMP9_SCSI_DATA_DIR_IN);
360
361 $_scsi_data_dir_VALUES{"NDMP9_SCSI_DATA_DIR_IN"} = $NDMP9_SCSI_DATA_DIR_IN;
362
363 push @EXPORT_OK, qw($NDMP9_SCSI_DATA_DIR_OUT);
364 push @{$EXPORT_TAGS{"scsi_data_dir"}}, qw($NDMP9_SCSI_DATA_DIR_OUT);
365
366 $_scsi_data_dir_VALUES{"NDMP9_SCSI_DATA_DIR_OUT"} = $NDMP9_SCSI_DATA_DIR_OUT;
367
368 #copy symbols in scsi_data_dir to constants
369 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"scsi_data_dir"}};
370
371 push @EXPORT_OK, qw(tape_open_mode_to_strings);
372 push @{$EXPORT_TAGS{"tape_open_mode"}}, qw(tape_open_mode_to_strings);
373
374 my %_tape_open_mode_VALUES;
375 #Convert a flag value to a list of names for flags that are set.
376 sub tape_open_mode_to_strings {
377     my ($flags) = @_;
378     my @result = ();
379
380     for my $k (keys %_tape_open_mode_VALUES) {
381         my $v = $_tape_open_mode_VALUES{$k};
382
383         #is this a matching flag?
384         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
385             push @result, $k;
386         }
387     }
388
389 #by default, just return the number as a 1-element list
390     if (!@result) {
391         return ($flags);
392     }
393
394     return @result;
395 }
396
397 push @EXPORT_OK, qw($NDMP9_TAPE_READ_MODE);
398 push @{$EXPORT_TAGS{"tape_open_mode"}}, qw($NDMP9_TAPE_READ_MODE);
399
400 $_tape_open_mode_VALUES{"NDMP9_TAPE_READ_MODE"} = $NDMP9_TAPE_READ_MODE;
401
402 push @EXPORT_OK, qw($NDMP9_TAPE_RDWR_MODE);
403 push @{$EXPORT_TAGS{"tape_open_mode"}}, qw($NDMP9_TAPE_RDWR_MODE);
404
405 $_tape_open_mode_VALUES{"NDMP9_TAPE_RDRW_MODE"} = $NDMP9_TAPE_RDWR_MODE;
406
407 push @EXPORT_OK, qw($NDMP9_TAPE_RAW_MODE);
408 push @{$EXPORT_TAGS{"tape_open_mode"}}, qw($NDMP9_TAPE_RAW_MODE);
409
410 $_tape_open_mode_VALUES{"NDMP9_TAPE_RAW_MODE"} = $NDMP9_TAPE_RAW_MODE;
411
412 #copy symbols in tape_open_mode to constants
413 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"tape_open_mode"}};
414
415 push @EXPORT_OK, qw(tape_mtio_op_to_strings);
416 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw(tape_mtio_op_to_strings);
417
418 my %_tape_mtio_op_VALUES;
419 #Convert a flag value to a list of names for flags that are set.
420 sub tape_mtio_op_to_strings {
421     my ($flags) = @_;
422     my @result = ();
423
424     for my $k (keys %_tape_mtio_op_VALUES) {
425         my $v = $_tape_mtio_op_VALUES{$k};
426
427         #is this a matching flag?
428         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
429             push @result, $k;
430         }
431     }
432
433 #by default, just return the number as a 1-element list
434     if (!@result) {
435         return ($flags);
436     }
437
438     return @result;
439 }
440
441 push @EXPORT_OK, qw($NDMP9_MTIO_FSF);
442 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw($NDMP9_MTIO_FSF);
443
444 $_tape_mtio_op_VALUES{"NDMP9_MTIO_FSF"} = $NDMP9_MTIO_FSF;
445
446 push @EXPORT_OK, qw($NDMP9_MTIO_BSF);
447 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw($NDMP9_MTIO_BSF);
448
449 $_tape_mtio_op_VALUES{"NDMP9_MTIO_BSF"} = $NDMP9_MTIO_BSF;
450
451 push @EXPORT_OK, qw($NDMP9_MTIO_FSR);
452 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw($NDMP9_MTIO_FSR);
453
454 $_tape_mtio_op_VALUES{"NDMP9_MTIO_FSR"} = $NDMP9_MTIO_FSR;
455
456 push @EXPORT_OK, qw($NDMP9_MTIO_BSR);
457 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw($NDMP9_MTIO_BSR);
458
459 $_tape_mtio_op_VALUES{"NDMP9_MTIO_BSR"} = $NDMP9_MTIO_BSR;
460
461 push @EXPORT_OK, qw($NDMP9_MTIO_REW);
462 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw($NDMP9_MTIO_REW);
463
464 $_tape_mtio_op_VALUES{"NDMP9_MTIO_REW"} = $NDMP9_MTIO_REW;
465
466 push @EXPORT_OK, qw($NDMP9_MTIO_EOF);
467 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw($NDMP9_MTIO_EOF);
468
469 $_tape_mtio_op_VALUES{"NDMP9_MTIO_EOF"} = $NDMP9_MTIO_EOF;
470
471 push @EXPORT_OK, qw($NDMP9_MTIO_OFF);
472 push @{$EXPORT_TAGS{"tape_mtio_op"}}, qw($NDMP9_MTIO_OFF);
473
474 $_tape_mtio_op_VALUES{"NDMP9_MTIO_OFF"} = $NDMP9_MTIO_OFF;
475
476 #copy symbols in tape_mtio_op to constants
477 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"tape_mtio_op"}};
478
479 push @EXPORT_OK, qw(mover_mode_to_strings);
480 push @{$EXPORT_TAGS{"mover_mode"}}, qw(mover_mode_to_strings);
481
482 my %_mover_mode_VALUES;
483 #Convert a flag value to a list of names for flags that are set.
484 sub mover_mode_to_strings {
485     my ($flags) = @_;
486     my @result = ();
487
488     for my $k (keys %_mover_mode_VALUES) {
489         my $v = $_mover_mode_VALUES{$k};
490
491         #is this a matching flag?
492         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
493             push @result, $k;
494         }
495     }
496
497 #by default, just return the number as a 1-element list
498     if (!@result) {
499         return ($flags);
500     }
501
502     return @result;
503 }
504
505 push @EXPORT_OK, qw($NDMP9_MOVER_MODE_READ);
506 push @{$EXPORT_TAGS{"mover_mode"}}, qw($NDMP9_MOVER_MODE_READ);
507
508 $_mover_mode_VALUES{"NDMP9_MOVER_MODE_READ"} = $NDMP9_MOVER_MODE_READ;
509
510 push @EXPORT_OK, qw($NDMP9_MOVER_MODE_WRITE);
511 push @{$EXPORT_TAGS{"mover_mode"}}, qw($NDMP9_MOVER_MODE_WRITE);
512
513 $_mover_mode_VALUES{"NDMP9_MOVER_MODE_WRITE"} = $NDMP9_MOVER_MODE_WRITE;
514
515 #copy symbols in mover_mode to constants
516 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"mover_mode"}};
517
518 push @EXPORT_OK, qw(addr_type_to_strings);
519 push @{$EXPORT_TAGS{"addr_type"}}, qw(addr_type_to_strings);
520
521 my %_addr_type_VALUES;
522 #Convert a flag value to a list of names for flags that are set.
523 sub addr_type_to_strings {
524     my ($flags) = @_;
525     my @result = ();
526
527     for my $k (keys %_addr_type_VALUES) {
528         my $v = $_addr_type_VALUES{$k};
529
530         #is this a matching flag?
531         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
532             push @result, $k;
533         }
534     }
535
536 #by default, just return the number as a 1-element list
537     if (!@result) {
538         return ($flags);
539     }
540
541     return @result;
542 }
543
544 push @EXPORT_OK, qw($NDMP9_ADDR_LOCAL);
545 push @{$EXPORT_TAGS{"addr_type"}}, qw($NDMP9_ADDR_LOCAL);
546
547 $_addr_type_VALUES{"NDMP9_ADDR_LOCAL"} = $NDMP9_ADDR_LOCAL;
548
549 push @EXPORT_OK, qw($NDMP9_ADDR_TCP);
550 push @{$EXPORT_TAGS{"addr_type"}}, qw($NDMP9_ADDR_TCP);
551
552 $_addr_type_VALUES{"NDMP9_ADDR_TCP"} = $NDMP9_ADDR_TCP;
553
554 push @EXPORT_OK, qw($NDMP9_ADDR_AS_CONNECTED);
555 push @{$EXPORT_TAGS{"addr_type"}}, qw($NDMP9_ADDR_AS_CONNECTED);
556
557 $_addr_type_VALUES{"NDMP9_ADDR_AS_CONNECTED"} = $NDMP9_ADDR_AS_CONNECTED;
558
559 #copy symbols in addr_type to constants
560 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"addr_type"}};
561
562 push @EXPORT_OK, qw(mover_state_to_strings);
563 push @{$EXPORT_TAGS{"mover_state"}}, qw(mover_state_to_strings);
564
565 my %_mover_state_VALUES;
566 #Convert a flag value to a list of names for flags that are set.
567 sub mover_state_to_strings {
568     my ($flags) = @_;
569     my @result = ();
570
571     for my $k (keys %_mover_state_VALUES) {
572         my $v = $_mover_state_VALUES{$k};
573
574         #is this a matching flag?
575         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
576             push @result, $k;
577         }
578     }
579
580 #by default, just return the number as a 1-element list
581     if (!@result) {
582         return ($flags);
583     }
584
585     return @result;
586 }
587
588 push @EXPORT_OK, qw($NDMP9_MOVER_STATE_IDLE);
589 push @{$EXPORT_TAGS{"mover_state"}}, qw($NDMP9_MOVER_STATE_IDLE);
590
591 $_mover_state_VALUES{"NDMP9_MOVER_STATE_IDLE"} = $NDMP9_MOVER_STATE_IDLE;
592
593 push @EXPORT_OK, qw($NDMP9_MOVER_STATE_LISTEN);
594 push @{$EXPORT_TAGS{"mover_state"}}, qw($NDMP9_MOVER_STATE_LISTEN);
595
596 $_mover_state_VALUES{"NDMP9_MOVER_STATE_LISTEN"} = $NDMP9_MOVER_STATE_LISTEN;
597
598 push @EXPORT_OK, qw($NDMP9_MOVER_STATE_ACTIVE);
599 push @{$EXPORT_TAGS{"mover_state"}}, qw($NDMP9_MOVER_STATE_ACTIVE);
600
601 $_mover_state_VALUES{"NDMP9_MOVER_STATE_ACTIVE"} = $NDMP9_MOVER_STATE_ACTIVE;
602
603 push @EXPORT_OK, qw($NDMP9_MOVER_STATE_PAUSED);
604 push @{$EXPORT_TAGS{"mover_state"}}, qw($NDMP9_MOVER_STATE_PAUSED);
605
606 $_mover_state_VALUES{"NDMP9_MOVER_STATE_PAUSED"} = $NDMP9_MOVER_STATE_PAUSED;
607
608 push @EXPORT_OK, qw($NDMP9_MOVER_STATE_HALTED);
609 push @{$EXPORT_TAGS{"mover_state"}}, qw($NDMP9_MOVER_STATE_HALTED);
610
611 $_mover_state_VALUES{"NDMP9_MOVER_STATE_HALTED"} = $NDMP9_MOVER_STATE_HALTED;
612
613 push @EXPORT_OK, qw($NDMP9_MOVER_STATE_STANDBY);
614 push @{$EXPORT_TAGS{"mover_state"}}, qw($NDMP9_MOVER_STATE_STANDBY);
615
616 $_mover_state_VALUES{"NDMP9_MOVER_STATE_STANDBY"} = $NDMP9_MOVER_STATE_STANDBY;
617
618 #copy symbols in mover_state to constants
619 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"mover_state"}};
620
621 push @EXPORT_OK, qw(data_halt_reason_to_strings);
622 push @{$EXPORT_TAGS{"data_halt_reason"}}, qw(data_halt_reason_to_strings);
623
624 my %_data_halt_reason_VALUES;
625 #Convert a flag value to a list of names for flags that are set.
626 sub data_halt_reason_to_strings {
627     my ($flags) = @_;
628     my @result = ();
629
630     for my $k (keys %_data_halt_reason_VALUES) {
631         my $v = $_data_halt_reason_VALUES{$k};
632
633         #is this a matching flag?
634         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
635             push @result, $k;
636         }
637     }
638
639 #by default, just return the number as a 1-element list
640     if (!@result) {
641         return ($flags);
642     }
643
644     return @result;
645 }
646
647 push @EXPORT_OK, qw($NDMP9_DATA_HALT_NA);
648 push @{$EXPORT_TAGS{"data_halt_reason"}}, qw($NDMP9_DATA_HALT_NA);
649
650 $_data_halt_reason_VALUES{"NDMP9_DATA_HALT_NA"} = $NDMP9_DATA_HALT_NA;
651
652 push @EXPORT_OK, qw($NDMP9_DATA_HALT_SUCCESSFUL);
653 push @{$EXPORT_TAGS{"data_halt_reason"}}, qw($NDMP9_DATA_HALT_SUCCESSFUL);
654
655 $_data_halt_reason_VALUES{"NDMP9_DATA_HALT_SUCCESSFUL"} = $NDMP9_DATA_HALT_SUCCESSFUL;
656
657 push @EXPORT_OK, qw($NDMP9_DATA_HALT_ABORTED);
658 push @{$EXPORT_TAGS{"data_halt_reason"}}, qw($NDMP9_DATA_HALT_ABORTED);
659
660 $_data_halt_reason_VALUES{"NDMP9_DATA_HALT_ABORTED"} = $NDMP9_DATA_HALT_ABORTED;
661
662 push @EXPORT_OK, qw($NDMP9_DATA_HALT_INTERNAL_ERROR);
663 push @{$EXPORT_TAGS{"data_halt_reason"}}, qw($NDMP9_DATA_HALT_INTERNAL_ERROR);
664
665 $_data_halt_reason_VALUES{"NDMP9_DATA_HALT_INTERNAL_ERROR"} = $NDMP9_DATA_HALT_INTERNAL_ERROR;
666
667 push @EXPORT_OK, qw($NDMP9_DATA_HALT_CONNECT_ERROR);
668 push @{$EXPORT_TAGS{"data_halt_reason"}}, qw($NDMP9_DATA_HALT_CONNECT_ERROR);
669
670 $_data_halt_reason_VALUES{"NDMP9_DATA_HALT_CONNECT_ERROR"} = $NDMP9_DATA_HALT_CONNECT_ERROR;
671
672 #copy symbols in data_halt_reason to constants
673 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"data_halt_reason"}};
674
675 push @EXPORT_OK, qw(mover_halt_reason_to_strings);
676 push @{$EXPORT_TAGS{"mover_halt_reason"}}, qw(mover_halt_reason_to_strings);
677
678 my %_mover_halt_reason_VALUES;
679 #Convert a flag value to a list of names for flags that are set.
680 sub mover_halt_reason_to_strings {
681     my ($flags) = @_;
682     my @result = ();
683
684     for my $k (keys %_mover_halt_reason_VALUES) {
685         my $v = $_mover_halt_reason_VALUES{$k};
686
687         #is this a matching flag?
688         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
689             push @result, $k;
690         }
691     }
692
693 #by default, just return the number as a 1-element list
694     if (!@result) {
695         return ($flags);
696     }
697
698     return @result;
699 }
700
701 push @EXPORT_OK, qw($NDMP9_MOVER_HALT_NA);
702 push @{$EXPORT_TAGS{"mover_halt_reason"}}, qw($NDMP9_MOVER_HALT_NA);
703
704 $_mover_halt_reason_VALUES{"NDMP9_MOVER_HALT_NA"} = $NDMP9_MOVER_HALT_NA;
705
706 push @EXPORT_OK, qw($NDMP9_MOVER_HALT_CONNECT_CLOSED);
707 push @{$EXPORT_TAGS{"mover_halt_reason"}}, qw($NDMP9_MOVER_HALT_CONNECT_CLOSED);
708
709 $_mover_halt_reason_VALUES{"NDMP9_MOVER_HALT_CONNECT_CLOSED"} = $NDMP9_MOVER_HALT_CONNECT_CLOSED;
710
711 push @EXPORT_OK, qw($NDMP9_MOVER_HALT_ABORTED);
712 push @{$EXPORT_TAGS{"mover_halt_reason"}}, qw($NDMP9_MOVER_HALT_ABORTED);
713
714 $_mover_halt_reason_VALUES{"NDMP9_MOVER_HALT_ABORTED"} = $NDMP9_MOVER_HALT_ABORTED;
715
716 push @EXPORT_OK, qw($NDMP9_MOVER_HALT_INTERNAL_ERROR);
717 push @{$EXPORT_TAGS{"mover_halt_reason"}}, qw($NDMP9_MOVER_HALT_INTERNAL_ERROR);
718
719 $_mover_halt_reason_VALUES{"NDMP9_MOVER_HALT_INTERNAL_ERROR"} = $NDMP9_MOVER_HALT_INTERNAL_ERROR;
720
721 push @EXPORT_OK, qw($NDMP9_MOVER_HALT_CONNECT_ERROR);
722 push @{$EXPORT_TAGS{"mover_halt_reason"}}, qw($NDMP9_MOVER_HALT_CONNECT_ERROR);
723
724 $_mover_halt_reason_VALUES{"NDMP9_MOVER_HALT_CONNECT_ERROR"} = $NDMP9_MOVER_HALT_CONNECT_ERROR;
725
726 #copy symbols in mover_halt_reason to constants
727 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"mover_halt_reason"}};
728
729 push @EXPORT_OK, qw(mover_pause_reason_to_strings);
730 push @{$EXPORT_TAGS{"mover_pause_reason"}}, qw(mover_pause_reason_to_strings);
731
732 my %_mover_pause_reason_VALUES;
733 #Convert a flag value to a list of names for flags that are set.
734 sub mover_pause_reason_to_strings {
735     my ($flags) = @_;
736     my @result = ();
737
738     for my $k (keys %_mover_pause_reason_VALUES) {
739         my $v = $_mover_pause_reason_VALUES{$k};
740
741         #is this a matching flag?
742         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
743             push @result, $k;
744         }
745     }
746
747 #by default, just return the number as a 1-element list
748     if (!@result) {
749         return ($flags);
750     }
751
752     return @result;
753 }
754
755 push @EXPORT_OK, qw($NDMP9_MOVER_PAUSE_NA);
756 push @{$EXPORT_TAGS{"mover_pause_reason"}}, qw($NDMP9_MOVER_PAUSE_NA);
757
758 $_mover_pause_reason_VALUES{"NDMP9_MOVER_PAUSE_NA"} = $NDMP9_MOVER_PAUSE_NA;
759
760 push @EXPORT_OK, qw($NDMP9_MOVER_PAUSE_EOM);
761 push @{$EXPORT_TAGS{"mover_pause_reason"}}, qw($NDMP9_MOVER_PAUSE_EOM);
762
763 $_mover_pause_reason_VALUES{"NDMP9_MOVER_PAUSE_EOM"} = $NDMP9_MOVER_PAUSE_EOM;
764
765 push @EXPORT_OK, qw($NDMP9_MOVER_PAUSE_EOF);
766 push @{$EXPORT_TAGS{"mover_pause_reason"}}, qw($NDMP9_MOVER_PAUSE_EOF);
767
768 $_mover_pause_reason_VALUES{"NDMP9_MOVER_PAUSE_EOF"} = $NDMP9_MOVER_PAUSE_EOF;
769
770 push @EXPORT_OK, qw($NDMP9_MOVER_PAUSE_SEEK);
771 push @{$EXPORT_TAGS{"mover_pause_reason"}}, qw($NDMP9_MOVER_PAUSE_SEEK);
772
773 $_mover_pause_reason_VALUES{"NDMP9_MOVER_PAUSE_SEEK"} = $NDMP9_MOVER_PAUSE_SEEK;
774
775 push @EXPORT_OK, qw($NDMP9_MOVER_PAUSE_MEDIA_ERROR);
776 push @{$EXPORT_TAGS{"mover_pause_reason"}}, qw($NDMP9_MOVER_PAUSE_MEDIA_ERROR);
777
778 $_mover_pause_reason_VALUES{"NDMP9_MOVER_PAUSE_MEDIA_ERROR"} = $NDMP9_MOVER_PAUSE_MEDIA_ERROR;
779
780 push @EXPORT_OK, qw($NDMP9_MOVER_PAUSE_EOW);
781 push @{$EXPORT_TAGS{"mover_pause_reason"}}, qw($NDMP9_MOVER_PAUSE_EOW);
782
783 $_mover_pause_reason_VALUES{"NDMP9_MOVER_PAUSE_EOW"} = $NDMP9_MOVER_PAUSE_EOW;
784
785 #copy symbols in mover_pause_reason to constants
786 push @{$EXPORT_TAGS{"constants"}},  @{$EXPORT_TAGS{"mover_pause_reason"}};
787 1;