subnet - Obtaining SubnetMask in C -
i wanted ip address , subnet mask. ip part done, couldn't find socket function return structure subnet mask in it. socket function exist, returns in structure?
thanks!
in windows using iphelper.
#include <winsock2.h> #include <iphlpapi.h> #include <stdio.h> #include <stdlib.h> #pragma comment(lib, "iphlpapi.lib") #define malloc(x) heapalloc(getprocessheap(), 0, (x)) #define free(x) heapfree(getprocessheap(), 0, (x)) /* note: use malloc() , free() */ int __cdecl main() { pip_adapter_info padapterinfo; ulong uloutbuflen = sizeof (ip_adapter_info); padapterinfo = (ip_adapter_info *) malloc(sizeof (ip_adapter_info)); getadaptersinfo(padapterinfo, &uloutbuflen); printf("\tip mask: \t%s\n", padapterinfo->ipaddresslist.ipmask.string); } if (padapterinfo) free(padapterinfo); return 0; }
Comments
Post a Comment