Open Lighting Architecture  Latest Git
UDPTransport.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  * UDPTransport.h
17  * Interface for the UDPTransport class
18  * Copyright (C) 2007 Simon Newton
19  */
20 
21 #ifndef LIBS_ACN_UDPTRANSPORT_H_
22 #define LIBS_ACN_UDPTRANSPORT_H_
23 
24 #include "ola/acn/ACNPort.h"
25 #include "ola/base/Macro.h"
27 #include "ola/network/Socket.h"
28 #include "libs/acn/PDU.h"
29 #include "libs/acn/PreamblePacker.h"
30 #include "libs/acn/Transport.h"
31 
32 namespace ola {
33 namespace acn {
34 
35 /*
36  * The OutgoingUDPTransport is a small shim that provides the options to
37  * UDPTransportImpl.
38  */
40  public:
42  const ola::network::IPV4Address &destination,
43  uint16_t port = ola::acn::ACN_PORT)
44  : m_impl(impl),
45  m_destination(destination, port) {
46  }
48 
49  bool Send(const PDUBlock<PDU> &pdu_block);
50 
51  private:
52  class OutgoingUDPTransportImpl *m_impl;
53  ola::network::IPV4SocketAddress m_destination;
54 
56 };
57 
58 
63  public:
65  PreamblePacker *packer = NULL)
66  : m_socket(socket),
67  m_packer(packer),
68  m_free_packer(false) {
69  if (!m_packer) {
70  m_packer = new PreamblePacker();
71  m_free_packer = true;
72  }
73  }
75  if (m_free_packer)
76  delete m_packer;
77  }
78 
79  bool Send(const PDUBlock<PDU> &pdu_block,
80  const ola::network::IPV4SocketAddress &destination);
81 
82  private:
83  ola::network::UDPSocket *m_socket;
84  PreamblePacker *m_packer;
85  bool m_free_packer;
86 };
87 
88 
95  public:
97  class BaseInflator *inflator);
99  if (m_recv_buffer)
100  delete[] m_recv_buffer;
101  }
102 
103  void Receive();
104 
105  private:
106  ola::network::UDPSocket *m_socket;
107  class BaseInflator *m_inflator;
108  uint8_t *m_recv_buffer;
109 };
110 } // namespace acn
111 } // namespace ola
112 #endif // LIBS_ACN_UDPTRANSPORT_H_
Definition: Transport.h:37
An abstract PDU inflator.
Definition: BaseInflator.h:64
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
Definition: Socket.h:238
Definition: UDPTransport.h:62
Represents a IPv4 Address.
Definition: IPV4Address.h:55
Definition: PreamblePacker.h:35
Definition: UDPTransport.h:94
Represents an IPv4 Address.
Definition: UDPTransport.h:39
Helper macros.
const uint16_t ACN_PORT
The port used for E1.31 & SDT communication.
Definition: ACNPort.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
An IPv4 SocketAddress.
Definition: SocketAddress.h:78
Definition: PDU.h:103
The TCP / UDP Ports used for transporting ACN.