1 #include "ace/UNIX_Addr.h"
5 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
7 #if defined (ACE_HAS_ALLOC_HOOKS)
8 # include "ace/Malloc_Base.h"
9 #endif /* ACE_HAS_ALLOC_HOOKS */
11 #if !defined (__ACE_INLINE__)
12 #include "ace/UNIX_Addr.inl"
13 #endif /* __ACE_INLINE__ */
15 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr
)
19 // Set a pointer to the address.
21 ACE_UNIX_Addr::set_addr (const void *addr
, int len
)
23 ACE_TRACE ("ACE_UNIX_Addr::set_addr");
25 this->ACE_Addr::base_set (AF_UNIX
, len
);
26 ACE_OS::memcpy (&this->unix_addr_
, addr
, len
);
29 // Return a pointer to the underlying address.
32 ACE_UNIX_Addr::get_addr () const
34 return (void *) &this->unix_addr_
;
37 // Transform the string into the current addressing format.
40 ACE_UNIX_Addr::string_to_addr (const char addr
[])
42 ACE_OS::strsncpy (this->unix_addr_
.sun_path
, addr
,
43 sizeof this->unix_addr_
.sun_path
);
45 this->set_size (sizeof this->unix_addr_
-
46 sizeof (this->unix_addr_
.sun_path
) +
47 ACE_OS::strlen (this->unix_addr_
.sun_path
));
51 // Transform the current address into string format.
54 ACE_UNIX_Addr::addr_to_string (ACE_TCHAR s
[], size_t len
) const
57 ACE_TEXT_CHAR_TO_TCHAR (this->unix_addr_
.sun_path
),
63 ACE_UNIX_Addr::hash () const
65 return ACE::hash_pjw (this->unix_addr_
.sun_path
);
69 ACE_UNIX_Addr::dump () const
71 #if defined (ACE_HAS_DUMP)
72 #endif /* ACE_HAS_DUMP */
75 // Do nothing constructor.
77 ACE_UNIX_Addr::ACE_UNIX_Addr ()
79 sizeof this->unix_addr_
- sizeof (this->unix_addr_
.sun_path
))
81 (void) ACE_OS::memset ((void *) &this->unix_addr_
,
83 sizeof this->unix_addr_
);
85 this->unix_addr_
.sun_family
= AF_UNIX
;
89 ACE_UNIX_Addr::set (const ACE_UNIX_Addr
&sa
)
91 if (sa
.get_type () == AF_ANY
)
92 (void) ACE_OS::memset ((void *) &this->unix_addr_
,
94 sizeof this->unix_addr_
);
96 ACE_OS::strcpy (this->unix_addr_
.sun_path
,
97 sa
.unix_addr_
.sun_path
);
99 this->unix_addr_
.sun_family
= AF_UNIX
;
100 this->base_set (sa
.get_type (), sa
.get_size ());
107 ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr
&sa
)
108 : ACE_Addr (AF_UNIX
, sa
.get_size ())
114 ACE_UNIX_Addr::set (const sockaddr_un
*un
, int len
)
116 (void) ACE_OS::memset ((void *) &this->unix_addr_
, 0,
117 sizeof this->unix_addr_
);
118 this->unix_addr_
.sun_family
= AF_UNIX
;
119 ACE_OS::strcpy (this->unix_addr_
.sun_path
, un
->sun_path
);
120 this->base_set (AF_UNIX
, len
);
124 ACE_UNIX_Addr::ACE_UNIX_Addr (const sockaddr_un
*un
, int len
)
130 ACE_UNIX_Addr::set (const char rendezvous_point
[])
132 (void) ACE_OS::memset ((void *) &this->unix_addr_
,
134 sizeof this->unix_addr_
);
135 this->unix_addr_
.sun_family
= AF_UNIX
;
136 (void) ACE_OS::strsncpy (this->unix_addr_
.sun_path
,
138 sizeof this->unix_addr_
.sun_path
);
140 this->ACE_Addr::base_set (AF_UNIX
,
141 sizeof this->unix_addr_
-
142 sizeof (this->unix_addr_
.sun_path
) +
143 ACE_OS::strlen (this->unix_addr_
.sun_path
));
147 // Create a ACE_Addr from a UNIX pathname.
149 ACE_UNIX_Addr::ACE_UNIX_Addr (const char rendezvous_point
[])
151 this->set (rendezvous_point
);
154 ACE_END_VERSIONED_NAMESPACE_DECL
156 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */