-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add localhost option to node creation (#520)
* Add localhost option to node creation Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com> * Bring localhost function from rmw Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com> * Satisfy uncrustify and address pr comments Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RCL__LOCALHOST_H_ | ||
#define RCL__LOCALHOST_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#include "rcl/types.h" | ||
#include "rcl/visibility_control.h" | ||
|
||
extern const char * const RCL_LOCALHOST_ENV_VAR; | ||
|
||
/// Determine if the user wants to communicate using loopback only. | ||
/** | ||
* Checks if localhost should be used for network communication checking ROS_LOCALHOST_ONLY env | ||
* variable | ||
* \returns true if ROS_LOCALHOST_ONLY is set and is 1, false otherwise. | ||
*/ | ||
RCL_PUBLIC | ||
bool | ||
rcl_localhost_only(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // RCL__LOCALHOST_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2019 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <rcl/localhost.h> | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include "rcutils/get_env.h" | ||
|
||
const char * const RCL_LOCALHOST_ENV_VAR = "ROS_LOCALHOST_ONLY"; | ||
|
||
bool | ||
rcl_localhost_only() | ||
{ | ||
const char * ros_local_host_env_val = NULL; | ||
return rcutils_get_env(RCL_LOCALHOST_ENV_VAR, &ros_local_host_env_val) == NULL && | ||
ros_local_host_env_val != NULL && strcmp(ros_local_host_env_val, "1") == 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters