Hello Mariano,

Thanks for reporting this. There was a b ug un Mib.pm that prevented the 
correct OID path bing sent back in the SNMP reply. This apparently causes 
some SNMP clients to think it got no reply at all.

I have attached a new Mib.pm for you to test. If it is OK it wil appear in 
the next release.

We apologise for this problem. Thank you for reporting it.

Cheers.

On Sun, 9 Sep 2001 03:44, Mariano Absatz wrote:
> Hi Mike,
>
> Now it (almost) works, the only point is that, apparently, it restarts and
> doesn't send back an acknowledge to the snmp console that sent the request:
>
> Here's the console:
> #snmpset -t 8 -r 1 -p 16146 192.168.19.1 rw-comm .1.3.6.1.2.1.67.1.1.1.1.4
> i 2 Timeout: No Response from 192.168.19.1
>
>
> Here's Radiator's log:
> Sat Sep  8 14:36:50 2001: DEBUG: SNMPAgent: received request from
>    192.168.1.7, 131, 189128152, rw-comm
> Sat Sep  8 14:36:52 2001: INFO: Server started: Radiator 2.18.2 on radius1
>
>
>
> never mind how long the timeout I use (here's 8 secs, but the reset is
> almost immediate). Any idea? (I'm using 2.18.2)
>
> El 7 Sep 2001, a las 9:26, Mike McCauley escribi�:
> > Hi Mariano,
> >
> > On Thu, 6 Sep 2001 23:58, Mariano Absatz wrote:
> > > Well, the point is... it didn't work, Radiator receives the request,
> > > but doesn't do anything about it.
> > >
> > > I tried with the three sets of OID's (the draft ones, RFC2619 &
> > > RFC2621), but to no avail.
> > >
> > > In the requesting machine, I send:
> > > snmpset -Ir -p 16146 192.168.19.1 rw-comm 1.3.6.1.3.79.1.1.1.4 i 2
> > > snmpset -Ir -p 16146 192.168.19.1 rw-comm 1.3.6.1.2.1.67.1.1.1.1.4 i
> > > 2 snmpset -Ir -p 16146 192.168.19.1 rw-comm 1.3.6.1.2.1.67.2.1.1.1.4
> > > i 2
> >
> > Ooos, you need to have a . at the front of the OID, else your snmp
> > interprets it as a relative OID. Try this: it works for me on 2.18.3:
> >
> > snmpset oscar public .1.3.6.1.3.79.1.1.1.4 i 2
> >
> > > and I allways get the following output:
> > > > Error in packet.
> > > > Reason: (noSuchName) There is no such variable name in this MIB.
> > > > Failed object:
> > >
> > > The trace 4 in the Radiator server says:
> > > Thu Sep  6 09:56:42 2001: DEBUG: SNMPAgent: received request from
> > >     192.168.1.7, 131, 293287917, rw-comm
> > > Thu Sep  6 10:32:13 2001: DEBUG: SNMPAgent: received request from
> > >     200.x.y.z, 131, 60580895, rw-comm
> > > Thu Sep  6 10:32:13 2001: WARNING: SNMPAgent: requesting host not
> > > defined as manager. Request from 200.x.y.z ignored
> > > Thu Sep  6 10:32:14 2001: DEBUG: SNMPAgent: received request from
> > >     192.168.1.7, 131, 60580895, rw-comm
> > > Thu Sep  6 10:34:35 2001: DEBUG: SNMPAgent: received request from
> > >     192.168.1.7, 131, 1490955430, rw-comm
> > > Thu Sep  6 10:39:45 2001: DEBUG: SNMPAgent: received request from
> > >     192.168.1.7, 131, 267748177, rw-comm
> > > Thu Sep  6 10:41:56 2001: DEBUG: SNMPAgent: received request from
> > >     192.168.1.7, 131, 1188183886, rw-comm
> > >
> > > And it doesn't restart...
> > >
> > > What is going wrong?
> > >
> > > El 6 Sep 2001, a las 15:07, Mike McCauley escribi�:
> > > > Hi Mariano,
> > > >
> > > > On Thu, 6 Sep 2001 07:46, Hugh Irvine wrote:
> > > > > ----------  Forwarded Message  ----------
> > > > > Subject: (RADIATOR) remote radiator restart
> > > > > Date: Wed, 5 Sep 2001 14:22:45 -0300
> > > > > From: "Mariano Absatz" <[EMAIL PROTECTED]>
> > > > > To: Radiator List <[EMAIL PROTECTED]>
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > > I am running Radiator 2.18.2 on a couple of Sun Netras (Solaris 8)
> > > > > authenticating against an Oracle database (on yet another Netra).
> > > > >
> > > > > We developed a web based front end for administration of the users
> > > > > in the Oracle database on a Sun Ultra 10 (also Solaris 8) with
> > > > > Apache and embedded Perl.
> > > > >
> > > > > The point is that, for instance, when I try to invoke a restart
> > > > > script through ssh, I get the following error:
> > > > >
> > > > > Doing it so through rsh, it works but it locks the connection (and
> > > > > anyway, I'd rather not have rshd running on the server.
> > > > >
> > > > > On the other hand, the manual states that through the SNMP agent I
> > > > > can restart Radiator, but I don't know how. Am I missing something?
> > > > > (I think this would be the cleanest method to do it).
> > > >
> > > > you need to set the SNMP variable
> > > > 1.3.6.1.3.79.1.1.1.4
> > > >
> > > > to the value 2, with something like:
> > > >
> > > > snmpset your.radius.server.address your_community
> > > > 1.3.6.1.3.79.1.1.1.4 i 2
> > > >
> > > > Note that this does not actually stop the server, it just rereads the
> > > > config, like with HUP.
> > > >
> > > > Cheers.
> > > >
> > > > Cheers.
> > > > ===
> > > > Archive at http://www.open.com.au/archives/radiator/
> > > > Announcements on [EMAIL PROTECTED]
> > > > To unsubscribe, email '[EMAIL PROTECTED]' with
> > > > 'unsubscribe radiator' in the body of the message.
# Mib.pm
#
# A Mib object is just a dictionary. Each node inside the mib
# is an entry in the hash.
#
# A MIB is arranged as a tree, with the root at .
# Each node in the tree is either:
# 1. A ref to a Mib object (ie a dictionary)
# 2. A ref to an array. Index 0 is a get fn, index 1 is a getnext fn, 
#    index 2 is a set fn, index 3 is an arbitrary arg that will be passed to 
#    all functions as the first argument. If the set function is not defined
#    the tree under that virtual node is assumed to be read-only. If the
#    getnext funciton is undefined, then it is assumed that there is no
#    subtree under the virtual node, and it is therefore a leaf.
#    that will service any subtree under that (virtual) node.
#    The get function is called like
#       ($error, $value, @pathused) = get_fn($arg, @path);
#    The getnext function is called like
#       ($error, $value, @pathused) = getnext_fn($arg, @path);
#    The set function is called like
#       ($error, $resultingvalue, @pathused) 
#            = set_fn($arg, $newvalue, @path);
# 3. A reference to a scalar. 
#
# Author: Mike McCauley ([EMAIL PROTECTED])
# Copyright (C) 1997 Open System Consultants
# $Id: Mib.pm,v 1.3 2000/02/15 07:07:54 mikem Exp mikem $


package Radius::Mib;
use strict;

# These need to match the definitions in @error_status_code
# in SNMP_Session.pm
$Radius::Mib::ERROR_OK = 0;
$Radius::Mib::ERROR_TOOBIG = 1;
$Radius::Mib::ERROR_NOSUCHNAME = 2;
$Radius::Mib::ERROR_BADVALUE = 3;
$Radius::Mib::ERROR_READONLY = 4;
$Radius::Mib::ERROR_GEN_ERR = 5;
$Radius::Mib::ERROR_NOACCESS = 6;
$Radius::Mib::ERROR_WRONGTYPE = 7;
$Radius::Mib::ERROR_WRONGLENGTH = 8;
$Radius::Mib::ERROR_WRONGENCODING = 9;
$Radius::Mib::ERROR_WRONGVALUE = 10;
$Radius::Mib::ERROR_NOCREATION = 11;
$Radius::Mib::ERROR_INCONSISTENTVALUE = 12;
$Radius::Mib::ERROR_RESOURCEUNAVAILABLE = 13;
$Radius::Mib::ERROR_COMMITFAILED = 14;
$Radius::Mib::ERROR_UNDOFAILED = 15;
$Radius::Mib::ERROR_AUTHORIZATIONERROR = 16;
$Radius::Mib::ERROR_NOTWRITABLE = 17;
$Radius::Mib::ERROR_INCONSISTENTNAME = 18;

#####################################################################
# Create a new Mib structure
# Its just an empty dictionary to start with
sub new
{
    my ($class) = @_;

    my $self = {};
    bless $self, $class;

    return $self;
}

#####################################################################
# createPath(@path, $object)
# Adds an object to the Mib at the position indicated by path
# path is an array of oids
# object is one of the permitted object types in a Mib
sub create
{
    my ($self, $object, @path) = @_;

    my $oid = shift(@path);
    if (@path)
    {
        # Add another sub Mib, if not one there already
        if (!exists($self->{$oid}))
        {
            $self->{$oid} = new Radius::Mib;
        }
        # Else its already there
        $self->{$oid}->create($object, @path);
    }
    else
    {
        # All done, now refer to the object
        $self->{$oid} = $object;
    }
}

#####################################################################
# get(\$root, @path)
# Get the value at the node given by @path relative to the
# root node.
# Returns ($error, $value, @pathused)
# pathused is the portion of @path that was used to get the value
# Usually its the same as @path, unless an error occurred
# This is recursive, and only searches _one_ level of the tree
# 
sub get
{
    my ($self, @path) = @_;

    my $oid = shift(@path);
    if (ref($self->{$oid}) eq 'Radius::Mib')
    {
        # Get the value from the sub Mib
        my ($error, $value, @path) = $self->{$oid}->get(@path);
        return ($error, $value, $oid, @path);
    }
    elsif (ref($self->{$oid}) eq 'SCALAR')
    {
        # Just return the value, and the place we are at
        return ($Radius::Mib::ERROR_OK, ${$self->{$oid}}, ($oid));
    }
    elsif (ref($self->{$oid}) eq 'ARRAY')
    {
        # Its an array of functions, which are to be called
        # to process the rest of the path
        # Call the get function (index 0) and pass it the remaining path
        my $fn = $self->{$oid}[0]; # Be defensive
        return ($Radius::Mib::ERROR_GEN_ERR, undef, ($oid))
            unless defined $fn;

        my ($error, $value, @path_used) 
            = &{$fn}($self->{$oid}[3], @path);

        # Return the value and the total path that was used
        return ($error, $value, ($oid, @path_used));
    }
    else
    {
        # Perhaps we are not at a leaf node. Anyways its an error
        # REVISIT: what kind of error?
        return ($Radius::Mib::ERROR_NOSUCHNAME, undef, ($oid));
    }
}

#####################################################################
# getnext(\$root, @path)
# Get the next value starting at the node given by @path relative to the
# root node. Root _must_ me a ref to a dictionary.
# Returns ($error, $value, @pathused)
# pathused is the path of the next value that we found
# This is recursive, and only searches _one_ level of the tree
# 
sub getnext
{
    my ($self, @path) = @_;

    my $oid = shift(@path);
    my $node;
    foreach $node (sort { $a <=> $b } keys %$self)
    {
        if (!defined $oid || $node >= $oid)
        {
            # If we have gone past the last one, then @path must be cleared
            @path = () if $node > $oid;

            my $newnode = $self->{$node};
            if (ref($newnode) eq 'Radius::Mib')
            {
                # Recursively descend into this dictionary
                my ($error, $retvalue, @path_used) 
                    = $newnode->getnext(@path);
                # If we found the next one, return it, else keep going
                return ($error, $retvalue, ($node, @path_used))
                    if $error == $Radius::Mib::ERROR_OK;
                
            }
            elsif (ref($newnode) eq 'SCALAR')
            {
                # If this is the "last" ignore it: its the next 
                # one we are interested in
                next if $node == $oid;

                # Gone past the last value, so take the next one we see
                # Just return the value, and the place we are at
                return ($Radius::Mib::ERROR_OK, $$newnode, ($node));
            }
            elsif (ref($newnode) eq 'ARRAY')
            {
                # Its an array of functions, which are to be called
                # to process the rest of the path
                # Call the getnext function (index 1) and pass it the 
                # remaining path
                my $fn = $$newnode[1]; # Be defensive

                # if no getnext function, then it must be a leaf
                # and we can decide whether its the "next" one,
                # and then call the get function directly
                if (!defined $fn)
                {
                    next if !defined $fn && $node == $oid;
                    $fn = $$newnode[0]; # Be defensive
                    return ($Radius::Mib::ERROR_GEN_ERR, undef, ($oid))
                        unless defined $fn;
                }
                
                my ($error, $retvalue, @path_used) 
                    = &{$fn}($$newnode[3], @path);
                # If we found the next one, return it, else keep going
                return ($error, $retvalue, ($node, @path_used))
                    if $error == $Radius::Mib::ERROR_OK;
                
            }
            else
            {
                # Perhaps we are not at a leaf node. Anyways its an error
                # REVISIT: what kind of error?
                return ($Radius::Mib::ERROR_NOSUCHNAME, undef, ($node));
            }
        }
    }
    # Not found in this level or lower
    return ($Radius::Mib::ERROR_NOSUCHNAME, undef, ($oid));
}

#####################################################################
# set(\$root, $value, @path)
# Set the value at the node given by @path relative to the
# root node.
# Returns ($error, $value, @pathused)
# pathused is the portion of @path that was used to set the value
# $value is the result after doing the set
# Usually its the same as @path, unless an error occurred
# This is recursive, and only searches _one_ level of the tree
# 
sub set
{
    my ($self, $value, @path) = @_;

    my $oid = shift(@path);

    if (ref($self->{$oid}) eq 'Radius::Mib')
    {
        # Get the value from the sub Mib
        my ($error, $value, @path) = $self->{$oid}->set($value, @path);
        return ($error, $value, $oid, @path);
    }
    elsif (ref($self->{$oid}) eq 'SCALAR')
    {
        # Just return the value, and the place we are at
        ${$self->{$oid}} = $value;
        return ($Radius::Mib::ERROR_OK, ${$self->{$oid}}, ($oid));
    }
    elsif (ref($self->{$oid}) eq 'ARRAY')
    {
        # Its an array of functions, which are to be called
        # to process the rest of the path
        # Call the set function (index 2) and pass it the remaining path
        my $fn = $self->{$oid}[2];
        return ($Radius::Mib::ERROR_READONLY, undef, ($oid))
            unless defined $fn;

        my ($error, $retvalue, @path_used) 
            = &{$fn}($self->{$oid}[3], $value, @path);

        # Return the value set and the total path that was used
        return ($error, $retvalue, ($oid, @path_used));
    }
    else
    {
        # Perhaps we are not at a leaf node. Anyways its an error
        # REVISIT: what kind of error?
        return ($Radius::Mib::ERROR_NOSUCHNAME, undef, ($oid));
    }
}

#####################################################################
# These functions are the equivalent of the above, but they use
# pretty paths in the form '1.2.3.4.5', both in an out
#
sub createPretty
{
    my ($self, $object, $path) = @_;
    return $self->create($object, split(/\./, $path));
}

sub getPretty
{
    my ($self, $path) = @_;

    my ($error, $value, @pathused) = $self->get(split(/\./, $path));
    return ($error, $value, join('.', @pathused));
}

sub getnextPretty
{
    my ($self, $path) = @_;

    my ($error, $value, @pathused) = $self->getnext(split(/\./, $path));
    return ($error, $value, join('.', @pathused));
}

sub setPretty
{
    my ($self, $nvalue, $path) = @_;

    my ($error, $value, @pathused) = $self->set($nvalue, split(/\./, $path));
    return ($error, $value, join('.', @pathused));
}


1;

Reply via email to