4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@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.
23 // Definition of non-inline template functions
25 #include "LLAddressing.ih"
33 ///////////////////////////////ct.p////////////////////////////////////////
35 template <class ForwardRange>
36 prefix_ void satcom::lib::LLSocketAddress::address(ForwardRange const & address)
38 if (boost::size(address) > sizeof(addr_.sll_addr))
39 throw InvalidLLSocketAddressException();
40 typename boost::range_const_iterator<ForwardRange>::type i (boost::begin(address));
41 ::memset(&addr_.sll_addr[0],sizeof(addr_.sll_addr),0);
43 for (; i != boost::end(address) && addr_.sll_halen<8; ++i, ++addr_.sll_halen)
44 addr_.sll_addr[addr_.sll_halen] = *i;
45 if (i != boost::end(address))
46 throw InvalidLLSocketAddressException();
49 template <class ForwardRange>
51 satcom::lib::llAddress(ForwardRange const & address,
52 typename boost::enable_if< boost::is_class<ForwardRange> >::type *)
54 if (boost::empty(address))
57 typename boost::range_const_iterator< ForwardRange >::type i (boost::begin(address));
59 s << std::hex << std::setw(2) << std::setfill('0') << unsigned(*i);
61 if (i == boost::end(address))
68 template <class ForwardRange>
69 prefix_ unsigned char satcom::lib::detail::HexConverter::operator()(ForwardRange const & v)
72 if (boost::size(v) != 2)
73 throw InvalidLLSocketAddressException();
74 typename boost::range_iterator< ForwardRange >::type i (boost::begin(v));
75 unsigned char n1 = hexnibble(*i) << 4;
76 return n1 + hexnibble(*(++i));
79 ///////////////////////////////ct.e////////////////////////////////////////
85 // c-file-style: "satcom"