X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FPacketSocketHandle.hh;h=b8748ff6412780da146d8432bf06db2f36c8117e;hb=5a5c6d7f0fae7ad6c0af49d7742955cb6cf618cf;hp=179d7aa93e351e903fea4c02537eb08b525285ff;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Socket/PacketSocketHandle.hh b/Socket/PacketSocketHandle.hh index 179d7aa..b8748ff 100644 --- a/Socket/PacketSocketHandle.hh +++ b/Socket/PacketSocketHandle.hh @@ -38,8 +38,10 @@ #include "PacketSocketHandle.ih" ///////////////////////////////hh.p//////////////////////////////////////// -namespace satcom { -namespace lib { +namespace senf { + + /// \addtogroup concrete_protocol_group + /// @{ typedef MakeSocketPolicy< LLAddressingPolicy, @@ -48,32 +50,110 @@ namespace lib { ReadablePolicy, WriteablePolicy, SocketBufferingPolicy - >::policy Packet_Policy; + >::policy Packet_Policy; ///< Policy of PacketProtocol + + /** \brief Raw Packet-Socket access (Linux) + + \par Socket Handle typedefs: + \ref PacketSocketHandle + + \par Protocol Interface: + ClientSocketHandle::read(), ClientSocketHandle::readfrom(), ClientSocketHandle::writeto(), + ClientSocketHandle::bind(), ClientSocketHandle::local(), ClientSocketHandle::rcvbuf(), + ClientSocketHandle::sndbuf() + + \par Address Type: + LLSocketAddress + + The PacketProtocol provides access to the linux packet socket API. This API gives access to + the low level network packets. The packet socket allows read() and write() operations. The + PacketProtocol has no concept of a server socket. + \see \ref ProtocolClientSocketHandle \n + \ref protocol_group + */ class PacketProtocol : public ConcreteSocketProtocol, public BSDSocketProtocol { public: enum SocketType { RawSocket, DatagramSocket }; + ///< Socket types + enum PromiscMode { Promiscuous, AllMulticast, None }; + ///< Interface modes + ///\name Constructors + ///@{ void init_client(SocketType type = RawSocket, int protocol = -1) const; + ///< Create packet socket + /**< The new socket will receive all packets of the given + IEEE 802.3 \a protocol. The socket will receive all + packets, if \a protocol is -1. - std::auto_ptr clone() const; + If \a type is \c RawSocket, the packet will include the + link-level header (the Ethernet header). Sent packets + must already include a well formed ll header. + + If \a type is \c DatagramSocket, the link level header + will not be part of the packet data. The ll header will + be removed from received packets and a correct ll + header will be created on sent packets. - enum PromiscMode { Promiscuous, AllMulticast, None }; + \param[in] type socket type + \param[in] protocol IEEE 802.3 protocol number */ + ///@} + + ///\name Protocol Interface + ///@{ + void promisc(std::string interface, PromiscMode mode) const; + ///< Change interface mode + /**< This member will change the reception on the given + interface. The modes available are + +
+
\e None
No special mode set. Only receive + packets addressed to the interface or of joined + multicast groups
+
\e AllMulticast
Additionally receive all + multicast traffic
+
\e Promiscuous
Receive all packets on the + wire
+
- void promisc(std::string interface, PromiscMode mode) const; - // See LLSocketAddress for a discussion/rationale for - // ForwardRange here + \param[in] interface interface to modify + \param[in] mode new interface mode */ + + // See LLSocketAddress for a discussion/rationale for ForwardRange here template void mcAdd(std::string interface, ForwardRange const & address) const; - template + ///< Enable reception of a multicast group + /**< mcAdd will join a new multicast group. The address + parameter is specified as an arbitrary forward range + (see Boost.Range) + of up to 8 bytes. This allows to initialize the + address from an arbitrary sources without excessive + copying. + + \param[in] interface interface with which to join + \param[in] address multicast address to join + + \see \ref LLSocketAddress */ + template void mcDrop(std::string interface, ForwardRange const & address) const; + ///< Disable reception of a multicast group + /**< \see \ref mcAdd() */ + ///@} + + ///\name Abstract Interface Implementation + ///@{ + std::auto_ptr clone() const; unsigned available() const; bool eof() const; + ///@} + private: template void do_mc(std::string interface, ForwardRange const & address, bool add) const; @@ -81,8 +161,11 @@ namespace lib { }; typedef ProtocolClientSocketHandle PacketSocketHandle; - -}} + ///< SocketHandle of the PacketProtocol + /**< \related PacketPrototol */ + + /// @} +} ///////////////////////////////hh.e//////////////////////////////////////// //#include "PacketSocketHandle.cci" @@ -94,5 +177,6 @@ namespace lib { // Local Variables: // mode: c++ -// c-file-style: "satcom" +// c-file-style: "senf" +// fill-column: 100 // End: