Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_sources (quicr PRIVATE
ctrl_message_types.cpp
${ctrl_messages_SOURCE}
messages.cpp
moqt_validate.cpp
publish_fetch_handler.cpp
publish_track_handler.cpp
fetch_track_handler.cpp
Expand Down
152 changes: 152 additions & 0 deletions src/moqt_validate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#include <quicr/detail/messages.h>

namespace quicr::messages {
bool SubscribeUpdate::Validate() const
{
return true;
}

bool Subscribe::Validate() const
{
return true;
}

bool SubscribeOk::Validate() const
{
return true;
}

bool SubscribeError::Validate() const
{
return true;
}

bool Announce::Validate() const
{
return true;
}

bool AnnounceOk::Validate() const
{
return true;
}

bool AnnounceError::Validate() const
{
return true;
}

bool Unannounce::Validate() const
{
return true;
}

bool Unsubscribe::Validate() const
{
return true;
}

bool SubscribeDone::Validate() const
{
return true;
}

bool AnnounceCancel::Validate() const
{
return true;
}

bool TrackStatusRequest::Validate() const
{
return true;
}

bool TrackStatus::Validate() const
{
return true;
}

bool Goaway::Validate() const
{
return true;
}

bool SubscribeAnnounces::Validate() const
{
return true;
}

bool SubscribeAnnouncesOk::Validate() const
{
return true;
}

bool SubscribeAnnouncesError::Validate() const
{
return true;
}

bool UnsubscribeAnnounces::Validate() const
{
return true;
}

bool MaxRequestId::Validate() const
{
return true;
}

bool Fetch::Validate() const
{
return true;
}
bool FetchCancel::Validate() const
{
return true;
}

bool FetchOk::Validate() const
{
return true;
}

bool FetchError::Validate() const
{
return true;
}

bool RequestsBlocked::Validate() const
{
return true;
}

bool Publish::Validate() const
{
return true;
}

bool PublishOk::Validate() const
{
return true;
}

bool PublishError::Validate() const
{
return true;
}

bool ClientSetup::Validate() const
{
return true;
}

bool ServerSetup::Validate() const
{
return true;
}

bool NewGroupRequest::Validate() const
{
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
{% endif %}

public:
virtual bool Validate() const;

{% for field in message.fields %}
{% if field.spec_name not in field_discards %}
{% if field.is_optional %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
{% endif %}
{% endif %}
{% endfor %}
if (!msg.Validate()) {
throw ProtocolViolationException("Invalid message");
}
return buffer;
}

Expand All @@ -52,6 +55,9 @@
*/
Bytes& operator<<(Bytes& buffer, const {{message.name}}& msg)
{
if (!msg.Validate()) {
throw std::invalid_argument("Invalid message");
}
Bytes payload;
// fill out payload
{% for field in message.fields %}
Expand Down
Loading