EthernetPacket.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief EthernetPacket inline non-template implementation */
16 
17 // Custom includes
18 
19 #define prefix_ inline
20 //-/////////////////////////////////////////////////////////////////////////////////////////////////
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 // senf::MACAddressParser
24 
25 prefix_ bool senf::MACAddressParser::local()
26  const
27 {
28  return (*this)[0] & 0x02;
29 }
30 
31 prefix_ bool senf::MACAddressParser::multicast()
32  const
33 {
34  return (*this)[0] & 0x01;
35 }
36 
37 prefix_ bool senf::MACAddressParser::broadcast()
38  const
39 {
40  return (*reinterpret_cast<std::uint32_t const *>(&(*this)[0]) ^ *reinterpret_cast<std::uint16_t const *>(&(*this)[4])) == 0xffff0000;
41 }
42 
43 prefix_ bool senf::MACAddressParser::null()
44  const
45 {
46  return (*reinterpret_cast<std::uint32_t const *>(&(*this)[0]) | *reinterpret_cast<std::uint16_t const *>(&(*this)[4])) == 0;
47 }
48 
49 prefix_ void senf::MACAddressParser::hash(boost::uint64_t * hash, boost::uint16_t const & otherKey)
50  const
51 {
52  std::copy(&(*this)[0], &(*this)[6], (std::uint8_t*)hash);
53  *(((std::uint16_t*)hash) + 3) = otherKey;
54 }
55 
56 
57 //-/////////////////////////////////////////////////////////////////////////////////////////////////
58 #undef prefix_
59 
60 
61 // Local Variables:
62 // mode: c++
63 // fill-column: 100
64 // c-file-style: "senf"
65 // indent-tabs-mode: nil
66 // ispell-local-dictionary: "american"
67 // compile-command: "scons -u test"
68 // comment-column: 40
69 // End: