PacketFence - BTS - PacketFence
View Issue Details
0001554PacketFencehardware modulespublic2012-09-18 18:562012-10-19 13:44
fgaudreault 
 
normalfeatureN/A
resolvedopen 
 
3.6.0devel 
0001554: Add a getPhonesLLDPAtIfIndex for Cisco modules
I think it is time now to put the effort to add LLDP support for the Cisco switches. This will allow us to support non-Cisco non-CDP phones on the Cisco switches.

I have an appointment tomorrow with a client, and I will try the nortel sub against a Cisco 3750 to see what happens.
No tags attached.
Issue History
2012-09-18 18:56fgaudreaultNew Issue
2012-09-19 11:34fgaudreaultNote Added: 0003079
2012-09-19 12:12fgaudreaultNote Edited: 0003079
2012-09-19 14:14fgaudreaultNote Added: 0003080
2012-09-19 14:14fgaudreaultNote Edited: 0003080
2012-09-24 14:49obilodeauStatusnew => assigned
2012-09-24 14:49obilodeauAssigned To => obilodeau
2012-09-24 17:07obilodeauNote Added: 0003090
2012-10-19 13:44fgaudreaultAssigned Toobilodeau =>
2012-10-19 13:44fgaudreaultStatusassigned => resolved
2012-10-19 13:44fgaudreaultFixed in Version => devel
2012-10-19 13:44fgaudreaultTarget Version => 3.6.0

Notes
(0003079)
fgaudreault   
2012-09-19 11:34   
(edited on: 2012-09-19 12:12)
Did that for Cisco using the Capabilities Flag. Need some rework:
sub getPhonesLLDPAtIfIndex {
    my ( $this, $ifIndex ) = @_;
    my $logger = Log::Log4perl::get_logger( ref($this) );
    my @phones;
    if ( !$this->isVoIPEnabled() ) {
        $logger->debug( "VoIP not enabled on switch "
                . $this->{_ip}
                . ". getPhonesLLDPAtIfIndex will return empty list." );
        return @phones;
    }
    my $oid_lldpRemPortId = '1.0.8802.1.1.2.1.4.1.1.7';
    my $oid_lldpRemSysDesc = '1.0.8802.1.1.2.1.4.1.1.10';
    my $oid_lldpRemSysCapEnabled = '1.0.8802.1.1.2.1.4.1.1.12';

    if ( !$this->connectRead() ) {
        return @phones;
    }

    #Transfer ifIndex to LLDP index
    my $lldpIndex = ($ifIndex-10000)+2;

    $logger->trace(
        "SNMP get_next_request for lldpRemSysCapEnabled: $oid_lldpRemSysCapEnabled");
    my $result = $this->{_sessionRead}
        ->get_table( -baseoid => $oid_lldpRemSysCapEnabled );
    foreach my $oid ( keys %{$result} ) {
        if ( $oid =~ /^$oid_lldpRemSysCapEnabled\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) {
            if ( $lldpIndex eq $2 ) {
                my $cache_lldpRemTimeMark = $1;
                my $cache_lldpRemLocalPortNum = $2;
                my $cache_lldpRemIndex = $3;
                if ( $this->getBitAtPosition($result->{$oid},5) ) {
                    $logger->trace(
                        "SNMP get_request for lldpRemPortId: $oid_lldpRemPortId.$cache_lldpRemTimeMark.$cache_lldpRemLocalPortNum.$cache_lldpRemIndex"
                    );
                    my $MACresult = $this->{_sessionRead}->get_request(
                        -varbindlist => [
                            "$oid_lldpRemPortId.$cache_lldpRemTimeMark.$cache_lldpRemLocalPortNum.$cache_lldpRemIndex"
                        ]
                    );
                    if ($MACresult
                        && ($MACresult->{
                                "$oid_lldpRemPortId.$cache_lldpRemTimeMark.$cache_lldpRemLocalPortNum.$cache_lldpRemIndex"
                            }
                            =~ /^0x([0-9A-Z]{2})([0-9A-Z]{2})([0-9A-Z]{2})([0-9A-Z]{2})([0-9A-Z]{2})([0-9A-Z]{2})$/i
                        )
                        )
                    {
                        push @phones, lc("$1:$2:$3:$4:$5:$6");
                        last;
                    }
                }
            }
        }
    }
    return @phones;
}

(0003080)
fgaudreault   
2012-09-19 14:14   
Also need rework:

sub getPhonesDPAtIfIndex {
    my ( $this, $ifIndex ) = @_;
    my $logger = Log::Log4perl::get_logger( ref($this) );
    my @phones;
    if ( !$this->isVoIPEnabled() ) {
        $logger->debug( "VoIP not enabled on switch "
                . $this->{_ip}
                . ". getPhonesDPAtIfIndex will return empty list." );
        return @phones;
    }
    # Check CDP First, then Check LLDP
    @phones = $this->getPhonesCDPAtIfIndex($ifIndex);

    if (!@phones) {
        @phones = $this->getPhonesLLDPAtIfIndex($ifIndex);
    }

    return @phones;
    
}

(0003090)
obilodeau   
2012-09-24 17:07   
Implementation in good shape. Missing a few things to fully complete it. Will most likely be completed tomorrow.

Branch: feature/lldp-enhancements