PacketSocketHandle.hh

Go to the documentation of this file.
00001 // $Id:PacketSocketHandle.hh 218 2007-03-20 14:39:32Z tho $
00002 //
00003 // Copyright (C) 2006
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00027 #ifndef HH_SENF_Socket_Protocols_Raw_PacketSocketHandle_
00028 #define HH_SENF_Socket_Protocols_Raw_PacketSocketHandle_ 1
00029 
00030 // Custom includes
00031 #include <senf/Socket/SocketPolicy.hh>
00032 #include <senf/Socket/SocketProtocol.hh>
00033 #include <senf/Socket/ProtocolClientSocketHandle.hh>
00034 #include <senf/Socket/FramingPolicy.hh>
00035 #include <senf/Socket/CommunicationPolicy.hh>
00036 #include <senf/Socket/ReadWritePolicy.hh>
00037 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
00038 #include <senf/Socket/Protocols/DatagramSocketProtocol.hh>
00039 #include "LLAddressing.hh"
00040 
00041 //#include "PacketSocketHandle.mpp"
00042 //#include "PacketSocketHandle.ih"
00043 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00044 
00045 namespace senf {
00046 
00048     //\{
00049 
00050     typedef MakeSocketPolicy<
00051         LLAddressingPolicy,
00052         DatagramFramingPolicy,
00053         UnconnectedCommunicationPolicy,
00054         ReadablePolicy,
00055         WriteablePolicy
00056         >::policy Packet_Policy;        
00057 
00077     class PacketSocketProtocol
00078         : public ConcreteSocketProtocol<Packet_Policy, PacketSocketProtocol>,
00079           public DatagramSocketProtocol,
00080           public BSDSocketProtocol
00081     {
00082     public:
00083         enum SocketType { RawSocket, DatagramSocket };
00085 
00087         //\{
00088         void init_client(SocketType type = RawSocket, int protocol = -1) const;
00090 
00108         //\}
00109 
00111         //\{
00112 
00113         void mcAdd(std::string const & interface, MACAddress const & address) const;
00115 
00121         void mcDrop(std::string const & interface, MACAddress const & address) const;
00123 
00125         void promisc(std::string const & interface, bool mode) const;
00127 
00128         //\}
00129 
00131         //\{
00132 
00133         unsigned available() const;
00134         bool eof() const;
00135 
00136         //\}
00137     };
00138 
00139     typedef ProtocolClientSocketHandle<PacketSocketProtocol> PacketSocketHandle;
00141 
00143     //\}
00144 }
00145 
00146 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00147 //#include "PacketSocketHandle.cci"
00148 //#include "PacketSocketHandle.ct"
00149 //#include "PacketSocketHandle.cti"
00150 //#include "PacketSocketHandle.mpp"
00151 #endif
00152 
00153 
00154 // Local Variables:
00155 // mode: c++
00156 // fill-column: 100
00157 // c-file-style: "senf"
00158 // indent-tabs-mode: nil
00159 // ispell-local-dictionary: "american"
00160 // compile-command: "scons -u test"
00161 // comment-column: 40
00162 // End: