remove redundant calls to rdstate()
This commit is contained in:
parent
65df669754
commit
474cc28d0e
|
@ -53,7 +53,7 @@ void Appliance::UdpStreamHandler(PDU::Stream stream) {
|
|||
|
||||
// Implementations shall check the ACN Packet Identifier and preamble size.
|
||||
if (!preamble)
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
|
||||
// implementations shall compute the size and position of the PDU block from
|
||||
// the preamble size and postamble size provided. ... ignoring any extra
|
||||
|
@ -83,7 +83,7 @@ void Appliance::TcpStreamHandler(PDU::Stream stream) {
|
|||
// implementations shall check the ACN Packet Identifier. If the ACN Packet
|
||||
// Identifier is not correct the receiver shall close the connection.
|
||||
if (!preamble)
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
|
||||
if (!stream->good())
|
||||
return;
|
||||
|
|
|
@ -82,7 +82,7 @@ Pdu::Pdu(PDU::Stream stream)
|
|||
void Pdu::readSetData() {
|
||||
// header may be inherited. check that one exists
|
||||
if (!header()) {
|
||||
stream_->setstate(stream_->rdstate() | std::ios_base::failbit);
|
||||
stream_->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ void Pdu::readSetData() {
|
|||
range pr(stream_, header->type, header->width);
|
||||
|
||||
if (!stream_->good() || pr.count * pr.incriment > stream_->available()) {
|
||||
stream_->setstate(stream_->rdstate() | std::ios_base::failbit);
|
||||
stream_->setstate(std::ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ void Pdu::readSetData() {
|
|||
|
||||
//set EOF if buffer insufficient for another property range
|
||||
if (stream_->available() < header->width * (header->type == SINGLE? 1 : 3))
|
||||
stream_->setstate(stream_->rdstate() | std::ios_base::eofbit);
|
||||
stream_->setstate(std::ios_base::eofbit);
|
||||
}
|
||||
setData(data);
|
||||
}
|
||||
|
|
10
acn/pdu.cpp
10
acn/pdu.cpp
|
@ -39,12 +39,12 @@ Pdu::Pdu(Stream stream, size_t vector_size)
|
|||
// read length and vector off of the stream
|
||||
// abort if the remaining PDU length isn't available
|
||||
if (stream->available() < (flags_.hasLength ? 3 : 2)) {
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
readLength(stream);
|
||||
if (!length_ || length_ > std::pow(2, (8 * (flags_.hasLength ? 3 : 2)) - 4)) {
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,14 +54,14 @@ Pdu::Pdu(Stream stream, size_t vector_size)
|
|||
|
||||
// abort if the remaining PDU length isn't available
|
||||
if (!stream->good() || stream->available() < len) {
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
// create a stream buffer for the header and data
|
||||
stream_ = Stream(new pdu_stream(stream->data(), len));
|
||||
if (stream_->available() != len) {
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ Pdu::Pdu(Stream stream, size_t vector_size)
|
|||
for (int i = 0; i < len; i++)
|
||||
stream->get();
|
||||
if (!stream->available())
|
||||
stream->setstate(stream->rdstate() | std::ios_base::eofbit);
|
||||
stream->setstate(std::ios_base::eofbit);
|
||||
|
||||
if (flags_.hasVector)
|
||||
readVector(vector_size);
|
||||
|
|
10
acn/pdu.h
10
acn/pdu.h
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
@ -68,17 +68,17 @@ public:
|
|||
Input/Output stream of nested PDU
|
||||
*/
|
||||
class pdu_stream
|
||||
: public std::basic_iostream<uint8_t>
|
||||
: public std::basic_istream<uint8_t>
|
||||
{
|
||||
public:
|
||||
pdu_stream(uint8_t * p, size_t l)
|
||||
: std::basic_iostream<uint8_t>(&_buffer)
|
||||
: std::basic_istream<uint8_t>(&_buffer)
|
||||
, _buffer(p, l) { rdbuf(&_buffer); }
|
||||
uint32_t available() { return _buffer.in_avail(); }
|
||||
uint8_t * data() { return _buffer.in_ptr(); };
|
||||
template<typename T> T readType() {
|
||||
if (available() < sizeof(T)) {
|
||||
setstate(rdstate() | std::ios_base::failbit);
|
||||
setstate(std::ios_base::failbit);
|
||||
return 0;
|
||||
}
|
||||
T ret = 0;
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
for (int i = sizeof(T); --i >= 0; )
|
||||
data[i] = get();
|
||||
if (!available())
|
||||
setstate(rdstate() | std::ios_base::eofbit);
|
||||
setstate(std::ios_base::eofbit);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace TCP {
|
|||
preamble_t::preamble_t(PDU::Stream stream) {
|
||||
stream->read(acn_id, sizeof(acn_id));
|
||||
if (stream->gcount() != 12)
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
length = stream->readType<decltype(length)>();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ preamble_t::preamble_t(PDU::Stream stream) {
|
|||
postamble_size = stream->readType<decltype(postamble_size)>();
|
||||
stream->read(acn_id, 12);
|
||||
if (stream->gcount() != 12)
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ rlp_header::rlp_header(PDU::Stream stream)
|
|||
uint8_t buf[16];
|
||||
stream->read(buf, 16);
|
||||
if (stream->gcount() != 16)
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
cid = UUID::uuid(buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace DATA {
|
|||
frame_header::frame_header(PDU::Stream stream) {
|
||||
stream->read(source_name, 64);
|
||||
if (stream->gcount() != 64)
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
priority = stream->readType<decltype(priority)>();
|
||||
sync_address = stream->readType<decltype(sync_address)>();
|
||||
sequence_number = stream->readType<decltype(sequence_number)>();
|
||||
|
|
|
@ -33,17 +33,17 @@ frame_sync_header::frame_sync_header(PDU::Stream stream) {
|
|||
sync_address = stream->readType<decltype(sync_address)>();
|
||||
stream->read(reserved, sizeof(reserved));
|
||||
if (stream->gcount() != sizeof(reserved))
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
|
||||
frame_discovery_header::frame_discovery_header(PDU::Stream stream) {
|
||||
stream->read(source_name, sizeof(source_name));
|
||||
if (stream->gcount() != sizeof(source_name))
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
stream->read(reserved, sizeof(reserved));
|
||||
if (stream->gcount() != sizeof(reserved))
|
||||
stream->setstate(stream->rdstate() | std::ios_base::failbit);
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -184,8 +184,7 @@ void Receiver::dataPacketHandler(std::shared_ptr<DATA::Pdu> frame) {
|
|||
// No priority outside the range of 0 to 200 shall be transmitted on
|
||||
// the network.
|
||||
if (source->priority() > 200)
|
||||
frame->stream()->setstate(frame->stream()->rdstate() |
|
||||
std::ios_base::failbit);
|
||||
frame->stream()->setstate(std::ios_base::failbit);
|
||||
|
||||
// 6.2.6 E1.31 Data Packet: Options
|
||||
// Preview_Data: Bit 7 (most significant bit)
|
||||
|
|
Loading…
Reference in New Issue