X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FRaw%2FPacketSocketHandle.cc;h=a57edf5f2df345ee0d3a5a9899c05640477225cc;hb=6f50bf49e282c0528f51faa0a245bbfa2b867399;hp=8027f528854d905609953c9c92e2fa93c427c676;hpb=fb08e3defcfb7cd8851ede0fab6cad424d168485;p=senf.git diff --git a/Socket/Protocols/Raw/PacketSocketHandle.cc b/Socket/Protocols/Raw/PacketSocketHandle.cc index 8027f52..a57edf5 100644 --- a/Socket/Protocols/Raw/PacketSocketHandle.cc +++ b/Socket/Protocols/Raw/PacketSocketHandle.cc @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -50,24 +50,18 @@ prefix_ void senf::PacketProtocol::init_client(SocketType type, int protocol) protocol = ETH_P_ALL; int sock = ::socket(PF_PACKET, socktype, htons(protocol)); if (sock < 0) - throw SystemException(errno); - body().fd(sock); -} - -prefix_ std::auto_ptr senf::PacketProtocol::clone() - const -{ - return std::auto_ptr(new PacketProtocol()); + throwErrno(); + fd(sock); } prefix_ unsigned senf::PacketProtocol::available() const { - if (! body().readable()) + if (! fh().readable()) return 0; - ssize_t l = ::recv(body().fd(),0,0,MSG_PEEK | MSG_TRUNC); + ssize_t l = ::recv(fd(),0,0,MSG_PEEK | MSG_TRUNC); if (l < 0) - throw SystemException(errno); + throwErrno(); return l; } @@ -84,14 +78,14 @@ namespace { struct packet_mreq mreq; mreq.mr_ifindex = ::if_nametoindex(interface.c_str()); if (mreq.mr_ifindex == 0) - throw senf::SystemException(EINVAL); + senf::throwErrno(EINVAL); mreq.mr_type = PACKET_MR_MULTICAST; mreq.mr_alen = 6; std::copy(address.begin(), address.end(), &mreq.mr_address[0]); if (::setsockopt(fd, SOL_PACKET, add ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) - throw senf::SystemException(errno); + senf::throwErrno(); } } @@ -100,14 +94,14 @@ prefix_ void senf::PacketProtocol::mcAdd(std::string const & interface, MACAddress const & address) const { - do_mc(body().fd(),interface,address,true); + do_mc(fd(),interface,address,true); } prefix_ void senf::PacketProtocol::mcDrop(std::string const & interface, MACAddress const & address) const { - do_mc(body().fd(),interface,address,false); + do_mc(fd(),interface,address,false); } ///////////////////////////////cc.e////////////////////////////////////////