From 88025588951f968ae149b62e358fabd6c155d2f0 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Mon, 4 May 2015 09:41:10 -0700
Subject: [PATCH] Add a hook to allow initial HTTP2 sequence number to be
 specified

---
 include/grpc/grpc.h                   |  3 +++
 src/core/transport/chttp2_transport.c | 13 +++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index 91e3d3018d..9bb826f323 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -111,6 +111,9 @@ typedef struct {
 #define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams"
 /* Maximum message length that the channel can receive */
 #define GRPC_ARG_MAX_MESSAGE_LENGTH "grpc.max_message_length"
+/* Initial sequence number for http2 transports */
+#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \
+  "grpc.http2.initial_sequence_number"
 
 /* Result of a grpc call. If the caller satisfies the prerequisites of a
    particular operation, the grpc_call_error returned will be GRPC_CALL_OK.
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 0bee37c614..10d4e9c30a 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -524,6 +524,19 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
           push_setting(t, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS,
                        channel_args->args[i].value.integer);
         }
+      } else if (0 == strcmp(channel_args->args[i].key,
+                             GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER)) {
+        if (channel_args->args[i].type != GRPC_ARG_INTEGER) {
+          gpr_log(GPR_ERROR, "%s: must be an integer",
+                  GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER);
+        } else if ((t->next_stream_id & 1) !=
+                   (channel_args->args[i].value.integer & 1)) {
+          gpr_log(GPR_ERROR, "%s: low bit must be %d on %s",
+                  GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER, t->next_stream_id & 1,
+                  t->is_client ? "client" : "server");
+        } else {
+          t->next_stream_id = channel_args->args[i].value.integer;
+        }
       }
     }
   }
-- 
GitLab