~ubuntu-branches/ubuntu/wily/torrus/wily-proposed

« back to all changes in this revision

Viewing changes to perllib/Torrus/DevDiscover/ComtechEFData.pm

  • Committer: Package Import Robot
  • Author(s): Bernhard Schmidt
  • Date: 2014-10-05 21:16:04 UTC
  • mfrom: (1.2.5)
  • mto: (6.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20141005211604-qqkvq1k0uqiv3bvk
Tags: upstream-2.08
ImportĀ upstreamĀ versionĀ 2.08

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#  Copyright (C) 2012 Stanislav Sinyagin
 
2
#
 
3
#  This program is free software; you can redistribute it and/or modify
 
4
#  it under the terms of the GNU General Public License as published by
 
5
#  the Free Software Foundation; either version 2 of the License, or
 
6
#  (at your option) any later version.
 
7
#
 
8
#  This program is distributed in the hope that it will be useful,
 
9
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
#  GNU General Public License for more details.
 
12
#
 
13
#  You should have received a copy of the GNU General Public License
 
14
#  along with this program; if not, write to the Free Software
 
15
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
16
 
 
17
# Comtech EF Data satellite modems
 
18
 
 
19
package Torrus::DevDiscover::ComtechEFData;
 
20
 
 
21
use strict;
 
22
use warnings;
 
23
 
 
24
use Torrus::Log;
 
25
 
 
26
 
 
27
$Torrus::DevDiscover::registry{'ComtechEFData'} = {
 
28
    'sequence'     => 500,
 
29
    'checkdevtype' => \&checkdevtype,
 
30
    'discover'     => \&discover,
 
31
    'buildConfig'  => \&buildConfig
 
32
    };
 
33
 
 
34
 
 
35
our %oiddef =
 
36
    (
 
37
     'ComtechEFData'     => '1.3.6.1.4.1.6247',
 
38
     'cdm570'            => '1.3.6.1.4.1.6247.24',
 
39
     'cdm570TxFrequency' => '1.3.6.1.4.1.6247.24.1.2.2.1.0',
 
40
     'cdm570TxDataRate'  => '1.3.6.1.4.1.6247.24.1.2.2.2.0',
 
41
     'cdm570RxFrequency' => '1.3.6.1.4.1.6247.24.1.2.3.1.0',
 
42
     'cdm570RxDataRate'  => '1.3.6.1.4.1.6247.24.1.2.3.2.0',
 
43
     'cdmipWanFpgaRxPayLoadCount' => '1.3.6.1.4.1.6247.4.8.5.6.0',
 
44
     );
 
45
 
 
46
 
 
47
my %cdm570_OID = (
 
48
    'cdm570TxFrequency' => 'cdm-wan-tx-freq',
 
49
    'cdm570TxDataRate'  => 'cdm-wan-tx-rate',
 
50
    'cdm570RxFrequency' => 'cdm-wan-rx-freq',
 
51
    'cdm570RxDataRate'  => 'cdm-wan-rx-rate',
 
52
    );
 
53
 
 
54
sub checkdevtype
 
55
{
 
56
    my $dd = shift;
 
57
    my $devdetails = shift;
 
58
 
 
59
    my $sysObjectID = $devdetails->snmpVar( $dd->oiddef('sysObjectID') );
 
60
    
 
61
    if( not $dd->oidBaseMatch( 'ComtechEFData', $sysObjectID ) )
 
62
    {
 
63
        return 0;
 
64
    }
 
65
 
 
66
    if( $dd->oidBaseMatch( 'cdm570', $sysObjectID ) )
 
67
    {
 
68
        $devdetails->setCap('cdm570');
 
69
    }
 
70
 
 
71
    $devdetails->setCap('interfaceIndexingPersistent');
 
72
    
 
73
    &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
 
74
        ($devdetails,
 
75
         {
 
76
             'loopback' => {
 
77
                 'ifType'  => 24,   # softwareLoopback
 
78
                 'ifDescr' => 'loopback'
 
79
             }
 
80
         });
 
81
    
 
82
    return 1;
 
83
}
 
84
 
 
85
 
 
86
sub discover
 
87
{
 
88
    my $dd = shift;
 
89
    my $devdetails = shift;
 
90
 
 
91
    my $data = $devdetails->data();
 
92
    my $session = $dd->session();
 
93
    
 
94
    $data->{'param'}{'snmp-oids-per-pdu'} = 10;
 
95
 
 
96
    # Get TX/RX frequency and data rate
 
97
    if( $devdetails->hasCap('cdm570') )
 
98
    {
 
99
        my @oids = ();
 
100
        foreach my $var ( sort keys %cdm570_OID )
 
101
        {
 
102
            push( @oids, $dd->oiddef($var) );
 
103
        }
 
104
 
 
105
        my $result = $session->get_request( -varbindlist => \@oids );
 
106
        if( not defined $result )
 
107
        {
 
108
            Error('Failed to get CDM570 radio parameters');
 
109
            return 0;
 
110
        }
 
111
        
 
112
        foreach my $var ( keys %cdm570_OID )
 
113
        {
 
114
            my $val = $result->{$dd->oiddef($var)};
 
115
            if( not defined($val) )
 
116
            {
 
117
                $val = 0;
 
118
            }
 
119
            $data->{'cdm570'}{$var} = $val;
 
120
            $data->{'param'}{$cdm570_OID{$var}} = $val;
 
121
        }
 
122
    }
 
123
        
 
124
    # Check if IP cotroller is present
 
125
    {
 
126
        my $oid = $dd->oiddef('cdmipWanFpgaRxPayLoadCount');        
 
127
        my $result = $session->get_request( -varbindlist => [$oid] );
 
128
        
 
129
        if( $session->error_status() == 0 and
 
130
            defined( $result ) and
 
131
            defined($result->{$oid}) )
 
132
        {
 
133
            $devdetails->setCap('CDMIPController');
 
134
        }
 
135
    }
 
136
    return 1;
 
137
}
 
138
 
 
139
 
 
140
sub buildConfig
 
141
{
 
142
    my $devdetails = shift;
 
143
    my $cb = shift;
 
144
    my $devNode = shift;
 
145
 
 
146
    if( $devdetails->hasCap('cdm570') )
 
147
    {
 
148
        $cb->addTemplateApplication($devNode, 'ComtechEFData::cdm570');
 
149
    }
 
150
    
 
151
    if( $devdetails->hasCap('CDMIPController') )
 
152
    {
 
153
        $cb->addTemplateApplication($devNode, 'ComtechEFData::cdmip');
 
154
    }
 
155
    
 
156
    return;
 
157
}
 
158
 
 
159
 
 
160
 
 
161
1;
 
162
 
 
163
 
 
164
# Local Variables:
 
165
# mode: perl
 
166
# indent-tabs-mode: nil
 
167
# perl-indent-level: 4
 
168
# End: