diff options
author | Luca Deri <deri@ntop.org> | 2020-08-26 12:25:28 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-08-26 12:25:28 +0200 |
commit | 487d91526258284df675f88593708a9261005b6e (patch) | |
tree | e2a7b60848add0b8940d9936943ff83fbdb81156 /src | |
parent | 5e1bb0dbc12f779151d386c63d7b7992b5940006 (diff) |
Added ndpi_http_method2str() API call
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_api.h.in | 2 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 4 | ||||
-rw-r--r-- | src/lib/ndpi_utils.c | 19 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index de3f90885..aac75f02c 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -928,7 +928,7 @@ extern "C" { ndpi_serializer *serializer); void ndpi_md5(const u_char *data, size_t data_len, u_char hash[16]); - + /* ptree (trie) API */ ndpi_ptree_t* ndpi_ptree_create(void); int ndpi_ptree_insert(ndpi_ptree_t *tree, const ndpi_ip_addr_t *addr, u_int8_t bits, u_int32_t user_data); diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 90cc13149..359ff6d84 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -477,6 +477,10 @@ PACK_ON struct tinc_cache_entry { u_int16_t dst_port; } PACK_OFF; +/* + In case the typedef below is modified, please update + ndpi_http_method2str (ndpi_utils.c) +*/ typedef enum { NDPI_HTTP_METHOD_UNKNOWN = 0, NDPI_HTTP_METHOD_OPTIONS, diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 7a9a662ac..24ceae440 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -1545,3 +1545,22 @@ const char* ndpi_risk2str(ndpi_risk_enum risk) { return(buf); } } + +/* ******************************************************************** */ + +const char* ndpi_http_method2str(ndpi_http_method m) { + switch(m) { + // case NDPI_HTTP_METHOD_UNKNOWN: return("Unknown"); + case NDPI_HTTP_METHOD_OPTIONS: return("OPTIONS"); + case NDPI_HTTP_METHOD_GET: return("GET"); + case NDPI_HTTP_METHOD_HEAD: return("HEAD"); + case NDPI_HTTP_METHOD_PATCH: return("PATCH"); + case NDPI_HTTP_METHOD_POST: return("POST"); + case NDPI_HTTP_METHOD_PUT: return("PUT"); + case NDPI_HTTP_METHOD_DELETE: return("DELETE"); + case NDPI_HTTP_METHOD_TRACE: return("TRACE"); + case NDPI_HTTP_METHOD_CONNECT: return("CONNECT"); + } + + return("Unknown HTTP method"); +} |