|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Services
Chapters
Feature Zones
|
IntroductionI needed some code that would give me the IP number of my machine. Not only the number assigned to it by DHCP, either on a LAN or by my ISP when dialing up, but also my IP number as seen from the web, if my machine is behind a router/firewall. It took a while before I figured it all out, and in the process I have seen a lot of code from others. I borrowed some code here and there, but I don't remember exactly what part, so it is hard to give credits to the authors of that code. Sorry about that. Hope I can make it up by sharing this code with you.
Relevant functions in the sample source codeThe sample program does essentially two things: it reports the IP numbers as 'known' by the TCP/IP software on your own machine ('internal' IP numbers) and it reports the IP numbers of your machine as seen from the web ('external' IP numbers). Of course one of the internal numbers will be the same as the external number if there is no router/firewall between your machine and the Internet.
Internal IP numbersInternal IP numbers are reported by function typedef struct _MIB_IPADDRTABLE { DWORD dwNumEntries; MIB_IPADDRROW table[ANY_SIZE]; } MIB_IPADDRTABLE, *PMIB_IPADDRTABLE;
The structure of 'table' looks like this: typedef struct _MIB_IPADDRROW { DWORD dwAddr; DWORD dwIndex; DWORD dwMask; DWORD dwBCastAddr; DWORD dwReasmSize; unsigned short unused1; unsigned short wType; } MIB_IPADDRROW, *PMIB_IPADDRROW;
External IP numbersExternal IP numbers are reported by function
How to pass through an authenticating proxy server
About the authorMy name is Nico Cuppen. I live in Haarlem, The Netherlands and I like programming. That's how I became a shareware author. You can find more info about me and my products on www.nicocuppen.com.
|
||||||||||||||||||||||