Line data Source code
1 : // 2 : // netlink_protocol.hpp 3 : // ~~~~~~~~~~~~~~~~~~~~ 4 : // 5 : // Created by Praveen K V 6 : // Copyright (c) 2012 Contrail Systems. All rights reserved. 7 : // 8 : // Borrowed heavily from boost::asio::local socket code 9 : 10 : #ifndef IO_NETLINK_PROTOCOL_HPP 11 : #define IO_NETLINK_PROTOCOL_HPP 12 : 13 : #include <boost/asio/detail/config.hpp> 14 : #include <boost/asio/basic_datagram_socket.hpp> 15 : #include <boost/asio/detail/socket_types.hpp> 16 : #include <boost/asio/netlink_endpoint.hpp> 17 : 18 : #include <boost/asio/detail/push_options.hpp> 19 : 20 : namespace boost { 21 : namespace asio { 22 : namespace netlink { 23 : 24 : // asio netlink socket support 25 : /** 26 : * The boost::asio::netlink::raw contains implementation of Netlink socket 27 : * in asio 28 : * 29 : * @par Thread Safety 30 : * @e Distinct @e objects: Safe.@n 31 : * @e Shared @e objects: Safe. 32 : * 33 : * @par Concepts: 34 : * Protocol. 35 : */ 36 : class raw { 37 : public: 38 0 : raw() : proto(0) {}; 39 0 : raw(int p) : proto(p) {}; 40 : 41 : /// Obtain an identifier for the type of the protocol. 42 0 : int type() const 43 : { 44 0 : return SOCK_RAW; 45 : } 46 : 47 : /// Obtain an identifier for the protocol. 48 0 : int protocol() const 49 : { 50 0 : return proto; 51 : } 52 : 53 : /// Obtain an identifier for the protocol family. 54 0 : int family() const 55 : { 56 : #if defined(__linux__) 57 0 : return AF_NETLINK; 58 : #else 59 : #error "Unsupported platform" 60 : #endif 61 : } 62 : 63 : /// The NETLINK domain socket type. 64 : typedef basic_raw_socket<raw> socket; 65 : typedef basic_endpoint<raw> endpoint; 66 : 67 : int proto; 68 : }; 69 : 70 : } // namespace netlink 71 : } // namespace asio 72 : } // namespace boost 73 : 74 : #include <boost/asio/detail/pop_options.hpp> 75 : 76 : #endif // IO_NETLINK_PROTOCOL_HPP