From e6626cef69f51a530a52573eef1f43ae534324ab Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 4 Oct 2016 09:51:20 -0400 Subject: [PATCH] if soap version is specified for probe, don't do both versions --- onvif/scripts/zmonvif-probe.pl | 95 ++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/onvif/scripts/zmonvif-probe.pl b/onvif/scripts/zmonvif-probe.pl index 60f66146c..50259b8e8 100755 --- a/onvif/scripts/zmonvif-probe.pl +++ b/onvif/scripts/zmonvif-probe.pl @@ -41,6 +41,7 @@ require WSDiscovery::TransportUDP; # Globals my $verbose = 0; +my $soap_version = undef; my $client; # ========================================================================= @@ -171,59 +172,64 @@ sub discover my %services; my $uuid_gen = Data::UUID->new(); + + if ( ( ! $soap_version ) or ( $soap_version eq '1.1' ) ) { - if($verbose) { - print "Probing for SOAP 1.1\n" - } - my $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({ + if($verbose) { + print "Probing for SOAP 1.1\n" + } + my $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({ # no_dispatch => '1', - }); - $svc_discover->set_soap_version('1.1'); + }); + $svc_discover->set_soap_version('1.1'); - my $uuid = $uuid_gen->create_str(); + my $uuid = $uuid_gen->create_str(); - my $result = $svc_discover->ProbeOp( - { # WSDiscovery::Types::ProbeType - Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType - Scopes => { value => '' }, - }, - WSDiscovery10::Elements::Header->new({ - Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' }, - MessageID => { value => "urn:uuid:$uuid" }, - To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' }, - }) - ); + my $result = $svc_discover->ProbeOp( + { # WSDiscovery::Types::ProbeType + Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType + Scopes => { value => '' }, + }, + WSDiscovery10::Elements::Header->new({ + Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' }, + MessageID => { value => "urn:uuid:$uuid" }, + To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' }, + }) + ); # print $result . "\n"; - interpret_messages($svc_discover, \%services, @responses); - @responses = (); + interpret_messages($svc_discover, \%services, @responses); + @responses = (); + } # end if doing soap 1.1 - if($verbose) { - print "Probing for SOAP 1.2\n" - } - $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({ + if ( ( ! $soap_version ) or ( $soap_version eq '1.2' ) ) { + if($verbose) { + print "Probing for SOAP 1.2\n" + } + $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({ # no_dispatch => '1', - }); - $svc_discover->set_soap_version('1.2'); + }); + $svc_discover->set_soap_version('1.2'); - # copies of the same Probe message must have the same MessageID. - # This is not a copy. So we generate a new uuid. - $uuid = $uuid_gen->create_str(); +# copies of the same Probe message must have the same MessageID. +# This is not a copy. So we generate a new uuid. + $uuid = $uuid_gen->create_str(); - # Everyone else, like the nodejs onvif code and odm only ask for NetworkVideoTransmitter - $result = $svc_discover->ProbeOp( - { # WSDiscovery::Types::ProbeType - xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl', }, - Types => 'dn:NetworkVideoTransmitter', # QNameListType - Scopes => { value => '' }, - }, - WSDiscovery10::Elements::Header->new({ - Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' }, - MessageID => { value => "urn:uuid:$uuid" }, - To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' }, - }) - ); +# Everyone else, like the nodejs onvif code and odm only ask for NetworkVideoTransmitter + $result = $svc_discover->ProbeOp( + { # WSDiscovery::Types::ProbeType + xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl', }, + Types => 'dn:NetworkVideoTransmitter', # QNameListType + Scopes => { value => '' }, + }, + WSDiscovery10::Elements::Header->new({ + Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' }, + MessageID => { value => "urn:uuid:$uuid" }, + To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' }, + }) + ); # print $result . "\n"; + } # end if doing soap 1.2 interpret_messages($svc_discover, \%services, @responses); } @@ -321,7 +327,7 @@ my $OPTIONS = "v"; sub HELP_MESSAGE { my ($fh, $pkg, $ver, $opts) = @_; - print $fh "Usage: " . __FILE__ . " [-v] probe \n"; + print $fh "Usage: " . __FILE__ . " [-v] probe \n"; print $fh " " . __FILE__ . " [-v] \n"; print $fh <