1 #include "ace/UNIX_Addr.h"
3 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
5 #if defined (ACE_HAS_ALLOC_HOOKS)
6 # include "ace/Malloc_Base.h"
7 #endif /* ACE_HAS_ALLOC_HOOKS */
9 #if !defined (__ACE_INLINE__)
10 #include "ace/UNIX_Addr.inl"
11 #endif /* __ACE_INLINE__ */
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr
)
17 // Set a pointer to the address.
19 ACE_UNIX_Addr::set_addr (const void *addr
, int len
)
21 ACE_TRACE ("ACE_UNIX_Addr::set_addr");
23 this->ACE_Addr::base_set (AF_UNIX
, len
);
24 ACE_OS::memcpy (&this->unix_addr_
, addr
, len
);
27 // Return a pointer to the underlying address.
30 ACE_UNIX_Addr::get_addr () const
32 return (void *) &this->unix_addr_
;
35 // Transform the string into the current addressing format.
38 ACE_UNIX_Addr::string_to_addr (const char addr
[])
40 ACE_OS::strsncpy (this->unix_addr_
.sun_path
, addr
,
41 sizeof this->unix_addr_
.sun_path
);
43 this->set_size (sizeof this->unix_addr_
-
44 sizeof (this->unix_addr_
.sun_path
) +
45 ACE_OS::strlen (this->unix_addr_
.sun_path
));
49 // Transform the current address into string format.
52 ACE_UNIX_Addr::addr_to_string (ACE_TCHAR s
[], size_t len
) const
55 ACE_TEXT_CHAR_TO_TCHAR (this->unix_addr_
.sun_path
),
61 ACE_UNIX_Addr::hash () const
63 return ACE::hash_pjw (this->unix_addr_
.sun_path
);
67 ACE_UNIX_Addr::dump () const
69 #if defined (ACE_HAS_DUMP)
70 #endif /* ACE_HAS_DUMP */
73 // Do nothing constructor.
75 ACE_UNIX_Addr::ACE_UNIX_Addr ()
77 sizeof this->unix_addr_
- sizeof (this->unix_addr_
.sun_path
))
79 (void) ACE_OS::memset ((void *) &this->unix_addr_
,
81 sizeof this->unix_addr_
);
83 this->unix_addr_
.sun_family
= AF_UNIX
;
87 ACE_UNIX_Addr::set (const ACE_UNIX_Addr
&sa
)
89 if (sa
.get_type () == AF_ANY
)
90 (void) ACE_OS::memset ((void *) &this->unix_addr_
,
92 sizeof this->unix_addr_
);
94 ACE_OS::strcpy (this->unix_addr_
.sun_path
,
95 sa
.unix_addr_
.sun_path
);
97 this->unix_addr_
.sun_family
= AF_UNIX
;
98 this->base_set (sa
.get_type (), sa
.get_size ());
105 ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr
&sa
)
106 : ACE_Addr (AF_UNIX
, sa
.get_size ())
112 ACE_UNIX_Addr::set (const sockaddr_un
*un
, int len
)
114 (void) ACE_OS::memset ((void *) &this->unix_addr_
, 0,
115 sizeof this->unix_addr_
);
116 this->unix_addr_
.sun_family
= AF_UNIX
;
117 ACE_OS::strcpy (this->unix_addr_
.sun_path
, un
->sun_path
);
118 this->base_set (AF_UNIX
, len
);
122 ACE_UNIX_Addr::ACE_UNIX_Addr (const sockaddr_un
*un
, int len
)
128 ACE_UNIX_Addr::set (const char rendezvous_point
[])
130 (void) ACE_OS::memset ((void *) &this->unix_addr_
,
132 sizeof this->unix_addr_
);
133 this->unix_addr_
.sun_family
= AF_UNIX
;
134 (void) ACE_OS::strsncpy (this->unix_addr_
.sun_path
,
136 sizeof this->unix_addr_
.sun_path
);
138 this->ACE_Addr::base_set (AF_UNIX
,
139 sizeof this->unix_addr_
-
140 sizeof (this->unix_addr_
.sun_path
) +
141 ACE_OS::strlen (this->unix_addr_
.sun_path
));
145 // Create a ACE_Addr from a UNIX pathname.
147 ACE_UNIX_Addr::ACE_UNIX_Addr (const char rendezvous_point
[])
149 this->set (rendezvous_point
);
152 ACE_END_VERSIONED_NAMESPACE_DECL
154 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */