Implements ndpi_get_category_id
This commit is contained in:
@@ -22,6 +22,7 @@ ndpi_init_detection_module
|
|||||||
ndpi_get_num_supported_protocols
|
ndpi_get_num_supported_protocols
|
||||||
ndpi_set_proto_defaults
|
ndpi_set_proto_defaults
|
||||||
ndpi_get_protocol_id
|
ndpi_get_protocol_id
|
||||||
|
ndpi_get_category_id
|
||||||
ndpi_find_port_based_protocol
|
ndpi_find_port_based_protocol
|
||||||
ndpi_get_http_method
|
ndpi_get_http_method
|
||||||
ndpi_get_http_url
|
ndpi_get_http_url
|
||||||
|
|||||||
+13
-2
@@ -533,13 +533,24 @@ extern "C" {
|
|||||||
* Return the ID of the protocol
|
* Return the ID of the protocol
|
||||||
*
|
*
|
||||||
* @par ndpi_mod = the detection module
|
* @par ndpi_mod = the detection module
|
||||||
* @par proto = the ID of the protocol
|
* @par proto = the protocol name
|
||||||
* @return the string name of the breed ID
|
* @return the ID of the protocol
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto);
|
int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the ID of the category
|
||||||
|
*
|
||||||
|
* @par ndpi_mod = the detection module
|
||||||
|
* @par proto = the category name
|
||||||
|
* @return the ID of the category
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int ndpi_get_category_id(struct ndpi_detection_module_struct *ndpi_mod, char *cat);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the list of the supported protocols
|
* Write the list of the supported protocols
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4676,6 +4676,7 @@ void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_mod,
|
|||||||
|
|
||||||
/* ****************************************************** */
|
/* ****************************************************** */
|
||||||
|
|
||||||
|
/* Keep it in order and in sync with ndpi_protocol_category_t in ndpi_typedefs.h */
|
||||||
static const char* categories[] = {
|
static const char* categories[] = {
|
||||||
"Unspecified",
|
"Unspecified",
|
||||||
"Media",
|
"Media",
|
||||||
@@ -4807,6 +4808,21 @@ int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *pr
|
|||||||
|
|
||||||
/* ****************************************************** */
|
/* ****************************************************** */
|
||||||
|
|
||||||
|
int ndpi_get_category_id(struct ndpi_detection_module_struct *ndpi_mod, char *cat) {
|
||||||
|
int i;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
for(i = 0; i < NDPI_PROTOCOL_NUM_CATEGORIES; i++) {
|
||||||
|
name = ndpi_category_get_name(ndpi_mod, i);
|
||||||
|
if(strcasecmp(cat, name) == 0)
|
||||||
|
return(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ****************************************************** */
|
||||||
|
|
||||||
void ndpi_dump_protocols(struct ndpi_detection_module_struct *ndpi_mod) {
|
void ndpi_dump_protocols(struct ndpi_detection_module_struct *ndpi_mod) {
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<(int)ndpi_mod->ndpi_num_supported_protocols; i++)
|
for(i=0; i<(int)ndpi_mod->ndpi_num_supported_protocols; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user