Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enum sequence and struct sequence validation #412

Merged
merged 5 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
39 changes: 30 additions & 9 deletions Development/nmos/control_protocol_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace nmos
// unknown property
utility::stringstream_t ss;
ss << U("unknown property: ") << property_id.serialize() << U(" to do Get");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::property_not_implemented }, ss.str());
}

Expand Down Expand Up @@ -82,15 +83,17 @@ namespace nmos
}
catch (const nmos::control_protocol_exception& e)
{
slog::log<slog::severities::error>(gate, SLOG_FLF) << "Set property: " << property_id.serialize() << " value: " << val.serialize() << " error: " << e.what();

return details::make_nc_method_result({ nc_method_status::parameter_error });
utility::stringstream_t ss;
ss << "Set property: " << property_id.serialize() << " value: " << val.serialize() << " error: " << e.what();
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, ss.str());
}
}

// unknown property
utility::stringstream_t ss;
ss << U("unknown property: ") << property_id.serialize() << " to do Set";
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::property_not_implemented }, ss.str());
}

Expand Down Expand Up @@ -126,12 +129,14 @@ namespace nmos
// out of bound
utility::stringstream_t ss;
ss << U("property: ") << property_id.serialize() << U(" is outside the available range to do GetSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::index_out_of_bounds }, ss.str());
}

// unknown property
utility::stringstream_t ss;
ss << U("unknown property: ") << property_id.serialize() << U(" to do GetSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::property_not_implemented }, ss.str());
}

Expand Down Expand Up @@ -163,6 +168,7 @@ namespace nmos
// property is not a sequence
utility::stringstream_t ss;
ss << U("property: ") << property_id.serialize() << U(" is not a sequence to do SetSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::invalid_request }, ss.str());
}

Expand Down Expand Up @@ -190,21 +196,24 @@ namespace nmos
}
catch (const nmos::control_protocol_exception& e)
{
slog::log<slog::severities::error>(gate, SLOG_FLF) << "Set sequence item: " << property_id.serialize() << " index: " << index << " value: " << val.serialize() << " error: " << e.what();

return details::make_nc_method_result({ nc_method_status::parameter_error });
utility::stringstream_t ss;
ss << "Set sequence item: " << property_id.serialize() << " index: " << index << " value: " << val.serialize() << " error: " << e.what();
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, ss.str());
}
}

// out of bound
utility::stringstream_t ss;
ss << U("property: ") << property_id.serialize() << U(" is outside the available range to do SetSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::index_out_of_bounds }, ss.str());
}

// unknown property
utility::stringstream_t ss;
ss << U("unknown property: ") << property_id.serialize() << U(" to do SetSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::property_not_implemented }, ss.str());
}

Expand Down Expand Up @@ -266,15 +275,17 @@ namespace nmos
}
catch (const nmos::control_protocol_exception& e)
{
slog::log<slog::severities::error>(gate, SLOG_FLF) << "Add sequence item: " << property_id.serialize() << " value: " << val.serialize() << " error: " << e.what();

utility::stringstream_t ss;
ss << "Add sequence item: " << property_id.serialize() << " value: " << val.serialize() << " error: " << e.what();
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result({ nc_method_status::parameter_error });
}
}

// unknown property
utility::stringstream_t ss;
ss << U("unknown property: ") << property_id.serialize() << U(" to do AddSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::property_not_implemented }, ss.str());
}

Expand All @@ -299,6 +310,7 @@ namespace nmos
// property is not a sequence
utility::stringstream_t ss;
ss << U("property: ") << property_id.serialize() << U(" is not a sequence to do RemoveSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::invalid_request }, ss.str());
}

Expand All @@ -317,12 +329,14 @@ namespace nmos
// out of bound
utility::stringstream_t ss;
ss << U("property: ") << property_id.serialize() << U(" is outside the available range to do RemoveSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::index_out_of_bounds }, ss.str());
}

// unknown property
utility::stringstream_t ss;
ss << U("unknown property: ") << property_id.serialize() << U(" to do RemoveSequenceItem");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::property_not_implemented }, ss.str());
}

Expand All @@ -346,6 +360,7 @@ namespace nmos
// property is not a sequence
utility::stringstream_t ss;
ss << U("property: ") << property_id.serialize() << U(" is not a sequence to do GetSequenceLength");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::invalid_request }, ss.str());
}

Expand All @@ -368,6 +383,7 @@ namespace nmos
// null
utility::stringstream_t ss;
ss << U("property: ") << property_id.serialize() << " is a null sequence to do GetSequenceLength";
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::invalid_request }, ss.str());
}
}
Expand All @@ -377,6 +393,7 @@ namespace nmos
// unknown property
utility::stringstream_t ss;
ss << U("unknown property: ") << property_id.serialize() << " to do GetSequenceLength";
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::property_not_implemented }, ss.str());
}

Expand Down Expand Up @@ -444,13 +461,17 @@ namespace nmos
// no role
utility::stringstream_t ss;
ss << U("role: ") << role.as_string() << U(" not found to do FindMembersByPath");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, ss.str());
}
}
else
{
// no members
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, U("no members to do FindMembersByPath"));
utility::stringstream_t ss;
ss << U("role: ") << role.as_string() << U(" has no members to do FindMembersByPath");
slog::log<slog::severities::error>(gate, SLOG_FLF) << utility::conversions::to_utf8string(ss.str());
jonathan-r-thorpe marked this conversation as resolved.
Show resolved Hide resolved
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, ss.str());
}
}

Expand Down
Loading
Loading