MMapPacketSocketHandle.ct
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief MMapPacketSocketHandle non-inline template implementation */
16 
17 #include "MMapPacketSocketHandle.ih"
18 
19 // Custom includes
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <linux/if_packet.h>
23 #include <net/ethernet.h>
24 #include <netinet/in.h>
25 #include <net/if.h>
26 #include <errno.h>
27 
28 #define prefix_
29 ///////////////////////////////ct.p////////////////////////////////////////
30 
31 template <class Policy, bool IsMMapReadable, bool IsMMapWriteable>
32 prefix_ void
33 senf::detail::ConnectedMMapPacketSocketProtocol_Bases<Policy,IsMMapReadable,IsMMapWriteable>::
34 init_client(std::string iface, unsigned qlen, unsigned frameSize,
35  typename LinuxPacketSocketProtocol::SocketType type, int protocol, unsigned reserve, bool qDiscBypass)
36  const
37 {
38  this->init_packetSocket(type, protocol);
39  static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).blocking(false);
40  static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).bind(LLSocketAddress(iface));
41  this->init_mmap(frameSize, qlen, qlen/2, reserve, qDiscBypass);
42 }
43 
44 template <class Policy>
45 prefix_ void
46 senf::detail::ConnectedMMapPacketSocketProtocol_Bases<Policy, true, false>::
47 init_client(std::string iface, unsigned qlen, unsigned frameSize,
48  typename LinuxPacketSocketProtocol::SocketType type, int protocol, unsigned reserve)
49  const
50 {
51  this->init_packetSocket(type, protocol);
52  static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).blocking(false);
53  static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).bind(LLSocketAddress(iface));
54  this->init_mmap(frameSize, qlen, 0, reserve);
55 }
56 
57 template <class Policy>
58 prefix_ void
59 senf::detail::ConnectedMMapPacketSocketProtocol_Bases<Policy, false, true>::
60 init_client(std::string iface, unsigned qlen, unsigned frameSize,
61  typename LinuxPacketSocketProtocol::SocketType type, int protocol, unsigned reserve, bool qDiscBypass)
62  const
63 {
64  this->init_packetSocket(type, protocol);
65  static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).blocking(false);
66  static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).bind(LLSocketAddress(iface));
67  this->init_mmap(frameSize, 0, qlen, reserve, qDiscBypass);
68 }
69 
70 template <class Policy>
71 prefix_ void
72 senf::detail::ConnectedMMapPacketSocketProtocol_Bases<Policy, false, false>::
73 init_client(std::string iface, unsigned frameSize, typename LinuxPacketSocketProtocol::SocketType type,
74  int protocol, unsigned reserve)
75  const
76 {
77  this->init_packetSocket(type, protocol);
78  static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).blocking(false);
79 }
80 
81 ///////////////////////////////ct.e////////////////////////////////////////
82 #undef prefix_
83 
84 
85 // Local Variables:
86 // mode: c++
87 // fill-column: 100
88 // comment-column: 40
89 // c-file-style: "senf"
90 // indent-tabs-mode: nil
91 // ispell-local-dictionary: "american"
92 // compile-command: "scons -u test"
93 // End: