Open Lighting Architecture: libs/acn/UDPTransport.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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/network/IPV4Address.h"
26#include "ola/network/Socket.h"
27#include "libs/acn/PDU.h"
28#include "libs/acn/PreamblePacker.h"
29#include "libs/acn/Transport.h"
30
31namespace ola {
32namespace acn {
33
34/*
35 * The OutgoingUDPTransport is a small shim that provides the options to
36 * UDPTransportImpl.
37 */
38 class OutgoingUDPTransport: public OutgoingTransport {
39 public:
40 OutgoingUDPTransport(class OutgoingUDPTransportImpl *impl,
41 const ola::network::IPV4Address &destination,
42 uint16_t port = ola::acn::ACN_PORT)
43 : m_impl(impl),
44 m_destination(destination, port) {
45 }
46 ~OutgoingUDPTransport() {}
47
48 bool Send(const PDUBlock<PDU> &pdu_block);
49
50 private:
51 class OutgoingUDPTransportImpl *m_impl;
52 ola::network::IPV4SocketAddress m_destination;
53
54 OutgoingUDPTransport(const OutgoingUDPTransport&);
55 OutgoingUDPTransport& operator=(const OutgoingUDPTransport&);
56};
57
58
62 class OutgoingUDPTransportImpl {
63 public:
64 OutgoingUDPTransportImpl(ola::network::UDPSocket *socket,
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 }
74 ~OutgoingUDPTransportImpl() {
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
94 class IncomingUDPTransport {
95 public:
96 IncomingUDPTransport(ola::network::UDPSocket *socket,
97 class BaseInflator *inflator);
98 ~IncomingUDPTransport() {
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_
ACNPort.h
The TCP / UDP Ports used for transporting ACN.
IPV4Address.h
Represents an IPv4 Address.
ola::acn::BaseInflator
Definition BaseInflator.h:63
ola::acn::OutgoingUDPTransportImpl
Definition UDPTransport.h:62
ola::acn::PDUBlock
Definition PDU.h:103
ola::acn::PreamblePacker
Definition PreamblePacker.h:35
ola::network::IPV4Address
Represents a IPv4 Address.
Definition IPV4Address.h:55
ola::network::IPV4SocketAddress
An IPv4 SocketAddress.
Definition SocketAddress.h:78
ola::network::UDPSocket
Definition Socket.h:239
ola::acn::ACN_PORT
const uint16_t ACN_PORT
The port used for E1.31 & SDT communication.
Definition ACNPort.h:57
ola::acn
ACN related code.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44