#!/usr/bin/perl # # Copyright (C) 2007, 2008 Chunghwa Telecommunication Corporation. # All rights reserved. # # Redistribution and use of this software in source and binary # forms, with or without modification, are permitted provided that # the following conditions and disclaimer are agreed and accepted # by the user: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with # the distribution. # # 3. Neither the names of the copyrighters, the name of the project # which is related to this software (hereinafter referred to as # "project") nor the names of the contributors may be used to # endorse or promote products derived from this software without # specific prior written permission. # # 4. No merchantable use may be permitted without prior written # notification to the copyrighters. # # 5. The copyrighters, the project and the contributors may prohibit # the use of this software at any time. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHTERS, THE PROJECT AND # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING # BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHTERS, THE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # $Name: MGM050_AG_0_9_0a $ # $Header: /home/cvs/ct-snmpv2c-ag/AG/AG_RFC3416_GetBulk_0NRep_-1MRep_0VB.seq,v 1.1.1.1 2008/04/09 03:03:19 cvs Exp $ # $Id: AG_RFC3416_GetBulk_0NRep_-1MRep_0VB.seq,v 1.1.1.1 2008/04/09 03:03:19 cvs Exp $ # ###################################################################### BEGIN { $V6evalTool::TestVersion = '$Name: MGM050_AG_0_9_0a $'; push( @INC, '..' ); } END { } #use strict; use SnmpDef qw( :types :versions :generictrap ); require "Snmp-ct.pm"; #------------------------------# # NUT configuration # #------------------------------# my $NutConfig={ 'rwcommunity' => $SNMP_BASE_CONFIG->{'rwcommunity'}, 'rocommunity' => $SNMP_BASE_CONFIG->{'rocommunity'}, 'base_request_id' => 12, }; #------------------------------# # configuration # #------------------------------# my @snmp_session_config = (); my $snmp_param = { 'snmp_session_config' => \@snmp_session_config }; $snmp_session_config[0] = { 'TN_INTERFACE' => 'Link0', 'TN_ADDR' => $TN_MG1_ADDR, 'TN_ADDR_PORT' => $TN_MG_PORT, 'TN_ADDR_PROTO' => 'UDP', 'TN_ADDR_FAMILY' => $ADDR_FAMILY, 'NUT_ADDR' => $NUT_ADDR_0, 'NUT_ADDR_PORT' => $NUT_AG_PORT, }; #-------------------- # SNMP Agent1 #-------------------- my @snmp_session = (); my @gen_snmp_msg_0 = (); my @gen_asn1_msg_0 = (); my @exp_snmp_msg_0 = (); my @exp_asn1_msg_0 = (); $snmp_session[0] = { 'socket_ref' => undef, 'snmp_one_session' => [ { 'gen_snmp_msg' => \@gen_snmp_msg_0, 'gen_asn1_msg' => \@gen_asn1_msg_0, 'dec_snmp_msg' => undef, 'dec_asn1_msg' => undef, 'exp_snmp_msg' => \@exp_snmp_msg_0, 'exp_asn1_msg' => \@exp_asn1_msg_0 } ] }; #-------------------------- # general preparation #-------------------------- my $request_id = $NutConfig->{'base_request_id'}; my $pdu_ref; #-------------------------- # Send packet definition #-------------------------- #------------------ # 1st message() #------------------ my @gen_varbind_list_0=(); $gen_varbind_list_0[0] = undef; # non-repeater = 0 # max-repetition = -1 $pdu_ref = Gen_SNMP_v2C_Bulk_PDU(GET_BULK_REQUEST, $request_id, 0, -1, \@gen_varbind_list_0); $gen_snmp_msg_0[0] = Gen_SNMP_v1v2C_Message(SNMP_VERSION_2C, SNMP_VERSION_2C, $NutConfig->{'rocommunity'}, PDU ,$pdu_ref); Print_SNMP_Message($gen_snmp_msg_0[0]->{'Message'}, 0); $gen_asn1_msg_0[0] = Trans_SNMP_ASN1_SNMP($gen_snmp_msg_0[0]); Print_ASN1_Message($gen_asn1_msg_0[0]->{'ASN1_Message'}, 0); #-------------------------- # Expect packet definition #-------------------------- #------------------ # 2nd message #------------------ my @exp_varbind_list_0=(); $exp_varbind_list_0[0] = undef; $pdu_ref = Gen_SNMP_v1v2C_PDU(GET_RESPONSE, $request_id, 0, 0, \@exp_varbind_list_0); $exp_snmp_msg_0[0] = Gen_SNMP_v1v2C_Message(SNMP_VERSION_2C, SNMP_VERSION_2C, $NutConfig->{'rocommunity'}, PDU ,$pdu_ref); $exp_asn1_msg_0[0] = Trans_SNMP_ASN1_SNMP($exp_snmp_msg_0[0]); # Print_ASN1_Message($exp_asn1_msg_0[0]->{'ASN1_Message'}, 0); ################################ # start tests # ################################ print "Call SNMPStartConnect...\n"; my $ret = SNMPStartConnect( $snmp_param, \@snmp_session ); unless ( defined($ret) ) { Debug_Print("ERROR:SNMPStartConnect\n"); SNMPExit($FAIL); } #------------------------------# # 1st packet (send) # #------------------------------# my $request_timeout = 60; # Print_Message( "=", ["Send 1st message\n"] ); print "Call SNMPSendRecv...\n"; $ret = undef; $ret = SNMPSendRecv( 1, 1, $request_timeout, $snmp_session[0]->{'socket_ref'}, $snmp_session[0]->{'snmp_one_session'}->[0] ); unless ( defined($ret) ) { SNMPExit($FAIL); } # Print_Message( "=", ["Receive 2nd message\n"] ); # print returned message Print_SNMP_Message($snmp_session[0]->{'snmp_one_session'}->[0]->{'dec_snmp_msg'}->[0]->{'Message'}, 0); Print_ASN1_Message($snmp_session[0]->{'snmp_one_session'}->[0]->{'dec_asn1_msg'}->[0]->{'ASN1_Message'}, 0); #------------------------------# # Judgment (2nd packet) # #------------------------------# Print_Message( "#", [ "Judgment (2nd packet)\n", "2. NUT replies SNMPv2C GetResponse with correct values to TN\n", ] ); my $recv_asn1_data = $snmp_session[0]->{'snmp_one_session'}->[0]->{'dec_asn1_msg'}->[0]->{'ASN1_Message'}; my $recv_snmp_data = $snmp_session[0]->{'snmp_one_session'}->[0]->{'dec_snmp_msg'}->[0]->{'Message'}; $ret = undef; $ret = JudgeASN1Msg( $recv_asn1_data, $exp_asn1_msg_0[0]->{'ASN1_Message'} ); unless ( defined($ret) ) { SNMPExit($FAIL); } #$ret = undef; #$ret = JudgeSNMPMsg( $recv_snmp_data, $exp_snmp_msg_0[0]->{'Message'} ); #unless ( defined($ret) ) { # SNMPExit($FAIL); #} Print_Message( "=", ["2nd packet PASS\n"] ); SNMPExit($OK); __END__ ###################################################################### =head1 NAME AG_RFC3416_GetBulk_0NRep_-1MRep_0VB.seq - GetBulk with zero non-repeaters, negative max-repetitions and zero variable-bindings =head1 Purpose Verify that NUT playing the SNMPv2C agent can properly process the GetBulkRequest object with zero values for non-repeaters and variable-bindings, negative values for max-repetitions packet from the SNMPv2C manager. =head1 TARGET SNMPv2-Agent =head1 SYNOPSIS =begin html
	AG_RFC3416_GetBulk_0NRep_-1MRep_0VB.seq [-tooloption ...]: KOI tool option
	See also SNMPConfig.pm
=end html =head1 INITIALIZATION =begin html =end html =head1 TEST PROCEDURE This test sequence is following. SNMP Manager1 (TN) SNMP Agent1 (NUT) | | |------------------------------------->| | 1. Send SNMPv2C GetBulk Request | | w/ 0 non-repeaters | | -1 max-repetitions | | 0 var-binds | | | |<-------------------------------------| OP1| 2. Receive SNMPv2C GetResponse | | | | | | | v v 1. TN sends SNMPv2C GetBulkRequest to NUT by issuing SNMPv2C GetBulkRequest with -1 for max-repetitions and zero values for non-repeaters and variable-bindings. 2. NUT replies SNMPv2C GetResponse with correct values to TN. =head1 JUDGMENT OP1 TN received SNMPv2C response from NUT responding to SNMPv2C GetBulk request correctly. Received packet with 1. SNMP version = 1, Community=same as NUT's SNMPv2C community PDU type = A2 2. Request-id is the same as the request id in the previously received SNMPv2C GetBulkRequest. 3. Error-status must be equal to zero and error-index must be equal zero. 4. The variable-binding list should be empty. =head1 TERMINATION None =head1 REFERENCE RFC 3416, Protocol Operations for version 2 of the Simple Network Management Prototol, Sec 4.2.3 =cut