How do i get the Ip from a connection to my pc ?

im playing with the netmon source and id like to add the remote ip of the connection ,too.
first i need the dwRemoteAddr to close the remote connection but i cant code or read VB code.

can anyone help ?

txtOutput = ""
nRet = GetTcpTable(pTcpTable, pdwSize, bOrder)
nRet = GetTcpTable(pTcpTable, pdwSize, bOrder)
For i = 0 To pTcpTable.dwNumEntries - 1
If pTcpTable.table(i).dwState - 1 <> MIB_TCP_STATE_LISTEN Then
txtOutput = txtOutput & c_ip(pTcpTable.table(i).dwLocalAddr) & ":" & _
c_port(pTcpTable.table(i).dwLocalPort) & vbTab & _
c_ip(pTcpTable.table(i).dwRemoteAddr) & ":" & _
c_port(pTcpTable.table(i).dwRemotePort) & vbTab & _
c_state(pTcpTable.table(i).dwState - 1) & vbCrLf
Else
txtOutput = txtOutput & c_ip(pTcpTable.table(i).dwLocalAddr) & ":" & _
c_port(pTcpTable.table(i).dwLocalPort) & vbTab & _
c_ip(pTcpTable.table(i).dwRemoteAddr) & ":0" & _
vbTab & _
c_state(pTcpTable.table(i).dwState - 1) & vbCrLf
End If
Next
End Sub

VB source here [3kb netstat]: http://www.ostrosoft.com/vb/projects/iphlpapi.html

http://www.ostrosoft.com/vb/projects/iphlpapi.gif

thanks !
Posted on 2002-01-06 02:52:02 by Max
I don't read VB either - and especially not VB that not indented at all ;).
You might want to look up the iphlp api in the platformsdk (or at
microsoft's online MSDN), these functions seem to be well documented.
Use GetTcpTable as a starting point.
Posted on 2002-01-06 04:05:23 by f0dder
Netmon uses GetTcpTable to get the list of connections, and as these list contains a MIB_TCPROW entry for each connection, you can find the remote address inside that entry:


MIB_TCPROW STRUCT
dwState DWORD ?
dwLocalAddr DWORD ?
dwLocalPort DWORD ?
[b] dwRemoteAddr DWORD ?[/b]
dwRemotePort DWORD ?
MIB_TCPROW ENDS


Thomas
Posted on 2002-01-06 04:24:38 by Thomas

....You might want to look up the iphlp api in the platformsdk (or at microsoft's online MSDN), these functions seem to be well documented....Use GetTcpTable as a starting point.


I recently posted the docs & include for iphlpapi in the networking section.

Thomas
Posted on 2002-01-06 04:26:46 by Thomas
searching hours google and then the result is since weeks on my pc *hahaha*

thanks thomas !
Posted on 2002-01-06 05:31:53 by Max