diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-03-25 01:01:50 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-03-25 01:01:50 +0000 |
commit | b8c6347b29f1655df9fb7a6c4b0b0a1aa16cb855 (patch) | |
tree | 4c7951b8a861b75a361fed329184e37dfa4a6bbc /ace | |
parent | 35c3c290bff12300023bd0e4db86cf5a138dff19 (diff) | |
download | ATCD-b8c6347b29f1655df9fb7a6c4b0b0a1aa16cb855.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace')
-rw-r--r-- | ace/ACE.cpp | 100 | ||||
-rw-r--r-- | ace/Malloc.h | 12 | ||||
-rw-r--r-- | ace/OS.h | 57 | ||||
-rw-r--r-- | ace/SOCK_Dgram_Bcast.cpp | 3 | ||||
-rw-r--r-- | ace/UNIX_Addr.cpp | 14 | ||||
-rw-r--r-- | ace/UNIX_Addr.h | 3 | ||||
-rw-r--r-- | ace/config-chorus.h | 2 |
7 files changed, 150 insertions, 41 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 1ea3416abb1..c885beba3bf 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -1341,3 +1341,103 @@ ACE::sock_error (int error) #endif /* ACE_WIN32 */ } +ACE_UINT32 +ACE::get_bcast_addr (ACE_UINT32 host_addr, + ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_INET_Addr::get_bcast_addr"); + +#if !defined(ACE_WIN32) + char buf[BUFSIZ]; + struct ifconf ifc; + struct ifreq *ifr; + + struct ifreq flags; + struct ifreq if_req; + + struct sockaddr_in ip_addr, if_addr; + + ACE_OS::memcpy ((void *) &ip_addr.sin_addr, + (void*) &host_addr, + sizeof ip_addr.sin_addr); + + ACE_HANDLE s = ACE_OS::socket (AF_INET, SOCK_STREAM, 0); + + if (s == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::socket"), -1); + + ifc.ifc_len = sizeof buf; + ifc.ifc_buf = buf; + + // Get interface structure and initialize the addresses using UNIX + // techniques + if (ACE_OS::ioctl (s, SIOCGIFCONF, (char *) &ifc) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", + "ACE_INET_Addr_::get_bcast_addr: ioctl (get interface configuration)"), + host_addr); + + ifr = ifc.ifc_req; + + for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0; n--, ifr++) + { + // Compare host ip address with interface ip address. + ACE_OS::memcpy (&if_addr, &ifr->ifr_addr, sizeof if_addr); + + if (ip_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr) + continue; + + if (ifr->ifr_addr.sa_family != AF_INET) + { + ACE_ERROR ((LM_ERROR, "%p\n", + "ACE_INET_Addr::get_bcast_addr: Not AF_INET")); + continue; + } + + flags = if_req = *ifr; + + if (ACE_OS::ioctl (s, SIOCGIFFLAGS, (char *) &flags) == -1) + { + ACE_ERROR ((LM_ERROR, "%p\n", + "ACE_INET_Addr::get_bcast_addr: ioctl (get interface flags)")); + continue; + } + + if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_UP) == 0) + { + ACE_ERROR ((LM_ERROR, "%p\n", + "ACE_INET_Addr::get_bcast_addr: Network interface is not up")); + continue; + } + + if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_LOOPBACK)) + continue; + + if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_BROADCAST)) + { + if (ACE_OS::ioctl (s, SIOCGIFBRDADDR, (char *) &if_req) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", + "ACE_INET_Addr::get_bcast_addr: ioctl (get broadaddr)")); + else + { + ACE_OS::memcpy ((struct sockaddr_in *)&ip_addr, + (struct sockaddr_in *)&if_req.ifr_broadaddr, + sizeof if_req.ifr_broadaddr); + + ACE_OS::memcpy ((void *)&host_addr, (void *)&ip_addr.sin_addr, + sizeof host_addr); + + ACE_OS::close (s); + return host_addr; + } + } + else + ACE_ERROR ((LM_ERROR, "%p\n", + "ACE_INET_Addr::get_bcast_addr: Broadcast is not enable for this interface.")); + + ACE_OS::close (s); + return host_addr; + } +#else + return (ACE_UINT32 (INADDR_BROADCAST)); +#endif /* !ACE_WIN32 */ +} diff --git a/ace/Malloc.h b/ace/Malloc.h index 606cc148648..b2d1d8f7e74 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -174,13 +173,16 @@ public: ACE_Malloc_Stats malloc_stats_; #endif /* ACE_MALLOC_STATS */ - long align_[(ACE_MALLOC_ALIGN/sizeof (long)) - - ((sizeof (ACE_Name_Node *) - + sizeof (ACE_Malloc_Header *) + MAXNAMELEN) / sizeof (long))]; - ACE_Malloc_Header base_; // Dummy node used to anchor the freelist. +#if 0 + long align_[ACE_MALLOC_ALIGN/sizeof (long)]; +#else + (ACE_MALLOC_ALIGN/sizeof (long)) - + 1 - ((sizeof (ACE_Name_Node *) + sizeof (ACE_Malloc_Header *) + MAXNAMELEN) / sizeof (long))]; +#endif /* 0 */ + void dump (void) const; // Dump the state of the object. }; @@ -209,19 +209,6 @@ struct ip_mreq }; #endif /* ACE_HAS_IP_MULTICAST */ -#if defined (ACE_LACKS_FILELOCKS) -struct flock -{ - short l_type; - short l_whence; - off_t l_start; - off_t l_len; /* len == 0 means until end of file */ - long l_sysid; - pid_t l_pid; - long l_pad[4]; /* reserve area */ -}; -#endif /* ACE_LACKS_FILELOCKS */ - #if defined (ACE_HAS_CHARPTR_SPRINTF) #define ACE_SPRINTF_ADAPTER(X) ::strlen (X) #else @@ -733,18 +720,6 @@ struct sembuf }; #endif /* ACE_LACKS_SEMBUF_T */ -#if defined (ACE_LACKS_UTSNAME_T) -#define _SYS_NMLN 257 -struct utsname -{ - char sysname[_SYS_NMLN]; - char nodename[_SYS_NMLN]; - char release[_SYS_NMLN]; - char version[_SYS_NMLN]; - char machine[_SYS_NMLN]; -}; -#endif /* ACE_LACKS_UTSNAME_T */ - #if defined (ACE_HAS_H_ERRNO) void herror (const char *str); #endif /* ACE_HAS_H_ERRNO */ @@ -1781,10 +1756,6 @@ extern "C" { #include /**/ <cx/select.h> #include /**/ <sys/uio.h> #include /**/ <time.h> -#include /**/ <sys/ioctl.h> -#include /**/ <dirent.h> -#include /**/ <sys/stat.h> -#include /**/ <unistd.h> #include /**/ <pwd.h> #include /**/ <stdfileio.h> @@ -1811,10 +1782,23 @@ typedef void (*__sighandler_t)(int); // keep Signal compilation happy #endif /* VXWORKS */ #include /**/ <sys/ioctl.h> #include /**/ <dirent.h> -#include /**/ <sys/utsname.h> #include /**/ <sys/stat.h> #include /**/ <unistd.h> +#if defined (ACE_LACKS_UTSNAME_T) +#define _SYS_NMLN 257 +struct utsname +{ + char sysname[_SYS_NMLN]; + char nodename[_SYS_NMLN]; + char release[_SYS_NMLN]; + char version[_SYS_NMLN]; + char machine[_SYS_NMLN]; +}; +#else +#include /**/ <sys/utsname.h> +#endif /* ACE_LACKS_UTSNAME_T */ + #if !defined (ACE_LACKS_PARAM_H) #include /**/ <sys/param.h> #endif /* ACE_LACKS_PARAM_H */ @@ -2412,6 +2396,19 @@ typedef int ACE_Sched_Priority; // forward declaration class ACE_Sched_Params; +#if defined (ACE_LACKS_FILELOCKS) +struct flock +{ + short l_type; + short l_whence; + off_t l_start; + off_t l_len; /* len == 0 means until end of file */ + long l_sysid; + pid_t l_pid; + long l_pad[4]; /* reserve area */ +}; +#endif /* ACE_LACKS_FILELOCKS */ + class ACE_Export ACE_OS // = TITLE // This class defines an operating system independent diff --git a/ace/SOCK_Dgram_Bcast.cpp b/ace/SOCK_Dgram_Bcast.cpp index 5a9174c00d7..0a949627d79 100644 --- a/ace/SOCK_Dgram_Bcast.cpp +++ b/ace/SOCK_Dgram_Bcast.cpp @@ -113,7 +113,8 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const char *host_name) ifc.ifc_len = sizeof buf; ifc.ifc_buf = buf; - // Get interface structure and initialize the addresses using UNIX techniques. + // Get interface structure and initialize the addresses using UNIX + // techniques. if (ACE_OS::ioctl (s, SIOCGIFCONF, (char *) &ifc) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface configuration)"), diff --git a/ace/UNIX_Addr.cpp b/ace/UNIX_Addr.cpp index 74a694f2b22..0293acf3d3d 100644 --- a/ace/UNIX_Addr.cpp +++ b/ace/UNIX_Addr.cpp @@ -37,10 +37,8 @@ ACE_UNIX_Addr::ACE_UNIX_Addr (void) (void) ACE_OS::memset ((void *) &this->unix_addr_, 0, sizeof this->unix_addr_); } -// Copy constructor. - -ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa) - : ACE_Addr (AF_UNIX, sa.get_size ()) +void +ACE_UNIX_Addr::set (const ACE_UNIX_Addr &sa) { size_t size = sa.get_size (); @@ -53,6 +51,14 @@ ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa) ACE_OS::strcpy (this->unix_addr_.sun_path, sa.unix_addr_.sun_path); } +// Copy constructor. + +ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa) + : ACE_Addr (AF_UNIX, sa.get_size ()) +{ + this->set (sa); +} + void ACE_UNIX_Addr::set (const sockaddr_un *un, int len) { diff --git a/ace/UNIX_Addr.h b/ace/UNIX_Addr.h index 07d7874ebff..65340c72472 100644 --- a/ace/UNIX_Addr.h +++ b/ace/UNIX_Addr.h @@ -39,6 +39,9 @@ public: ACE_UNIX_Addr (const sockaddr_un *, int len); // Creates an ACE_INET_Addr from a sockaddr_un structure. + void set (const ACE_UNIX_Addr &sa); + // Creates an ACE_UNIX_Addr from another <ACE_UNIX_Addr>. + void set (const char rendezvous_point[]); // Creates an ACE_UNIX_Addr from a string. diff --git a/ace/config-chorus.h b/ace/config-chorus.h index 049cc627ed9..a86adde6294 100644 --- a/ace/config-chorus.h +++ b/ace/config-chorus.h @@ -48,7 +48,7 @@ #define ACE_LACKS_MSYNC #define ACE_LACKS_MADVISE -#define ACE_LACKS_MALLOC_T +#define ACE_LACKS_MALLOC_H #define ACE_LACKS_MEMORY_H #define ACE_LACKS_PARAM_H |