From: edavid3001 on
Here is the problem:

We have several DHCP servers running on *nix boxes. We have a 24/7
computer operator that are very entry level.

We have a DHCPCHECK.exe program that checks to see if DHCP is running,
and on what servers. It is their job to verify the proper servers
respond.

This program is DOS based, and fails in XP. It worked in NT 4.0.

I am trying to figure out how to do this in XP. I am aware of DHCPLOC,
but this is too complicated for them to use.

I have wrote a VB6 program that makes a DHCP request. I can verify in
Ethereal that the request invokes responses from the DHCPserver (I
haven't completed the request to RFC yet, though it works. I want to
get past this hurdle first.)

The problem is that although the request makes it back to the client PC
per Ethereal, and on broadcast port 255.255.255.255, the problem is
that I cannot bind to port 68 UDP in VB6 to get these replys.

Since DHCPLoc can see and parse the responses, I must be doing
something wrong.

First, is there an easy DHCP check I can use to replace this older one?
Second, what is wrong with my VB6 program with regards to port 68?
Posted below: (I am aware I should do option explicit et. al.)

/Begin code -- if this wraps in your news reader, you may need to add _
or remove <crlf>'s.

Private Sub Command1_Click()
Winsock2.Close
Winsock1.Close

Winsock2.RemoteHost = "255.255.255.255"
Winsock2.RemotePort = 67
Winsock2.LocalPort = 68

'This is where it fails - address already in use
Winsock2.Bind 68


'Winsock2.Listen
'Winsock2.Connect



Winsock1.RemoteHost = "255.255.255.255"
Winsock1.LocalPort = 67
Winsock1.RemotePort = 67
Winsock1.Connect
zero64 = Space(64)
zero64 = Replace(zero65, " ", Chr$(0))


dataout = Chr$(1) + Chr$(1) + Chr$(6) + Chr$(0) + Chr$(0) + Chr$(0) +
Chr$(0) + Chr$(0) + Chr$(60) + Chr$(0) + Chr$(128) + Chr$(0)
'at this point we are to client ip address
dataout = dataout + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) +
Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) +
Chr$(0) + Chr$(0) + Chr$(0)
'At this point we are up to NEXT SERVER IP address

'This does the relay agent, then mac address of client all 00
dataout = dataout + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) +
Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0)
'Now we are into servername
dataout = dataout + zero64
'Now we are into bootp file name
dataout = dataout + zero64 + zero64
'now magic cookie 63 82 53 63
dataout = dataout + Chr$(99) + Chr$(130) + Chr$(83) + Chr$(99)
'request type
dataout = dataout + Chr$(53) + Chr$(1) + Chr$(1) + Chr$(255)
Winsock1.SendData dataout
DoEvents
Winsock1.Close
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData Data$
Debug.Print "winsock1:" + Winsock1.RemoteHostIP
'Debug.Print "winsock1:";

Debug.Print Data$
End Sub

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Winsock2.GetData Data$
Debug.Print "winsock2:" + Data$
Debug.Print "winsock2:" + Winsock2.RemoteHostIP
End Sub

From: James A. Gayhart on
Hi,

Here's some aircode:

With Winsock2
.Protocol = sckUDPProtocol
.LocalPort = 68
.Bind
End With

You'll also need a bit of code in the Winsock2_DataArrival event. Lastly,
after you close the connection to Winsock2 (Winsock2.Close), you should wait
until the connection is actually closed:

With Winsock2
.Close
Do While .State <> sckClosed
DoEvents
Loop
End With

Let me know if that helps.
--
James A. Gayhart
http://www.silverjaguar.com/blog/


<edavid3001(a)gmail.com> wrote in message
news:1107467712.984133.10930(a)l41g2000cwc.googlegroups.com...
> Here is the problem:
>
> We have several DHCP servers running on *nix boxes. We have a 24/7
> computer operator that are very entry level.
>
> We have a DHCPCHECK.exe program that checks to see if DHCP is running,
> and on what servers. It is their job to verify the proper servers
> respond.
>
> This program is DOS based, and fails in XP. It worked in NT 4.0.
>
> I am trying to figure out how to do this in XP. I am aware of DHCPLOC,
> but this is too complicated for them to use.
>
> I have wrote a VB6 program that makes a DHCP request. I can verify in
> Ethereal that the request invokes responses from the DHCPserver (I
> haven't completed the request to RFC yet, though it works. I want to
> get past this hurdle first.)
>
> The problem is that although the request makes it back to the client PC
> per Ethereal, and on broadcast port 255.255.255.255, the problem is
> that I cannot bind to port 68 UDP in VB6 to get these replys.
>
> Since DHCPLoc can see and parse the responses, I must be doing
> something wrong.
>
> First, is there an easy DHCP check I can use to replace this older one?
> Second, what is wrong with my VB6 program with regards to port 68?
> Posted below: (I am aware I should do option explicit et. al.)
>
> /Begin code -- if this wraps in your news reader, you may need to add _
> or remove <crlf>'s.
>
> Private Sub Command1_Click()
> Winsock2.Close
> Winsock1.Close
>
> Winsock2.RemoteHost = "255.255.255.255"
> Winsock2.RemotePort = 67
> Winsock2.LocalPort = 68
>
> 'This is where it fails - address already in use
> Winsock2.Bind 68
>
>
> 'Winsock2.Listen
> 'Winsock2.Connect
>
>
>
> Winsock1.RemoteHost = "255.255.255.255"
> Winsock1.LocalPort = 67
> Winsock1.RemotePort = 67
> Winsock1.Connect
> zero64 = Space(64)
> zero64 = Replace(zero65, " ", Chr$(0))
>
>
> dataout = Chr$(1) + Chr$(1) + Chr$(6) + Chr$(0) + Chr$(0) + Chr$(0) +
> Chr$(0) + Chr$(0) + Chr$(60) + Chr$(0) + Chr$(128) + Chr$(0)
> 'at this point we are to client ip address
> dataout = dataout + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) +
> Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) +
> Chr$(0) + Chr$(0) + Chr$(0)
> 'At this point we are up to NEXT SERVER IP address
>
> 'This does the relay agent, then mac address of client all 00
> dataout = dataout + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) +
> Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0)
> 'Now we are into servername
> dataout = dataout + zero64
> 'Now we are into bootp file name
> dataout = dataout + zero64 + zero64
> 'now magic cookie 63 82 53 63
> dataout = dataout + Chr$(99) + Chr$(130) + Chr$(83) + Chr$(99)
> 'request type
> dataout = dataout + Chr$(53) + Chr$(1) + Chr$(1) + Chr$(255)
> Winsock1.SendData dataout
> DoEvents
> Winsock1.Close
> End Sub
>
> Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
> Winsock1.GetData Data$
> Debug.Print "winsock1:" + Winsock1.RemoteHostIP
> 'Debug.Print "winsock1:";
>
> Debug.Print Data$
> End Sub
>
> Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
> Winsock2.GetData Data$
> Debug.Print "winsock2:" + Data$
> Debug.Print "winsock2:" + Winsock2.RemoteHostIP
> End Sub
>


From: Michael B. Johnson on
On 3 Feb 2005 14:02:07 -0800, edavid3001(a)gmail.com wrote:

>Here is the problem:
>
>I am trying to figure out how to do this in XP. I am aware of DHCPLOC,
>but this is too complicated for them to use.

Here's a lazy idea....

If DHCPLOC can be automated, scripted or run from the commandline, you
could easily write a VB wrapper for it, supplying the appropriate
options automatically for your users. That way it becomes an "easy"
tool for them to use.
_______________________
Michael B. Johnson
 | 
Pages: 1
Prev: NEOPOINT GENERATOR
Next: VB3 anyone...?