vcpe/srcs/libs/include/misc.h

54 lines
2.0 KiB
C

//
// 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
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;
const char *get_cur_process_dir();
const char *get_cur_process_name();
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);
int str_to_mac(const char *str, unsigned char mac[6]);
int get_nic_info(const char *pName,
unsigned int *pIp,
unsigned int *pNetmask,
unsigned int *pBoardcast,
unsigned char *pMac);
int str_to_ipaddr(const char *pIp, unsigned int *ipAddr);
unsigned long long get_current_time_ms();
int process_lock_pidfile(char *pFilePath);
void process_unlock_pidfile();
int get_all_network_info(PSYS_NIC_INFO pInfo);
const char *u32_to_str_ip(unsigned int ip);
const char *u32_to_str_ip_safe(unsigned int ip);
unsigned short udp_checksum(unsigned int saddr, unsigned int daddr, unsigned char *pUdp);
unsigned short ip_checksum(unsigned char *pIp);
int string_mac_to_bytes(const char *pStrMac, unsigned char macByte[6]);
unsigned long long ntohll(unsigned long long val);
#ifdef __cplusplus
}
#endif
#endif //DAEMON_AGENT_MISC_MISC_H