2022-05-10 06:43:27 +00:00
|
|
|
//
|
|
|
|
// Created by xajhu on 2021/7/2 0002.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DAEMON_AGENT_MISC_MISC_H
|
|
|
|
#define DAEMON_AGENT_MISC_MISC_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-03-29 09:02:21 +00:00
|
|
|
typedef struct {
|
|
|
|
char ethName[16];
|
|
|
|
unsigned char mac[6];
|
|
|
|
unsigned int ipv4Addr;
|
|
|
|
unsigned int ipv4Mask;
|
|
|
|
unsigned int ipv4Boardcast;
|
|
|
|
} NIC_CTX, *PNIC_CTX;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PNIC_CTX pNicCtx;
|
|
|
|
unsigned int nicCnt;
|
|
|
|
} SYS_NIC_INFO, *PSYS_NIC_INFO;
|
|
|
|
|
2023-02-02 02:58:49 +00:00
|
|
|
const char *get_cur_process_dir();
|
|
|
|
const char *get_cur_process_name();
|
2022-05-10 06:43:27 +00:00
|
|
|
int file_exists(const char *pPath);
|
|
|
|
const char *basename_v2(const char *path);
|
|
|
|
int dirname_v2(const char *path, char *dir);
|
|
|
|
unsigned long long get_partition_free_size(const char *pPartPath);
|
|
|
|
int copy_file(const char *pSrc, const char *pDest);
|
|
|
|
char *bin2hex(char *p, const unsigned char *cp, unsigned int count);
|
|
|
|
int shell_with_output(const char *pCmd, char **pResult);
|
2022-06-10 09:03:27 +00:00
|
|
|
int str_to_mac(const char *str, unsigned char mac[6]);
|
2022-12-02 06:42:15 +00:00
|
|
|
int get_nic_info(const char *pName,
|
|
|
|
unsigned int *pIp,
|
|
|
|
unsigned int *pNetmask,
|
2023-03-29 09:02:21 +00:00
|
|
|
unsigned int *pBoardcast,
|
2022-06-10 09:03:27 +00:00
|
|
|
unsigned char *pMac);
|
|
|
|
int str_to_ipaddr(const char *pIp, unsigned int *ipAddr);
|
2022-12-03 08:46:52 +00:00
|
|
|
unsigned long long get_current_time_ms();
|
2023-03-03 07:08:35 +00:00
|
|
|
int process_lock_pidfile(char *pFilePath);
|
|
|
|
void process_unlock_pidfile();
|
2023-03-29 09:02:21 +00:00
|
|
|
int get_all_network_info(PSYS_NIC_INFO pInfo);
|
|
|
|
const char *u32_to_str_ip(unsigned int ip);
|
2023-04-25 01:17:08 +00:00
|
|
|
const char *u32_to_str_ip_safe(unsigned int ip);
|
2023-04-11 09:09:27 +00:00
|
|
|
unsigned short udp_checksum(unsigned int saddr, unsigned int daddr, unsigned char *pUdp);
|
|
|
|
unsigned short ip_checksum(unsigned char *pIp);
|
2023-04-20 08:46:20 +00:00
|
|
|
int string_mac_to_bytes(const char *pStrMac, unsigned char macByte[6]);
|
2022-05-10 06:43:27 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2022-12-02 06:42:15 +00:00
|
|
|
#endif //DAEMON_AGENT_MISC_MISC_H
|