-
Notifications
You must be signed in to change notification settings - Fork 0
/
wakeup-client.h
executable file
·81 lines (68 loc) · 1.77 KB
/
wakeup-client.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Some needed constants */
#define PACKET_BUF 17*6
#define MAC_ADDR_MAX 6
#define MAC_ADDR_STR_MAX 64
#define CONVERT_BASE 16
#define ADDR_LEN 16
#define REMOTE_ADDR "255.255.255.255"
#define REMOTE_PORT 9
#define ARGS_BUF_MAX 128
#define USAGE "Usage: %s [-r remoteaddr] [-f filename1, ...|mac1, ...]\n"
/**
* @brief Structure for mac address
*/
typedef struct
{
unsigned char mac_addr[MAC_ADDR_MAX];
char mac_addr_str[MAC_ADDR_STR_MAX];
} mac_addr_t;
/**
* @brief Structure for wol packet ( header )
*/
typedef struct
{
char remote_addr[ADDR_LEN];
mac_addr_t *mac_addr;
} wol_header_t;
/**
* @brief Sends the WOL magic packet to the given mac address
*
* @param wol_header WOL header packet
* @param sock The socket to send the magic packet
*
* @return integer
*/
int sendWOL( const wol_header_t *wol_header, const int sock );
/**
* @brief Creates the UDP socket to send the WOL magic packet
*
* @return integer
*/
int startupSocket( );
/**
* @brief Gets the next mac address from the terminal arguments
*
* @param argument The arguments
* @param length The length of the arguments.
*
* @return mac_addr_t *
*/
mac_addr_t *nextAddrFromArg( char **argument, int length );
/**
* @brief Gets the next mac address from a file.
*
* @param filenames The filenames with the mac addresses on each line.
* @param length The length of the filename array
*
* @return mac_addr_t *
*/
mac_addr_t *nextAddrFromFile( char **filenames, int length );
/**
* @brief Converts a mac address string to a mac address struct of type mac_addr_t
*
* @param mac The mac address to convert
* @param packedMac The mac address struct of type mac_addr_t
*
* @return integer
*/
int packMacAddr( const char *mac, mac_addr_t *packedMac );