Compartilhar via


IP_ADDR_STRING (Compact 2013)

3/26/2014

This structure stores an IP address and corresponding subnet mask as dotted decimal strings. This structure represents a node in a linked list of IP addresses.

Syntax

typedef struct _IP_ADDR_STRING {
  struct _IP_ADDR_STRING* Next;
  IP_ADDRESS_STRING IpAddress;
  IP_MASK_STRING IpMask;
  DWORD Context;
} IP_ADDR_STRING, *PIP_ADDR_STRING;

Members

  • Next
    A pointer to the next IP_ADDR_STRING structure in the list.
  • IpAddress
    A structure type with a single member, String. The String member is a char array of size 16. This array holds the IP address.
  • IpMask
    A structure type with a single member, String. The String member is a char array of size 16. This array holds the subnet mask for the IP address.
  • Context
    Network table entry (NTE). This value corresponds to the NTEContext parameters in the AddIPAddress and DeleteIPAddress functions.

Example Code

The following example retrieves the network parameters for the local device and prints information from the returned data.

// Link with IPHlpAPI.lib
//
#include <winsock2.h>
#include <iphlpapi.h>
#include <stdio.h>

int __cdecl main() {
   
   FIXED_INFO * FixedInfo;
   ULONG    ulOutBufLen;
   DWORD    dwRetVal;
   IP_ADDR_STRING * pIPAddr;

   FixedInfo = (FIXED_INFO *) GlobalAlloc( GPTR, sizeof( FIXED_INFO ) );
   ulOutBufLen = sizeof( FIXED_INFO );
   
   if( ERROR_BUFFER_OVERFLOW == GetNetworkParams( FixedInfo, &ulOutBufLen ) ) {
      GlobalFree( FixedInfo );
      FixedInfo = (FIXED_INFO *) GlobalAlloc( GPTR, ulOutBufLen );
   }

   if ( dwRetVal = GetNetworkParams( FixedInfo, &ulOutBufLen ) ) {
        printf( "Call to GetNetworkParams failed. Return Value: %08x\n", dwRetVal );
        exit(1);
   }
   else {
      printf( "Host Name: %s\n", FixedInfo -> HostName );
      printf( "Domain Name: %s\n", FixedInfo -> DomainName );
      
      printf( "DNS Servers:\n" );
      printf( "\t%s\n", FixedInfo -> DnsServerList.IpAddress.String );
      
      pIPAddr = FixedInfo -> DnsServerList.Next;
      while ( pIPAddr ) {
         printf( "\t%s\n", pIPAddr ->IpAddress.String );
         pIPAddr = pIPAddr -> Next;
      }
   }
   exit( 0 );
}

Requirements

Header

iptypes.h

See Also

Reference

IP Helper Structures
AddIPAddress
DeleteIPAddress
IP_ADAPTER_INFO
IP_ADDRESS_STRING