summaryrefslogtreecommitdiff
path: root/ACE/ace/Netlink_Addr.h
blob: c204d628b66ab02d2d34d882a18f426ea2cd83a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//=============================================================================
/**
 *  @file    Netlink_Addr.h
 *
 * @author Robert Iakobashvilli <coroberti@gmail.com>
 * @author Raz Ben Yehuda <raziebe@gmail.com>
 */
//=============================================================================

#ifndef ACE_NETLINK_ADDR_H
#define ACE_NETLINK_ADDR_H

#include /**/ "ace/pre.h"

#include /**/ "ace/config-all.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
  #pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#ifdef  ACE_HAS_NETLINK

#include "ace/OS_NS_string.h"
#include "ace/Global_Macros.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_unistd.h"
#include "ace/Addr.h"
#include "ace/os_include/sys/os_socket.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

/**
 * @class ACE_Netlink_Addr
 *
 * @brief Defines a C++ wrapper facade for the netlink sockets
 */
class ACE_Export ACE_Netlink_Addr : public ACE_Addr {
public:
  /// Default constructor.
  ACE_Netlink_Addr (void);

  /// Copy constructor.
  ACE_Netlink_Addr (const ACE_Netlink_Addr &);

  /// Creates an ACE_INET_Addr from a sockaddr_in structure.
  ACE_Netlink_Addr (const sockaddr_nl *, int len);

  /// Dtor
  ~ACE_Netlink_Addr (void);

  /**
   * @param naddr sets the nl_ member @see nl_
   */
  int set (const ACE_Netlink_Addr &naddr);
  /**
   * sets the pid and groups fields of member nl_  @see nl_
   */
  void set (int pid, int gid);
  /**
   * set nl_ to nl_  @see nl_
   */
  int set (const sockaddr_nl *, int len);
  /**
   * @return pid
   */
  int get_pid (void) const;
  /**
   * @return the group id @see nl_
   */
  int get_gid (void) const;
  /**
   * @return addr pointer @see nl_
   */
  virtual void *get_addr (void) const;
  /**
   * @return nl_ member  @see nl_  size
   */
  int get_addr_size (void) const;
  /**
   * Set a pointer to the address
   */
  virtual void set_addr (const void *, int len= sizeof(sockaddr_nl) );

  /// Declare the dynamic allocation hooks.
  ACE_ALLOC_HOOK_DECLARE;

private:
  /**
   * @return family type  AF_NETLINK
   *
   * */
  int determine_type (void) const;
  /**
   * set nl_  @see nl_ to zero and sets address family to default value
   */
  void reset (void);

  sockaddr_nl  nl_;
};

ACE_END_VERSIONED_NAMESPACE_DECL

#if defined (__ACE_INLINE__)
#include "ace/Netlink_Addr.inl"
#endif /* __ACE_INLINE__ */

#endif /* ACE_HAS_NETLINK */

#include /**/ "ace/post.h"

#endif /* ACE_NETLINK_ADDR_H */