-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacknowledge.c
49 lines (34 loc) · 1.15 KB
/
acknowledge.c
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
/**
* file : acknowledge.h
* license : GPLV3
* copyright : Hugo Camboulive
* description : This header contains information
* about functions and structures used to send an
* ACK message to a teamspeak server.
*/
#include "acknowledge.h"
#include "highlevel.h"
struct acknowledge {
uint32_t function;
uint32_t private_id;
uint32_t public_id;
uint32_t counter;
};
static struct acknowledge * init_acknowledge(uint32_t private_id, uint32_t public_id, uint32_t counter) {
struct acknowledge * msg;
msg = (struct acknowledge *)calloc(1, sizeof(struct acknowledge));
msg->function = TYPE_ACKNOWLEDGE;
msg->private_id = GUINT32_TO_LE(private_id);
msg->public_id = GUINT32_TO_LE(public_id);
msg->counter = GUINT32_TO_LE(counter);
return msg;
}
static void destroy_acknowledge(struct acknowledge * msg) {
free(msg);
}
void send_acknowledge(uint32_t private_id, uint32_t public_id, uint32_t counter, int s, const struct sockaddr * to) {
struct acknowledge * msg;
msg = init_acknowledge(private_id, public_id, counter);
sendto(s, msg, sizeof(struct acknowledge), 0, to, sizeof(*to));
destroy_acknowledge(msg);
}