#include <netinet/in.h>
void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
+ struct in_addr in;
CREATE_NEW_OBJECT;
add_hb(is_pxe_valid);
add_hi(pxe.nictype);
add_hs(pxe.mac_addr);
- char ip[16] = {0};
- snprintf(ip,sizeof(ip), "%d.%d.%d.%d",
- hardware->pxe.ip_addr[0],
- hardware->pxe.ip_addr[1],
- hardware->pxe.ip_addr[2],
- hardware->pxe.ip_addr[3]);
- add_s("pxe.client_ip",inet_ntoa(hardware->pxe.dhcpdata.cip));
- add_s("pxe.next_server_ip",inet_ntoa(hardware->pxe.dhcpdata.sip));
- add_s("pxe.relay_agent_ip",inet_ntoa(hardware->pxe.dhcpdata.gip));
- add_s("pxe.ipaddr",ip);
+ in.s_addr = hardware->pxe.dhcpdata.cip;
+ add_s("pxe.client_ip", inet_ntoa(in));
+ in.s_addr = hardware->pxe.dhcpdata.sip;
+ add_s("pxe.next_server_ip",inet_ntoa(in));
+ in.s_addr = hardware->pxe.dhcpdata.gip;
+ add_s("pxe.relay_agent_ip",inet_ntoa(in));
+ memcpy(&in, hardware->pxe.ip_addr, sizeof in);
+ add_s("pxe.ipaddr",inet_ntoa(in));
add_b("gpxe_detected",is_gpxe());
}
FLUSH_OBJECT;
#include <stdint.h>
#include <klibc/compiler.h>
+#include <klibc/extern.h>
#define __htons_macro(v) ((uint16_t) \
(((uint16_t)(v) << 8) | \
in_addr_t s_addr;
};
-char * inet_ntoa (in_addr_t addr);
+__extern char *inet_ntoa(struct in_addr);
+
#endif /* _NETINET_IN_H */
#include <stdio.h>
#include <netinet/in.h>
-char * inet_ntoa ( in_addr_t addr ) {
- static char buf[16] = {0};
- uint8_t *bytes = ( uint8_t * ) &addr;
-
- sprintf ( buf, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3] );
- return buf;
+
+char *inet_ntoa(struct in_addr addr)
+{
+ static char buf[16];
+ const uint8_t *bytes = (const uint8_t *)&addr.s_addr;
+
+ sprintf(buf, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]);
+ return buf;
}