OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.1.0
API documentation
EobiPacketParser.cpp
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #include "EobiPacketParser.h"
21 #include "../PacketHeader.h"
22 #include "MessageDataStructures.h"
25 
26 using namespace OnixS;
29 
32 
33 
34 EobiPacketParser::EobiPacketParser()
35  : data_(nullptr)
36  , size_(0)
37  , offset_(0)
38 {
39 }
40 
42 {
43 }
44 
46  const Networking::Byte *packetData,
47  size_t packetDataSize)
48 {
49  if (!checkPacketContent(packetData, packetDataSize))
50  {
51  return false;
52  }
53 
54  data_ = packetData;
55  size_ = packetDataSize;
56  offset_ = sizeof(PacketHeader);
57 
58  return true;
59 }
60 
62 {
63  return (size_ > offset_);
64 }
65 
67 {
68  if ((offset_ + sizeof(MessageHeader)) > size_)
69  {
70  return nullptr;
71  }
72 
73  const BaseMsgData *message = reinterpret_cast<const BaseMsgData*>(data_ + offset_);
74 
75  if ((offset_ + message->BodyLen) > size_)
76  {
77  return nullptr;
78  }
79 
80  offset_ += message->BodyLen;
81 
82  return message;
83 }
84 
86  const Networking::Byte *packet,
87  size_t size)
88 {
89  const PacketHeader *header = reinterpret_cast<const PacketHeader*>(packet);
90 
91  return (checkPacketHeader(packet, size) ? header->MarketSegmentID : 0xFFFFFFFF);
92 }
93 
94 
95 // parsing
96 
97 bool EobiPacketParser::checkPacketHeader(const Byte *packetData, size_t size)
98 {
99  if (size < sizeof(PacketHeader))
100  {
101  return false;
102  }
103 
104  const PacketHeader *header = reinterpret_cast<const PacketHeader*>(packetData);
105 
106  return (header->BodyLen == sizeof(PacketHeader)
107  && (header->TemplateID == PacketHeader::TemplateIdValue));
108 }
109 
110 bool EobiPacketParser::checkPacketContent(const Byte *packetData, size_t size)
111 {
112  if (!checkPacketHeader(packetData, size))
113  {
114  return false;
115  }
116 
117  // TODO: check calculated packet size and MsgSeqNums
118 
119  return true;
120 }
PacketHeaderForEobi PacketHeader
bool attachPacketData(const Networking::Byte *packet, size_t size)
static MarketSegmentId getMarketSegmentId(const Networking::Byte *packet, size_t size)
Definition: Defines.h:30
BaseMsgData MessageHeader
UInt32 MarketSegmentId
Alias for Market Segment ID type.
Definition: Defines.h:40