aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/transport/chttp2
diff options
context:
space:
mode:
authorGravatar ctiller <ctiller@google.com>2014-12-10 08:43:47 -0800
committerGravatar Michael Lumish <mlumish@google.com>2014-12-10 13:22:22 -0800
commit48b5a4586a1292453c316c562afcee80b3d2b67d (patch)
tree4504df8e7865af964c71bf731812c178e8a8f16d /src/core/transport/chttp2
parent15e664bf6d193dbe99b68e98c7e97e36e67d3d2e (diff)
Advertise h2-16, h2-15, h2-14, and accept any of them.
(Fixing the rollback from earlier - we were passing '1' as the protocol count, not num_alpn_protocols) Change on 2014/12/10 by ctiller <ctiller@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81783755
Diffstat (limited to 'src/core/transport/chttp2')
-rw-r--r--src/core/transport/chttp2/alpn.c17
-rw-r--r--src/core/transport/chttp2/alpn.h9
2 files changed, 21 insertions, 5 deletions
diff --git a/src/core/transport/chttp2/alpn.c b/src/core/transport/chttp2/alpn.c
index cd9cf67a90..8107406f8b 100644
--- a/src/core/transport/chttp2/alpn.c
+++ b/src/core/transport/chttp2/alpn.c
@@ -32,14 +32,25 @@
*/
#include "src/core/transport/chttp2/alpn.h"
+#include <grpc/support/log.h>
+#include <grpc/support/useful.h>
-static const char *const supported_versions[] = {GRPC_CHTTP2_ALPN_VERSION,
- "h2-15", "h2-14"};
+/* in order of preference */
+static const char *const supported_versions[] = {"h2-16", "h2-15", "h2-14"};
int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) {
size_t i;
- for (i = 0; i < sizeof(supported_versions) / sizeof(const char *); i++) {
+ for (i = 0; i < GPR_ARRAY_SIZE(supported_versions); i++) {
if (!strncmp(version, supported_versions[i], size)) return 1;
}
return 0;
}
+
+size_t grpc_chttp2_num_alpn_versions() {
+ return GPR_ARRAY_SIZE(supported_versions);
+}
+
+const char *grpc_chttp2_get_alpn_version_index(size_t i) {
+ GPR_ASSERT(i < GPR_ARRAY_SIZE(supported_versions));
+ return supported_versions[i];
+}
diff --git a/src/core/transport/chttp2/alpn.h b/src/core/transport/chttp2/alpn.h
index 1353a18b1b..de4da8fedb 100644
--- a/src/core/transport/chttp2/alpn.h
+++ b/src/core/transport/chttp2/alpn.h
@@ -36,9 +36,14 @@
#include <string.h>
-#define GRPC_CHTTP2_ALPN_VERSION "h2-15"
-
/* Retuns 1 if the version is supported, 0 otherwise. */
int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size);
+/* Returns the number of protocol versions to advertise */
+size_t grpc_chttp2_num_alpn_versions();
+
+/* Returns the protocol version at index i (0 <= i <
+ * grpc_chttp2_num_alpn_versions()) */
+const char *grpc_chttp2_get_alpn_version_index(size_t i);
+
#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_ALPN_H_ */