|
| 1 | +// Copyright 2020 Open Source Robotics Foundation, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#ifndef RMW__SECURITY_OPTIONS_H_ |
| 16 | +#define RMW__SECURITY_OPTIONS_H_ |
| 17 | + |
| 18 | +#ifdef __cplusplus |
| 19 | +extern "C" |
| 20 | +{ |
| 21 | +#endif |
| 22 | + |
| 23 | +#include <stdbool.h> |
| 24 | + |
| 25 | +#include "rcutils/allocator.h" |
| 26 | + |
| 27 | +#include "rmw/ret_types.h" |
| 28 | +#include "rmw/visibility_control.h" |
| 29 | + |
| 30 | +typedef enum RMW_PUBLIC_TYPE rmw_security_enforcement_policy_t |
| 31 | +{ |
| 32 | + RMW_SECURITY_ENFORCEMENT_PERMISSIVE, |
| 33 | + RMW_SECURITY_ENFORCEMENT_ENFORCE, |
| 34 | +} rmw_security_enforcement_policy_t; |
| 35 | + |
| 36 | +typedef struct RMW_PUBLIC_TYPE rmw_security_options_t |
| 37 | +{ |
| 38 | + enum rmw_security_enforcement_policy_t enforce_security; |
| 39 | + char * security_root_path; |
| 40 | +} rmw_security_options_t; |
| 41 | + |
| 42 | +/// Get zero initialized security options. |
| 43 | +RMW_PUBLIC |
| 44 | +rmw_security_options_t |
| 45 | +rmw_get_zero_initialized_security_options(); |
| 46 | + |
| 47 | +/// Get default initialized security options. |
| 48 | +RMW_PUBLIC |
| 49 | +rmw_security_options_t |
| 50 | +rmw_get_default_security_options(); |
| 51 | + |
| 52 | +/// Copy the given security options. |
| 53 | +/** |
| 54 | + * \param src security options to be copied. |
| 55 | + * \param allocator allocator used when copying data to the new security options. |
| 56 | + * \param dst security options to be set. |
| 57 | + * \returns RMW_RET_BAD_ALLOC, or |
| 58 | + * \returns RMW_RET_OK |
| 59 | + */ |
| 60 | +RMW_PUBLIC |
| 61 | +rmw_ret_t |
| 62 | +rmw_security_options_copy( |
| 63 | + const rmw_security_options_t * src, |
| 64 | + const rcutils_allocator_t * allocator, |
| 65 | + rmw_security_options_t * dst); |
| 66 | + |
| 67 | +/// Set the security root path for the given security options. |
| 68 | +/** |
| 69 | + * The provided `security_root_path` will be copied into allocated memory. |
| 70 | + * |
| 71 | + * \param security_root_path path to be set. |
| 72 | + * \param allocator allocator used to allocate the new path. |
| 73 | + * \param security_options security options to be set. |
| 74 | + * \returns RMW_RET_BAD_ALLOC, or |
| 75 | + * \returns RMW_RET_OK |
| 76 | + */ |
| 77 | +rmw_ret_t |
| 78 | +rmw_security_options_set_root_path( |
| 79 | + const char * security_root_path, |
| 80 | + const rcutils_allocator_t * allocator, |
| 81 | + rmw_security_options_t * security_options); |
| 82 | + |
| 83 | +/// Finalize the given security_options. |
| 84 | +/** |
| 85 | + * \param security_options security options to be finalized. |
| 86 | + * \param allocator allocator used to deallocate the root path. |
| 87 | + * \returns RMW_RET_ERROR, or |
| 88 | + * \returns RMW_RET_OK |
| 89 | + */ |
| 90 | +RMW_PUBLIC |
| 91 | +rmw_ret_t |
| 92 | +rmw_security_options_fini( |
| 93 | + rmw_security_options_t * security_options, |
| 94 | + const rcutils_allocator_t * allocator); |
| 95 | + |
| 96 | +#ifdef __cplusplus |
| 97 | +} |
| 98 | +#endif |
| 99 | + |
| 100 | +#endif // RMW__SECURITY_OPTIONS_H_ |
0 commit comments