Use inet_ntop() to display configured EoE parameters.
This commit is contained in:
parent
a1552bdf61
commit
e4588964a5
|
|
@ -21,14 +21,16 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "CommandConfig.h"
|
||||||
|
#include "MasterDevice.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "CommandConfig.h"
|
#include <arpa/inet.h>
|
||||||
#include "MasterDevice.h"
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -307,6 +309,7 @@ void CommandConfig::showDetailedConfigs(
|
||||||
if (ip.mac_address_included or ip.ip_address_included or
|
if (ip.mac_address_included or ip.ip_address_included or
|
||||||
ip.subnet_mask_included or ip.gateway_included or
|
ip.subnet_mask_included or ip.gateway_included or
|
||||||
ip.dns_included or ip.name_included) {
|
ip.dns_included or ip.name_included) {
|
||||||
|
char addr[32];
|
||||||
cout << indent << "EoE IP parameters:" << endl;
|
cout << indent << "EoE IP parameters:" << endl;
|
||||||
if (ip.mac_address_included) {
|
if (ip.mac_address_included) {
|
||||||
cout << indent << " MAC address: "
|
cout << indent << " MAC address: "
|
||||||
|
|
@ -319,36 +322,20 @@ void CommandConfig::showDetailedConfigs(
|
||||||
<< ip.mac_address[5] << dec << endl;
|
<< ip.mac_address[5] << dec << endl;
|
||||||
}
|
}
|
||||||
if (ip.ip_address_included) {
|
if (ip.ip_address_included) {
|
||||||
const uint8_t *addr = (const uint8_t *) &ip.ip_address;
|
inet_ntop(AF_INET, &ip.ip_address, addr, sizeof(addr));
|
||||||
cout << indent << " IP address: "
|
cout << indent << " IP address: " << addr << endl;
|
||||||
<< (unsigned int) addr[0] << "."
|
|
||||||
<< (unsigned int) addr[1] << "."
|
|
||||||
<< (unsigned int) addr[2] << "."
|
|
||||||
<< (unsigned int) addr[3] << endl;
|
|
||||||
}
|
}
|
||||||
if (ip.subnet_mask_included) {
|
if (ip.subnet_mask_included) {
|
||||||
const uint8_t *addr = (const uint8_t *) &ip.subnet_mask;
|
inet_ntop(AF_INET, &ip.subnet_mask, addr, sizeof(addr));
|
||||||
cout << indent << " Subnet mask: "
|
cout << indent << " Subnet mask: " << addr << endl;
|
||||||
<< (unsigned int) addr[0] << "."
|
|
||||||
<< (unsigned int) addr[1] << "."
|
|
||||||
<< (unsigned int) addr[2] << "."
|
|
||||||
<< (unsigned int) addr[3] << endl;
|
|
||||||
}
|
}
|
||||||
if (ip.gateway_included) {
|
if (ip.gateway_included) {
|
||||||
const uint8_t *addr = (const uint8_t *) &ip.gateway;
|
inet_ntop(AF_INET, &ip.gateway, addr, sizeof(addr));
|
||||||
cout << indent << " Default gateway: "
|
cout << indent << " Default gateway: " << addr << endl;
|
||||||
<< (unsigned int) addr[0] << "."
|
|
||||||
<< (unsigned int) addr[1] << "."
|
|
||||||
<< (unsigned int) addr[2] << "."
|
|
||||||
<< (unsigned int) addr[3] << endl;
|
|
||||||
}
|
}
|
||||||
if (ip.dns_included) {
|
if (ip.dns_included) {
|
||||||
const uint8_t *addr = (const uint8_t *) &ip.dns;
|
inet_ntop(AF_INET, &ip.dns, addr, sizeof(addr));
|
||||||
cout << indent << " DNS server address: "
|
cout << indent << " DNS server address: " << addr << endl;
|
||||||
<< (unsigned int) addr[0] << "."
|
|
||||||
<< (unsigned int) addr[1] << "."
|
|
||||||
<< (unsigned int) addr[2] << "."
|
|
||||||
<< (unsigned int) addr[3] << endl;
|
|
||||||
}
|
}
|
||||||
if (ip.name_included) {
|
if (ip.name_included) {
|
||||||
cout << indent << " Hostname: " << ip.name << endl;
|
cout << indent << " Hostname: " << ip.name << endl;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue