MCPcopy Create free account
hub / github.com/COVESA/vsomeip / get_requester_policies

Method get_requester_policies

implementation/security/src/policy_manager_impl.cpp:1003–1065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1001}
1002
1003void policy_manager_impl::get_requester_policies(const std::shared_ptr<policy> _policy,
1004 std::set<std::shared_ptr<policy>>& _requesters) const {
1005
1006 std::scoped_lock lock_outer{any_client_policies_mutex_, _policy->mutex_};
1007 for (const auto& o : _policy->offers_) {
1008 for (const auto& p : any_client_policies_) {
1009 if (p == _policy)
1010 continue;
1011
1012 std::scoped_lock lock_inner(p->mutex_);
1013
1014 auto its_policy = std::make_shared<policy>();
1015 its_policy->credentials_ = p->credentials_;
1016
1017 for (const auto& r : p->requests_) {
1018 // o represents an offer by a service interval and its instances
1019 // (a set of intervals)
1020 // r represents a request by a service interval and its instances
1021 // and methods (instance intervals mapped to interval sets of methods)
1022 //
1023 // Thus, r matches o if their service identifiers as well as their
1024 // instances overlap. If r and o match, a new policy must be
1025 // created that contains the overlapping services/instances mapping
1026 // of r and o together with the methods from r
1027 service_t its_o_lower, its_o_upper, its_r_lower, its_r_upper;
1028 get_bounds(o.first, its_o_lower, its_o_upper);
1029 get_bounds(r.first, its_r_lower, its_r_upper);
1030
1031 if (its_o_lower <= its_r_upper && its_r_lower <= its_o_upper) {
1032 auto its_service_min = std::max(its_o_lower, its_r_lower);
1033 auto its_service_max = std::min(its_r_upper, its_o_upper);
1034
1035 for (const auto& i : o.second) {
1036 for (const auto& j : r.second) {
1037 for (const auto& k : j.second) {
1038 instance_t its_i_lower, its_i_upper, its_k_lower, its_k_upper;
1039 get_bounds(i, its_i_lower, its_i_upper);
1040 get_bounds(k, its_k_lower, its_k_upper);
1041
1042 if (its_i_lower <= its_k_upper && its_k_lower <= its_i_upper) {
1043 auto its_instance_min = std::max(its_i_lower, its_k_lower);
1044 auto its_instance_max = std::min(its_i_upper, its_k_upper);
1045
1046 boost::icl::interval_map<instance_t, boost::icl::interval_set<method_t>> its_instances_methods;
1047 its_instances_methods += std::make_pair(
1048 boost::icl::interval<instance_t>::closed(its_instance_min, its_instance_max), j.second);
1049
1050 its_policy->requests_ +=
1051 std::make_pair(boost::icl::interval<instance_t>::closed(its_service_min, its_service_max),
1052 its_instances_methods);
1053 }
1054 }
1055 }
1056 }
1057 }
1058 }
1059
1060 if (!its_policy->requests_.empty()) {

Callers 1

TESTFunction · 0.45

Calls 2

get_boundsFunction · 0.85
insertMethod · 0.80

Tested by

no test coverage detected