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 non-inline template implementation */
17 #include "MMapPacketSocketHandle.ih"
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>
29 ///////////////////////////////ct.p////////////////////////////////////////
31 template <class Policy, bool IsMMapReadable, bool IsMMapWriteable>
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)
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);
44 template <class Policy>
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)
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);
57 template <class Policy>
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)
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);
70 template <class Policy>
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)
77 this->init_packetSocket(type, protocol);
78 static_socket_cast< ClientSocketHandle<Policy> >(this->fh()).blocking(false);
81 ///////////////////////////////ct.e////////////////////////////////////////
89 // c-file-style: "senf"
90 // indent-tabs-mode: nil
91 // ispell-local-dictionary: "american"
92 // compile-command: "scons -u test"