Exemplo n.º 1
0
        protected static void OnProbeReceive(object sender, DiscoverProbeEventArgs e)
        {
            Console.WriteLine(string.Format("Probe received from {0}", e.Sender.ToString()));
            DiscoveryServer  server  = sender as DiscoveryServer;
            ProbeMatchesType matches = server.BuildProbeMatches(e.Probe);

            e.Response = matches;
        }
Exemplo n.º 2
0
        protected ProbeMatchesType discoverDevice()
        {
            ProbeMatchesType r = null;
            var T = _rebootTimeout;

            var start = System.DateTime.Now;
            var end   = start.AddMilliseconds(T);

            while (System.DateTime.Now <= end && null == r)
            {
                r = sendUnicastProbeRequest();
            }

            Assert(null != r,
                   "The DUT did not send PROBE MATCH message within the timeout.",
                   "Checking PROBE MATCH is received");

            return(r);
        }
        /// <summary>
        /// Capture requirements for ProbeMatches strcture
        /// </summary>
        /// <param name="probeMatches">ProbeMatches structure</param>
        private void CaptureProbeMatchesRequirements(ProbeMatchesType probeMatches)
        {
            #region MS-PCCRD_R29

            // Since the message parsed by stack layer properly, capture the requirement directly.
            Site.CaptureRequirement(
                29,
                @"[The schema definition of ProbeMatch message is:]
                <wsd:ProbeMatches>
                  <wsd:ProbeMatch>
                    <wsa:EndpointReference>
                      <wsa:Address>
                              urn:uuid:87A89944-0230-43a5-AC4E-FAB1386C8E2C
                      </wsa:Address>
                    </wsa:EndpointReference>
                    <wsd:Types>
                      PeerDist:PeerDistData
                    </wsd:Types>
                    <wsd:Scopes>
                0200000000000000000000000000000000000000000000000000000000000000
                0000000000000000000000000000000000000000000000000000000000000000
                    </wsd:Scopes>
                    <wsd:XAddrs>
                      157.59.141.183:54321
                    </wsd:XAddrs>
                    <wsd:MetadataVersion>
                      1
                    </wsd:MetadataVersion>
                    <PeerDist:PeerDistData>
                      <PeerDist:BlockCount>
                        0000002A
                      </PeerDist:BlockCount>
                    </PeerDist:PeerDistData>
                  </wsd:ProbeMatch>
                </wsd:ProbeMatches>");

            #endregion

            foreach (ProbeMatchType match in probeMatches.ProbeMatch)
            {
                this.CaptureProbeMatchRequirements(match);
            }
        }
        /// <summary>
        /// Receive the pccrd messages
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="message">The soap envelope message</param>
        private void Client_ReceivePccrdMessage(IPEndPoint sender, SoapEnvelope message)
        {
            Status status = new Status();

            status.ErrorCode = string.Empty;
            status.FaultType = FaultType.OK;

            WsdHeader header = (WsdHeader)message.Header;

            if (this.startReceiving && (!this.returned.Contains(header.MessageID.Value)))
            {
                this.returned.Add(header.MessageID.Value);
                ProbeMatchesType matches = ((ProbeMatchOp)message.Body).ProbeMatches;
                this.CaptureHeaderRequirements(header);
                this.CaptureProbeMatchesRequirements(matches);
                PccrdBothRoleCaptureCode.CaptureCommonRequirements(Site);
                foreach (ProbeMatchType match in matches.ProbeMatch)
                {
                    PccrdBothRoleCaptureCode.CaptureTypesElementRequirements(match.Types, Site);
                    PccrdBothRoleCaptureCode.CaptureScopesElementRequirements(match.Scopes, Site);
                }

                ProbeMatchMsg probeMatchMsg = new ProbeMatchMsg();
                probeMatchMsg.InstanceId    = header.AppSequence.InstanceId.ToString();
                probeMatchMsg.MessageNumber = header.AppSequence.MessageNumber;
                PeerProperties[] result = new PeerProperties[matches.ProbeMatch.Length];

                for (int i = 0; i < matches.ProbeMatch.Length; i++)
                {
                    result[i]                 = new PeerProperties();
                    result[i].Address         = matches.ProbeMatch[i].EndpointReference.Address.Value;
                    result[i].BlockCount      = matches.ProbeMatch[i].Any[0].InnerText;
                    result[i].MetadataVersion = matches.ProbeMatch[i].MetadataVersion;
                    result[i].Scopes          = matches.ProbeMatch[i].Scopes.Text[0];
                    result[i].Types           = matches.ProbeMatch[i].Types;
                    result[i].XAddrs          = matches.ProbeMatch[i].XAddrs;
                }

                probeMatchMsg.Matches = result;
                this.ReceiveProbeMatchMessage(status, probeMatchMsg);
            }
        }
Exemplo n.º 5
0
        protected ProbeMatchesType sendUnicastProbeRequest()
        {
            ProbeMatchesType r = null;

            var discoveryFinished = new EventWaitHandle(false, EventResetMode.AutoReset);
            var helloReceivedFlag = false;
            var discovery         = new Discovery(_nic.IP);

            discovery.MessageSent += (sender, args) => LogRequest(args.Message);
            discovery.Discovered  += (sender, args) =>
            {
                LogResponse(string.Join("", args.Message.Raw.Select(e => Convert.ToChar(e).ToString()).ToArray()));

                var response = args.Message.ToSoapMessage <ProbeMatchesType>();
                if (null != response)
                {
                    r = response.Object;
                    helloReceivedFlag = true;
                }
            };
            discovery.DiscoveryFinished += (sender, args) => discoveryFinished.Set();

            try
            {
                BeginStep("Sending Unicast Probe request");
                var address = System.Net.IPAddress.IsLoopback(_cameraIp) ? _nic.IP : _cameraIp;
                discovery.Probe(address, null, null);

                WaitForResponse(new WaitHandle[] { discoveryFinished });
            }
            catch (FaultException e)
            {
                LogFault(e);
            }
            finally
            {
                StepPassed();
            }

            return(r);
        }
Exemplo n.º 6
0
        protected ProbeMatchesType discoverDevice()
        {
            ProbeMatchesType r = null;
            var T = _rebootTimeout;

            var start = System.DateTime.Now;
            var end   = start.AddMilliseconds(T);

            while (System.DateTime.Now <= end && (null == r || !GetProbeScopes(r.ProbeMatch).Contains("onvif://www.onvif.org/Profile/Q/Operational")))
            {
                r = sendUnicastProbeRequest();
            }

            var flag = false;
            var msg  = string.Empty;

            if (null == r)
            {
                msg = "The DUT did not send PROBE MATCH message within the timeout.";
            }
            else if (!GetProbeScopes(r.ProbeMatch).Contains("onvif://www.onvif.org/Profile/Q/Operational"))
            {
                msg = "The DUT sent PROBE MATCH message but it has no scope 'onvif://www.onvif.org/Profile/Q/Operational'.";
            }
            else if (GetProbeScopes(r.ProbeMatch).Contains("onvif://www.onvif.org/Profile/Q/FactoryDefault"))
            {
                msg = "The DUT sent PROBE MATCH message but it has scope 'onvif://www.onvif.org/Profile/Q/FactoryDefault'.";
            }
            else
            {
                flag = true;
            }

            Assert(flag, msg, "Checking PROBE MATCH is received");

            return(r);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProbeMatchOp"/> class
 /// </summary>
 public ProbeMatchOp()
 {
     this.probeMatches = new ProbeMatchesType();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProbeMatchOp"/> class
 /// </summary>
 public ProbeMatchOp()
 {
     this.probeMatches = new ProbeMatchesType();
 }