COPS-Client

 view release on metacpan or  search on metacpan

lib/COPS/Client.pm  view on Meta::CPAN

 
=head2 decode_radius_attribute

    This function takes the output from FreeRadius 2.1.9 and expands it where possible. The
    supported attributes are

         CableLabs-Event-Message
         CableLabs-QoS-Descriptor

    When called this function returns the converted attribute into a hash of the attributes
    found and decoded.

    An example of use would be

    my %return_data;

    $cops_client->decode_radius_attribute("CableLabs-Event-Message",
        "
        0x00034c163b873939393939393939303030303030303000bc69f2000700022020203232323200312b3030303030300000002b32303130303631343135313233382e3032330000000080000400",
        \%return_data);

lib/COPS/Client.pm  view on Meta::CPAN


sub new {

        my $self = {};
        bless $self;

        my ( $class , $attr ) =@_;

        my ( %template );
        my ( %current_data );
        my ( %complete_decoded_data );
        my ( %handles );

        $self->{_GLOBAL}{'DEBUG'}=0;

        while (my($field, $val) = splice(@{$attr}, 0, 2))
                { $self->{_GLOBAL}{$field}=$val; }

        $self->{_GLOBAL}{'STATUS'}="OK";

        if ( !$self->{_GLOBAL}{'VendorID'} )

lib/COPS/Client.pm  view on Meta::CPAN

        $self->{_GLOBAL}{'current_command'}="";
	$self->{_GLOBAL}{'Classifier_Encoded'}="";
	$self->{_GLOBAL}{'Envelope_Encoded'}="";
	$self->{_GLOBAL}{'TimeLimit'}="";
	$self->{_GLOBAL}{'VolumeLimit'}="";
	$self->{_GLOBAL}{'OpaqueData'}="";
	$self->{_GLOBAL}{'RKS_Encoded'}="";

        $self->{_GLOBAL}{'template'}= \%template;
        $self->{_GLOBAL}{'current_data'}= \%current_data;
        $self->{_GLOBAL}{'complete_decoded_data'} = \%complete_decoded_data;

	$self->{_GLOBAL}{'Listener_HandlesP'}= \%handles;

        return $self;
}

sub disconnect
{
my ( $self ) = shift;
if ( $self->{_GLOBAL}{'Handle'} )

lib/COPS/Client.pm  view on Meta::CPAN

						}
                                	}
                                foreach my $handler ( keys %{$handles} )
                                        { if ( $handler ne $handle ) { delete ${$handles}{$handler}; } }
                                if ( !${$handles}{$handle} ) { waitpid($child,0); exit(0); }
                                waitpid($child,0);
                                exit(0);
                                }
                        if ( ${$handles}{$handle}{'addr'} )
                                {
                                if ( $self->{_GLOBAL}{'complete_decoded_data'}{ ${$handles}{$handle}{'addr'} } )
                                        { undef $self->{_GLOBAL}{'complete_decoded_data'}{ ${$handles}{$handle}{'addr'} }; }
                                }
                        delete ${$handles}{$handle};
                        $self->{_GLOBAL}{'Listen_Selector'}->remove($handle);
                        $handle->close();
                        }

                        if ( $link )
                                {
				print "Got data set as '$dataset'\n";
                                ${$handles}{$handle}{'data'}.=$dataset;

lib/COPS/Client.pm  view on Meta::CPAN



print "Remaing data set length is '".length($decode_data)."'\n" if $self->{_GLOBAL}{'DEBUG'}>0;

while ( length($decode_data)> 0 )
	{
	$decode_data = $self-> decode_cops_message ( $decode_data );
	}


print "all cops messages decoded.\n" if $self->{_GLOBAL}{'DEBUG'}>0;

$self->{_GLOBAL}{'message_client_id'} = $client_id;
$self->{_GLOBAL}{'message_opcode'} = $opcode;

$self->{_GLOBAL}{'data_received'} = substr( $self->{_GLOBAL}{'data_received'}, $total_length, length($self->{_GLOBAL}{'data_received'})-$total_length);

return 1;
}

sub decode_cops_message



( run in 0.272 second using v1.01-cache-2.11-cpan-26ccb49234f )