4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief PacketParser inline non-template implementation */
33 #include "PacketData.hh"
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::PacketParserBase
43 prefix_ senf::PacketParserBase::data_iterator senf::PacketParserBase::i()
51 prefix_ senf::PacketParserBase::data_iterator senf::PacketParserBase::end()
57 prefix_ senf::PacketParserBase::ParserProtector::ParserProtector(PacketParserBase const * p)
58 : safe_i_( *p), parser_(p)
61 prefix_ senf::PacketParserBase::ParserProtector::ParserProtector(ParserProtector const & other_)
62 : safe_i_( *other_.parser_), parser_(other_.parser_)
67 prefix_ senf::PacketParserBase::ParserProtector::~ParserProtector()
69 if (parser_) const_cast<PacketParserBase *>(parser_)->i_ = safe_i_;
74 prefix_ senf::PacketParserBase::ParserProtector senf::PacketParserBase::protect()
77 return ParserProtector(this);
80 prefix_ bool senf::PacketParserBase::check(size_type size)
83 return size <= size_type(std::distance(i(),end()));
86 prefix_ void senf::PacketParserBase::validate(size_type size)
90 throw TruncatedPacketException();
93 prefix_ senf::PacketParserBase::PacketParserBase(data_iterator i, state_type s)
97 prefix_ senf::PacketParserBase::PacketParserBase(data_iterator i, state_type s,
106 prefix_ senf::PacketParserBase::data_iterator senf::PacketParserBase::i(size_type offset)
110 return boost::next(i_, offset);
113 prefix_ senf::PacketParserBase::state_type senf::PacketParserBase::state()
119 prefix_ senf::PacketData & senf::PacketParserBase::data()
125 prefix_ void senf::PacketParserBase::init()
129 prefix_ void senf::PacketParserBase::defaultInit()
133 prefix_ senf::Packet senf::PacketParserBase::packet()
136 // OUCH ... I hate this but for some awkward packet types, access to the packet
137 // from the parser is really needed (e.g. UDP when building the pseudo-header
138 // for calculating the checksum).
139 return Packet(PacketInterpreterBase::ptr(static_cast<PacketInterpreterBase*>(&data())));
142 //-/////////////////////////////////////////////////////////////////////////////////////////////////
149 // c-file-style: "senf"
150 // indent-tabs-mode: nil
151 // ispell-local-dictionary: "american"
152 // compile-command: "scons -u test"
153 // comment-column: 40