src: linux/*.h -> netinet/*.h
This commit is contained in:
2
build.sh
2
build.sh
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
./autogen.sh;
|
||||
./configure --prefix=$(pwd)/target;
|
||||
./configure --enable-debug --prefix=$(pwd)/target;
|
||||
make -j
|
||||
make install
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <linux/in.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/tcp.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <pcap.h>
|
||||
@@ -52,14 +46,6 @@ typedef struct Address_ {
|
||||
#define addr_data8 address.address_un_data8
|
||||
#define addr_in6addr address.address_un_in6
|
||||
|
||||
#define COPY_ADDRESS(a, b) do { \
|
||||
(b)->family = (a)->family; \
|
||||
(b)->addr_data32[0] = (a)->addr_data32[0]; \
|
||||
(b)->addr_data32[1] = (a)->addr_data32[1]; \
|
||||
(b)->addr_data32[2] = (a)->addr_data32[2]; \
|
||||
(b)->addr_data32[3] = (a)->addr_data32[3]; \
|
||||
} while (0)
|
||||
|
||||
/* Set the IPv4 addresses into the Addrs of the Packet.
|
||||
* Make sure p->ip4h is initialized and validated.
|
||||
*
|
||||
@@ -85,18 +71,18 @@ typedef struct Address_ {
|
||||
* Make sure p->ip6h is initialized and validated. */
|
||||
#define SET_IPV6_SRC_ADDR(p, a) do { \
|
||||
(a)->family = AF_INET6; \
|
||||
(a)->addr_data32[0] = (p)->ip6h->saddr.s6_addr32[0]; \
|
||||
(a)->addr_data32[1] = (p)->ip6h->saddr.s6_addr32[1]; \
|
||||
(a)->addr_data32[2] = (p)->ip6h->saddr.s6_addr32[2]; \
|
||||
(a)->addr_data32[3] = (p)->ip6h->saddr.s6_addr32[3]; \
|
||||
(a)->addr_data32[0] = (p)->ip6h->ip6_src.__in6_u.__u6_addr32[0]; \
|
||||
(a)->addr_data32[1] = (p)->ip6h->ip6_src.__in6_u.__u6_addr32[1]; \
|
||||
(a)->addr_data32[2] = (p)->ip6h->ip6_src.__in6_u.__u6_addr32[2]; \
|
||||
(a)->addr_data32[3] = (p)->ip6h->ip6_src.__in6_u.__u6_addr32[3]; \
|
||||
} while (0)
|
||||
|
||||
#define SET_IPV6_DST_ADDR(p, a) do { \
|
||||
(a)->family = AF_INET6; \
|
||||
(a)->addr_data32[0] = (p)->ip6h->daddr.s6_addr32[0]; \
|
||||
(a)->addr_data32[1] = (p)->ip6h->daddr.s6_addr32[1]; \
|
||||
(a)->addr_data32[2] = (p)->ip6h->daddr.s6_addr32[2]; \
|
||||
(a)->addr_data32[3] = (p)->ip6h->daddr.s6_addr32[3]; \
|
||||
(a)->addr_data32[0] = (p)->ip6h->ip6_dst.__in6_u.__u6_addr32[0]; \
|
||||
(a)->addr_data32[1] = (p)->ip6h->ip6_dst.__in6_u.__u6_addr32[1]; \
|
||||
(a)->addr_data32[2] = (p)->ip6h->ip6_dst.__in6_u.__u6_addr32[2]; \
|
||||
(a)->addr_data32[3] = (p)->ip6h->ip6_dst.__in6_u.__u6_addr32[3]; \
|
||||
} while (0)
|
||||
|
||||
#define TCP_GET_RAW_SRC_PORT(tcph) ntohs((tcph)->source)
|
||||
@@ -131,7 +117,7 @@ typedef struct Address_ {
|
||||
typedef struct Packet_ {
|
||||
struct ethhdr *ethh;
|
||||
struct iphdr *iph;
|
||||
struct ipv6hdr *ip6h;
|
||||
struct ip6_hdr *ip6h;
|
||||
struct tcphdr *tcph;
|
||||
|
||||
char srcip[46];
|
||||
@@ -268,15 +254,15 @@ int packet_decode_ipv6(Packet *p, const unsigned char *data, unsigned int len)
|
||||
int ret = -1;
|
||||
unsigned short ip6_payload_len;
|
||||
unsigned char ip6_nexthdr;
|
||||
struct ipv6hdr *ip6h;
|
||||
struct ip6_hdr *ip6h;
|
||||
|
||||
if (len < IPV6_HEADER_LEN) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ip6h = (struct ipv6hdr *)data;
|
||||
ip6_payload_len = ntohs(ip6h->payload_len);
|
||||
ip6_nexthdr = ip6h->nexthdr;
|
||||
ip6h = (struct ip6_hdr *)data;
|
||||
ip6_payload_len = ntohs(ip6h->ip6_ctlun.ip6_un1.ip6_un1_plen);
|
||||
ip6_nexthdr = ip6h->ip6_ctlun.ip6_un1.ip6_un1_nxt;
|
||||
|
||||
if (len < IPV6_HEADER_LEN + ip6_payload_len) {
|
||||
goto exit;
|
||||
@@ -443,7 +429,7 @@ void example_detect(struct osfp_db *osfp_db, Packet *p)
|
||||
char str_buf[1024];
|
||||
//unsigned char *iph = (unsigned char *)(p->iph != NULL ? (void *)p->iph : (void *)p->ip6h);
|
||||
struct iphdr *iph;
|
||||
struct ipv6hdr *ip6h;
|
||||
struct ip6_hdr *ip6h;
|
||||
struct tcphdr *tcph;
|
||||
unsigned int tcph_len;
|
||||
struct osfp_result *result = NULL;
|
||||
@@ -451,7 +437,7 @@ void example_detect(struct osfp_db *osfp_db, Packet *p)
|
||||
printf("Example ipv4 header detect: --------------------------\n");
|
||||
|
||||
iph = (struct iphdr *)p->iph;
|
||||
ip6h = (struct ipv6hdr *)p->ip6h;
|
||||
ip6h = (struct ip6_hdr *)p->ip6h;
|
||||
tcph = (struct tcphdr *)p->tcph;
|
||||
tcph_len = tcph->doff << 2;
|
||||
|
||||
@@ -641,8 +627,6 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
osfp_score_db_debug_print(osfp_db->score_db);
|
||||
|
||||
// loop
|
||||
while (1) {
|
||||
int r = pcap_dispatch(pcap_handle, 0, (pcap_handler)process_packet, (void*)osfp_db);
|
||||
|
||||
@@ -183,7 +183,7 @@ exit:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct osfp_result *osfp_ipv6_identify(struct osfp_db *db, struct ipv6hdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len)
|
||||
struct osfp_result *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;
|
||||
|
||||
69
src/osfp.h
69
src/osfp.h
@@ -2,61 +2,21 @@
|
||||
#define __OSFP_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <linux/in.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/tcp.h>
|
||||
|
||||
/**
|
||||
* @brief 定义操作系统类别的名称常量。
|
||||
*/
|
||||
#define OSFP_OS_CLASS_NAME_UNKNOWN "Unknown"
|
||||
#define OSFP_OS_CLASS_NAME_WINDOWS "Windows"
|
||||
#define OSFP_OS_CLASS_NAME_LINUX "Linux"
|
||||
#define OSFP_OS_CLASS_NAME_MAC_OS "Mac OS"
|
||||
#define OSFP_OS_CLASS_NAME_IOS "iOS"
|
||||
#define OSFP_OS_CLASS_NAME_ANDROID "Android"
|
||||
#define OSFP_OS_CLASS_NAME_OTHERS "Others"
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief 枚举表示不同的操作系统类别。
|
||||
*/
|
||||
enum osfp_os_class_id {
|
||||
OSFP_OS_CLASS_UNKNOWN, // 未知
|
||||
OSFP_OS_CLASS_WINDOWS, // Windows
|
||||
OSFP_OS_CLASS_LINUX, // Linux
|
||||
OSFP_OS_CLASS_MAC_OS, // Mac OS
|
||||
OSFP_OS_CLASS_IOS, // iOS
|
||||
OSFP_OS_CLASS_ANDROID, // Android
|
||||
OSFP_OS_CLASS_OTHERS, // 其他
|
||||
OSFP_OS_CLASS_MAX,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 结构体用于 osfp_result 中的详细结果。
|
||||
*/
|
||||
struct osfp_result_detail {
|
||||
unsigned int score; // 得分
|
||||
unsigned int possibility; // 可能性
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 结构体用于表示操作系统识别结果。
|
||||
*/
|
||||
struct osfp_result {
|
||||
char *json_str; // JSON 字符串
|
||||
enum osfp_os_class_id likely_os_class; // 最可能的操作系统类别
|
||||
struct osfp_result_detail details[OSFP_OS_CLASS_MAX]; // 详细结果数组
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 结构体用于表示操作系统指纹库。
|
||||
*/
|
||||
struct osfp_db {
|
||||
char *db_json_path; // 操作系统指纹库 JSON 文件路径
|
||||
void *score_db; // 分数数据库指针
|
||||
};
|
||||
enum osfp_os_class_id;
|
||||
struct osfp_result_detail;
|
||||
struct osfp_result;
|
||||
struct osfp_db;
|
||||
|
||||
/**
|
||||
* @brief 创建一个新的操作系统指纹库。
|
||||
@@ -93,7 +53,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 ipv6hdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len);
|
||||
struct osfp_result *osfp_ipv6_identify(struct osfp_db *db, struct ip6_hdr* l3_hdr, struct tcphdr *l4_hdr, size_t l4_hdr_len);
|
||||
|
||||
/**
|
||||
* @brief 通过 json 格式的指纹识别操作系统。
|
||||
@@ -127,4 +87,7 @@ char *osfp_result_score_detail_export(struct osfp_result *result);
|
||||
*/
|
||||
void osfp_result_free(struct osfp_result *result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <linux/in.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -28,8 +23,30 @@
|
||||
|
||||
#include "osfp.h"
|
||||
|
||||
#define OSFP_TCP_OPTLENMAX 64
|
||||
#define OSFP_TCP_OPTMAX 20
|
||||
static inline unsigned long long osfp_rdtsc(void)
|
||||
{
|
||||
union {
|
||||
unsigned long long tsc_64;
|
||||
struct {
|
||||
unsigned int lo_32;
|
||||
unsigned int hi_32;
|
||||
};
|
||||
} tsc;
|
||||
|
||||
asm volatile("rdtsc" :
|
||||
"=a" (tsc.lo_32),
|
||||
"=d" (tsc.hi_32));
|
||||
return tsc.tsc_64;
|
||||
}
|
||||
|
||||
#define osfp_profile_cycle(x) volatile unsigned long long x = 0
|
||||
#define osfp_profile_get_cycle(x) do { \
|
||||
x = osfp_rdtsc(); \
|
||||
} while(0)
|
||||
|
||||
#define OSFP_BIT_U32(n) (1UL << (n))
|
||||
|
||||
#define OSFP_PERCENTILE 100
|
||||
|
||||
#define OSFP_ETHERNET_HEADER_LEN 14
|
||||
#define OSFP_VLAN_HEADER_LEN 4
|
||||
@@ -37,8 +54,8 @@
|
||||
#define OSFP_IPV6_HEADER_LEN 40
|
||||
#define OSFP_TCP_HEADER_LEN 20
|
||||
#define OSFP_TCP_DATA_OFF_MAX 60
|
||||
|
||||
|
||||
#define OSFP_TCP_OPTLENMAX 64
|
||||
#define OSFP_TCP_OPTMAX 20
|
||||
//# TCP Options (opt_type) - http://www.iana.org/assignments/tcp-parameters
|
||||
#define OSFP_TCP_OPT_EOL 0 //# end of option list
|
||||
#define OSFP_TCP_OPT_NOP 1 //# no operation
|
||||
@@ -74,7 +91,6 @@
|
||||
#define OSFP_TCP_OPY_ENCNEG 69 //# Encryption Negotiation (TCP-ENO) [RFC8547]
|
||||
#define OSFP_TCP_OPT_EXP1 253 //# RFC3692-style Experiment 1 (also improperly used for shipping products)
|
||||
#define OSFP_TCP_OPT_EXP2 254 //# RFC3692-style Experiment 2 (also improperly used for shipping products)
|
||||
|
||||
#define OSFP_TCP_OPT_SACKOK_LEN 2
|
||||
#define OSFP_TCP_OPT_WS_LEN 3
|
||||
#define OSFP_TCP_OPT_TS_LEN 10
|
||||
@@ -84,28 +100,39 @@
|
||||
#define OSFP_TCP_OPT_TFO_MIN_LEN 4 /* kind, len, 2 bytes cookie: 4 */
|
||||
#define OSFP_TCP_OPT_TFO_MAX_LEN 18 /* kind, len, 18 */
|
||||
|
||||
static inline unsigned long long osfp_rdtsc(void)
|
||||
{
|
||||
union {
|
||||
unsigned long long tsc_64;
|
||||
struct {
|
||||
unsigned int lo_32;
|
||||
unsigned int hi_32;
|
||||
};
|
||||
} tsc;
|
||||
|
||||
asm volatile("rdtsc" :
|
||||
"=a" (tsc.lo_32),
|
||||
"=d" (tsc.hi_32));
|
||||
return tsc.tsc_64;
|
||||
}
|
||||
/**
|
||||
* @brief 定义操作系统类别的名称常量。
|
||||
*/
|
||||
#define OSFP_OS_CLASS_NAME_UNKNOWN "Unknown"
|
||||
#define OSFP_OS_CLASS_NAME_WINDOWS "Windows"
|
||||
#define OSFP_OS_CLASS_NAME_LINUX "Linux"
|
||||
#define OSFP_OS_CLASS_NAME_MAC_OS "Mac OS"
|
||||
#define OSFP_OS_CLASS_NAME_IOS "iOS"
|
||||
#define OSFP_OS_CLASS_NAME_ANDROID "Android"
|
||||
#define OSFP_OS_CLASS_NAME_OTHERS "Others"
|
||||
|
||||
#define osfp_profile_cycle(x) volatile unsigned long long x = 0
|
||||
#define osfp_profile_get_cycle(x) do { \
|
||||
x = osfp_rdtsc(); \
|
||||
} while(0)
|
||||
/**
|
||||
* @brief 枚举表示不同的操作系统类别。
|
||||
*/
|
||||
enum osfp_os_class_id {
|
||||
OSFP_OS_CLASS_UNKNOWN, // 未知
|
||||
OSFP_OS_CLASS_WINDOWS, // Windows
|
||||
OSFP_OS_CLASS_LINUX, // Linux
|
||||
OSFP_OS_CLASS_MAC_OS, // Mac OS
|
||||
OSFP_OS_CLASS_IOS, // iOS
|
||||
OSFP_OS_CLASS_ANDROID, // Android
|
||||
OSFP_OS_CLASS_OTHERS, // 其他
|
||||
OSFP_OS_CLASS_MAX,
|
||||
};
|
||||
|
||||
|
||||
#define OSFP_OS_CLASS_FLAG_WINDOWS OSFP_BIT_U32(OSFP_OS_CLASS_WINDOWS)
|
||||
#define OSFP_OS_CLASS_FLAG_LINUX OSFP_BIT_U32(OSFP_OS_CLASS_LINUX)
|
||||
#define OSFP_OS_CLASS_FLAG_MAC_OS OSFP_BIT_U32(OSFP_OS_CLASS_MAC_OS)
|
||||
#define OSFP_OS_CLASS_FLAG_IOS OSFP_BIT_U32(OSFP_OS_CLASS_IOS)
|
||||
#define OSFP_OS_CLASS_FLAG_ANDROID OSFP_BIT_U32(OSFP_OS_CLASS_ANDROID)
|
||||
|
||||
#define OSFP_BIT_U32(n) (1UL << (n))
|
||||
|
||||
enum osfp_error_code {
|
||||
OSFP_NOERR,
|
||||
@@ -116,16 +143,33 @@ enum osfp_error_code {
|
||||
OSFP_ERR_SCORE_DB_UNSUPPORTED,
|
||||
|
||||
OSFP_ERR_FINGERPRINTING_UNSUPPORTED,
|
||||
|
||||
};
|
||||
|
||||
#define OSFP_OS_CLASS_FLAG_WINDOWS OSFP_BIT_U32(OSFP_OS_CLASS_WINDOWS)
|
||||
#define OSFP_OS_CLASS_FLAG_LINUX OSFP_BIT_U32(OSFP_OS_CLASS_LINUX)
|
||||
#define OSFP_OS_CLASS_FLAG_MAC_OS OSFP_BIT_U32(OSFP_OS_CLASS_MAC_OS)
|
||||
#define OSFP_OS_CLASS_FLAG_IOS OSFP_BIT_U32(OSFP_OS_CLASS_IOS)
|
||||
#define OSFP_OS_CLASS_FLAG_ANDROID OSFP_BIT_U32(OSFP_OS_CLASS_ANDROID)
|
||||
|
||||
#define OSFP_PERCENTILE 100
|
||||
/**
|
||||
* @brief 结构体用于 osfp_result 中的详细结果。
|
||||
*/
|
||||
struct osfp_result_detail {
|
||||
unsigned int score; // 得分
|
||||
unsigned int possibility; // 可能性
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 结构体用于表示操作系统识别结果。
|
||||
*/
|
||||
struct osfp_result {
|
||||
char *json_str; // JSON 字符串
|
||||
enum osfp_os_class_id likely_os_class; // 最可能的操作系统类别
|
||||
struct osfp_result_detail details[OSFP_OS_CLASS_MAX]; // 详细结果数组
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 结构体用于表示操作系统指纹库。
|
||||
*/
|
||||
struct osfp_db {
|
||||
char *db_json_path; // 操作系统指纹库 JSON 文件路径
|
||||
void *score_db; // 分数数据库指针
|
||||
};
|
||||
|
||||
const char *osfp_os_class_id_to_name(enum osfp_os_class_id os_class);
|
||||
enum osfp_os_class_id osfp_os_class_name_to_id(char *name);
|
||||
|
||||
@@ -368,7 +368,7 @@ int osfp_fingerprinting_tcp(struct tcphdr *tcph, unsigned int tcph_len, struct o
|
||||
|
||||
tcp_off = tcph->doff << 2;
|
||||
tcp_window_size = ntohs(tcph->window);
|
||||
tcp_flags = *((unsigned char *)&tcph->window - 1);
|
||||
tcp_flags = *((unsigned char *)&tcph->ack_seq + 5);
|
||||
|
||||
if (tcp_off != tcph_len) {
|
||||
goto exit;
|
||||
@@ -409,7 +409,7 @@ exit:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int osfp_fingerprinting_ipv6(struct ipv6hdr *iph, struct osfp_fingerprint *fp)
|
||||
int osfp_fingerprinting_ipv6(struct ip6_hdr *iph, struct osfp_fingerprint *fp)
|
||||
{
|
||||
if (iph == NULL || fp == NULL) {
|
||||
goto exit;
|
||||
@@ -417,8 +417,8 @@ int osfp_fingerprinting_ipv6(struct ipv6hdr *iph, struct osfp_fingerprint *fp)
|
||||
|
||||
//unsigned int ip_id = 0;
|
||||
//unsigned int ip_tos = 0;
|
||||
unsigned int ip_total_length = OSFP_IPV6_HEADER_LEN + ntohs(iph->payload_len);
|
||||
unsigned int ip_ttl = compute_ip_ttl(iph->hop_limit);
|
||||
unsigned int ip_total_length = OSFP_IPV6_HEADER_LEN + ntohs(iph->ip6_ctlun.ip6_un1.ip6_un1_plen);
|
||||
unsigned int ip_ttl = compute_ip_ttl(iph->ip6_ctlun.ip6_un1.ip6_un1_hlim);
|
||||
|
||||
//osfp_fingerprint_setup_field(fp, OSFP_FIELD_IP_ID, &ip_id, sizeof(ip_id));
|
||||
//osfp_fingerprint_setup_field(fp, OSFP_FIELD_IP_TOS, &ip_tos, sizeof(ip_tos));
|
||||
@@ -445,7 +445,7 @@ int osfp_fingerprinting(unsigned char *iph, unsigned char *tcph, unsigned int tc
|
||||
ret = osfp_fingerprinting_ipv4((struct iphdr *)iph, fp);
|
||||
break;
|
||||
case 6:
|
||||
ret = osfp_fingerprinting_ipv6((struct ipv6hdr *)iph, fp);
|
||||
ret = osfp_fingerprinting_ipv6((struct ip6_hdr *)iph, fp);
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
|
||||
@@ -55,7 +55,7 @@ unsigned int osfp_fingerprint_get_field_type(enum osfp_field_id field_id);
|
||||
int osfp_fingerprinting_tcp_option(unsigned char *pkt, unsigned int pktlen, struct osfp_fingerprint *fp);
|
||||
int osfp_fingerprinting_tcp(struct tcphdr *tcph, unsigned int tcph_len, struct osfp_fingerprint *fp);
|
||||
int osfp_fingerprinting_ipv4(struct iphdr *iph, struct osfp_fingerprint *fp);
|
||||
int osfp_fingerprinting_ipv6(struct ipv6hdr *iph, struct osfp_fingerprint *fp);
|
||||
int osfp_fingerprinting_ipv6(struct ip6_hdr *iph, struct osfp_fingerprint *fp);
|
||||
int osfp_fingerprinting(unsigned char *iph, unsigned char *tcph, unsigned int tcph_len, struct osfp_fingerprint *fp, unsigned int ip_version);
|
||||
|
||||
#ifdef UNITTEST
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "osfp.h"
|
||||
#include "osfp_fingerprint.h"
|
||||
#include "osfp_common.h"
|
||||
|
||||
struct osfp_os_class_score {
|
||||
unsigned int scores[OSFP_OS_CLASS_MAX];
|
||||
|
||||
228
test/osfp_test
228
test/osfp_test
@@ -1,228 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
# osfp_test - temporary wrapper script for .libs/osfp_test
|
||||
# Generated by libtool (GNU libtool) 2.4.2
|
||||
#
|
||||
# The osfp_test program cannot be directly executed until all the libtool
|
||||
# libraries that it depends on are installed.
|
||||
#
|
||||
# This wrapper script should never be moved out of the build directory.
|
||||
# If it is, it will not operate correctly.
|
||||
|
||||
# Sed substitution that helps us do robust quoting. It backslashifies
|
||||
# metacharacters that are still active within double-quoted strings.
|
||||
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
|
||||
|
||||
# Be Bourne compatible
|
||||
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
|
||||
emulate sh
|
||||
NULLCMD=:
|
||||
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
|
||||
# is contrary to our usage. Disable this feature.
|
||||
alias -g '${1+"$@"}'='"$@"'
|
||||
setopt NO_GLOB_SUBST
|
||||
else
|
||||
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
|
||||
fi
|
||||
BIN_SH=xpg4; export BIN_SH # for Tru64
|
||||
DUALCASE=1; export DUALCASE # for MKS sh
|
||||
|
||||
# The HP-UX ksh and POSIX shell print the target directory to stdout
|
||||
# if CDPATH is set.
|
||||
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
|
||||
|
||||
relink_command="(cd /root/geedge/libosfp/test; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/root/.cargo/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin; export PATH; gcc -I../src -g -O2 -DUNITTEST -o \$progdir/\$file osfp_test-test.o ../src/.libs/libosfp.so -Wl,-rpath -Wl,/root/geedge/libosfp/src/.libs -Wl,-rpath -Wl,/root/geedge/libosfp/target/lib)"
|
||||
|
||||
# This environment variable determines our operation mode.
|
||||
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
|
||||
# install mode needs the following variables:
|
||||
generated_by_libtool_version='2.4.2'
|
||||
notinst_deplibs=' ../src/.libs/libosfp.la'
|
||||
else
|
||||
# When we are sourced in execute mode, $file and $ECHO are already set.
|
||||
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
|
||||
file="$0"
|
||||
|
||||
# A function that is used when there is no print builtin or printf.
|
||||
func_fallback_echo ()
|
||||
{
|
||||
eval 'cat <<_LTECHO_EOF
|
||||
$1
|
||||
_LTECHO_EOF'
|
||||
}
|
||||
ECHO="printf %s\\n"
|
||||
fi
|
||||
|
||||
# Very basic option parsing. These options are (a) specific to
|
||||
# the libtool wrapper, (b) are identical between the wrapper
|
||||
# /script/ and the wrapper /executable/ which is used only on
|
||||
# windows platforms, and (c) all begin with the string --lt-
|
||||
# (application programs are unlikely to have options which match
|
||||
# this pattern).
|
||||
#
|
||||
# There are only two supported options: --lt-debug and
|
||||
# --lt-dump-script. There is, deliberately, no --lt-help.
|
||||
#
|
||||
# The first argument to this parsing function should be the
|
||||
# script's ../libtool value, followed by no.
|
||||
lt_option_debug=
|
||||
func_parse_lt_options ()
|
||||
{
|
||||
lt_script_arg0=$0
|
||||
shift
|
||||
for lt_opt
|
||||
do
|
||||
case "$lt_opt" in
|
||||
--lt-debug) lt_option_debug=1 ;;
|
||||
--lt-dump-script)
|
||||
lt_dump_D=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
|
||||
test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
|
||||
lt_dump_F=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%^.*/%%'`
|
||||
cat "$lt_dump_D/$lt_dump_F"
|
||||
exit 0
|
||||
;;
|
||||
--lt-*)
|
||||
$ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Print the debug banner immediately:
|
||||
if test -n "$lt_option_debug"; then
|
||||
echo "osfp_test:osfp_test:${LINENO}: libtool wrapper (GNU libtool) 2.4.2" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Used when --lt-debug. Prints its arguments to stdout
|
||||
# (redirection is the responsibility of the caller)
|
||||
func_lt_dump_args ()
|
||||
{
|
||||
lt_dump_args_N=1;
|
||||
for lt_arg
|
||||
do
|
||||
$ECHO "osfp_test:osfp_test:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
|
||||
lt_dump_args_N=`expr $lt_dump_args_N + 1`
|
||||
done
|
||||
}
|
||||
|
||||
# Core function for launching the target application
|
||||
func_exec_program_core ()
|
||||
{
|
||||
|
||||
if test -n "$lt_option_debug"; then
|
||||
$ECHO "osfp_test:osfp_test:${LINENO}: newargv[0]: $progdir/$program" 1>&2
|
||||
func_lt_dump_args ${1+"$@"} 1>&2
|
||||
fi
|
||||
exec "$progdir/$program" ${1+"$@"}
|
||||
|
||||
$ECHO "$0: cannot exec $program $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# A function to encapsulate launching the target application
|
||||
# Strips options in the --lt-* namespace from $@ and
|
||||
# launches target application with the remaining arguments.
|
||||
func_exec_program ()
|
||||
{
|
||||
case " $* " in
|
||||
*\ --lt-*)
|
||||
for lt_wr_arg
|
||||
do
|
||||
case $lt_wr_arg in
|
||||
--lt-*) ;;
|
||||
*) set x "$@" "$lt_wr_arg"; shift;;
|
||||
esac
|
||||
shift
|
||||
done ;;
|
||||
esac
|
||||
func_exec_program_core ${1+"$@"}
|
||||
}
|
||||
|
||||
# Parse options
|
||||
func_parse_lt_options "$0" ${1+"$@"}
|
||||
|
||||
# Find the directory that this script lives in.
|
||||
thisdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
|
||||
test "x$thisdir" = "x$file" && thisdir=.
|
||||
|
||||
# Follow symbolic links until we get to the real thisdir.
|
||||
file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
|
||||
while test -n "$file"; do
|
||||
destdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
|
||||
|
||||
# If there was a directory component, then change thisdir.
|
||||
if test "x$destdir" != "x$file"; then
|
||||
case "$destdir" in
|
||||
[\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
|
||||
*) thisdir="$thisdir/$destdir" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
file=`$ECHO "$file" | /usr/bin/sed 's%^.*/%%'`
|
||||
file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
|
||||
done
|
||||
|
||||
# Usually 'no', except on cygwin/mingw when embedded into
|
||||
# the cwrapper.
|
||||
WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
|
||||
if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
|
||||
# special case for '.'
|
||||
if test "$thisdir" = "."; then
|
||||
thisdir=`pwd`
|
||||
fi
|
||||
# remove .libs from thisdir
|
||||
case "$thisdir" in
|
||||
*[\\/].libs ) thisdir=`$ECHO "$thisdir" | /usr/bin/sed 's%[\\/][^\\/]*$%%'` ;;
|
||||
.libs ) thisdir=. ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Try to get the absolute directory name.
|
||||
absdir=`cd "$thisdir" && pwd`
|
||||
test -n "$absdir" && thisdir="$absdir"
|
||||
|
||||
program=lt-'osfp_test'
|
||||
progdir="$thisdir/.libs"
|
||||
|
||||
if test ! -f "$progdir/$program" ||
|
||||
{ file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /usr/bin/sed 1q`; \
|
||||
test "X$file" != "X$progdir/$program"; }; then
|
||||
|
||||
file="$$-$program"
|
||||
|
||||
if test ! -d "$progdir"; then
|
||||
mkdir "$progdir"
|
||||
else
|
||||
rm -f "$progdir/$file"
|
||||
fi
|
||||
|
||||
# relink executable if necessary
|
||||
if test -n "$relink_command"; then
|
||||
if relink_command_output=`eval $relink_command 2>&1`; then :
|
||||
else
|
||||
printf %s\n "$relink_command_output" >&2
|
||||
rm -f "$progdir/$file"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
|
||||
{ rm -f "$progdir/$program";
|
||||
mv -f "$progdir/$file" "$progdir/$program"; }
|
||||
rm -f "$progdir/$file"
|
||||
fi
|
||||
|
||||
if test -f "$progdir/$program"; then
|
||||
if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
|
||||
# Run the actual program with our arguments.
|
||||
func_exec_program ${1+"$@"}
|
||||
fi
|
||||
else
|
||||
# The program doesn't exist.
|
||||
$ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
|
||||
$ECHO "This script is just a wrapper for $program." 1>&2
|
||||
$ECHO "See the libtool documentation for more information." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "osfp_fingerprint.h"
|
||||
#include "osfp_score_db.h"
|
||||
#include "osfp_log.h"
|
||||
|
||||
#include "osfp_common.h"
|
||||
|
||||
#define DATA_FILE_PATH "./data.json"
|
||||
|
||||
Reference in New Issue
Block a user