# Send our half of the initial handshake
my $xml_decl = '<?xml version="1.0" encoding="us-ascii"?>';
my $junoscript = '<junoscript version="1.0" os="perl-api">';
$conn->send($xml_decl . "\n" . $junoscript . "\n");
=head1 DESCRIPTION
This is an internal class used by JUNOS::Device only. Its constructor
returns an access method class based on the access method specified by
JUNOS::Device. If the access method 'telnet' is selected, an object
of class JUNOS::Access::telnet will be returned. Once JUNOS::Device
has the reference to the new access method object, it uses it to
make connection, and exchange information with the destination.
All access method classes (e.g. JUNOS::Access::telnet) must subclass
from JUNOS::Access.
=head1 CONSTRUCTOR
new($ARGS)
The constructor of JUNOS::Access simply looks at the access method type
and creates and returns an object of class JUNOS::Access::<access_method>
(e.g. JUNOS::Access::telnet). $CLASS is the prefix for the access
method class, "$CLASS::$access". $ARGS is the reference to a hash
table containing the type of the access method, this hash table is
supplied by the application while calling the constructor of JUNOS::Device.
=head1 METHODS
connect(%ARGS)
This method is called to start a session with the destination host.
Internally, this method simplies calls the start method which is
always overloaded by the subclass.
ARGS is a hash table containing additional input parameters to
establish the session. See the individual access method subclass
to see if additional iput parameters are accepted.
disconnect()
shutdown the underlying mechanics and free/destory them. This
method should be overloaded by the subclass. If not overloaded,
it simplies kill the process that it started for the current
session, which works for telnet and rsh.
eof()
Has the end-of-file been seen?
incoming()
Feed data back to the access method when JUNOS::Device finds something
that it doesn't understand. This is to have the access method object
parse the connection specific messages, such as 'Host not found'.
These messages are specific to the access method type so the incoming
method is always overridden by the subclass. If the underlying code
used by the subclass already deals with errors in connect(), recv()
or send(), then this can be a NOP method.
recv()
read the next chunk of data.
send($DATA)
send data to the JUNOScript server.
start(%ARGS)
To be overloaded by subclass to start the underlaying mechanics
to open a session with the JUNOScript server at the destination.
ARGS is a hash table containing additional input parameters to
establish the session. See the individual access method subclass
to see if additional iput parameters are accepted.
start_command($ACCESS, @FLAGS, $WHO, $EXEC)
This method is called by the subclass of JUNOS::Access to start
a telnet or rsh session.
start_command_sockets()
This method is called by the subclass to start a command using
unix-domain socket pairs; it is currently not used.
The following hash keys are used by JUNOS::Device.
seen_xml
Whether the <xml> element has been received.
seen_eof
Whether eof has been received.
=5= |