public PacketCaptureHandler(PacketCapture parent, FilterIp[] filters, PacketCaptureCallback success, PacketErrorCallback error)
        {
            this.parent = parent;
            this.filters = filters;
            this.success = success;
            this.error = error;

            this.parent.AddHandler(this);
        }
        /// <summary>
        /// Creates a new multipath traceroute with the specified settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public MultipathTraceroute(MultipathTracerouteSettings settings, PacketCapture capture)
        {
            // Validate the settings.
            if ((settings.AttemptsPerFlow == 0) || (settings.AttemptsPerFlow > 255))
                throw new ArgumentException("The maximum attempts per flow is invalid (1..255).");
            if ((settings.FlowCount == 0) || (settings.FlowCount > 255))
                throw new ArgumentException("The maximum flow count is invalid (1..255).");
            if (settings.MinimumHops == 0)
                throw new ArgumentException("The minimum hops count is invalid (1..255).");
            if (settings.MaximumHops == 0)
                throw new ArgumentException("The maximum hops count is invalid (1..255).");
            if (settings.MinimumHops >= settings.MaximumHops)
                throw new ArgumentException("The minimum hops must be smaller than the maximum hops.");
            if (settings.MaximumUnknownHops == 0)
                throw new ArgumentException("The maximum unknown hops count is invalid (1..255).");
            if ((settings.DataLength == 0) || (settings.DataLength > 1024))
                throw new ArgumentException("The data length is invalid (1..1024).");
            if ((settings.MinimumPort < 1024) || (settings.MinimumPort > 65520))
                throw new ArgumentException("The minimum port is invalid (1024..65520).");
            if ((settings.MaximumPort < 1024) || (settings.MaximumPort > 65520))
                throw new ArgumentException("The maximum port is invalid (1024..65520).");
            if (settings.MinimumPort >= settings.MaximumPort)
                throw new ArgumentException("The minimum port must be smaller than the maximum port.");
            if (settings.DataLength < 2)
                throw new ArgumentException("The minimum data length is 2.");

            // Set the packet capture.
            this.capture = capture;

            // Set the settings.
            this.settings = settings;

            // Global parameters.
            ProtoPacketIcmp.IgnoreChecksum = true;

            // Initialize the receiving buffers.
            //for (int index = 0; index < MultipathTraceroute.bufferCount; index++)
            //{
            //	this.bufferRecv[index] = new byte[MultipathTraceroute.bufferSize];
            //	this.bufferQueue.Enqueue(index);
            //}

            // Create the timer.
            this.timer = new Timer((object state) =>
            {
                lock (this.syncResults)
                {
                    // For all results.
                    foreach (MultipathTracerouteResult result in this.results)
                    {
                        // Call the result timeout method.
                        result.Timeout();
                    }
                }
            }, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(MultipathTraceroute.requestsTimeout));
        }
 public MultipathTracerouteCaptureHandler(PacketCapture parent, MultipathTracerouteResult result, PacketCaptureCallback success, PacketErrorCallback error)
     : base(parent, result.PacketFilters, success, error)
 {
     this.Result = result;
 }