Move sourcecode into 'senf/' directory
[senf.git] / senf / Packets / 80221Bundle / MIHPacket.cci
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@berlios.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 /** \file
24     \brief MIH protocol inline non-template implementation */
25
26 //#include "MIHPacket.ih"
27
28 // Custom includes
29
30 #define prefix_ inline
31 ///////////////////////////////cci.p////////////////////////////////////////
32
33 ///////////////////////////////////////////////////////////////////////////
34 // MIHFId
35 prefix_ senf::MIHFId::MIHFId()
36     :  boost::variant< boost::blank, senf::MACAddress, senf::INet4Address, 
37             senf::INet6Address, std::string, senf::EUI64 > ( boost::blank())
38 { }
39
40 prefix_ senf::MIHFId::MIHFId(senf::MACAddress const & addr)
41     :  boost::variant< boost::blank, senf::MACAddress, senf::INet4Address, 
42             senf::INet6Address, std::string, senf::EUI64 > ( addr)
43 { }
44
45 prefix_ senf::MIHFId::MIHFId(senf::INet4Address const & addr)
46     :  boost::variant< boost::blank, senf::MACAddress, senf::INet4Address, 
47             senf::INet6Address, std::string, senf::EUI64 > ( addr)
48 { }
49
50 prefix_ senf::MIHFId::MIHFId(senf::INet6Address const & addr)
51     :  boost::variant< boost::blank, senf::MACAddress, senf::INet4Address, 
52             senf::INet6Address, std::string, senf::EUI64 > ( addr)
53 { }
54
55 prefix_ senf::MIHFId::MIHFId(std::string const & addr)
56     :  boost::variant< boost::blank, senf::MACAddress, senf::INet4Address, 
57             senf::INet6Address, std::string, senf::EUI64 > ( addr)
58 { }
59
60 prefix_ senf::MIHFId::MIHFId(senf::EUI64 const & addr)
61     :  boost::variant< boost::blank, senf::MACAddress, senf::INet4Address, 
62             senf::INet6Address, std::string, senf::EUI64 > ( addr)
63 { }
64
65 prefix_ senf::MIHFId::Type senf::MIHFId::type()
66     const
67 {
68     return boost::apply_visitor( GetTypeVisitor(), *this );
69 }
70
71 prefix_ bool senf::MIHFId::operator==(senf::MIHFId const & other)
72     const
73 {
74     return boost::apply_visitor( EqualsVisitor(), *this, other);
75 }
76
77 prefix_ bool senf::MIHFId::operator<(senf::MIHFId const & other)
78     const 
79 {
80     if (type() != other.type()) return type() < other.type();
81     return boost::apply_visitor( LessThanVisitor(), *this, other);
82 }
83
84 ///////////////////////////////////////////////////////////////////////////
85 // MIHFId_TLVParser
86
87 prefix_ std::string senf::MIHFId_TLVParser::asString()
88     const
89 {
90     return std::string( i(1+length_bytes()), i(1+length_bytes()+length()) );
91 }
92
93 prefix_ senf::MACAddress senf::MIHFId_TLVParser::asMACAddress()
94     const
95 {
96     return MACAddress::from_data( 
97             getNAIDecodedIterator( i(1+length_bytes()), i(1+length_bytes()+12) ));
98 }
99
100 prefix_ senf::INet4Address senf::MIHFId_TLVParser::asINet4Address()
101     const
102 {
103     return INet4Address::from_data( 
104             getNAIDecodedIterator( i(1+length_bytes()), i(1+length_bytes()+8) ));
105 }
106
107 prefix_ senf::INet6Address senf::MIHFId_TLVParser::asINet6Address()
108     const
109 {
110     return INet6Address::from_data( 
111             getNAIDecodedIterator( i(1+length_bytes()), i(1+length_bytes()+32) ));
112 }
113
114 prefix_ senf::EUI64 senf::MIHFId_TLVParser::asEUI64()
115     const
116 {
117     return EUI64::from_data( 
118             getNAIDecodedIterator( i(1+length_bytes()), i(1+length_bytes()+16) ));
119 }
120
121 ///////////////////////////////cci.e////////////////////////////////////////
122 #undef prefix_
123
124 \f
125 // Local Variables:
126 // mode: c++
127 // fill-column: 100
128 // c-file-style: "senf"
129 // indent-tabs-mode: nil
130 // ispell-local-dictionary: "american"
131 // compile-command: "scons -u test"
132 // comment-column: 40
133 // End: