1 // $Id: IPv6ExtOptionType.ct 869 2008-06-09 13:57:27Z pug $
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Philipp.Batroff@fokus.fraunhofer.de
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.
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.
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.
24 \brief IPv6Extension-Options non-inline template implementation */
26 //#include "IPv6ExtOptionType.ih"
31 ///////////////////////////////ct.p////////////////////////////////////////
33 template <class ForwardReadableRange>
34 prefix_ void senf::IPv6GenericOptionTLVParser::value(ForwardReadableRange const &range)
36 unsigned int rangeSize = boost::size(range);
38 if ( (rangeSize-2) != optionLength() )
39 resize(optionLength()+2, rangeSize);
40 std::copy(boost::next(boost::begin(range), 2), boost::next(boost::end(range)), boost::next(i(), 2 + optionLength() ));
41 unsigned int val = *(boost::begin(range));
42 unsigned int mask = 192u;
43 altAction() = (val & mask) >> 6;
45 changeFlag() = (val & mask) >> 5;
47 optionType() = (val & mask);
48 optionLength() = *(boost::next( boost::begin(range), 1));
51 template <class ForwardReadableRange>
52 prefix_ void senf::IPv6GenericOptionTLVParser::setPayload(ForwardReadableRange const &range)
54 unsigned int rangeSize = boost::size(range);
55 if ( rangeSize != optionLength() )
56 resize( (optionLength() + 2), (rangeSize + 2) );
57 std::copy( boost::begin(range), boost::end(range), boost::next( i(), 2));
58 optionLength() = rangeSize;
62 template <class Parser>
63 prefix_ Parser& senf::IPv6GenericOptionTLVParser::init()
65 size_type oldSize ( bytes() );
66 resize( oldSize, senf::init_bytes<Parser>::value);
67 data_iterator j = i();
68 std::advance(j, senf::init_bytes<Parser>::value);
69 std::fill(i() , j, 0u);
71 Parser::optionType() = Parser::typeCode;
75 // template <class Parser>
76 // prefix_ Parser& senf::GenericOptTypeTLVParser::get()
78 // SENF_ASSERT (optionType() == typeCode);
83 ///////////////////////////////ct.e////////////////////////////////////////
90 // c-file-style: "senf"
91 // indent-tabs-mode: nil
92 // ispell-local-dictionary: "american"
93 // compile-command: "scons -u test"