Code cleanup
This commit is contained in:
@@ -516,9 +516,7 @@ ndpi_classify (const unsigned short *pkt_len, const struct timeval *pkt_time,
|
|||||||
features[i+8+MC_BINS_LEN*MC_BINS_LEN+MC_BINS_TIME*MC_BINS_TIME] = bd[i]/((float)(ob));
|
features[i+8+MC_BINS_LEN*MC_BINS_LEN+MC_BINS_TIME*MC_BINS_TIME] = bd[i]/((float)(ob));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ob+ib > 100 && use_bd) {
|
|
||||||
score = ndpi_parameters_bd[0];
|
score = ndpi_parameters_bd[0];
|
||||||
for (i = 1; i < NUM_PARAMETERS_BD_LOGREG; i++) {
|
for (i = 1; i < NUM_PARAMETERS_BD_LOGREG; i++) {
|
||||||
score += features[i]*ndpi_parameters_bd[i];
|
score += features[i]*ndpi_parameters_bd[i];
|
||||||
|
|||||||
+13
-8
@@ -363,11 +363,11 @@ static void addDefaultPort(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
u_int8_t customUserProto,
|
u_int8_t customUserProto,
|
||||||
ndpi_default_ports_tree_node_t **root,
|
ndpi_default_ports_tree_node_t **root,
|
||||||
const char *_func, int _line) {
|
const char *_func, int _line) {
|
||||||
ndpi_default_ports_tree_node_t *ret;
|
|
||||||
u_int16_t port;
|
u_int16_t port;
|
||||||
|
|
||||||
for(port=range->port_low; port<=range->port_high; port++) {
|
for(port=range->port_low; port<=range->port_high; port++) {
|
||||||
ndpi_default_ports_tree_node_t *node = (ndpi_default_ports_tree_node_t*)ndpi_malloc(sizeof(ndpi_default_ports_tree_node_t));
|
ndpi_default_ports_tree_node_t *node = (ndpi_default_ports_tree_node_t*)ndpi_malloc(sizeof(ndpi_default_ports_tree_node_t));
|
||||||
|
ndpi_default_ports_tree_node_t *ret;
|
||||||
|
|
||||||
if(!node) {
|
if(!node) {
|
||||||
NDPI_LOG_ERR(ndpi_str, "%s:%d not enough memory\n", _func, _line);
|
NDPI_LOG_ERR(ndpi_str, "%s:%d not enough memory\n", _func, _line);
|
||||||
@@ -400,10 +400,11 @@ static int removeDefaultPort(ndpi_port_range *range,
|
|||||||
ndpi_default_ports_tree_node_t **root)
|
ndpi_default_ports_tree_node_t **root)
|
||||||
{
|
{
|
||||||
ndpi_default_ports_tree_node_t node;
|
ndpi_default_ports_tree_node_t node;
|
||||||
ndpi_default_ports_tree_node_t *ret;
|
|
||||||
u_int16_t port;
|
u_int16_t port;
|
||||||
|
|
||||||
for(port=range->port_low; port<=range->port_high; port++) {
|
for(port=range->port_low; port<=range->port_high; port++) {
|
||||||
|
ndpi_default_ports_tree_node_t *ret;
|
||||||
|
|
||||||
node.proto = def, node.default_port = port;
|
node.proto = def, node.default_port = port;
|
||||||
ret = (ndpi_default_ports_tree_node_t*)ndpi_tdelete(&node, (void*)root,
|
ret = (ndpi_default_ports_tree_node_t*)ndpi_tdelete(&node, (void*)root,
|
||||||
ndpi_default_ports_tree_node_t_cmp); /* Add it to the tree */
|
ndpi_default_ports_tree_node_t_cmp); /* Add it to the tree */
|
||||||
@@ -2442,12 +2443,12 @@ int ndpi_get_protocol_id_master_proto(struct ndpi_detection_module_struct *ndpi_
|
|||||||
|
|
||||||
static ndpi_default_ports_tree_node_t* ndpi_get_guessed_protocol_id(struct ndpi_detection_module_struct *ndpi_str,
|
static ndpi_default_ports_tree_node_t* ndpi_get_guessed_protocol_id(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
u_int8_t proto, u_int16_t sport, u_int16_t dport) {
|
u_int8_t proto, u_int16_t sport, u_int16_t dport) {
|
||||||
const void *ret;
|
|
||||||
ndpi_default_ports_tree_node_t node;
|
ndpi_default_ports_tree_node_t node;
|
||||||
|
|
||||||
if(sport && dport) {
|
if(sport && dport) {
|
||||||
int low = ndpi_min(sport, dport);
|
int low = ndpi_min(sport, dport);
|
||||||
int high = ndpi_max(sport, dport);
|
int high = ndpi_max(sport, dport);
|
||||||
|
const void *ret;
|
||||||
|
|
||||||
node.default_port = low; /* Check server port first */
|
node.default_port = low; /* Check server port first */
|
||||||
ret = ndpi_tfind(&node,
|
ret = ndpi_tfind(&node,
|
||||||
@@ -4314,7 +4315,7 @@ int ndpi_enable_loaded_categories(struct ndpi_detection_module_struct *ndpi_str)
|
|||||||
#ifdef HAVE_HYPERSCAN
|
#ifdef HAVE_HYPERSCAN
|
||||||
if(ndpi_str->custom_categories.num_to_load > 0) {
|
if(ndpi_str->custom_categories.num_to_load > 0) {
|
||||||
const char **expressions;
|
const char **expressions;
|
||||||
unsigned int *ids, i;
|
unsigned int *ids;
|
||||||
int rc;
|
int rc;
|
||||||
struct hs_list *head = ndpi_str->custom_categories.to_load;
|
struct hs_list *head = ndpi_str->custom_categories.to_load;
|
||||||
|
|
||||||
@@ -5874,10 +5875,10 @@ int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_str, char *pr
|
|||||||
|
|
||||||
int ndpi_get_category_id(struct ndpi_detection_module_struct *ndpi_str, char *cat) {
|
int ndpi_get_category_id(struct ndpi_detection_module_struct *ndpi_str, char *cat) {
|
||||||
int i;
|
int i;
|
||||||
const char *name;
|
|
||||||
|
|
||||||
for(i = 0; i < NDPI_PROTOCOL_NUM_CATEGORIES; i++) {
|
for(i = 0; i < NDPI_PROTOCOL_NUM_CATEGORIES; i++) {
|
||||||
name = ndpi_category_get_name(ndpi_str, i);
|
const char *name = ndpi_category_get_name(ndpi_str, i);
|
||||||
|
|
||||||
if(strcasecmp(cat, name) == 0)
|
if(strcasecmp(cat, name) == 0)
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
@@ -5905,12 +5906,14 @@ void ndpi_dump_protocols(struct ndpi_detection_module_struct *ndpi_str) {
|
|||||||
* first slen characters of s.
|
* first slen characters of s.
|
||||||
*/
|
*/
|
||||||
char* ndpi_strnstr(const char *s, const char *find, size_t slen) {
|
char* ndpi_strnstr(const char *s, const char *find, size_t slen) {
|
||||||
char c, sc;
|
char c;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if((c = *find++) != '\0') {
|
if((c = *find++) != '\0') {
|
||||||
len = strnlen(find, slen);
|
len = strnlen(find, slen);
|
||||||
do {
|
do {
|
||||||
|
char sc;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if(slen-- < 1 || (sc = *s++) == '\0')
|
if(slen-- < 1 || (sc = *s++) == '\0')
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -5930,12 +5933,14 @@ char* ndpi_strnstr(const char *s, const char *find, size_t slen) {
|
|||||||
* Same as ndpi_strnstr but case-insensitive
|
* Same as ndpi_strnstr but case-insensitive
|
||||||
*/
|
*/
|
||||||
char* ndpi_strncasestr(const char *s, const char *find, size_t slen) {
|
char* ndpi_strncasestr(const char *s, const char *find, size_t slen) {
|
||||||
char c, sc;
|
char c;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if((c = *find++) != '\0') {
|
if((c = *find++) != '\0') {
|
||||||
len = strlen(find);
|
len = strlen(find);
|
||||||
do {
|
do {
|
||||||
|
char sc;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if(slen-- < 1 || (sc = *s++) == '\0')
|
if(slen-- < 1 || (sc = *s++) == '\0')
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|||||||
Vendored
-4
@@ -126,10 +126,6 @@ u_int16_t ht_get(hashtable_t *hashtable, char *key) {
|
|||||||
int bin = 0;
|
int bin = 0;
|
||||||
entry_t *pair;
|
entry_t *pair;
|
||||||
|
|
||||||
#ifdef HASH_DEBUG
|
|
||||||
printf("*** %s() %s = %u ***\n", __FUNCTION__, key, pair->value);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bin = ht_hash(hashtable, key);
|
bin = ht_hash(hashtable, key);
|
||||||
|
|
||||||
/* Step through the bin, looking for our value. */
|
/* Step through the bin, looking for our value. */
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
READER="../example/ndpiReader -p ../example/protos.txt -c ../example/categories.txt"
|
READER="../example/ndpiReader -p ../example/protos.txt -c ../example/categories.txt"
|
||||||
|
|
||||||
RC=0
|
RC=0
|
||||||
|
|||||||
Reference in New Issue
Block a user