diff options
| author | zhuzhenjun <[email protected]> | 2023-10-12 15:05:58 +0800 |
|---|---|---|
| committer | zhuzhenjun <[email protected]> | 2023-10-12 15:36:31 +0800 |
| commit | 8b8627b0d8e06cb2d1073b2e86741dad8c39d4f6 (patch) | |
| tree | e41e8a5e70bc0d043f34b2a1651e026a15d54b4f /src | |
| parent | 7e1849233b8640e6139143c99423bf71cca0b6b2 (diff) | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/MESA_osfp.c (renamed from src/osfp.c) | 20 | ||||
| -rw-r--r-- | src/MESA_osfp.h (renamed from src/osfp.h) | 16 | ||||
| -rw-r--r-- | src/osfp_common.c | 7 | ||||
| -rw-r--r-- | src/osfp_common.h | 8 | ||||
| -rw-r--r-- | src/osfp_fingerprint.c | 2 | ||||
| -rw-r--r-- | src/osfp_score_db.c | 2 | ||||
| -rw-r--r-- | src/osfp_score_db.h | 1 | ||||
| -rw-r--r-- | src/version.map | 2 |
8 files changed, 28 insertions, 30 deletions
diff --git a/src/osfp.c b/src/MESA_osfp.c index e822436..f88cff8 100644 --- a/src/osfp.c +++ b/src/MESA_osfp.c @@ -1,6 +1,6 @@ #include "osfp_common.h" -#include "osfp.h" +#include "MESA_osfp.h" #include "osfp_fingerprint.h" #include "osfp_score_db.h" #include "osfp_log.h" @@ -70,7 +70,7 @@ exit: return NULL; } -const char *osfp_result_os_name_get(struct osfp_result *result) +const char *MESA_osfp_result_os_name_get(struct osfp_result *result) { enum osfp_os_class_id os_class; @@ -86,7 +86,7 @@ const char *osfp_result_os_name_get(struct osfp_result *result) return osfp_os_class_id_to_name(os_class); } -char *osfp_result_score_detail_export(struct osfp_result *result) +char *MESA_osfp_result_score_detail_export(struct osfp_result *result) { int i; char *result_str = NULL; @@ -150,7 +150,7 @@ exit: return result_str; } -void osfp_result_free(struct osfp_result *result) +void MESA_osfp_result_free(struct osfp_result *result) { if (result) { if (result->json_str) { @@ -160,7 +160,7 @@ void osfp_result_free(struct osfp_result *result) } } -struct osfp_result *osfp_ipv4_identify(struct osfp_db *db, struct iphdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len) +struct osfp_result *MESA_osfp_ipv4_identify(struct osfp_db *db, struct iphdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len) { int ret = OSFP_EINVAL; struct osfp_fingerprint fp; @@ -203,7 +203,7 @@ exit: return NULL; } -struct osfp_result *osfp_ipv6_identify(struct osfp_db *db, struct ip6_hdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len) +struct osfp_result *MESA_osfp_ipv6_identify(struct osfp_db *db, struct ip6_hdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len) { int ret = OSFP_EINVAL; struct osfp_fingerprint fp; @@ -234,7 +234,7 @@ exit: return NULL; } -struct osfp_result *osfp_json_identify(struct osfp_db *db, const char *json_str) +struct osfp_result *MESA_osfp_json_identify(struct osfp_db *db, const char *json_str) { int ret = OSFP_EINVAL; struct osfp_fingerprint fp; @@ -265,7 +265,7 @@ exit: return NULL; } -struct osfp_db *osfp_db_new(const char *db_json_file) +struct osfp_db *MESA_osfp_db_new(const char *db_json_file) { int ret; struct osfp_db *db; @@ -299,12 +299,12 @@ struct osfp_db *osfp_db_new(const char *db_json_file) return db; exit: if (db) { - osfp_db_free(db); + MESA_osfp_db_free(db); } return NULL; } -void osfp_db_free(struct osfp_db *db) +void MESA_osfp_db_free(struct osfp_db *db) { if (db) { if (db->db_json_path) { diff --git a/src/osfp.h b/src/MESA_osfp.h index bf01738..af62d8f 100644 --- a/src/osfp.h +++ b/src/MESA_osfp.h @@ -23,14 +23,14 @@ struct osfp_db; * @param db_json_path 操作系统指纹库 JSON 文件的路径。 * @return 指向新创建的操作系统指纹库的指针。 */ -struct osfp_db *osfp_db_new(const char *db_json_path); +struct osfp_db *MESA_osfp_db_new(const char *db_json_path); /** * @brief 释放操作系统指纹库占用的内存。 * * @param db 指向要释放的操作系统指纹库的指针。 */ -void osfp_db_free(struct osfp_db *db); +void MESA_osfp_db_free(struct osfp_db *db); /** * @brief 通过 IPv4 头部和 TCP 头部识别操作系统。 @@ -41,7 +41,7 @@ void osfp_db_free(struct osfp_db *db); * @param l4_hdr_len TCP 头部的长度(注意:包含TCP选项部分)。 * @return 指向操作系统识别结果的指针。 */ -struct osfp_result *osfp_ipv4_identify(struct osfp_db *db, struct iphdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len); +struct osfp_result *MESA_osfp_ipv4_identify(struct osfp_db *db, struct iphdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len); /** * @brief 通过 IPv6 头部和 TCP 头部识别操作系统。 @@ -52,7 +52,7 @@ struct osfp_result *osfp_ipv4_identify(struct osfp_db *db, struct iphdr* l3_hdr, * @param l4_hdr_len TCP 头部的长度(注意:包含TCP选项部分)。 * @return 指向操作系统识别结果的指针(注意:内存需要使用者释放)。 */ -struct osfp_result *osfp_ipv6_identify(struct osfp_db *db, struct ip6_hdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len); +struct osfp_result *MESA_osfp_ipv6_identify(struct osfp_db *db, struct ip6_hdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len); /** * @brief 通过 json 格式的指纹识别操作系统。 @@ -61,7 +61,7 @@ struct osfp_result *osfp_ipv6_identify(struct osfp_db *db, struct ip6_hdr* l3_hd * @param json_str 指纹字符串。 * @return 指向操作系统识别结果的指针(注意:内存需要使用者释放)。 */ -struct osfp_result *osfp_json_identify(struct osfp_db *db, const char *json_str); +struct osfp_result *MESA_osfp_json_identify(struct osfp_db *db, const char *json_str); /** * @brief 获取操作系统识别结果的操作系统名称。 @@ -69,7 +69,7 @@ struct osfp_result *osfp_json_identify(struct osfp_db *db, const char *json_str) * @param result 操作系统识别结果。 * @return 指向操作系统名称的常量字符指针(注意:这块内存将由osfp_result_free释放)。 */ -const char *osfp_result_os_name_get(struct osfp_result *result); +const char *MESA_osfp_result_os_name_get(struct osfp_result *result); /** * @brief 导出操作系统识别结果的得分详情。 @@ -77,14 +77,14 @@ const char *osfp_result_os_name_get(struct osfp_result *result); * @param result 操作系统识别结果。 * @return 指向得分详情字符串的指针(注意:内存需要使用者释放)。 */ -char *osfp_result_score_detail_export(struct osfp_result *result); +char *MESA_osfp_result_score_detail_export(struct osfp_result *result); /** * @brief 释放操作系统识别结果占用的内存。 * * @param result 操作系统识别结果。 */ -void osfp_result_free(struct osfp_result *result); +void MESA_osfp_result_free(struct osfp_result *result); #ifdef __cplusplus } diff --git a/src/osfp_common.c b/src/osfp_common.c index 53139fa..968b07d 100644 --- a/src/osfp_common.c +++ b/src/osfp_common.c @@ -1,6 +1,6 @@ #include "osfp_common.h" -#include "osfp.h" +#include "MESA_osfp.h" unsigned int osfp_profile_enable; @@ -19,6 +19,11 @@ struct osfp_profile_counter osfp_profile_score; struct osfp_profile_counter osfp_profile_result_build; struct osfp_profile_counter osfp_profile_result_export; +const char *osfp_os_class_id_to_name(enum osfp_os_class_id os_class) +{ + return osfp_os_class_name[os_class]; +} + void osfp_profile_counter_print(struct osfp_profile_counter *profile, const char *name) { printf("profile %s: avg: %lu max: %lu min: %lu curr: %lu total: %lu count: %lu\n", diff --git a/src/osfp_common.h b/src/osfp_common.h index 4e75873..1cc686b 100644 --- a/src/osfp_common.h +++ b/src/osfp_common.h @@ -21,8 +21,6 @@ #include "cJSON.h" -#include "osfp.h" - static inline unsigned long long osfp_rdtsc(void) { union { @@ -197,10 +195,6 @@ struct osfp_db { enum osfp_os_class_id osfp_os_class_name_to_id(char *name); -extern const char *osfp_os_class_name[OSFP_OS_CLASS_MAX]; -static inline const char *osfp_os_class_id_to_name(enum osfp_os_class_id os_class) -{ - return osfp_os_class_name[os_class]; -} +const char *osfp_os_class_id_to_name(enum osfp_os_class_id os_class); #endif diff --git a/src/osfp_fingerprint.c b/src/osfp_fingerprint.c index cc8a64b..52b180b 100644 --- a/src/osfp_fingerprint.c +++ b/src/osfp_fingerprint.c @@ -1,6 +1,6 @@ #include "osfp_common.h" -#include "osfp.h" +#include "MESA_osfp.h" #include "osfp_fingerprint.h" #include "osfp_log.h" diff --git a/src/osfp_score_db.c b/src/osfp_score_db.c index 5e88e21..bf6cd87 100644 --- a/src/osfp_score_db.c +++ b/src/osfp_score_db.c @@ -1,6 +1,6 @@ #include "osfp_common.h" -#include "osfp.h" +#include "MESA_osfp.h" #include "osfp_fingerprint.h" #include "osfp_score_db.h" #include "osfp_log.h" diff --git a/src/osfp_score_db.h b/src/osfp_score_db.h index 3ee9a84..4e38cc9 100644 --- a/src/osfp_score_db.h +++ b/src/osfp_score_db.h @@ -1,7 +1,6 @@ #ifndef __OSFP_SCORE_DB_H__ #define __OSFP_SCORE_DB_H__ -#include "osfp.h" #include "osfp_fingerprint.h" #include "osfp_common.h" diff --git a/src/version.map b/src/version.map index 317c75d..50bf794 100644 --- a/src/version.map +++ b/src/version.map @@ -1,4 +1,4 @@ { - global: osfp*;GIT_VERSION_*; + global: MESA_osfp*;GIT_VERSION_*; local: *; }; |
