summaryrefslogtreecommitdiff
path: root/ace/OS.cpp
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2003-07-25 09:36:11 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2003-07-25 09:36:11 +0000
commit608a1bacb8e5ebf7f05464af3e584ce336facd43 (patch)
tree4c36337e44488141f49b3cf6c58b295277a91c80 /ace/OS.cpp
parent9b180642c1d2ac7669cfe2e8ba4e50be7784af70 (diff)
downloadATCD-608a1bacb8e5ebf7f05464af3e584ce336facd43.tar.gz
ChangeLogTag: Fri Jul 25 09:11:12 UTC 2003 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'ace/OS.cpp')
-rw-r--r--ace/OS.cpp122
1 files changed, 63 insertions, 59 deletions
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 1b6b5ac4cd9..5722d741817 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -4807,12 +4807,12 @@ ACE_Thread_ID::handle (ACE_hthread_t thread_handle)
void
ACE_Thread_ID::to_string (char* thr_id)
{
-
+
char format[128]; // Converted format string
char *fp; // Current format pointer
fp = format;
*fp++ = '%'; // Copy in the %
-
+
#if defined (ACE_WIN32)
ACE_OS::strcpy (fp, "u");
ACE_OS::sprintf (thr_id,
@@ -7715,145 +7715,149 @@ ACE_OS::num_processors_online (void)
#endif
int
-ACE_OS::getmacaddress (struct macaddr_node_t *node)
+ACE_OS::getmacaddress (struct macaddr_node_t *node)
{
- ACE_OS_TRACE ("getmacaddr");
-
+ ACE_OS_TRACE ("ACE_OS::getmacaddress");
+
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
-
+
/** Define a structure for use with the netbios routine */
struct ADAPTERSTAT
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
};
-
+
NCB ncb;
LANA_ENUM lenum;
unsigned char result;
-
+
ACE_OS::memset (&ncb, 0, sizeof(ncb));
ncb.ncb_command = NCBENUM;
ncb.ncb_buffer = ACE_reinterpret_cast (unsigned char*,&lenum);
ncb.ncb_length = sizeof(lenum);
-
+
result = Netbios (&ncb);
-
+
for(int i = 0; i < lenum.length; i++)
{
ACE_OS::memset (&ncb, 0, sizeof(ncb));
ncb.ncb_command = NCBRESET;
ncb.ncb_lana_num = lenum.lana [i];
-
+
/** Reset the netbios */
result = Netbios (&ncb);
-
- if (ncb.ncb_retcode != NRC_GOODRET)
+
+ if (ncb.ncb_retcode != NRC_GOODRET)
{
return -1;
}
-
+
ADAPTERSTAT adapter;
ACE_OS::memset (&ncb, 0, sizeof (ncb));
+# if defined (__BORLANDC__) || defined (__MINGW32__)
+ ACE_OS::strcpy (ACE_reinterpret_cast (char*, ncb.ncb_callname), "*");
+# else
ACE_OS::strcpy (ACE_static_cast (char*, ncb.ncb_callname), "*");
+# endif /* __BORLANDC__ || __MINGW32__ */
ncb.ncb_command = NCBASTAT;
ncb.ncb_lana_num = lenum.lana[i];
ncb.ncb_buffer = ACE_reinterpret_cast (unsigned char*, &adapter);
ncb.ncb_length = sizeof (adapter);
-
+
result = Netbios (&ncb);
-
+
if (result == 0)
{
ACE_OS::memcpy (node->node,
- adapter.adapt.adapter_address,
+ adapter.adapt.adapter_address,
6);
return 0;
}
}
return 0;
#elif defined (sun)
-
+
int result = 0;
-
+
/** obtain the local host name */
char hostname [MAXHOSTNAMELEN];
ACE_OS::hostname (hostname, sizeof (hostname));
-
+
/** Get the hostent to use with ioctl */
- struct hostent *phost =
+ struct hostent *phost =
ACE_OS::gethostbyname (hostname);
-
- if (phost == 0)
+
+ if (phost == 0)
{
return -1;
}
-
- ACE_HANDLE handle =
+
+ ACE_HANDLE handle =
ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
- if (handle == ACE_INVALID_HANDLE)
+
+ if (handle == ACE_INVALID_HANDLE)
{
return -1;
}
-
+
char **paddrs = phost->h_addr_list;
-
+
struct arpreq ar;
-
- struct sockaddr_in *psa =
+
+ struct sockaddr_in *psa =
(struct sockaddr_in *)&(ar.arp_pa);
-
- ACE_OS::memset (&ar,
- 0,
+
+ ACE_OS::memset (&ar,
+ 0,
sizeof (struct arpreq));
-
+
psa->sin_family = AF_INET;
-
- ACE_OS::memcpy (&(psa->sin_addr),
- *paddrs,
- sizeof (struct in_addr));
-
- if (ACE_OS::ioctl (handle,
- SIOCGARP,
+
+ ACE_OS::memcpy (&(psa->sin_addr),
+ *paddrs,
+ sizeof (struct in_addr));
+
+ if (ACE_OS::ioctl (handle,
+ SIOCGARP,
&ar) == -1)
{
return -1;
}
-
+
ACE_OS::close (handle);
-
+
ACE_OS::memcpy (node->node,
ar.arp_ha.sa_data,
6);
-
+
return 0;
-
+
#elif defined (linux)
-
+
struct ifreq ifr;
-
- ACE_HANDLE handle =
+
+ ACE_HANDLE handle =
ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
-
- if (handle == ACE_INVALID_HANDLE)
+
+ if (handle == ACE_INVALID_HANDLE)
{
return -1;
}
-
+
ACE_OS::strcpy (ifr.ifr_name, "eth0");
-
- if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0)
+
+ if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0)
{
ACE_OS::close (handle);
return -1;
}
-
- struct sockaddr* sa =
+
+ struct sockaddr* sa =
(struct sockaddr *) &ifr.ifr_addr;
-
- ACE_OS::memcpy (node->node,
- sa->sa_data,
+
+ ACE_OS::memcpy (node->node,
+ sa->sa_data,
6);
return 0;