Open Lighting Architecture  Latest Git
PreamblePacker.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  * PreamblePacker.h
17  * This class takes a block of Root Layer PDUs, prepends the ACN preamble and
18  * writes the data to a buffer.
19  * Copyright (C) 2012 Simon Newton
20  */
21 
22 #ifndef LIBS_ACN_PREAMBLEPACKER_H_
23 #define LIBS_ACN_PREAMBLEPACKER_H_
24 
25 #include "ola/io/IOStack.h"
26 #include "libs/acn/PDU.h"
27 
28 namespace ola {
29 namespace acn {
30 
31 /*
32  * Pack a Root PDU block and the ACN Preamble into a memory block. This class
33  * isn't reentrant so be careful where you use it.
34  */
36  public:
37  PreamblePacker() : m_send_buffer(NULL) {}
38  ~PreamblePacker();
39 
40  const uint8_t *Pack(const PDUBlock<PDU> &pdu_block,
41  unsigned int *length);
42 
43  static void AddUDPPreamble(ola::io::IOStack *stack);
44  static void AddTCPPreamble(ola::io::IOStack *stack);
45 
46  static const uint8_t ACN_HEADER[];
47  static const unsigned int ACN_HEADER_SIZE;
48  static const unsigned int MAX_DATAGRAM_SIZE = 1472;
49 
50  private:
51  uint8_t *m_send_buffer;
52 
53  void Init();
54 
55  static const uint8_t TCP_ACN_HEADER[];
56  static const unsigned int TCP_ACN_HEADER_SIZE;
57 };
58 } // namespace acn
59 } // namespace ola
60 #endif // LIBS_ACN_PREAMBLEPACKER_H_
static void AddUDPPreamble(ola::io::IOStack *stack)
Definition: PreamblePacker.cpp:93
Definition: PreamblePacker.h:35
static void AddTCPPreamble(ola::io::IOStack *stack)
Definition: PreamblePacker.cpp:102
Definition: IOStack.h:40
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: PDU.h:103