LCOV - code coverage report
Current view: top level - root/contrail/controller/lib/boost/asio - netlink_endpoint.hpp (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 12 0.0 %
Date: 2026-08-03 02:19:58 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //
       2             : // netlink_endpoint.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_ENDPOINT_HPP
      11             : #define IO_NETLINK_ENDPOINT_HPP
      12             : 
      13             : #include <boost/asio/detail/config.hpp>
      14             : #include <boost/asio/detail/push_options.hpp>
      15             : #if defined(__linux__)
      16             : #include <linux/netlink.h>
      17             : #endif
      18             : 
      19             : namespace boost {
      20             : namespace asio {
      21             : namespace netlink {
      22             : 
      23             : /// Describes an endpoint for a NETLINK socket.
      24             : /**
      25             :  * The boost::asio::netlink::basic_endpoint class template describes an endpoint
      26             :  * that may be associated with a particular NETLINK socket.
      27             :  *
      28             :  * @par Thread Safety
      29             :  * @e Distinct @e objects: Safe.@n
      30             :  * @e Shared @e objects: Unsafe.
      31             :  *
      32             :  * @par Concepts:
      33             :  * Endpoint.
      34             :  */
      35             : template <typename Protocol>
      36             : class basic_endpoint
      37             : {
      38             : public:
      39             :   /// The protocol type associated with the endpoint.
      40             :   typedef Protocol protocol_type;
      41             : 
      42             :   /// underlying implementation of the socket layer.
      43             :   /// Dummy definition. Not used for netlink since we dont need "bind"
      44             :   typedef boost::asio::detail::socket_addr_type data_type;
      45             : 
      46             :   /// Default constructor.
      47           0 :   basic_endpoint() {
      48           0 :       memset(&impl_, 0, sizeof(impl_));
      49             : #if defined(__linux__)
      50           0 :       sa.nl_family = AF_NETLINK;
      51             : #endif
      52           0 :   }
      53             : 
      54           0 :   data_type *data() {
      55           0 :       return &impl_;
      56             :   }
      57             : 
      58           0 :   const data_type *data() const {
      59           0 :       return &impl_;
      60             :   }
      61             : 
      62           0 :   std::size_t size() const {
      63           0 :       return sizeof(sa);
      64             :   }
      65             : 
      66             :   /// The protocol associated with the endpoint.
      67           0 :   protocol_type protocol() const {
      68           0 :     return protocol_type();
      69             :   }
      70             : 
      71             : private:
      72             :   // The underlying NETLINK domain endpoint.
      73             :   union {
      74             :       data_type impl_;
      75             : #if defined(__linux__)
      76             :       struct sockaddr_nl sa;
      77             : #endif
      78             :   };
      79             : };
      80             : 
      81             : } // namespace netlink
      82             : } // namespace asio
      83             : } // namespace boost
      84             : 
      85             : #include <boost/asio/detail/pop_options.hpp>
      86             : 
      87             : #endif // IO_NETLINK_ENDPOINT_HPP

Generated by: LCOV version 1.14