MMapPacketSocketHandle.ih
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 internal header */
16 
17 #ifndef IH_SENF_senf_Socket_Protocols_Raw_MMapPacketSocketHandle_
18 #define IH_SENF_senf_Socket_Protocols_Raw_MMapPacketSocketHandle_ 1
19 
20 // Custom includes
21 #include <senf/Socket/SocketPolicy.hh>
22 #include <senf/Socket/ReadWritePolicy.hh>
23 #include <senf/Socket/QueueReadWritePolicy.hh>
24 
25 ///////////////////////////////ih.p////////////////////////////////////////
26 
27 namespace senf {
28 namespace detail {
29 
30  template <class Policy,
31  bool IsMMapReadable=ReadPolicyIs<Policy, QueueReadPolicy>::value,
32  bool IsMMapWriteable=WritePolicyIs<Policy, QueueWritePolicy>::value>
33  struct ConnectedMMapPacketSocketProtocol_Bases
34  : public DatagramSocketProtocol,
35  public BSDSocketProtocol,
36  public MMapSocketProtocol,
37  public MMapReadableSocketProtocol,
38  public LinuxPacketSocketProtocol
39  {
40  void init_client(std::string iface,
41  unsigned qlen,
42  unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
43  typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
44  int protocol = -1,
45  unsigned reserve=SENF_PACKET_VECTOR_HEADROOM,
46  bool qDiscBypass = false) const;
47  ///< Create packet socket
48  /**< The new socket will receive all packets of the given
49  IEEE 802.3 \a protocol. The socket will receive all
50  packets, if \a protocol is -1.
51 
52  If \a type is \c RawSocket, the packet will include the
53  link-level header (the Ethernet header). Sent packets
54  must already include a well formed ll header.
55 
56  If \a type is \c DatagramSocket, the link level header
57  will not be part of the packet data. The ll header will
58  be removed from received packets and a correct ll
59  header will be created on sent packets.
60 
61  \param[in] iface interface to bind to
62  \param[in] qlen number of frames in rx queue
63  \param[in] txqlen number of frames in tx queue
64  \param[in] frameSize size of single frame in queue
65  \param[in] type socket type
66  \param[in] protocol IEEE 802.3 protocol number */
67  /**< \note This member is implicitly called from the
68  ProtocolClientSocketHandle::ProtocolClientSocketHandle()
69  constructor */
70  };
71 
72  template <class Policy>
73  struct ConnectedMMapPacketSocketProtocol_Bases<Policy, true, false>
74  : public DatagramSocketProtocol,
75  public BSDSocketProtocol,
76  public MMapSocketProtocol,
77  public MMapReadableSocketProtocol,
78  public LinuxPacketSocketProtocol
79  {
80  void init_client(std::string iface,
81  unsigned qlen,
82  unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
83  typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
84  int protocol = -1,
85  unsigned reserve=SENF_PACKET_VECTOR_HEADROOM) const;
86  };
87 
88  template <class Policy>
89  struct ConnectedMMapPacketSocketProtocol_Bases<Policy, false, true>
90  : public DatagramSocketProtocol,
91  public BSDSocketProtocol,
92  public MMapSocketProtocol,
93  public LinuxPacketSocketProtocol,
94  public ReadableLinuxPacketProtocol
95  {
96  void init_client(std::string iface,
97  unsigned qlen,
98  unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
99  typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
100  int protocol = -1,
101  unsigned reserve=SENF_PACKET_VECTOR_HEADROOM,
102  bool qDiscBypass = false) const;
103  };
104 
105  template <class Policy>
106  struct ConnectedMMapPacketSocketProtocol_Bases<Policy, false, false>
107  : public DatagramSocketProtocol,
108  public BSDSocketProtocol,
109  public LinuxPacketSocketProtocol,
110  public ReadableLinuxPacketProtocol
111  {
112  void init_client(std::string iface,
113  unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
114  typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
115  int protocol = -1,
116  unsigned reserve=SENF_PACKET_VECTOR_HEADROOM) const;
117  };
118 
119 }}
120 
121 ///////////////////////////////ih.e////////////////////////////////////////
122 #endif
123 
124 
125 // Local Variables:
126 // mode: c++
127 // fill-column: 100
128 // comment-column: 40
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
132 // compile-command: "scons -u test"
133 // End: