|
| 1 | +// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). |
| 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 | +#include <rmw/rmw.h> |
| 16 | +#include <rmw_microxrcedds_c/rmw_c_macros.h> |
| 17 | + |
| 18 | +#include "./rmw_microros_internal/types.h" |
| 19 | +#include "./rmw_microros_internal/error_handling_internal.h" |
| 20 | + |
| 21 | +rmw_ret_t |
| 22 | +rmw_get_gid_for_client( |
| 23 | + const rmw_client_t * client, |
| 24 | + rmw_gid_t * gid) |
| 25 | +{ |
| 26 | + RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT); |
| 27 | + RMW_CHECK_ARGUMENT_FOR_NULL(gid, RMW_RET_INVALID_ARGUMENT); |
| 28 | + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( |
| 29 | + client->implementation_identifier, |
| 30 | + RMW_RET_INCORRECT_RMW_IMPLEMENTATION); |
| 31 | + |
| 32 | + rmw_uxrce_client_t * custom_client = (rmw_uxrce_client_t *)client->data; |
| 33 | + |
| 34 | + if (sizeof(uxrObjectId) > RMW_GID_STORAGE_SIZE) { |
| 35 | + RMW_UROS_TRACE_MESSAGE("Not enough memory for impl ids") |
| 36 | + return RMW_RET_ERROR; |
| 37 | + } |
| 38 | + |
| 39 | + memset(gid->data, 0, RMW_GID_STORAGE_SIZE); |
| 40 | + memcpy( |
| 41 | + gid->data, |
| 42 | + &custom_client->client_id, |
| 43 | + sizeof(uxrObjectId)); |
| 44 | + |
| 45 | + return RMW_RET_OK; |
| 46 | +} |
0 commit comments