00001
00002
00003 #include "ace/UNIX_Addr.h"
00004
00005 ACE_RCSID(ace, UNIX_Addr, "UNIX_Addr.cpp,v 4.16 2005/10/28 23:55:10 ossama Exp")
00006
00007 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
00008
00009 #if !defined (__ACE_INLINE__)
00010 #include "ace/UNIX_Addr.inl"
00011 #endif
00012
00013 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr)
00016
00017
00018 void
00019 ACE_UNIX_Addr::set_addr (void *addr, int len)
00020 {
00021 ACE_TRACE ("ACE_UNIX_Addr::set_addr");
00022
00023 this->ACE_Addr::base_set (AF_UNIX, len);
00024 ACE_OS::memcpy ((void *) &this->unix_addr_,
00025 (void *) addr,
00026 len);
00027 }
00028
00029
00030
00031 void *
00032 ACE_UNIX_Addr::get_addr (void) const
00033 {
00034 return (void *) &this->unix_addr_;
00035 }
00036
00037
00038
00039 int
00040 ACE_UNIX_Addr::string_to_addr (const char addr[])
00041 {
00042 ACE_OS::strsncpy (this->unix_addr_.sun_path, addr,
00043 sizeof this->unix_addr_.sun_path);
00044 return 0;
00045 }
00046
00047
00048
00049 int
00050 ACE_UNIX_Addr::addr_to_string (ACE_TCHAR s[], size_t len) const
00051 {
00052 ACE_OS::strsncpy (s,
00053 ACE_TEXT_CHAR_TO_TCHAR (this->unix_addr_.sun_path),
00054 len);
00055 return 0;
00056 }
00057
00058 u_long
00059 ACE_UNIX_Addr::hash (void) const
00060 {
00061 return ACE::hash_pjw (this->unix_addr_.sun_path);
00062 }
00063
00064 void
00065 ACE_UNIX_Addr::dump (void) const
00066 {
00067 #if defined (ACE_HAS_DUMP)
00068 #endif
00069 }
00070
00071
00072
00073 ACE_UNIX_Addr::ACE_UNIX_Addr (void)
00074 : ACE_Addr (AF_UNIX, sizeof this->unix_addr_)
00075 {
00076 (void) ACE_OS::memset ((void *) &this->unix_addr_,
00077 0,
00078 sizeof this->unix_addr_);
00079
00080 this->unix_addr_.sun_family = AF_UNIX;
00081 }
00082
00083 int
00084 ACE_UNIX_Addr::set (const ACE_UNIX_Addr &sa)
00085 {
00086 if (sa.get_type () == AF_ANY)
00087 (void) ACE_OS::memset ((void *) &this->unix_addr_,
00088 0,
00089 sizeof this->unix_addr_);
00090 else
00091 ACE_OS::strcpy (this->unix_addr_.sun_path,
00092 sa.unix_addr_.sun_path);
00093
00094 this->unix_addr_.sun_family = AF_UNIX;
00095 this->base_set (sa.get_type (), sa.get_size ());
00096
00097 return 0;
00098 }
00099
00100
00101
00102 ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa)
00103 : ACE_Addr (AF_UNIX, sa.get_size ())
00104 {
00105 this->set (sa);
00106 }
00107
00108 int
00109 ACE_UNIX_Addr::set (const sockaddr_un *un, int len)
00110 {
00111 (void) ACE_OS::memset ((void *) &this->unix_addr_, 0,
00112 sizeof this->unix_addr_);
00113 this->unix_addr_.sun_family = AF_UNIX;
00114 ACE_OS::strcpy (this->unix_addr_.sun_path, un->sun_path);
00115 this->base_set (AF_UNIX, len);
00116 return 0;
00117 }
00118
00119 ACE_UNIX_Addr::ACE_UNIX_Addr (const sockaddr_un *un, int len)
00120 {
00121 this->set (un, len);
00122 }
00123
00124 int
00125 ACE_UNIX_Addr::set (const char rendezvous_point[])
00126 {
00127 (void) ACE_OS::memset ((void *) &this->unix_addr_,
00128 0,
00129 sizeof this->unix_addr_);
00130 this->unix_addr_.sun_family = AF_UNIX;
00131 (void) ACE_OS::strsncpy (this->unix_addr_.sun_path,
00132 rendezvous_point,
00133 sizeof this->unix_addr_.sun_path);
00134
00135 this->ACE_Addr::base_set (AF_UNIX,
00136 sizeof this->unix_addr_ -
00137 sizeof (this->unix_addr_.sun_path) +
00138 ACE_OS::strlen (this->unix_addr_.sun_path));
00139 return 0;
00140 }
00141
00142
00143
00144 ACE_UNIX_Addr::ACE_UNIX_Addr (const char rendezvous_point[])
00145 {
00146 this->set (rendezvous_point);
00147 }
00148
00149 ACE_END_VERSIONED_NAMESPACE_DECL
00150
00151 #endif