示例#1
0
		internal PingReply(IcmpEchoReply reply)
		{
			address = new IPAddress((long) reply.address);
			ipStatus = (IPStatus) reply.status;
			options = new PingOptions(reply);
			if (this.ipStatus == IPStatus.Success)
			{
				rtt = reply.roundTripTime;
				buffer = new byte[reply.dataSize];
				Marshal.Copy(reply.data, this.buffer, 0, reply.dataSize);
			}
			else
			{
				buffer = new byte[0];
			}
		}
示例#2
0
 internal PingReply(IcmpEchoReply reply)
 {
     address  = new IPAddress((long)reply.address);
     ipStatus = (IPStatus)reply.status;
     options  = new PingOptions(reply);
     if (this.ipStatus == IPStatus.Success)
     {
         rtt    = reply.roundTripTime;
         buffer = new byte[reply.dataSize];
         Marshal.Copy(reply.data, this.buffer, 0, reply.dataSize);
     }
     else
     {
         buffer = new byte[0];
     }
 }
示例#3
0
        private PingReply InternalSend(IPAddress address, byte [] buffer, int timeout, PingOptions options)
        {
            if (_handlePingV4 == IntPtr.Zero)
            {
                _handlePingV4 = IcmpCreateFile();
            }
            if (_replyBuffer == IntPtr.Zero)
            {
                _replyBuffer = MarshalEx.AllocHLocal(0xffff);
            }

            IPOptions ipo = new IPOptions(options);

            InitStructure(buffer);
            IcmpSendEcho2(_handlePingV4, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, (uint)address.Address, _requestBuffer, (ushort)buffer.Length, ref ipo, _replyBuffer, 0xffff, (uint)timeout);
            FreeStructure();

            IcmpEchoReply reply = (IcmpEchoReply)Marshal.PtrToStructure(this._replyBuffer, typeof(IcmpEchoReply));

            return(new PingReply(reply));
        }
示例#4
0
		internal PingOptions(IcmpEchoReply reply)
		{
            ttl = reply.ttl;
			dontFragment = (reply.flags & IPOptions.DontFragmentFlag) > 0;
		}
示例#5
0
 internal PingOptions(IcmpEchoReply reply)
 {
     ttl          = reply.ttl;
     dontFragment = (reply.flags & IPOptions.DontFragmentFlag) > 0;
 }