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
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
15 \brief MMapPacketSocketHandle internal header */
17 #ifndef IH_SENF_senf_Socket_Protocols_Raw_MMapPacketSocketHandle_
18 #define IH_SENF_senf_Socket_Protocols_Raw_MMapPacketSocketHandle_ 1
21 #include <senf/Socket/SocketPolicy.hh>
22 #include <senf/Socket/ReadWritePolicy.hh>
23 #include <senf/Socket/QueueReadWritePolicy.hh>
25 ///////////////////////////////ih.p////////////////////////////////////////
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
40 void init_client(std::string iface,
42 unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
43 typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
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.
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.
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.
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()
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
80 void init_client(std::string iface,
82 unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
83 typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
85 unsigned reserve=SENF_PACKET_VECTOR_HEADROOM) const;
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
96 void init_client(std::string iface,
98 unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
99 typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
101 unsigned reserve=SENF_PACKET_VECTOR_HEADROOM,
102 bool qDiscBypass = false) const;
105 template <class Policy>
106 struct ConnectedMMapPacketSocketProtocol_Bases<Policy, false, false>
107 : public DatagramSocketProtocol,
108 public BSDSocketProtocol,
109 public LinuxPacketSocketProtocol,
110 public ReadableLinuxPacketProtocol
112 void init_client(std::string iface,
113 unsigned frameSize=(1u << SENF_PACKET_VECTOR_SIZE_INDEX),
114 typename LinuxPacketSocketProtocol::SocketType type = LinuxPacketSocketProtocol::RawSocket,
116 unsigned reserve=SENF_PACKET_VECTOR_HEADROOM) const;
121 ///////////////////////////////ih.e////////////////////////////////////////
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"