ipconfig的C语言实现(3)

printf("\tPhysical Address. . . . . . : ");
        for (UINT i=0; i<pAdapt->AddressLength; i++)
        {
            if (i == (pAdapt->AddressLength - 1))
                printf("%.2X\n",(int)pAdapt->Address[i]);
            else
                printf("%.2X-",(int)pAdapt->Address[i]);
        }       

printf("\tDHCP Enabled. . . . . . . . : %s\n", (pAdapt->DhcpEnabled ? "yes" : "no"));

pAddrStr = &(pAdapt->IpAddressList);
        while(pAddrStr)
        {
            printf("\tIP Address. . . . . . . . . : %s\n", pAddrStr->IpAddress.String);
            printf("\tSubnet Mask . . . . . . . . : %s\n", pAddrStr->IpMask.String);
            pAddrStr = pAddrStr->Next;
        }

printf("\tDefault Gateway . . . . . . : %s\n", pAdapt->GatewayList.IpAddress.String);
        pAddrStr = pAdapt->GatewayList.Next;
        while(pAddrStr)
        {
            printf("%52s\n", pAddrStr->IpAddress.String);
            pAddrStr = pAddrStr->Next;
        }

printf("\tDHCP Server . . . . . . . . : %s\n", pAdapt->DhcpServer.IpAddress.String);
        printf("\tPrimary WINS Server . . . . : %s\n", pAdapt->PrimaryWinsServer.IpAddress.String);
        printf("\tSecondary WINS Server . . . : %s\n", pAdapt->SecondaryWinsServer.IpAddress.String);

struct tm *newtime;

// Display coordinated universal time - GMT
        newtime = gmtime(&pAdapt->LeaseObtained); 
        printf( "\tLease Obtained. . . . . . . : %s", asctime( newtime ) );

newtime = gmtime(&pAdapt->LeaseExpires); 
        printf( "\tLease Expires . . . . . . . : %s", asctime( newtime ) );

pAdapt = pAdapt->Next;
    }
}

void DoUsage(bool doUsage)
{

if(doUsage)
 {
 printf("\nUSAGE:\n"
    "    ipconfig [/? | /all | /renew [adapter] | /release [adapter] |\n"
    "              /flushdns | /displaydns | /registerdns |\n"
    "              /showclassid adapter |\n"
    "              /setclassid adapter [classid] ]\n"
    "\n"
    "where\n"
    "    adapter        Connection name\n"
    "                  (wildcard characters * and ? allowed, see examples)\n"
    "\n"
    "    Options:\n"
    "      /?          Display this help message\n"
    "      /all        Display full configuration information.\n"
    "      /release    Release the IP address for the specified adapter.\n"
    "      /renew      Renew the IP address for the specified adapter.\n"
    "      /flushdns    Purges the DNS Resolver cache.\n"
    "      /registerdns Refreshes all DHCP leases and re-registers DNS names.\n"
    "      /displaydns  Display the contents of the DNS Resolver Cache.\n"
    "      /showclassid Displays all the dhcp class IDs allowed for adapter.\n"
    "      /setclassid  Modifies the dhcp class id.\n"
    "\n"
    "The default is to display only the IP address, subnet mask and\n"
    "default gateway for each adapter bound to TCP/IP.\n"
    "\n"
    "For Release and Renew, if no adapter name is specified, then the IP address\n"
    "leases for all adapters bound to TCP/IP will be released or renewed.\n"
    "\n"
    "For Setclassid, if no ClassId is specified, then the ClassId is removed.\n"
    "\n"
    "Examples:\n"
    "    > ipconfig                  ... Show information.\n"
    "    > ipconfig /all              ... Show detailed information\n"
    "    > ipconfig /renew            ... renew all adapters\n"
    "    > ipconfig /renew EL*        ... renew any connection that has its\n"
    "                                    name starting with EL\n"
    "    > ipconfig /release *Con*    ... release all matching connections,\n"
    "                                    eg. \"Local Area Connection 1\" or\n"
    "                                        \"Local Area Connection 2\"\n");
 
 
 
 
 }

else
 {
 printf("ilegal code!");
 
 }

}
void DoDisplayDns(bool doDisplayDns)

{
if(doDisplayDns)
{
    char hostname[256];
 int iRet = 0;
 WSADATA wsaData;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/57fda19319241a422019eec4f90ad986.html