Open Lighting Architecture  Latest Git
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 abstract the
20  * transport protocol (IP/UDP in this case).
21  * Copyright (C) 2011 Simon Newton
22  */
23 
24 #ifndef LIBS_ACN_TRANSPORTHEADER_H_
25 #define LIBS_ACN_TRANSPORTHEADER_H_
26 
28 
29 namespace ola {
30 namespace acn {
31 
32 /*
33  * The header for the transport layer
34  */
36  public:
37  enum TransportType {
38  TCP,
39  UDP,
40  UNDEFINED,
41  };
42 
43  TransportHeader() : m_transport_type(UNDEFINED) {}
44 
45  TransportHeader(const TransportHeader& other)
46  : m_source(other.m_source),
47  m_transport_type(other.m_transport_type) {}
48 
50  TransportType type)
51  : m_source(source),
52  m_transport_type(type) {}
53 
54  ~TransportHeader() {}
55  const ola::network::IPV4SocketAddress& Source() const { return m_source; }
56  TransportType Transport() const { return m_transport_type; }
57 
58  bool operator==(const TransportHeader &other) const {
59  return (m_source == other.m_source &&
60  m_transport_type == other.m_transport_type);
61  }
62 
63  void operator=(const TransportHeader &other) {
64  m_source = other.m_source;
65  m_transport_type = other.m_transport_type;
66  }
67 
68  private:
70  TransportType m_transport_type;
71 };
72 } // namespace acn
73 } // namespace ola
74 #endif // LIBS_ACN_TRANSPORTHEADER_H_
Definition: TransportHeader.h:35
Represents Socket Addresses.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
An IPv4 SocketAddress.
Definition: SocketAddress.h:78