Open Lighting Architecture  0.9.1
 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  };
42 
43  TransportHeader() {}
45  TransportType type)
46  : m_source(source),
47  m_transport_type(type) {}
48 
49  ~TransportHeader() {}
50  const ola::network::IPV4SocketAddress& Source() const { return m_source; }
51  TransportType Transport() const { return m_transport_type; }
52 
53  bool operator==(const TransportHeader &other) const {
54  return (m_source == other.m_source &&
55  m_transport_type == other.m_transport_type);
56  }
57 
58  void operator=(const TransportHeader &other) {
59  m_source = other.m_source;
60  m_transport_type = other.m_transport_type;
61  }
62 
63  private:
65  TransportType m_transport_type;
66 };
67 } // namespace e131
68 } // namespace plugin
69 } // namespace ola
70 #endif // PLUGINS_E131_E131_TRANSPORTHEADER_H_