more work on SDT

This commit is contained in:
Kevin Matz 2021-02-02 14:19:32 -05:00
parent 5620a6c7e1
commit 63e2aeca41
2 changed files with 111 additions and 1 deletions

65
libESTA/acn/sdt.cpp Normal file
View File

@ -0,0 +1,65 @@
/*
sdt.cpp
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "sdt.h"
namespace ACN {
namespace SDT {
/**
compare to another sessionID
*/
bool SessionId::operator== (const SessionId & other) const {
return ((other.cid == cid) &
(other.number == number) &
(other.protocol == protocol));
}
/**
get the ID of the session
*/
SessionId Session::id() {
SessionId ret;
ret.cid = leader->cid();
ret.number = number;
ret.protocol = protocol;
return ret;
}
Pdu::Pdu(PDU::Stream stream)
: PDU::Pdu(stream, 1) // vectors are 1 octet
{
if (stream->fail()) return;
if (!buffer_->good()) return;
// SDT client blocks are the only SDT type to have a header.
// SDT client blocks have a different vector length?!?
// if (flags_.hasHeader)
// setHeader(new sdt_header(buffer_));
}
}; // SDT
}; // ACN

View File

@ -24,13 +24,51 @@
#pragma once
#include <cstdint>
#include <memory>
#include <unordered_map>
#include "component.h"
#include "pdu.h"
// ANSI E1.17- 2015, Architecture for Control Networks
// Session Data Transport Protocol
namespace ACN {
namespace SDT {
using std::uint32_t;
// 3.1 Session Identity
struct SessionId {
UUID::uuid cid; // the component ID (CID) of the session leader
uint16_t number; // the session number the leader has assigned
uint32_t protocol; // the ID of the protocol carried by the session
bool operator== (const SessionId &) const;
};
// 3.3 Sequenced Channels
// Sequenced channels transport three categories of traffic:
enum Direction {
internal, // SDT internal traffic
downstream, // Session downstream traffic
upstream // Session upstream traffic
};
struct Channel {
std::shared_ptr<Component> owner;
Direction direction = internal;
};
// 3.5.1.1 Member Identifiers
using MID = uint16_t;
struct Session {
uint16_t number;
uint32_t protocol;
std::shared_ptr<ACN::Component> leader;
std::shared_ptr<Channel> downstream;
std::unordered_map<MID, std::shared_ptr<Channel>> upstream;
SessionId id();
private:
MID next_id_ = 1;
};
// 7.1 Protocol Code
static const uint32_t SDT_PROTOCOL_ID = 1; // PDU protocol value
@ -63,5 +101,12 @@ enum ip_addr_spec_t {
SDT_ADDR_IPV6 = 2
};
class Pdu
: public PDU::Pdu
{
public:
Pdu(PDU::Stream);
};
} // SDT
} // ACN