Skip to content

Commit

Permalink
Switch to one participant per context.
Browse files Browse the repository at this point in the history
Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Oct 25, 2019
1 parent 813b94d commit de00c5d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 66 deletions.
2 changes: 1 addition & 1 deletion rmw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ set(rmw_sources
"src/names_and_types.c"
"src/publisher_options.c"
"src/sanity_checks.c"
"src/security_options.c"
"src/subscription_options.c"
"src/node_security_options.c"
"src/validate_full_topic_name.c"
"src/validate_namespace.c"
"src/validate_node_name.c"
Expand Down
20 changes: 1 addition & 19 deletions rmw/include/rmw/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,11 @@ extern "C"

#include <stdint.h>

#include "rmw/init_options.h"
#include "rmw/macros.h"
#include "rmw/ret_types.h"
#include "rmw/types.h"
#include "rmw/visibility_control.h"

/// Implementation defined context structure returned by rmw_init().
/**
* This should be defined by the rmw implementation.
*/
typedef struct rmw_context_impl_t rmw_context_impl_t;

/// Initialization context structure which is used to store init specific information.
typedef struct RMW_PUBLIC_TYPE rmw_context_t
{
/// Locally (process local) unique ID that represents this init/shutdown cycle.
uint64_t instance_id;
/// Implementation identifier, used to ensure two different implementations are not being mixed.
const char * implementation_identifier;
/// Implementation defined context information.
/** May be NULL if there is no implementation defined context information. */
rmw_context_impl_t * impl;
} rmw_context_t;

/// Return a zero initialized context structure.
RMW_PUBLIC
RMW_WARN_UNUSED
Expand Down
27 changes: 1 addition & 26 deletions rmw/include/rmw/init_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,9 @@ extern "C"
#include "rcutils/allocator.h"
#include "rmw/macros.h"
#include "rmw/ret_types.h"
#include "rmw/types.h"
#include "rmw/visibility_control.h"

/// Implementation defined options structure used during rmw_init().
/**
* This should be defined by the rmw implementation.
*/
typedef struct rmw_init_options_impl_t rmw_init_options_impl_t;

/// Options structure used during rmw_init().
typedef struct RMW_PUBLIC_TYPE rmw_init_options_t
{
/// Locally (process local) unique ID that represents this init/shutdown cycle.
/**
* This should be set by the caller of `rmw_init()` to a number that is
* unique within this process.
* It is designed to be used with `rcl_init()` and `rcl_get_instance_id()`.
*/
uint64_t instance_id;
/// Implementation identifier, used to ensure two different implementations are not being mixed.
const char * implementation_identifier;
// TODO(wjwwood): replace with rmw_allocator_t when that refactor happens
/// Allocator used during internal allocation of init options, if needed.
rcutils_allocator_t allocator;
/// Implementation defined init options.
/** May be NULL if there are no implementation defined options. */
rmw_init_options_impl_t * impl;
} rmw_init_options_t;

/// Return a zero initialized init options structure.
RMW_PUBLIC
RMW_WARN_UNUSED
Expand Down
2 changes: 1 addition & 1 deletion rmw/include/rmw/rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ rmw_create_node(
const char * name,
const char * namespace_,
size_t domain_id,
const rmw_node_security_options_t * security_options,
const rmw_security_options_t * security_options,
bool localhost_only);

/// Finalize a given node handle, reclaim the resources, and deallocate the node handle.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Open Source Robotics Foundation, Inc.
// Copyright 2017-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.
Expand All @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMW__NODE_SECURITY_OPTIONS_H_
#define RMW__NODE_SECURITY_OPTIONS_H_
#ifndef RMW__SECURITY_OPTIONS_H_
#define RMW__SECURITY_OPTIONS_H_

#ifdef __cplusplus
extern "C"
Expand All @@ -23,15 +23,15 @@ extern "C"
#include "rmw/types.h"

RMW_PUBLIC
rmw_node_security_options_t
rmw_get_zero_initialized_node_security_options();
rmw_security_options_t
rmw_get_zero_initialized_security_options();

RMW_PUBLIC
rmw_node_security_options_t
rmw_get_default_node_security_options();
rmw_security_options_t
rmw_get_default_security_options();

#ifdef __cplusplus
}
#endif

#endif // RMW__NODE_SECURITY_OPTIONS_H_
#endif // RMW__SECURITY_OPTIONS_H_
57 changes: 54 additions & 3 deletions rmw/include/rmw/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extern "C"
// map rcutils specific log levels to rmw speicfic type
#include <rcutils/logging.h>

#include "rmw/init.h"
#include "rmw/loaned_message_sequence.h"
#include "rmw/ret_types.h"
#include "rmw/serialized_message.h"
Expand All @@ -37,6 +36,24 @@ extern "C"
// implementation. It may need to be increased in the future.
#define RMW_GID_STORAGE_SIZE 24

/// Implementation defined context structure returned by rmw_init().
/**
* This should be defined by the rmw implementation.
*/
typedef struct rmw_context_impl_t rmw_context_impl_t;

/// Initialization context structure which is used to store init specific information.
typedef struct RMW_PUBLIC_TYPE rmw_context_t
{
/// Locally (process local) unique ID that represents this init/shutdown cycle.
uint64_t instance_id;
/// Implementation identifier, used to ensure two different implementations are not being mixed.
const char * implementation_identifier;
/// Implementation defined context information.
/** May be NULL if there is no implementation defined context information. */
rmw_context_impl_t * impl;
} rmw_context_t;

typedef struct RMW_PUBLIC_TYPE rmw_node_t
{
const char * implementation_identifier;
Expand Down Expand Up @@ -252,11 +269,45 @@ enum RMW_PUBLIC_TYPE rmw_security_enforcement_policy_t
RMW_SECURITY_ENFORCEMENT_ENFORCE,
};

typedef struct RMW_PUBLIC_TYPE rmw_node_security_options_t
typedef struct RMW_PUBLIC_TYPE rmw_security_options_t
{
enum rmw_security_enforcement_policy_t enforce_security;
const char * security_root_path;
} rmw_node_security_options_t;
} rmw_security_options_t;

/// Constant which indicates that the default domain id should be used.
#define RCL_NODE_OPTIONS_DEFAULT_DOMAIN_ID SIZE_MAX

/// Implementation defined options structure used during rmw_init().
/**
* This should be defined by the rmw implementation.
*/
typedef struct rmw_init_options_impl_t rmw_init_options_impl_t;

/// Options structure used during rmw_init().
typedef struct RMW_PUBLIC_TYPE rmw_init_options_t
{
/// Locally (process local) unique ID that represents this init/shutdown cycle.
/**
* This should be set by the caller of `rmw_init()` to a number that is
* unique within this process.
* It is designed to be used with `rcl_init()` and `rcl_get_instance_id()`.
*/
uint64_t instance_id;
/// Implementation identifier, used to ensure two different implementations are not being mixed.
const char * implementation_identifier;
/// ROS domain id
size_t domain_id;
/// Security options
rmw_security_options_t security_options;

// TODO(wjwwood): replace with rmw_allocator_t when that refactor happens
/// Allocator used during internal allocation of init options, if needed.
rcutils_allocator_t allocator;
/// Implementation defined init options.
/** May be NULL if there are no implementation defined options. */
rmw_init_options_impl_t * impl;
} rmw_init_options_t;

enum RMW_PUBLIC_TYPE rmw_qos_reliability_policy_t
{
Expand Down
16 changes: 8 additions & 8 deletions rmw/src/node_security_options.c → rmw/src/security_options.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Open Source Robotics Foundation, Inc.
// Copyright 2017-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.
Expand All @@ -12,19 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "rmw/node_security_options.h"
#include "rmw/security_options.h"

rmw_node_security_options_t
rmw_get_zero_initialized_node_security_options()
rmw_security_options_t
rmw_get_zero_initialized_security_options()
{
static rmw_node_security_options_t null_security_options = {0, NULL};
static rmw_security_options_t null_security_options = {0, NULL};
return null_security_options;
}

rmw_node_security_options_t
rmw_get_default_node_security_options()
rmw_security_options_t
rmw_get_default_security_options()
{
static rmw_node_security_options_t default_options;
static rmw_security_options_t default_options;
default_options.enforce_security = RMW_SECURITY_ENFORCEMENT_PERMISSIVE;
default_options.security_root_path = NULL;
return default_options;
Expand Down

0 comments on commit de00c5d

Please sign in to comment.