Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransportHeader.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * TransportHeader.h
17  * Interface for the TransportHeader class.
18  * This holds the source IP of the packet which is used to address replies
19  * correctly. At some point in the future we should try to abtract the
20  * transport protocol (IP/UDP in this case).
21  * Copyright (C) 2011 Simon Newton
22  */
23 
24 #ifndef PLUGINS_E131_E131_TRANSPORTHEADER_H_
25 #define PLUGINS_E131_E131_TRANSPORTHEADER_H_
26 
28 
29 namespace ola {
30 namespace plugin {
31 namespace e131 {
32 
33 /*
34  * The header for the transport layer
35  */
37  public:
38  enum TransportType {
39  TCP,
40  UDP,
41  UNDEFINED,
42  };
43 
44  TransportHeader() : m_transport_type(UNDEFINED) {}
46  TransportType type)
47  : m_source(source),
48  m_transport_type(type) {}
49 
50  ~TransportHeader() {}
51  const ola::network::IPV4SocketAddress& Source() const { return m_source; }
52  TransportType Transport() const { return m_transport_type; }
53 
54  bool operator==(const TransportHeader &other) const {
55  return (m_source == other.m_source &&
56  m_transport_type == other.m_transport_type);
57  }
58 
59  void operator=(const TransportHeader &other) {
60  m_source = other.m_source;
61  m_transport_type = other.m_transport_type;
62  }
63 
64  private:
66  TransportType m_transport_type;
67 };
68 } // namespace e131
69 } // namespace plugin
70 } // namespace ola
71 #endif // PLUGINS_E131_E131_TRANSPORTHEADER_H_