1 // $Id:PacketSocketHandle.hh 218 2007-03-20 14:39:32Z tho $
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief PacketProtocol and PacketSocketHandle public header
27 #ifndef HH_PacketSocketHandle_
28 #define HH_PacketSocketHandle_ 1
31 #include "../../../Socket/SocketPolicy.hh"
32 #include "../../../Socket/SocketProtocol.hh"
33 #include "../../../Socket/ProtocolClientSocketHandle.hh"
34 #include "../../../Socket/FramingPolicy.hh"
35 #include "../../../Socket/CommunicationPolicy.hh"
36 #include "../../../Socket/ReadWritePolicy.hh"
37 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
38 #include "LLAddressing.hh"
40 //#include "PacketSocketHandle.mpp"
41 //#include "PacketSocketHandle.ih"
42 ///////////////////////////////hh.p////////////////////////////////////////
46 /// \addtogroup concrete_protocol_group
49 typedef MakeSocketPolicy<
51 DatagramFramingPolicy,
52 UnconnectedCommunicationPolicy,
55 >::policy Packet_Policy; ///< Policy of PacketProtocol
57 /** \brief Raw Packet-Socket access (Linux)
59 \par Socket Handle typedefs:
60 \ref PacketSocketHandle (ProtocolClientSocketHandle)
62 \par Policy Interface:
63 ClientSocketHandle::read(), ClientSocketHandle::readfrom(), ClientSocketHandle::writeto(),
64 ClientSocketHandle::bind(), ClientSocketHandle::local(), ClientSocketHandle::rcvbuf(),
65 ClientSocketHandle::sndbuf()
70 The PacketProtocol provides access to the linux packet socket API. This API gives access to
71 the low level network packets. The packet socket allows read() and write() operations. The
72 PacketProtocol has no concept of a server socket.
74 This class is utilized as the protocol class of the ProtocolClientSocketHandle via the
75 Socket Handle typedefs above.
78 : public ConcreteSocketProtocol<Packet_Policy, PacketProtocol>,
79 public BSDSocketProtocol
82 enum SocketType { RawSocket, DatagramSocket };
87 void init_client(SocketType type = RawSocket, int protocol = -1) const;
88 ///< Create packet socket
89 /**< The new socket will receive all packets of the given
90 IEEE 802.3 \a protocol. The socket will receive all
91 packets, if \a protocol is -1.
93 If \a type is \c RawSocket, the packet will include the
94 link-level header (the Ethernet header). Sent packets
95 must already include a well formed ll header.
97 If \a type is \c DatagramSocket, the link level header
98 will not be part of the packet data. The ll header will
99 be removed from received packets and a correct ll
100 header will be created on sent packets.
102 \param[in] type socket type
103 \param[in] protocol IEEE 802.3 protocol number */
104 /**< \note This member is implicitly called from the
105 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
109 ///\name Protocol Interface
112 void mcAdd(std::string const & interface, MACAddress const & address) const;
113 ///< Enable reception of a multicast group
114 /**< mcAdd will join a new multicast group.
116 \param[in] interface interface with which to join
117 \param[in] address multicast address to join
119 \see \ref LLSocketAddress */
120 void mcDrop(std::string const & interface, MACAddress const & address) const;
121 ///< Disable reception of a multicast group
122 /**< \see \ref mcAdd() */
126 ///\name Abstract Interface Implementation
129 unsigned available() const;
135 typedef ProtocolClientSocketHandle<PacketProtocol> PacketSocketHandle;
136 ///< SocketHandle of the PacketProtocol
137 /**< \related PacketPrototol */
142 ///////////////////////////////hh.e////////////////////////////////////////
143 //#include "PacketSocketHandle.cci"
144 //#include "PacketSocketHandle.ct"
145 //#include "PacketSocketHandle.cti"
146 //#include "PacketSocketHandle.mpp"
153 // c-file-style: "senf"
154 // indent-tabs-mode: nil
155 // ispell-local-dictionary: "american"
156 // compile-command: "scons -u test"
157 // comment-column: 40