-
Notifications
You must be signed in to change notification settings - Fork 92
/
utils.h
66 lines (55 loc) · 1.62 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: GPL-3.0-only
/*
* Copyright (c) 2023 Dengfeng Liu <[email protected]>
*/
#ifndef XFRPC_UTILS_H_
#define XFRPC_UTILS_H_
#include <stddef.h>
/**
* Structure to hold dynamic string data for curl operations
*/
struct mycurl_string {
char *ptr; /* Pointer to string data */
size_t len; /* Length of string */
};
/**
* Sleep for specified seconds and microseconds
* @param s Seconds to sleep
* @param u Microseconds to sleep
*/
void s_sleep(unsigned int s, unsigned int u);
/**
* Validate an IP address string
* @param ip_address IP address string to validate
* @return 1 if valid, 0 if invalid
*/
int is_valid_ip_address(const char *ip_address);
/**
* Display available network interface names
* @return 0 on success, negative value on failure
*/
int show_net_ifname(void);
/**
* Get network interface name
* @param if_buf Buffer to store interface name
* @param blen Length of buffer
* @return 0 on success, negative value on failure
*/
int get_net_ifname(char *if_buf, int blen);
/**
* Get MAC address of specified network interface
* @param net_if_name Network interface name
* @param mac Buffer to store MAC address
* @param mac_len Length of MAC buffer
* @return 0 on success, negative value on failure
*/
int get_net_mac(const char *net_if_name, char *mac, int mac_len);
/**
* Unify DNS name format
* @param dname Original DNS name
* @param udname_buf Buffer to store unified DNS name
* @param udname_buf_len Length of buffer
* @return 0 on success, negative value on failure
*/
int dns_unified(const char *dname, char *udname_buf, int udname_buf_len);
#endif // XFRPC_UTILS_H_