diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/impl/call.h | 9 | ||||
-rw-r--r-- | include/grpc++/security/auth_metadata_processor.h | 1 | ||||
-rw-r--r-- | include/grpc++/security/credentials.h | 21 | ||||
-rw-r--r-- | include/grpc++/server.h | 10 | ||||
-rw-r--r-- | include/grpc++/server_builder.h | 7 | ||||
-rw-r--r-- | include/grpc/census.h | 4 | ||||
-rw-r--r-- | include/grpc/compression.h | 2 | ||||
-rw-r--r-- | include/grpc/grpc.h | 4 | ||||
-rw-r--r-- | include/grpc/grpc_security.h | 44 | ||||
-rw-r--r-- | include/grpc/support/port_platform.h | 15 | ||||
-rw-r--r-- | include/grpc/support/slice_buffer.h | 5 |
11 files changed, 98 insertions, 24 deletions
diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h index fca5603047..df45d6f485 100644 --- a/include/grpc++/impl/call.h +++ b/include/grpc++/impl/call.h @@ -126,11 +126,11 @@ class WriteOptions { } private: - void SetBit(const gpr_int32 mask) { flags_ |= mask; } + void SetBit(const gpr_uint32 mask) { flags_ |= mask; } - void ClearBit(const gpr_int32 mask) { flags_ &= ~mask; } + void ClearBit(const gpr_uint32 mask) { flags_ &= ~mask; } - bool GetBit(const gpr_int32 mask) const { return flags_ & mask; } + bool GetBit(const gpr_uint32 mask) const { return (flags_ & mask) != 0; } gpr_uint32 flags_; }; @@ -248,8 +248,7 @@ class CallOpRecvMessage { if (*status) { got_message = true; *status = SerializationTraits<R>::Deserialize(recv_buf_, message_, - max_message_size) - .ok(); + max_message_size).ok(); } else { got_message = false; grpc_byte_buffer_destroy(recv_buf_); diff --git a/include/grpc++/security/auth_metadata_processor.h b/include/grpc++/security/auth_metadata_processor.h index 9b9c06e3b6..25011f33ba 100644 --- a/include/grpc++/security/auth_metadata_processor.h +++ b/include/grpc++/security/auth_metadata_processor.h @@ -71,4 +71,3 @@ class AuthMetadataProcessor { } // namespace grpc #endif // GRPCXX_AUTH_METADATA_PROCESSOR_H_ - diff --git a/include/grpc++/security/credentials.h b/include/grpc++/security/credentials.h index e423849714..ff41bc597e 100644 --- a/include/grpc++/security/credentials.h +++ b/include/grpc++/security/credentials.h @@ -34,10 +34,13 @@ #ifndef GRPCXX_CREDENTIALS_H #define GRPCXX_CREDENTIALS_H +#include <map> #include <memory> #include <grpc++/impl/grpc_library.h> #include <grpc++/support/config.h> +#include <grpc++/support/status.h> +#include <grpc++/support/string_ref.h> namespace grpc { class ChannelArguments; @@ -165,6 +168,24 @@ std::shared_ptr<Credentials> CompositeCredentials( /// Credentials for an unencrypted, unauthenticated channel std::shared_ptr<Credentials> InsecureCredentials(); +// User defined metadata credentials. +class MetadataCredentialsPlugin { + public: + virtual ~MetadataCredentialsPlugin() {} + + // If this method returns true, the Process function will be scheduled in + // a different thread from the one processing the call. + virtual bool IsBlocking() const { return true; } + + // Gets the auth metatada produced by this plugin. + virtual Status GetMetadata( + grpc::string_ref service_url, + std::multimap<grpc::string, grpc::string>* metadata) = 0; +}; + +std::shared_ptr<Credentials> MetadataCredentialsFromPlugin( + std::unique_ptr<MetadataCredentialsPlugin> plugin); + } // namespace grpc #endif // GRPCXX_CREDENTIALS_H diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 18a8017880..1a62df5698 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -37,6 +37,7 @@ #include <list> #include <memory> +#include <grpc/compression.h> #include <grpc++/completion_queue.h> #include <grpc++/impl/call.h> #include <grpc++/impl/grpc_library.h> @@ -99,7 +100,7 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { /// \param max_message_size Maximum message length that the channel can /// receive. Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, - int max_message_size); + int max_message_size, grpc_compression_options compression_options); /// Register a service. This call does not take ownership of the service. /// The service must exist for the lifetime of the Server instance. @@ -214,11 +215,10 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool serialization_status = *status && payload_ && - SerializationTraits<Message>::Deserialize(payload_, request_, - server_->max_message_size_) - .ok(); + SerializationTraits<Message>::Deserialize( + payload_, request_, server_->max_message_size_).ok(); bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status); - *status = serialization_status && *status; + *status = serialization_status&&* status; return ret; } diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 496e7862c5..05937f150b 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -37,6 +37,7 @@ #include <memory> #include <vector> +#include <grpc/compression.h> #include <grpc++/support/config.h> namespace grpc { @@ -92,6 +93,11 @@ class ServerBuilder { max_message_size_ = max_message_size; } + /// Set the compression options to be used by the server. + void SetCompressionOptions(const grpc_compression_options& options) { + compression_options_ = options; + } + /// Tries to bind \a server to the given \a addr. /// /// It can be invoked multiple times. @@ -133,6 +139,7 @@ class ServerBuilder { }; int max_message_size_; + grpc_compression_options compression_options_; std::vector<std::unique_ptr<NamedService<RpcService>>> services_; std::vector<std::unique_ptr<NamedService<AsynchronousService>>> async_services_; diff --git a/include/grpc/census.h b/include/grpc/census.h index 2f36665d46..d0bc90420c 100644 --- a/include/grpc/census.h +++ b/include/grpc/census.h @@ -424,8 +424,8 @@ extern census_aggregation_ops census_agg_window; construction via census_define_view(). */ typedef struct { const census_aggregation_ops *ops; - const void - *create_arg; /* Argument to be used for aggregation initialization. */ + const void * + create_arg; /* Argument to be used for aggregation initialization. */ } census_aggregation; /** A census view type. Opaque. */ diff --git a/include/grpc/compression.h b/include/grpc/compression.h index 82e326fe0e..30163be2ff 100644 --- a/include/grpc/compression.h +++ b/include/grpc/compression.h @@ -95,7 +95,7 @@ void grpc_compression_options_init(grpc_compression_options *opts); /** Mark \a algorithm as enabled in \a opts. */ void grpc_compression_options_enable_algorithm( - grpc_compression_options *opts, grpc_compression_algorithm algorithm); + grpc_compression_options *opts, grpc_compression_algorithm algorithm); /** Mark \a algorithm as disabled in \a opts. */ void grpc_compression_options_disable_algorithm( diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 47f3df6605..0c854a5b0c 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -595,8 +595,8 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *call, void grpc_call_destroy(grpc_call *call); /** Request notification of a new call. - Once a call is received, a notification tagged with \a tag_new is added to - \a cq_for_notification. \a call, \a details and \a request_metadata are + Once a call is received, a notification tagged with \a tag_new is added to + \a cq_for_notification. \a call, \a details and \a request_metadata are updated with the appropriate call information. \a cq_bound_to_call is bound to \a call, and batch operation notifications for that call will be posted to \a cq_bound_to_call. diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 87bc250429..7a442e2ace 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -123,14 +123,54 @@ grpc_credentials *grpc_google_refresh_token_credentials_create( /* Creates an Oauth2 Access Token credentials with an access token that was aquired by an out of band mechanism. */ -grpc_credentials *grpc_access_token_credentials_create( - const char *access_token, void *reserved); +grpc_credentials *grpc_access_token_credentials_create(const char *access_token, + void *reserved); /* Creates an IAM credentials object for connecting to Google. */ grpc_credentials *grpc_google_iam_credentials_create( const char *authorization_token, const char *authority_selector, void *reserved); +/* Callback function to be called by the metadata credentials plugin + implementation when the metadata is ready. + - user_data is the opaque pointer that was passed in the get_metadata method + of the grpc_metadata_credentials_plugin (see below). + - creds_md is an array of credentials metadata produced by the plugin. It + may be set to NULL in case of an error. + - num_creds_md is the number of items in the creds_md array. + - status must be GRPC_STATUS_OK in case of success or another specific error + code otherwise. + - error_details contains details about the error if any. In case of success + it should be NULL and will be otherwise ignored. */ +typedef void (*grpc_credentials_plugin_metadata_cb)( + void *user_data, const grpc_metadata *creds_md, size_t num_creds_md, + grpc_status_code status, const char *error_details); + +/* grpc_metadata_credentials plugin is an API user provided structure used to + create grpc_credentials objects that can be set on a channel (composed) or + a call. See grpc_credentials_metadata_create_from_plugin below. + The grpc client stack will call the get_metadata method of the plugin for + every call in scope for the credentials created from it. */ +typedef struct { + /* The implementation of this method has to be non-blocking. + - service_url is the fully qualified URL that the client stack is + connecting to. + - cb is the callback that needs to be called when the metadata is ready. + - user_data needs to be passed as the first parameter of the callback. */ + void (*get_metadata)(void *state, const char *service_url, + grpc_credentials_plugin_metadata_cb cb, void *user_data); + + /* Destroys the plugin state. */ + void (*destroy)(void *state); + + /* State that will be set as the first parameter of the methods above. */ + void *state; +} grpc_metadata_credentials_plugin; + +/* Creates a credentials object from a plugin. */ +grpc_credentials *grpc_metadata_credentials_create_from_plugin( + grpc_metadata_credentials_plugin plugin, void *reserved); + /* --- Secure channel creation. --- */ /* Creates a secure channel using the passed-in credentials. */ diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 69ff18eed6..434dd6de87 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -46,10 +46,13 @@ #define NOMINMAX #endif /* NOMINMAX */ -#if defined(_WIN32_WINNT) -#if _WIN32_WINNT < 0x0600 -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 +#ifndef _WIN32_WINNT +#error \ + "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)" +#else /* !defined(_WIN32_WINNT) */ +#if (_WIN32_WINNT < 0x0600) +#error \ + "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)" #endif /* _WIN32_WINNT < 0x0600 */ #endif /* defined(_WIN32_WINNT) */ @@ -121,6 +124,7 @@ #define GPR_GETPID_IN_UNISTD_H 1 #define GPR_HAVE_MSG_NOSIGNAL 1 #elif defined(__linux__) +#define GPR_POSIX_CRASH_HANDLER 1 #define GPR_PLATFORM_STRING "linux" #ifndef _BSD_SOURCE #define _BSD_SOURCE @@ -177,6 +181,7 @@ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif +#define GPR_MSG_IOVLEN_TYPE int #if TARGET_OS_IPHONE #define GPR_PLATFORM_STRING "ios" #define GPR_CPU_IPHONE 1 @@ -185,6 +190,7 @@ #define GPR_PLATFORM_STRING "osx" #define GPR_CPU_POSIX 1 #define GPR_GCC_TLS 1 +#define GPR_POSIX_CRASH_HANDLER 1 #endif #define GPR_GCC_ATOMIC 1 #define GPR_POSIX_LOG 1 @@ -316,6 +322,7 @@ typedef uintptr_t gpr_uintptr; /* INT64_MAX is unavailable on some platforms. */ #define GPR_INT64_MAX (gpr_int64)(~(gpr_uint64)0 >> 1) +#define GPR_UINT32_MAX (~(gpr_uint32)0) /* maximum alignment needed for any type on this platform, rounded up to a power of two */ diff --git a/include/grpc/support/slice_buffer.h b/include/grpc/support/slice_buffer.h index 04db003ac5..e4f296c32a 100644 --- a/include/grpc/support/slice_buffer.h +++ b/include/grpc/support/slice_buffer.h @@ -77,7 +77,7 @@ size_t gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb, gpr_slice slice); void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *slices, size_t n); /* add a very small (less than 8 bytes) amount of data to the end of a slice buffer: returns a pointer into which to add the data */ -gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, unsigned len); +gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t len); /* pop the last buffer, but don't unref it */ void gpr_slice_buffer_pop(gpr_slice_buffer *sb); /* clear a slice buffer, unref all elements */ @@ -87,7 +87,8 @@ void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b); /* move all of the elements of src into dst */ void gpr_slice_buffer_move_into(gpr_slice_buffer *src, gpr_slice_buffer *dst); /* remove n bytes from the end of a slice buffer */ -void gpr_slice_buffer_trim_end(gpr_slice_buffer *src, size_t n); +void gpr_slice_buffer_trim_end(gpr_slice_buffer *src, size_t n, + gpr_slice_buffer *garbage); #ifdef __cplusplus } |