File: MSWin32.pm

package info (click to toggle)
libnet-route-perl 0.02-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 335; makefile: 2
file content (98 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package Net::Route::Parser::MSWin32;
use 5.008;
use strict;
use warnings;
use version; our ( $VERSION ) = '$Revision: 366 $' =~ m{(\d+)}xms;
use Moose;
use Readonly;
use Net::Route;
use Net::Route::Parser qw(:ip_re :route_re);

extends 'Net::Route::Parser';

sub command_line
{
    return [qw(c:\WINDOWS\system32\route print)];
}

sub parse_routes
{
    my ( $self, $text_lines_ref ) = @_;

    my @routes;
    foreach my $line ( @{$text_lines_ref} )
    {
        chomp $line;

        if ( my @values = ( $line =~ $ROUTE_RE ) )
        {
            my ( $dest, $dest_mask, $gateway, $interface, $metric ) = @values;

            my $route_ref = Net::Route->new( {
                   'destination' => $self->create_ip_object( $dest, $dest_mask ),
                   'gateway'     => $self->create_ip_object( $gateway ),
                   'is_active'   => 1,                              # TODO
                   'is_dynamic' => 0,            # TODO
                   'metric'     => $metric,
                   'interface'  => $interface,

                } );
            push @routes, $route_ref;
        }
    }

    return \@routes;
}

no Moose;
__PACKAGE__->meta->make_immutable();
1;

__END__

=head1 NAME

Net::Route::Parser::MSWin32 - Internal class


=head1 SYNOPSIS

Internal.


=head1 VERSION

Revision $Revision: 366 $.


=head1 DESCRIPTION

This class parses Windows' C<route print> output. It implements
L<Net::Route::Parser>.

=head2 Object Methods

=head3 command_line()

=head3 parse_routes()


=head1 INTERFACE

See L<Net::Route::Parser>.


=head1 AUTHOR

Created by Alexandre Storoz, C<< <astoroz@straton-it.fr> >>

Maintained by Thomas Equeter, C<< <tequeter@straton-it.fr> >>


=head1 LICENSE AND COPYRIGHT

Copyright (C) 2009 Straton IT.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.