1 #include /* */ "ace/SOCK_Netlink.h"
5 #include "ace/Log_Category.h"
7 #include "ace/OS_NS_string.h"
8 #include "ace/OS_NS_unistd.h"
9 #include "ace/SOCK_Netlink.h"
10 #include "ace/OS_NS_sys_socket.h"
11 #if defined (ACE_HAS_ALLOC_HOOKS)
12 # include "ace/Malloc_Base.h"
13 #endif /* ACE_HAS_ALLOC_HOOKS */
15 #if !defined (__ACE_INLINE__)
16 #include "ace/SOCK_Netlink.inl"
17 #endif /* __ACE_INLINE__ */
19 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
21 ACE_ALLOC_HOOK_DEFINE (ACE_SOCK_Netlink
)
23 int ACE_SOCK_Netlink::open (ACE_Netlink_Addr
&local
,
25 int protocol
) //! protocol of your choosing
27 ACE_TRACE ("ACE_SOCK_Netlink::open");
29 if ( ACE_SOCK::open (SOCK_RAW
,
30 protocol_family
, //! RAW or DGRAM valid
32 ACE_TRACE ("ACE_SOCK_Netlink::open failed to open");
36 if (ACE_OS::bind(this->get_handle(),
37 (sockaddr
*)local
.get_addr(),
38 local
.get_addr_size()) == -1 ) {
39 ACE_TRACE ("ACE_SOCK_Netlink::open failed to bind socket");
46 ACE_SOCK_Netlink::ACE_SOCK_Netlink (ACE_Netlink_Addr
&local
,
50 ACE_TRACE ("ACE_SOCK_Netlink::ACE_SOCK_Netlink");
52 if (this->open (local
,
55 ACELIB_ERROR ((LM_ERROR
,
57 ACE_TEXT ("ACE_SOCK_Netlink")));
61 ACE_SOCK_Netlink::send (const iovec iov
[],
66 ACE_TRACE ("ACE_SOCK_Netlink::send");
69 send_msg
.msg_iov
= (iovec
*) iov
;
70 send_msg
.msg_iovlen
= n
;
71 send_msg
.msg_name
= (char *) addr
.get_addr ();
72 send_msg
.msg_namelen
= addr
.get_size ();
73 send_msg
.msg_control
= 0;
74 send_msg
.msg_controllen
= 0;
75 send_msg
.msg_flags
= 0;
77 return ACE_OS::sendmsg (this->get_handle (),
83 ACE_SOCK_Netlink::recv (iovec iov
[],
88 ACE_TRACE ("ACE_SOCK_Netlink::recv");
91 recv_msg
.msg_iov
= (iovec
*) iov
;
92 recv_msg
.msg_iovlen
= n
;
93 recv_msg
.msg_name
= (char *) addr
.get_addr ();
94 recv_msg
.msg_namelen
= addr
.get_size ();
95 recv_msg
.msg_control
= 0;
96 recv_msg
.msg_controllen
= 0;
97 recv_msg
.msg_flags
= 0;
99 ssize_t status
= ACE_OS::recvmsg (this->get_handle (),
103 if (recv_msg
.msg_flags
& MSG_TRUNC
)
106 addr
.set_size (recv_msg
.msg_namelen
);
107 addr
.set_type (((sockaddr_in
*) addr
.get_addr())->sin_family
);
112 ACE_END_VERSIONED_NAMESPACE_DECL
114 #endif /* ACE_HAS_NETLINK */