adding PF_INET[6], SOCK_RAW sockets called RawV[4|6]ClientSocketHandle while naming...
[senf.git] / Socket / Protocols / INet / RawInetProtocol.cc
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum NETwork research (NET)
4 //     David Wagner <david.wagner@fokus.fraunhofer.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21
22 #include "RawInetProtocol.hh"
23
24 // Custom includes
25 #include <sys/socket.h>
26 #include <netinet/in.h>
27 #include <sys/ioctl.h>
28 #include <linux/sockios.h> // for SIOCINQ / SIOCOUTQ
29 #include <net/if.h> // for if_nametoindex
30 #include "../../../Socket/SocketHandle.hh"
31
32 //#include "UDPProtocol.mpp"
33 #define prefix_
34 ///////////////////////////////cc.p////////////////////////////////////////
35
36 prefix_ unsigned senf::RawInetProtocol::available()
37     const
38 {
39     int n;
40     if (::ioctl(body().fd(),SIOCINQ,&n) < 0)
41         throwErrno();
42     return n;
43 }
44
45 prefix_ bool senf::RawInetProtocol::eof()
46     const
47 {
48     return false;
49 }
50 #undef prefix_