File Coverage

blib/lib/Mobile/Executive.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Mobile::Executive;
2              
3             # Executive.pm - the mobile agent client support code.
4             #
5             # Author: Paul Barry, paul.barry@itcarlow.ie
6             # Create: October 2002.
7             # Update: April 2003 - version 1.x series supports relocation.
8             # May 2003 - version 2.x adds support for authentication and
9             # encryption using Crypt::RSA.
10              
11             require Exporter;
12              
13             our $VERSION = 2.03;
14              
15             our @ISA = qw( Exporter );
16              
17             # We export all the symbols declared in this module by default.
18              
19             our @EXPORT = qw(
20             relocate
21             $absolute_fn
22             $public_key
23             $private_key
24             );
25              
26             our @EXPORT_OK = qw(
27             );
28            
29             our %EXPORT_TAGS = (
30             );
31            
32 1     1   17479 use constant KEY_ID => 'Mobile::Executive ID';
  1         2  
  1         77  
33 1     1   5 use constant KEY_SIZE => 1024;
  1         3  
  1         40  
34 1     1   5 use constant KEY_PASS => 'Mobile::Executive PASS';
  1         3  
  1         42  
35              
36 1     1   6 use constant TRUE => 1;
  1         1  
  1         81  
37 1     1   5 use constant FALSE => 0;
  1         2  
  1         431  
38              
39              
40             BEGIN {
41              
42             # This BEGIN block is executed as soon as the module is "used".
43             # We determine the absolute path and filename of the program using
44             # this module. This is important, as the Devel::Scooby.pm module needs
45             # this information during a relocate. Note the use of 'our'.
46             # We also generate a PK+ and PK- for "users" of this module.
47              
48 1     1   1990 use Crypt::RSA; # Provides authentication and encryption services.
  0            
  0            
49             use File::Spec; # Provides filename and path services.
50              
51             our $absolute_fn = File::Spec->rel2abs( File::Spec->curdir ) . '/' . $0;
52              
53             my $rsa = new Crypt::RSA;
54              
55             our ( $public_key, $private_key ) =
56             $rsa->keygen(
57             Identity => KEY_ID . "$$" . "$0",
58             Size => KEY_SIZE,
59             Password => KEY_PASS . "$0" . "$$",
60             Verbosity => FALSE
61             ) or die $rsa->errstr, "\n";
62             }
63              
64             sub relocate {
65              
66             # The relocate subroutine.
67             #
68             # IN: The IP name/address and protocol port number of a Location to
69             # relocate to.
70             #
71             # OUT: nothing.
72              
73             my $ip_address = shift;
74             my $protocol_port = shift;
75              
76             # Does nothing - just a place holder. The Devel::Scooby module
77             # runs its own relocate code as part of its "sub" invocation. That is,
78             # a call to this relocate results in the Devel::Scooby running its own
79             # version of "relocate".
80              
81             return;
82             }
83              
84             1; # As it is required by Perl.
85              
86             ##########################################################################
87             # Documentation starts here.
88             ##########################################################################
89              
90             =pod
91              
92             =head1 NAME
93              
94             "Mobile::Executive" - used to signal the intention to relocate a Scooby mobile agent from the current Location to some other (possibly remote) Location.
95              
96             =head1 VERSION
97              
98             2.03 (version 1.0x never released).
99              
100             =head1 SYNOPSIS
101              
102             use Mobile::Executive;
103              
104             ...
105              
106             relocate( $remote_location, $remote_port );
107              
108             =head1 DESCRIPTION
109              
110             Part of the Scooby mobile agent machinery, the B module provides a means to signal the agents intention to relocate to another Location. Typical usage is as shown in the B section above. Assuming an instance of B is executing on B<$remote_location> at protocol port number B<$remote_port>, the agent stops executing on the current Location, relocates to the remote Location, then continues to execute from the statement immediately AFTER the B statement.
111              
112             Note: a functioning keyserver is required.
113              
114             =head1 Overview
115              
116             The only subroutine provided to programs that use this module is:
117              
118             =over 4
119              
120             relocate
121              
122             =back
123              
124             and it takes two parameters: a IP address (or name) of the remote Location, and the protocol port number that the Location is listening on.
125              
126             =head1 Internal methods/subroutines
127              
128             A Perl B block determines the absolute path to the mobile agents source code file, and puts it into the B<$absolute_fn> scalar (which is automatically exported). This block also generates a PK+/PK- pairing (in B<$public_key> and B<$private_key>) and exports both values (as they are used by B).
129              
130             =head1 RULES FOR WRITING MOBILE AGENTS
131              
132             There used to be loads, but now there is only one. Read the B, available on-line at: B.
133              
134             =head1 SEE ALSO
135              
136             The B class (for creating Locations), and the B module (for running mobile agents).
137              
138             The Scooby Website: B.
139              
140             =head1 AUTHOR
141              
142             Paul Barry, Institute of Technology, Carlow in Ireland, B, B.
143              
144             =head1 COPYRIGHT
145              
146             Copyright (c) 2003, Paul Barry. All Rights Reserved.
147              
148             This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
149