}
/* Pull out IP address and print it as a sanity check */
- rval = ((struct sockaddr_in *)target->ai_addr)->sin_addr.s_addr;
DT_Mdep_printf ("Server Name: %s \n", hostname);
- DT_Mdep_printf ("Server Net Address: %d.%d.%d.%d\n",
- (rval >> 0) & 0xff,
- (rval >> 8) & 0xff,
- (rval >> 16) & 0xff,
- (rval >> 24) & 0xff);
+ DT_Mdep_printf ("Server Net Address: %s\n",
+ inet_ntoa(((struct sockaddr_in *)target->ai_addr)->sin_addr));
*to_netaddr = * ((DAT_IA_ADDRESS_PTR) target->ai_addr);
DT_Mdep_GetCpuMhz (
void )
{
-#define DT_CPU_MHZ_BUFFER_SIZE 128
+#define DT_TSC_BUFFER_SIZE 128
#if defined (__PPC__) || defined (__PPC64__)
-#define DT_CPU_MHZ_MHZ "clock"
+#define DT_TSC_RATE "timebase"
+#define DT_TSC_BASE 1000000.0
#else
-#define DT_CPU_MHZ_MHZ "cpu MHz"
+#define DT_TSC_RATE "cpu MHz"
+#define DT_TSC_BASE 1.0
#endif
-#define DT_CPU_MHZ_DELIMITER ":"
+#define DT_TSC_DELIMITER ":"
FILE *fp;
- char buffer[DT_CPU_MHZ_BUFFER_SIZE];
+ char buffer[DT_TSC_BUFFER_SIZE];
char *mhz_str;
fp = fopen ("/proc/cpuinfo", "r");
for (;;)
{
- if ( NULL == fgets (buffer, DT_CPU_MHZ_BUFFER_SIZE, fp) )
+ if ( NULL == fgets (buffer, DT_TSC_BUFFER_SIZE, fp) )
{
printf ("cpu MHZ not found\n");
exit (1);
}
- if ( !strncmp (buffer, DT_CPU_MHZ_MHZ, strlen (DT_CPU_MHZ_MHZ) ) )
+ if ( !strncmp (buffer, DT_TSC_RATE, strlen (DT_TSC_RATE) ) )
{
- (void) strtok (buffer, DT_CPU_MHZ_DELIMITER);
- mhz_str = strtok (NULL, DT_CPU_MHZ_DELIMITER);
+ (void) strtok (buffer, DT_TSC_DELIMITER);
+ mhz_str = strtok (NULL, DT_TSC_DELIMITER);
break;
}
exit (1);
}
- return strtod (mhz_str, NULL);
+ return strtod (mhz_str, NULL) / DT_TSC_BASE;
}
else if (ip6_addr->sin6_family == AF_INET )
{
- int rval;
-
ip_addr = (struct sockaddr_in *)pt_ptr->ia_attr.ia_address_ptr;
- rval = (int) ip_addr->sin_addr.s_addr;
- DT_Tdep_PT_Printf (phead, "\tLocal IP address %d.%d.%d.%d\n",
- (rval >> 0) & 0xff,
- (rval >> 8) & 0xff,
- (rval >> 16) & 0xff,
- (rval >> 24) & 0xff);
+ DT_Tdep_PT_Printf (phead, "\tLocal IP address %s\n",
+ inet_ntoa(ip_addr->sin_addr));
}
DT_Tdep_PT_Printf (phead, "***** ***** ***** ***** ***** *****\n");
}
else { /* CLIENT */
struct addrinfo *target;
- int rval;
if (getaddrinfo (hostname, NULL, NULL, &target) != 0) {
printf("\n remote name resolution failed!\n");
exit ( 1 );
}
- rval = ((struct sockaddr_in *)target->ai_addr)->sin_addr.s_addr;
printf ("%d Server Name: %s \n", getpid(), hostname);
- printf ("%d Server Net Address: %d.%d.%d.%d\n", getpid(),
- (rval >> 0) & 0xff,
- (rval >> 8) & 0xff,
- (rval >> 16) & 0xff,
- (rval >> 24) & 0xff);
+ printf ("%d Server Net Address: %s\n", getpid(),
+ inet_ntoa(((struct sockaddr_in *)target->ai_addr)->sin_addr));
remote_addr = *((DAT_IA_ADDRESS_PTR)target->ai_addr);