Several corections & doc update
- GOAWAY frame encoding
- Header decompression corretion
- Header decompression debug
Change-Id: Ibf089c2332e73ba4af51b44d8b43a81cf0f1ab80
Signed-off-by: Gabor Szalai <gabor.szalai@ericsson.com>
diff --git a/doc/HTTP2_CNL113851_1551.pdf b/doc/HTTP2_CNL113851_1551.pdf
deleted file mode 100644
index 0190752..0000000
--- a/doc/HTTP2_CNL113851_1551.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/HTTP2_CNL113851_1551.adoc b/doc/HTTP2_Description.adoc
similarity index 81%
rename from doc/HTTP2_CNL113851_1551.adoc
rename to doc/HTTP2_Description.adoc
index e24c79d..44d4ba2 100644
--- a/doc/HTTP2_CNL113851_1551.adoc
+++ b/doc/HTTP2_Description.adoc
@@ -1,38 +1,23 @@
----
-Author: Gábor Szalai
-Version: 1551-CNL 113 851, Rev. A
-Date: 2017-04-10
-
----
= HTTP2 Protocol Modules for TTCN-3 Toolset with Titan, Description
:author: Gábor Szalai
-:revnumber: 1551-CNL 113 851, Rev. A
-:revdate: 2017-04-10
-:toc:
+:toc: left
-= Functionality
+== Functionality
The HTTP2 protocol module implements the message structures of the related protocol <<_4, [4]>> in a formalized way, using the standard specification language TTCN-3. This allows defining of test data (templates) in the TTCN-3 language and correctly encoding/decoding messages when executing test suites using the Titan TTCN-3 test environment.
-== Implemented Protocols
+=== Implemented Protocols
This set of protocol modules implements protocol messages and constants of the HTTP2 protocol as described in https://tools.ietf.org/html/rfc7540[RFC7540].
Header compression is implemented as described in https://tools.ietf.org/html/rfc7541[RFC7541].
-=== Modified and Non-Implemented Protocol Elements
+==== Modified and Non-Implemented Protocol Elements
None.
-=== Ericsson-Specific Changes
-None.
-
-== Backward Incompatibilities
-
-None
-
-== System Requirements
+=== System Requirements
Protocol modules are a set of TTCN-3 source code files that can be used as part of TTCN-3 test suites only. Hence, protocol modules alone do not put specific requirements on the system used. However, in order to compile and execute a TTCN-3 test suite using the set of protocol modules the following system requirements must be satisfied:
@@ -40,27 +25,27 @@
NOTE: This version of the test port is not compatible with Titan releases earlier than CRL 113 200/5 R4A.
-= Usage
+== Usage
-== Installation
+=== Installation
The set of protocol modules can be used in developing TTCN-3 test suites using any text editor; however, to make the work more efficient a TTCN3enabled text editor is recommended (for example `nedit`, `xemacs`). Since the HTTP2 protocol is used as a part of a TTCN-3 test suite, this requires TTCN-3 Test Executor be installed before the module can be compiled and executed together with other parts of the test suite. For more details on the installation of TTCN-3 Test Executor see the relevant section of <<_2, [2]>>.
-== Configuration
+=== Configuration
None.
-== Examples
+=== Examples
None.
-= Interface Description
+== Interface Description
-== HTTP2 Frame Handling
+=== HTTP2 Frame Handling
The HTTP2 frame is represented by the `HTTP2_Frame` union.
-=== HTTP2 Frame Encoding Functions
+==== HTTP2 Frame Encoding Functions
[source]
f_HTTP2_encode_frame(in HTTP2_Frame pl_frame) return octetstring
@@ -79,7 +64,7 @@
* `_1_` – Decoding failed.
* `_0_` – Decoding OK
-== Header Compression
+=== Header Compression
The protocol module provides functions and framework for header compression.
@@ -100,7 +85,8 @@
----
HTTP2_comp_context_encode(inout HTTP2_comp_context pl_context, in HTTP2_header_block pl_hblock, out octetstring pl_frame_data) return integer
-HTTP2_comp_context_decode(inout HTTP2_comp_context pl_context, out HTTP2_header_block pl_hblock, in octetstring pl_frame_data) return integer
+HTTP2_comp_context_decode(inout HTTP2_comp_context pl_context, out HTTP2_header_block pl_hblock, in octetstring pl_frame_data,
+ in boolean pl_enable_debug:=tsp_HTTP2_comp_context_decode_debug) return integer
----
3. Delete the context with
@@ -110,15 +96,17 @@
+
WARNING: Non-freed context leads to memory leak!!!!
-= Terminology
+==== Header decompression debug
-None.
+In order to debug the header decompression the 4th parameter of the function `HTTP2_comp_context_decode` should be set to `true`. Also the `DEBUG` log category should be included to the `FileMask`.
-= Abbreviations
+The header decompression debug can be enabled globally by setting the module parameter `tsp_HTTP2_comp_context_decode_debug` to `true`.
+
+== Abbreviations
TTCN-3:: Testing and Test Control Notation version 3
-= References
+== References
[[_1]]
[1] ETSI ES 201 873-1 v4.4.1 (2012-04) +
diff --git a/doc/change.log b/doc/change.log
index e69de29..6d36b1f 100644
--- a/doc/change.log
+++ b/doc/change.log
@@ -0,0 +1,14 @@
+= HTTP2 Protocol Modules for TTCN-3 Toolset with Titan, Change log
+:author: Gábor Szalai
+:toc: left
+
+== Changes
+
+=== R1C
+
+Header decompression correction
+
+=== R1D
+
+Debug loggin added.
+
diff --git a/src/HTTP2_EncDec.cc b/src/HTTP2_EncDec.cc
index 5d0b5fd..13014a8 100644
--- a/src/HTTP2_EncDec.cc
+++ b/src/HTTP2_EncDec.cc
@@ -1,17 +1,16 @@
/******************************************************************************
-* Copyright (c) 2000-2018 Ericsson Telecom AB AB
+* Copyright (c) 2017-2019 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
-*
* Contributors:
* Gabor Szalai - initial implementation and initial documentation
******************************************************************************/
//
// File: HTTP2_EncDec.cc
// Description: Encoder/decoder function for HTTP2
-// Rev: R1A
+// Rev: R1D
// Prodnr: CNL 113 851
@@ -245,7 +244,7 @@
// The value is not fit into the prefix_len bits
do {
ret_val++;
- val += ( ((uint32_t)(buff[ret_val] & 0x7F)) << (7*ret_val) );
+ val += ( ((uint32_t)(buff[ret_val] & 0x7F)) << (7*(ret_val-1)) );
} while(buff[ret_val] & 0x80);
ret_val++;
} else {
@@ -1230,7 +1229,19 @@
return ret_val;
}
-static int HTTP2_decode_one_header(const unsigned char* buff, int buff_len, CHARSTRING& hname, CHARSTRING& hval, HTTP2_compression_ctx* comp_ctx){
+static void http2_debug_log(const char *fmt, ...) {
+ TTCN_Logger::begin_event(TTCN_DEBUG);
+ TTCN_Logger::log_event("HTTP2 protocol module debug: ");
+ va_list args;
+ va_start(args, fmt);
+ TTCN_Logger::log_event_va_list(fmt, args);
+ va_end(args);
+ TTCN_Logger::end_event();
+}
+
+static int HTTP2_decode_one_header(const unsigned char* buff, int buff_len, CHARSTRING& hname, CHARSTRING& hval, HTTP2_compression_ctx* comp_ctx, bool debug_enabled){
+ if(debug_enabled){http2_debug_log("HTTP2_decode_one_header called");}
+
if(buff_len<1){
return -1; //not enough data
}
@@ -1246,7 +1257,8 @@
}
comp_ctx->set_max_size(idx);
-//printf("Dynamic Table Size Update %d\r\n", idx);
+ if(debug_enabled){http2_debug_log("Dynamic Table Size Update %d", idx);}
+
return ret_val;
}
@@ -1254,7 +1266,7 @@
if(buff[0] & 0x80){ // indexed field representation
unsigned char filler;
ret_val=decode_integer(buff,idx,7,filler);
-//printf("indexed field representation %d\r\n", idx);
+ if(debug_enabled){http2_debug_log("Indexed field representation %d", idx);}
if(ret_val>buff_len){
return -1;
@@ -1286,11 +1298,11 @@
add_hdr=1;
unsigned char filler;
ret_val=decode_integer(buff,idx,6,filler);
-//printf("Literal Header Field with Incremental Indexing %d\r\n", idx);
+ if(debug_enabled){http2_debug_log("Literal Header Field with Incremental Indexing %d", idx);}
} else if(((buff[0] & 0xF0)== 0x10) || ((buff[0] & 0xF0)== 0x00)){ // Literal Header Field without Indexing
unsigned char filler;
ret_val=decode_integer(buff,idx,4,filler);
-//printf("Literal Header Field withot Indexing %d %x\r\n", idx,buff[0]);
+ if(debug_enabled){http2_debug_log("Literal Header Field without Incremental Indexing %d", idx);}
} else {
// not possible
return -1;
@@ -1417,7 +1429,7 @@
return 0;
}
-INTEGER HTTP2__comp__context__decode(HTTP2__Types::HTTP2__comp__context& pl_context, HTTP2__Types::HTTP2__header__block& pl_hblock, const OCTETSTRING& pl_stream){
+INTEGER HTTP2__comp__context__decode(HTTP2__Types::HTTP2__comp__context& pl_context, HTTP2__Types::HTTP2__header__block& pl_hblock, const OCTETSTRING& pl_stream, const BOOLEAN& pl_enable_debug){
const unsigned char* ptr=(const unsigned char*)pl_stream;
int ptr_len=pl_stream.lengthof();
@@ -1430,11 +1442,13 @@
CHARSTRING hname="";
CHARSTRING hval="";
int hlen =-1;
- hlen=HTTP2_decode_one_header(ptr,ptr_len,hname, hval, &(ctx->remote));
+ hlen=HTTP2_decode_one_header(ptr,ptr_len,hname, hval, &(ctx->remote),pl_enable_debug);
if(hlen==-1){
+ if(pl_enable_debug){http2_debug_log("decoded header len %d",hlen);}
return 1;
}
-printf("decoded header len %d %s %s\r\n",hlen,(const char*)hname,(const char*)hval);
+ if(pl_enable_debug){http2_debug_log("decoded header len %d %s %s",hlen,(const char*)hname,(const char*)hval);}
+
if(hname==":method"){
if(!pl_hblock.pseudo__headers().ispresent()) pl_hblock.pseudo__headers()() = HTTP2__pseudo__headers(OMIT_VALUE,OMIT_VALUE,OMIT_VALUE,OMIT_VALUE,OMIT_VALUE);
pl_hblock.pseudo__headers()().method()=hval;
@@ -1591,7 +1605,7 @@
ret_val=int2oct(0x7,1) // Type: GOAWAY frame (type=0x7)
+ int2oct(flags,1)
+ int2oct(0,4) // The stream identifier for a GOAWAY frame MUST be zero
- + int2oct(pl__frame.goaway__frame().last__stream__id(),4) ;
+ + int2oct(pl__frame.goaway__frame().last__stream__id(),4)
+ int2oct(pl__frame.goaway__frame().error__code(),4) ;
if(pl__frame.goaway__frame().debug__data().ispresent()){
ret_val=ret_val+pl__frame.goaway__frame().debug__data()();
diff --git a/src/HTTP2_Types.ttcn b/src/HTTP2_Types.ttcn
index efca538..55adf8f 100644
--- a/src/HTTP2_Types.ttcn
+++ b/src/HTTP2_Types.ttcn
@@ -1,19 +1,20 @@
/******************************************************************************
-* Copyright (c) 2000-2018 Ericsson Telecom AB AB
+* Copyright (c) 2017-2019 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
-*
* Contributors:
* Gabor Szalai - initial implementation and initial documentation
******************************************************************************/
//
// File: HTTP2_Types.ttcn
// Description: Functions and types for HTTP2
-// Rev: R1A
+// Rev: R1D
// Prodnr: CNL 113 851
module HTTP2_Types{
+
+modulepar boolean tsp_HTTP2_comp_context_decode_debug:=false
external function f_HTTP2_encode_frame(in HTTP2_Frame pl_frame) return octetstring
with {
@@ -266,7 +267,7 @@
// otherwise - error code
external function HTTP2_comp_context_decode(inout HTTP2_comp_context pl_context,
out HTTP2_header_block pl_hblock,
- in octetstring pl_frame_data) return integer
+ in octetstring pl_frame_data, in boolean pl_enable_debug:=tsp_HTTP2_comp_context_decode_debug) return integer
// Free and release the header compression context