Module: kamailio
Branch: 5.2
Commit: 18444d619b87c3734f3078f09c50a4fef1f8a259
URL:
https://github.com/kamailio/kamailio/commit/18444d619b87c3734f3078f09c50a4f…
Author: Federico Cabiddu <federico.cabiddu(a)gmail.com>
Committer: Federico Cabiddu <federico.cabiddu(a)gmail.com>
Date: 2019-11-21T11:26:53+01:00
core: add support for parsing http/2 replies parsing
(cherry picked from commit 17be36102e3a1c286c69a5da193dd8405000ab62)
---
Modified: src/core/parser/msg_parser.h
Modified: src/core/parser/parse_fline.c
Modified: src/core/parser/parse_fline.h
---
Diff:
https://github.com/kamailio/kamailio/commit/18444d619b87c3734f3078f09c50a4f…
Patch:
https://github.com/kamailio/kamailio/commit/18444d619b87c3734f3078f09c50a4f…
---
diff --git a/src/core/parser/msg_parser.h b/src/core/parser/msg_parser.h
index 969fbc6f9b..7199c5905d 100644
--- a/src/core/parser/msg_parser.h
+++ b/src/core/parser/msg_parser.h
@@ -146,9 +146,12 @@ if ( (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&
\
SIP_VERSION, SIP_VERSION_LEN))
#define IS_HTTP_REPLY(rpl) \
- ((rpl)->first_line.u.reply.version.len >= HTTP_VERSION_LEN && \
+ (((rpl)->first_line.u.reply.version.len >= HTTP_VERSION_LEN && \
!strncasecmp((rpl)->first_line.u.reply.version.s, \
- HTTP_VERSION, HTTP_VERSION_LEN))
+ HTTP_VERSION, HTTP_VERSION_LEN)) || \
+ ((rpl)->first_line.u.reply.version.len >= HTTP2_VERSION_LEN && \
+ !strncasecmp((rpl)->first_line.u.reply.version.s, \
+ HTTP2_VERSION, HTTP2_VERSION_LEN)))
#define IS_SIP_REPLY(rpl) \
((rpl)->first_line.u.reply.version.len >= SIP_VERSION_LEN && \
diff --git a/src/core/parser/parse_fline.c b/src/core/parser/parse_fline.c
index e6b93aca58..bdd4824818 100644
--- a/src/core/parser/parse_fline.c
+++ b/src/core/parser/parse_fline.c
@@ -96,21 +96,28 @@ char* parse_first_line(char* buffer, unsigned int len, struct
msg_start* fl)
fl->flags|=FLINE_FLAG_PROTO_SIP;
fl->u.reply.version.len=SIP_VERSION_LEN;
tmp=buffer+SIP_VERSION_LEN;
- } else if (http_reply_parse != 0 &&
- (*tmp=='H' || *tmp=='h') &&
+ } else if (http_reply_parse != 0 && (*tmp=='H' || *tmp=='h')) {
/* 'HTTP/1.' */
- strncasecmp( tmp+1, HTTP_VERSION+1, HTTP_VERSION_LEN-1)==0 &&
- /* [0|1] */
- ((*(tmp+HTTP_VERSION_LEN)=='0') || (*(tmp+HTTP_VERSION_LEN)=='1'))
&&
- (*(tmp+HTTP_VERSION_LEN+1)==' ') ){
- /* ugly hack to be able to route http replies
- * Note: - the http reply must have a via
- * - the message is marked as SIP_REPLY (ugly)
- */
- fl->type=SIP_REPLY;
- fl->flags|=FLINE_FLAG_PROTO_HTTP;
- fl->u.reply.version.len=HTTP_VERSION_LEN+1 /*include last digit*/;
- tmp=buffer+HTTP_VERSION_LEN+1 /* last digit */;
+ if (strncasecmp( tmp+1, HTTP_VERSION+1, HTTP_VERSION_LEN-1)==0 &&
+ /* [0|1] */
+ ((*(tmp+HTTP_VERSION_LEN)=='0') || (*(tmp+HTTP_VERSION_LEN)=='1'))
&&
+ (*(tmp+HTTP_VERSION_LEN+1)==' ') ){
+ /* ugly hack to be able to route http replies
+ * Note: - the http reply must have a via
+ * - the message is marked as SIP_REPLY (ugly)
+ */
+ fl->type=SIP_REPLY;
+ fl->flags|=FLINE_FLAG_PROTO_HTTP;
+ fl->u.reply.version.len=HTTP_VERSION_LEN+1 /*include last digit*/;
+ tmp=buffer+HTTP_VERSION_LEN+1 /* last digit */;
+ /* 'HTTP/2' */
+ } else if (strncasecmp( tmp+1, HTTP2_VERSION+1, HTTP2_VERSION_LEN-1)==0 &&
+ (*(tmp+HTTP2_VERSION_LEN)==' ')) {
+ fl->type=SIP_REPLY;
+ fl->flags|=FLINE_FLAG_PROTO_HTTP;
+ fl->u.reply.version.len=HTTP2_VERSION_LEN;
+ tmp=buffer+HTTP2_VERSION_LEN;
+ }
} else IFISMETHOD( INVITE, 'I' )
else IFISMETHOD( CANCEL, 'C')
else IFISMETHOD( ACK, 'A' )
diff --git a/src/core/parser/parse_fline.h b/src/core/parser/parse_fline.h
index 2add9b0efb..63f74ececf 100644
--- a/src/core/parser/parse_fline.h
+++ b/src/core/parser/parse_fline.h
@@ -49,6 +49,9 @@
#define HTTP_VERSION "HTTP/1."
#define HTTP_VERSION_LEN (sizeof(HTTP_VERSION)-1)
+#define HTTP2_VERSION "HTTP/2"
+#define HTTP2_VERSION_LEN (sizeof(HTTP2_VERSION)-1)
+
#define CANCEL "CANCEL"
#define ACK "ACK"
#define INVITE "INVITE"