RawINetSocketHandle.cc

Go to the documentation of this file.
00001 // $Id: RawINetSocketHandle.cc 597 2008-01-15 09:16:20Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     David Wagner <dw6@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 
00023 #include "RawINetSocketHandle.hh"
00024 
00025 // Custom includes
00026 #include <sys/types.h>
00027 #include <sys/socket.h>
00028 #include <sys/ioctl.h>
00029 
00030 #include <senf/Utils/Exception.hh>
00031 
00032 //#include "UDPSocketHandle.mpp"
00033 #define prefix_
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 // senf::RawV4SocketProtocol
00038 
00039 prefix_ void senf::RawV4SocketProtocol::init_client()
00040     const
00041 {
00042     init_client(IPPROTO_RAW);
00043 }
00044 
00045 prefix_ void
00046 senf::RawV4SocketProtocol::init_client(int const & protocol)
00047     const
00048 {
00049     int sock = ::socket(PF_INET, SOCK_RAW, protocol);
00050     if (sock < 0)
00051         SENF_THROW_SYSTEM_EXCEPTION("");
00052     fd(sock);
00053 }
00054 
00055 prefix_ void
00056 senf::RawV4SocketProtocol::init_client(int const & protocol, INet4SocketAddress const & address)
00057     const
00058 {
00059     init_client(protocol);
00060     clientHandle().bind(address);
00061 }
00062 
00063 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00064 // senf::RawV6SocketProtocol::
00065 
00066 prefix_ void senf::RawV6SocketProtocol::init_client()
00067     const
00068 {
00069     init_client(IPPROTO_RAW);
00070 }
00071 
00072 prefix_ void senf::RawV6SocketProtocol::init_client(int const & protocol)
00073     const
00074 {
00075     int sock = ::socket(PF_INET6,SOCK_RAW,protocol);
00076     if (sock < 0)
00077         SENF_THROW_SYSTEM_EXCEPTION("");
00078     fd(sock);
00079 }
00080 
00081 prefix_ void
00082 senf::RawV6SocketProtocol::init_client(int const & protocol, INet6SocketAddress const & address)
00083     const
00084 {
00085     init_client(protocol);
00086     clientHandle().bind(address);
00087 }
00088 
00089 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00090 #undef prefix_
00091 //#include "RawINetSocketHandle.mpp"
00092 
00093 
00094 // Local Variables:
00095 // mode: c++
00096 // fill-column: 100
00097 // comment-column: 40
00098 // c-file-style: "senf"
00099 // indent-tabs-mode: nil
00100 // ispell-local-dictionary: "american"
00101 // compile-command: "scons -u test"
00102 // End: