00001 #include "ace_pch.h"
00002
00003
00004
00005 #include "ace/UNIX_Addr.h"
00006
00007 ACE_RCSID(ace, UNIX_Addr, "$Id: UNIX_Addr.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:23 chad Exp $")
00008
00009 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
00010
00011 #if !defined (__ACE_INLINE__)
00012 #include "ace/UNIX_Addr.i"
00013 #endif
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 void
00030 ACE_UNIX_Addr::dump (void) const
00031 {
00032 }
00033
00034
00035
00036 ACE_UNIX_Addr::ACE_UNIX_Addr (void)
00037 : ACE_Addr (AF_UNIX, sizeof this->unix_addr_)
00038 {
00039 (void) ACE_OS::memset ((void *) &this->unix_addr_,
00040 0,
00041 sizeof this->unix_addr_);
00042
00043 this->unix_addr_.sun_family = AF_UNIX;
00044 }
00045
00046 int
00047 ACE_UNIX_Addr::set (const ACE_UNIX_Addr &sa)
00048 {
00049 if (sa.get_type () == AF_ANY)
00050 (void) ACE_OS::memset ((void *) &this->unix_addr_,
00051 0,
00052 sizeof this->unix_addr_);
00053 else
00054 ACE_OS::strcpy (this->unix_addr_.sun_path,
00055 sa.unix_addr_.sun_path);
00056
00057 this->unix_addr_.sun_family = AF_UNIX;
00058 this->base_set (sa.get_type (), sa.get_size ());
00059
00060 return 0;
00061 }
00062
00063
00064
00065 ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa)
00066 : ACE_Addr (AF_UNIX, sa.get_size ())
00067 {
00068 this->set (sa);
00069 }
00070
00071 int
00072 ACE_UNIX_Addr::set (const sockaddr_un *un, int len)
00073 {
00074 (void) ACE_OS::memset ((void *) &this->unix_addr_, 0,
00075 sizeof this->unix_addr_);
00076 this->unix_addr_.sun_family = AF_UNIX;
00077 ACE_OS::strcpy (this->unix_addr_.sun_path, un->sun_path);
00078 this->base_set (AF_UNIX, len);
00079 return 0;
00080 }
00081
00082 ACE_UNIX_Addr::ACE_UNIX_Addr (const sockaddr_un *un, int len)
00083 {
00084 this->set (un, len);
00085 }
00086
00087 int
00088 ACE_UNIX_Addr::set (const char rendezvous_point[])
00089 {
00090 (void) ACE_OS::memset ((void *) &this->unix_addr_,
00091 0,
00092 sizeof this->unix_addr_);
00093 this->unix_addr_.sun_family = AF_UNIX;
00094 size_t len = ACE_OS::strlen (rendezvous_point);
00095 size_t maxlen = sizeof this->unix_addr_.sun_path;
00096
00097 (void) ACE_OS::memcpy (this->unix_addr_.sun_path,
00098 rendezvous_point,
00099 len >= maxlen ? maxlen - 1 : len);
00100
00101 this->ACE_Addr::base_set (AF_UNIX,
00102 sizeof this->unix_addr_ -
00103 sizeof (this->unix_addr_.sun_path) +
00104 ACE_OS::strlen (this->unix_addr_.sun_path));
00105 return 0;
00106 }
00107
00108
00109
00110 ACE_UNIX_Addr::ACE_UNIX_Addr (const char rendezvous_point[])
00111 {
00112 this->set (rendezvous_point);
00113 }
00114
00115 #endif