NEW FILE HEADER / COPYRIGHT FORMAT
[senf.git] / Socket / Protocols / INet / RawInetProtocol.cc
1 // Copyright (C) 2007 
2 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
3 // Kompetenzzentrum NETwork research (NET)
4 //     David Wagner <dw6@berlios.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(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
51 ///////////////////////////////cc.e////////////////////////////////////////
52 #undef prefix_
53 //#include "UDPProtocol.mpp"
54
55 \f
56 // Local Variables:
57 // mode: c++
58 // fill-column: 100
59 // comment-column: 40
60 // c-file-style: "senf"
61 // indent-tabs-mode: nil
62 // ispell-local-dictionary: "american"
63 // compile-command: "scons -u test"
64 // End: