<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indented! &#187; DHCP</title>
	<atom:link href="http://www.indented.co.uk/index.php/tag/dhcp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indented.co.uk</link>
	<description></description>
	<lastBuildDate>Mon, 17 Oct 2011 19:03:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>NetShell</title>
		<link>http://www.indented.co.uk/index.php/2010/11/25/netshell/</link>
		<comments>http://www.indented.co.uk/index.php/2010/11/25/netshell/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 19:56:50 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[DHCP]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[subnet]]></category>
		<category><![CDATA[Subnet Math]]></category>
		<category><![CDATA[SysLog]]></category>

		<guid isPermaLink="false">http://www.indented.co.uk/?p=1561</guid>
		<description><![CDATA[It&#8217;s been a while since I&#8217;ve posted, and since it&#8217;s almost Christmas I thought I&#8217;d better get on with it. Without further ado I want to post NetShell (I&#8217;m not very good at coming up with imaginative names). NetShell is a collection of 17 functions and a few supporting functions in a script module. Download [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I&#8217;ve posted, and since it&#8217;s almost Christmas I thought I&#8217;d better get on with it.</p>
<p>Without further ado I want to post NetShell (I&#8217;m not very good at coming up with imaginative names). NetShell is a collection of 17 functions and a few supporting functions in a script module. </p>
<p>Download <a href='http://www.indented.co.uk/wp-content/uploads/2011/05/NetShell.zip'>NetShell</a><br />
<span id="more-1561"></span><br />
Installation is a manual process, but not too hard. Open up Documents\WindowsPowerShell\Modules, extract the ZIP file. Make sure it includes the NetShell folder or it won&#8217;t work. The module is not currently signed, something else on the to-do list. Once it&#8217;s there, Import-Module NetShell and off you go.</p>
<p>It includes the following:</p>
<table>
<tr>
<td><b>ConvertTo-BinaryIP</b></td>
<td>Converts an IP address into a binary string</td>
</tr>
<tr>
<td><b>ConvertTo-Byte</b></td>
<td>A supporting function, a simple conversion of a string to a byte array (ASCII encoding)</td>
</tr>
<tr>
<td><b>ConvertTo-DecimalIP</b></td>
<td>Converts an IP address to 32-bit decimal number</td>
</tr>
<tr>
<td><b>ConvertTo-DottedDecimalIP</b></td>
<td>Converts a binary or 32-bit decimal back to an IP</td>
</tr>
<tr>
<td><b>ConvertTo-Mask</b></td>
<td>Converts from a mask length. For example, gets you from 22 to 255.255.252.0</td>
</tr>
<tr>
<td><b>ConvertTo-MaskLength</b></td>
<td>Converts from the IP form of a mask to the length</td>
</tr>
<tr>
<td><b>ConvertTo-String</b></td>
<td>Another supporting function, converts a byte array to a string (ASCII encoding)</td>
</tr>
<tr>
<td><b>Get-BroadcastAddress</b></td>
<td>Returns the broadcast address for the specified IP address and subnet mask</td>
</tr>
<tr>
<td><b>Get-NetworkAddress</b></td>
<td>Returns the network address for the specified IP address and subnet mask</td>
</tr>
<tr>
<td><b>Get-NetworkRange</b></td>
<td>Returns every IP within the specified range</td>
</tr>
<tr>
<td><b>Get-NetworkSummary</b></td>
<td>Everything about an IP address and mask I considered useful</td>
</tr>
<tr>
<td><b>New-DhcpDiscoverPacket</b></td>
<td>A supporting function for Send-DhcpDiscover. Creates the packet to send (a large byte array)</td>
</tr>
<tr>
<td><b>New-Socket</b></td>
<td>Creates an instance of System.Net.Sockets.Socket, an arbitrary network socket to do with as you please.</td>
</tr>
<tr>
<td><b>New-SysLogDateTime</b></td>
<td>A supporting function to create a DateTime string in the format SysLog likes.</td>
</tr>
<tr>
<td><b>Read-DhcpOption</b></td>
<td>A supporting function to read off an Option from a DHCP packet. Needs to be fed the Extended.BinaryReader class at the top of the module.</td>
</tr>
<tr>
<td><b>Read-DhcpPacket</b></td>
<td>Creates and uses an instance of Extended.BinaryReader to process a DHCP packet and translate the fields.</td>
</tr>
<tr>
<td><b>Receive-Bytes</b></td>
<td>Receives a stream of bytes from the network using a socket</td>
</tr>
<tr>
<td><b>Remove-Socket</b></td>
<td>Cleans up after New-Socket</td>
</tr>
<tr>
<td><b>Send-Bytes</b></td>
<td>Sends an arbitrary byte array over the network using a socket</td>
</tr>
<tr>
<td><b>Send-DhcpDiscover</b></td>
<td>Creates and sends a DHCPDISCOVER packet, then processes and returns the response</td>
</tr>
<tr>
<td><b>Start-Syslog</b></td>
<td>Starts a SysLog server. No termination for this one at the moment. Needs a bit more work.</td>
</tr>
<tr>
<td><b>Test-Smtp</b></td>
<td>Does the SMTP test you normally wind up doing with telnet, returning all the results along with the SMTP banner.</td>
</tr>
<tr>
<td><b>Test-SysLogDateTime</b></td>
<td>A supporting function to check the format of a DateTime that may or may not be present in a SysLog message.</td>
</tr>
<tr>
<td><b>Test-SysLogPRI</b></td>
<td>A supporting function to test of the PRI value in a SysLog message.</td>
</tr>
<tr>
<td><b>Test-TcpPort</b></td>
<td>Returns a boolean indicating whether or not the port connection succeeded.</td>
</tr>
</table>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2010/11/25/netshell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DHCP Discovery</title>
		<link>http://www.indented.co.uk/index.php/2010/02/17/dhcp-discovery/</link>
		<comments>http://www.indented.co.uk/index.php/2010/02/17/dhcp-discovery/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 12:46:24 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[DHCP]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.indented.co.uk/?p=1436</guid>
		<description><![CDATA[A PowerShell script to send a DHCP Discover request and listen for DHCP Offer responses, it can be used for finding DHCP servers (including rogue servers), or for testing DHCP servers and relays. The output from this script is an object containing a decode of the DHCP packet and a number of options. By default [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>A PowerShell script to send a DHCP Discover request and listen for DHCP Offer responses, it can be used for finding DHCP servers (including rogue servers), or for testing DHCP servers and relays. The output from this script is an object containing a decode of the DHCP packet and a number of options.<br />
<span id="more-1436"></span><br />
By default the script uses a spoofed MAC address of AA:BB:CC:DD:EE:FF to send the offer, a specific MAC address can be specified using the MacAddressString parameter. </p>
<p>The script can listen for DHCP offers for a specified number of seconds by using the DiscoverTimeout parameter, by default the script listens for 60 seconds. Note that a timeout is set for the ReceiveFrom method, this is set to 10 seconds in the script and applies to each receive attempt. If the connection times out the script will stop listening for offers regardless of the value for DiscoverTimeout.</p>
<p>This script has only been tested using PowerShell 2.0.</p>
<pre class="brush: powershell; title: ; notranslate">
&lt;#
  Net-DhcpDiscover.ps1

  Author: Chris Dent
  Date: 16/02/2010

  A script to send a DHCPDISCOVER request and report on DHCPOFFER
  responses returned by all DHCP Servers on the current subnet.

  DHCP Packet Format (RFC 2131 - http://www.ietf.org/rfc/rfc2131.txt):

  0                   1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |     op (1)    |   htype (1)   |   hlen (1)    |   hops (1)    |
  +---------------+---------------+---------------+---------------+
  |                            xid (4)                            |
  +-------------------------------+-------------------------------+
  |           secs (2)            |           flags (2)           |
  +-------------------------------+-------------------------------+
  |                          ciaddr  (4)                          |
  +---------------------------------------------------------------+
  |                          yiaddr  (4)                          |
  +---------------------------------------------------------------+
  |                          siaddr  (4)                          |
  +---------------------------------------------------------------+
  |                          giaddr  (4)                          |
  +---------------------------------------------------------------+
  |                                                               |
  |                          chaddr  (16)                         |
  |                                                               |
  |                                                               |
  +---------------------------------------------------------------+
  |                                                               |
  |                          sname   (64)                         |
  +---------------------------------------------------------------+
  |                                                               |
  |                          file    (128)                        |
  +---------------------------------------------------------------+
  |                                                               |
  |                          options (variable)                   |
  +---------------------------------------------------------------+

   FIELD      OCTETS       DESCRIPTION
   -----      ------       -----------

   op            1  Message op code / message type.
                    1 = BOOTREQUEST, 2 = BOOTREPLY
   htype         1  Hardware address type, see ARP section in &quot;Assigned
                    Numbers&quot; RFC; e.g., '1' = 10mb ethernet.
   hlen          1  Hardware address length (e.g.  '6' for 10mb
                    ethernet).
   hops          1  Client sets to zero, optionally used by relay agents
                    when booting via a relay agent.
   xid           4  Transaction ID, a random number chosen by the
                    client, used by the client and server to associate
                    messages and responses between a client and a
                    server.
   secs          2  Filled in by client, seconds elapsed since client
                    began address acquisition or renewal process.
   flags         2  Flags (see figure 2).
   ciaddr        4  Client IP address; only filled in if client is in
                    BOUND, RENEW or REBINDING state and can respond
                    to ARP requests.
   yiaddr        4  'your' (client) IP address.
   siaddr        4  IP address of next server to use in bootstrap;
                    returned in DHCPOFFER, DHCPACK by server.
   giaddr        4  Relay agent IP address, used in booting via a
                    relay agent.
   chaddr       16  Client hardware address.
   sname        64  Optional server host name, null terminated string.
   file        128  Boot file name, null terminated string; &quot;generic&quot;
                    name or null in DHCPDISCOVER, fully qualified
                    directory-path name in DHCPOFFER.
   options     var  Optional parameters field.  See the options
                    documents for a list of defined options.
#&gt;

#
# Parameters
#

Param(
  # MAC Address String in Hex-Decimal Format can be delimited with
  # dot, dash or colon (or none)
  [String]$MacAddressString = &quot;AA:BB:CC:DD:EE:FF&quot;,
  # Length of time (in seconds) to spend waiting for Offers if
  # the connection does not timeout first
  [Byte]$DiscoverTimeout = 60
)

# Build a DHCPDISCOVER packet to send
#
# Caller: Main

Function New-DhcpDiscoverPacket
{
  Param(
    [String]$MacAddressString = &quot;AA:BB:CC:DD:EE:FF&quot;
  )

  # Generate a Transaction ID for this request

  $XID = New-Object Byte[] 4
  $Random = New-Object Random
  $Random.NextBytes($XID)

  # Convert the MAC Address String into a Byte Array

  # Drop any characters which might be used to delimit the string
  $MacAddressString = $MacAddressString -Replace &quot;-|:|\.&quot;
  $MacAddress = [BitConverter]::GetBytes((
    [UInt64]::Parse($MacAddressString,
    [Globalization.NumberStyles]::HexNumber)))
  # Reverse the MAC Address array
  [Array]::Reverse($MacAddress)

  # Create the Byte Array
  $DhcpDiscover = New-Object Byte[] 243

  # Copy the Transaction ID Bytes into the array
  [Array]::Copy($XID, 0, $DhcpDiscover, 4, 4)

  # Copy the MacAddress Bytes into the array (drop the first 2 bytes,
  # too many bytes returned from UInt64)
  [Array]::Copy($MACAddress, 2, $DhcpDiscover, 28, 6)

  # Set the OP Code to BOOTREQUEST
  $DhcpDiscover[0] = 1
  # Set the Hardware Address Type to Ethernet
  $DhcpDiscover[1] = 1
  # Set the Hardware Address Length (number of bytes)
  $DhcpDiscover[2] = 6
  # Set the Broadcast Flag
  $DhcpDiscover[10] = 128
  # Set the Magic Cookie values
  $DhcpDiscover[236] = 99
  $DhcpDiscover[237] = 130
  $DhcpDiscover[238] = 83
  $DhcpDiscover[239] = 99
  # Set the DHCPDiscover Message Type Option
  $DhcpDiscover[240] = 53
  $DhcpDiscover[241] = 1
  $DhcpDiscover[242] = 1

  Return $DhcpDiscover
}

# Parse a DHCP Packet, returning an object containing each field
#
# Caller: Main

Function Read-DhcpPacket( [Byte[]]$Packet )
{
  $Reader = New-Object IO.BinaryReader(New-Object IO.MemoryStream(@(,$Packet)))

  $DhcpResponse = New-Object Object

  # Get and translate the Op code
  $DhcpResponse | Add-Member NoteProperty Op $Reader.ReadByte()
  if ($DhcpResponse.Op -eq 1)
  {
    $DhcpResponse.Op = &quot;BootRequest&quot;
  }
  else
  {
    $DhcpResponse.Op = &quot;BootResponse&quot;
  }

  $DhcpResponse | Add-Member NoteProperty HType -Value $Reader.ReadByte()
  if ($DhcpResponse.HType -eq 1) { $DhcpResponse.HType = &quot;Ethernet&quot; }

  $DhcpResponse | Add-Member NoteProperty HLen $Reader.ReadByte()
  $DhcpResponse | Add-Member NoteProperty Hops $Reader.ReadByte()
  $DhcpResponse | Add-Member NoteProperty XID $Reader.ReadUInt32()
  $DhcpResponse | Add-Member NoteProperty Secs $Reader.ReadUInt16()
  $DhcpResponse | Add-Member NoteProperty Flags $Reader.ReadUInt16()
  # Broadcast is the only flag that can be present, the other bits are reserved
  if ($DhcpResponse.Flags -BAnd 128) { $DhcpResponse.Flags = @(&quot;Broadcast&quot;) }

  $DhcpResponse | Add-Member NoteProperty CIAddr `
    $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
    &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;)
  $DhcpResponse | Add-Member NoteProperty YIAddr `
    $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
    &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;)
  $DhcpResponse | Add-Member NoteProperty SIAddr `
    $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
    &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;)
  $DhcpResponse | Add-Member NoteProperty GIAddr `
    $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
    &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;)

  $MacAddrBytes = New-Object Byte[] 16
  [Void]$Reader.Read($MacAddrBytes, 0, 16)
  $MacAddress = [String]::Join(
    &quot;:&quot;, $($MacAddrBytes[0..5] | %{ [String]::Format('{0:X2}', $_) }))
  $DhcpResponse | Add-Member NoteProperty CHAddr $MacAddress

  $DhcpResponse | Add-Member NoteProperty SName `
    $([String]::Join(&quot;&quot;, $Reader.ReadChars(64)).Trim())
  $DhcpResponse | Add-Member NoteProperty File `
    $([String]::Join(&quot;&quot;, $Reader.ReadChars(128)).Trim())

  $DhcpResponse | Add-Member NoteProperty MagicCookie `
    $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
    &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;)

  # Start reading Options

  $DhcpResponse | Add-Member NoteProperty Options @()
  While ($Reader.BaseStream.Position -lt $Reader.BaseStream.Length)
  {
    $Option = New-Object Object
    $Option | Add-Member NoteProperty OptionCode $Reader.ReadByte()
    $Option | Add-Member NoteProperty OptionName &quot;&quot;
    $Option | Add-Member NoteProperty Length 0
    $Option | Add-Member NoteProperty OptionValue &quot;&quot;

    If ($Option.OptionCode -ne 0 -And $Option.OptionCode -ne 255)
    {
      $Option.Length = $Reader.ReadByte()
    }

    Switch ($Option.OptionCode)
    {
      0 { $Option.OptionName = &quot;PadOption&quot; }
      1 {
        $Option.OptionName = &quot;SubnetMask&quot;
        $Option.OptionValue = `
          $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
          &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;) }
      3 {
        $Option.OptionName = &quot;Router&quot;
        $Option.OptionValue = `
          $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
          &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;) }
      6 {
        $Option.OptionName = &quot;DomainNameServer&quot;
        $Option.OptionValue = @()
        For ($i = 0; $i -lt ($Option.Length / 4); $i++)
        {
          $Option.OptionValue += `
            $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
            &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;)
        } }
      15 {
        $Option.OptionName = &quot;DomainName&quot;
        $Option.OptionValue = [String]::Join(
          &quot;&quot;, $Reader.ReadChars($Option.Length)) }
      51 {
        $Option.OptionName = &quot;IPAddressLeaseTime&quot;
        # Read as Big Endian
        $Value = ($Reader.ReadByte() * [Math]::Pow(256, 3)) + `
          ($Reader.ReadByte() * [Math]::Pow(256, 2)) + `
          ($Reader.ReadByte() * 256) + `
          $Reader.ReadByte()
        $Option.OptionValue = $(New-TimeSpan -Seconds $Value) }
      53 {
        $Option.OptionName = &quot;DhcpMessageType&quot;
        Switch ($Reader.ReadByte())
        {
          1 { $Option.OptionValue = &quot;DHCPDISCOVER&quot; }
          2 { $Option.OptionValue = &quot;DHCPOFFER&quot; }
          3 { $Option.OptionValue = &quot;DHCPREQUEST&quot; }
          4 { $Option.OptionValue = &quot;DHCPDECLINE&quot; }
          5 { $Option.OptionValue = &quot;DHCPACK&quot; }
          6 { $Option.OptionValue = &quot;DHCPNAK&quot; }
          7 { $Option.OptionValue = &quot;DHCPRELEASE&quot; }
        } }
      54 {
        $Option.OptionName = &quot;DhcpServerIdentifier&quot;
        $Option.OptionValue = `
          $(&quot;$($Reader.ReadByte()).$($Reader.ReadByte()).&quot; + `
          &quot;$($Reader.ReadByte()).$($Reader.ReadByte())&quot;) }
      58 {
        $Option.OptionName = &quot;RenewalTime&quot;
        # Read as Big Endian
        $Value = ($Reader.ReadByte() * [Math]::Pow(256, 3)) + `
          ($Reader.ReadByte() * [Math]::Pow(256, 2)) + `
          ($Reader.ReadByte() * 256) + `
          $Reader.ReadByte()
        $Option.OptionValue = $(New-TimeSpan -Seconds $Value) }
      59 {
        $Option.OptionName = &quot;RebindingTime&quot;
        # Read as Big Endian
        $Value = ($Reader.ReadByte() * [Math]::Pow(256, 3)) + `
          ($Reader.ReadByte() * [Math]::Pow(256, 2)) + `
          ($Reader.ReadByte() * 256) + `
          $Reader.ReadByte()
        $Option.OptionValue = $(New-TimeSpan -Seconds $Value) }
      255 { $Option.OptionName = &quot;EndOption&quot; }
      default {
        # For all options which are not decoded here
        $Option.OptionName = &quot;NoOptionDecode&quot;
        $Buffer = New-Object Byte[] $Option.Length
        [Void]$Reader.Read($Buffer, 0, $Option.Length)
        $Option.OptionValue = $Buffer
      }
    }

    # Override the ToString method
    $Option | Add-Member ScriptMethod ToString `
        { Return &quot;$($this.OptionName) ($($this.OptionValue))&quot; } -Force

    $DhcpResponse.Options += $Option
  }

  Return $DhcpResponse
}

# Create a UDP Socket with Broadcast and Address Re-use enabled.
#
# Caller: Main

Function New-UdpSocket
{
  Param(
    [Int32]$SendTimeOut = 5,
    [Int32]$ReceiveTimeOut = 5
  )

  $UdpSocket = New-Object Net.Sockets.Socket(
    [Net.Sockets.AddressFamily]::InterNetwork,
    [Net.Sockets.SocketType]::Dgram,
    [Net.Sockets.ProtocolType]::Udp)
  $UdpSocket.EnableBroadcast = $True
  $UdpSocket.ExclusiveAddressUse = $False
  $UdpSocket.SendTimeOut = $SendTimeOut * 1000
  $UdpSocket.ReceiveTimeOut = $ReceiveTimeOut * 1000

  Return $UdpSocket
}

# Close down a Socket
#
# Caller: Main

Function Remove-Socket
{
  Param(
    [Net.Sockets.Socket]$Socket
  )

  $Socket.Shutdown(&quot;Both&quot;)
  $Socket.Close()
}

#
# Main
#

# Create a Byte Array for the DHCPDISCOVER packet
$Message = New-DhcpDiscoverPacket -Send 10 -Receive 10

# Create a socket
$UdpSocket = New-UdpSocket

# UDP Port 68 (Server-to-Client port)
$EndPoint = [Net.EndPoint](
  New-Object Net.IPEndPoint($([Net.IPAddress]::Any, 68)))
# Listen on $EndPoint
$UdpSocket.Bind($EndPoint)

# UDP Port 67 (Client-to-Server port)
$EndPoint = [Net.EndPoint](
 New-Object Net.IPEndPoint($([Net.IPAddress]::Broadcast, 67)))
# Send the DHCPDISCOVER packet
$BytesSent = $UdpSocket.SendTo($Message, $EndPoint)

# Begin receiving and processing responses
$NoConnectionTimeOut = $True

$Start = Get-Date

While ($NoConnectionTimeOut)
{
  $BytesReceived = 0
  Try
  {
    # Placeholder EndPoint for the Sender
    $SenderEndPoint = [Net.EndPoint](
      New-Object Net.IPEndPoint($([Net.IPAddress]::Any, 0)))
    # Receive Buffer
    $ReceiveBuffer = New-Object Byte[] 1024
    $BytesReceived = $UdpSocket.ReceiveFrom($ReceiveBuffer, [Ref]$SenderEndPoint)
  }
  #
  # Catch a SocketException, thrown when the Receive TimeOut value is reached
  #
  Catch [Net.Sockets.SocketException]
  {
    $NoConnectionTimeOut = $False
  }

  If ($BytesReceived -gt 0)
  {
    Read-DhcpPacket $ReceiveBuffer[0..$BytesReceived]
  }

  If ((Get-Date) -gt $Start.AddSeconds($DiscoverTimeout))
  {
    # Exit condition, not error condition
    $NoConnectionTimeOut = $False
  }
}

Remove-Socket $UdpSocket
</pre>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2010/02/17/dhcp-discovery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

