aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/grpc++/channel_filter.h13
-rw-r--r--src/core/lib/transport/transport.h8
2 files changed, 19 insertions, 2 deletions
diff --git a/include/grpc++/channel_filter.h b/include/grpc++/channel_filter.h
index 542e6a0f35..53e42a7cb8 100644
--- a/include/grpc++/channel_filter.h
+++ b/include/grpc++/channel_filter.h
@@ -62,8 +62,13 @@ class ChannelData {
grpc_channel_element *elem,
grpc_transport_op *op);
+ const char* peer() const { return peer_; }
+
protected:
- explicit ChannelData(const grpc_channel_args &) {}
+ ChannelData(const grpc_channel_args &args, const char *peer) : peer_(peer) {}
+
+ private:
+ const char *peer_; // Do not own.
};
// Represents call data.
@@ -96,8 +101,12 @@ class ChannelFilter {
static void InitChannelElement(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_channel_element_args *args) {
+ const char* peer = args->optional_transport
+ ? grpc_transport_get_peer(exec_ctx,
+ args->optional_transport)
+ : nullptr;
// Construct the object in the already-allocated memory.
- new (elem->channel_data) ChannelDataType(*args->channel_args);
+ new (elem->channel_data) ChannelDataType(*args->channel_args, peer);
}
static void DestroyChannelElement(grpc_exec_ctx *exec_ctx,
diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h
index ed06fc3ed2..107bb802f6 100644
--- a/src/core/lib/transport/transport.h
+++ b/src/core/lib/transport/transport.h
@@ -43,6 +43,10 @@
#include "src/core/lib/transport/byte_stream.h"
#include "src/core/lib/transport/metadata_batch.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* forward declarations */
typedef struct grpc_transport grpc_transport;
@@ -264,4 +268,8 @@ void grpc_transport_destroy(grpc_exec_ctx *exec_ctx, grpc_transport *transport);
char *grpc_transport_get_peer(grpc_exec_ctx *exec_ctx,
grpc_transport *transport);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H */