Minor optimizations

This commit is contained in:
Luca Deri
2017-11-28 00:44:08 +01:00
parent 8eaf0cefa1
commit 7090ef838c
+51 -80
View File
@@ -4655,90 +4655,61 @@ void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_mod,
/* ****************************************************** */ /* ****************************************************** */
static const char* categories[] = {
"Unspecified",
"Media",
"VPN",
"DataTransfer",
"Email",
"Download-FileTransfer-FileSharing",
"Web",
"SocialNetwork",
"Game",
"Chat",
"VoIP",
"Database",
"RemoteAccess",
"Cloud",
"Network",
"Collaborative",
"RPC",
"NetworkTool",
"System",
"SoftwareUpdate",
"",
"",
"",
"",
""
};
const char* ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_mod, const char* ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol_category_t category) { ndpi_protocol_category_t category) {
if(!ndpi_mod) return(NULL); if(!ndpi_mod) return(NULL);
switch(category) { if(category < NDPI_PROTOCOL_CATEGORY_CUSTOM_1)
case NDPI_PROTOCOL_CATEGORY_MEDIA: return(categories[category]);
return("Media"); else {
break; switch(category) {
case NDPI_PROTOCOL_CATEGORY_VPN: case NDPI_PROTOCOL_CATEGORY_CUSTOM_1:
return("VPN"); return(ndpi_mod->custom_category_labels[0]);
break; break;
case NDPI_PROTOCOL_CATEGORY_DATA_TRANSFER: case NDPI_PROTOCOL_CATEGORY_CUSTOM_2:
return("DataTransfer"); return(ndpi_mod->custom_category_labels[1]);
break; break;
case NDPI_PROTOCOL_CATEGORY_MAIL: case NDPI_PROTOCOL_CATEGORY_CUSTOM_3:
return("Email"); return(ndpi_mod->custom_category_labels[2]);
break; break;
case NDPI_PROTOCOL_CATEGORY_DOWNLOAD_FT: case NDPI_PROTOCOL_CATEGORY_CUSTOM_4:
return("Download-FileTransfer-FileSharing"); return(ndpi_mod->custom_category_labels[3]);
break; break;
case NDPI_PROTOCOL_CATEGORY_WEB: case NDPI_PROTOCOL_CATEGORY_CUSTOM_5:
return("Web"); return(ndpi_mod->custom_category_labels[4]);
break; break;
case NDPI_PROTOCOL_CATEGORY_SOCIAL_NETWORK: case NDPI_PROTOCOL_NUM_CATEGORIES:
return("SocialNetwork"); return("Code should not use this internal constant");
break; break;
case NDPI_PROTOCOL_CATEGORY_GAME: }
return("Game");
break;
case NDPI_PROTOCOL_CATEGORY_CHAT:
return("Chat");
break;
case NDPI_PROTOCOL_CATEGORY_VOIP:
return("VoIP");
break;
case NDPI_PROTOCOL_CATEGORY_DATABASE:
return("Database");
break;
case NDPI_PROTOCOL_CATEGORY_REMOTE_ACCESS:
return("RemoteAccess");
break;
case NDPI_PROTOCOL_CATEGORY_CLOUD:
return("Cloud");
break;
case NDPI_PROTOCOL_CATEGORY_NETWORK:
return("Network");
break;
case NDPI_PROTOCOL_CATEGORY_COLLABORATIVE:
return("Collaborative");
break;
case NDPI_PROTOCOL_CATEGORY_RPC:
return("RPC");
break;
case NDPI_PROTOCOL_CATEGORY_NETWORK_TOOL:
return("NetworkTool");
break;
case NDPI_PROTOCOL_CATEGORY_SYSTEM_OS:
return("System");
break;
case NDPI_PROTOCOL_CATEGORY_UNSPECIFIED:
return("Unspecified");
break;
case NDPI_PROTOCOL_CATEGORY_SW_UPDATE:
return("SoftwareUpdate");
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_1:
return(ndpi_mod->custom_category_labels[0]);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_2:
return(ndpi_mod->custom_category_labels[1]);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_3:
return(ndpi_mod->custom_category_labels[2]);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_4:
return(ndpi_mod->custom_category_labels[3]);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_5:
return(ndpi_mod->custom_category_labels[4]);
break;
case NDPI_PROTOCOL_NUM_CATEGORIES:
return("Code should not use this internal constant");
break;
} }
return("Unspecified"); return("Unspecified");