Fixed whitespace in all files (no tabs)
[senf.git] / Packets / IpV4Packet.cc
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 // Definition of non-inline non-template functions
24
25 #include "IpV4Packet.hh"
26 //#include "IpV4Packet.ih"
27 #include "EthernetPacket.hh"
28
29 // Custom includes
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33
34 #define prefix_
35 ///////////////////////////////cc.p////////////////////////////////////////
36
37 namespace {
38     senf::PacketRegistry<senf::EtherTypes>::RegistrationProxy<senf::IpV4Packet>
39         registerIpV4Packet (0x0800);
40
41     senf::PacketRegistry<senf::IpTypes>::RegistrationProxy<senf::IpV4Packet>
42         regsiterIpV4Packet2 (4); // IP-in-IP encapsulation
43 }
44
45 prefix_ void senf::IpV4Packet::v_nextInterpreter()
46     const
47 {
48     registerInterpreter(protocol(),begin()+bytes(),end());
49 }
50
51 prefix_ void senf::IpV4Packet::v_finalize()
52 {}
53
54 prefix_ void senf::IpV4Packet::v_dump(std::ostream & os)
55     const
56 {
57     struct in_addr in;
58     in.s_addr = htonl(source());
59     std::string src (inet_ntoa(in));
60     in.s_addr = htonl(destination());
61     std::string dst (inet_ntoa(in));
62     os << "Internet protocol Version 4:\n"
63        << "  version       : " << version() << "\n"
64        << "  IHL           : " << ihl() << "\n"
65        << "  TOS           : " << unsigned(tos()) << "\n"
66        << "  length        : " << length() << "\n"
67        << "  identifier    : " << identifier() << "\n"
68        << "  DF            : " << df() << "\n"
69        << "  MF            : " << mf() << "\n"
70        << "  fragment      : " << frag() << "\n"
71        << "  TTL           : " << unsigned(ttl()) << "\n"
72        << "  protocol      : " << unsigned(protocol()) << "\n"
73        << "  CRC           : " << std::hex << crc() << std::dec << "\n"
74        << "  source        : " << src << "\n"
75        << "  destination   : " << dst << "\n";
76 }
77
78 ///////////////////////////////cc.e////////////////////////////////////////
79 #undef prefix_
80
81 \f
82 // Local Variables:
83 // mode: c++
84 // fill-column: 100
85 // c-file-style: "senf"
86 // indent-tabs-mode: nil
87 // ispell-local-dictionary: "american"
88 // End: