summaryrefslogtreecommitdiff
path: root/toxcore/ping_array.api.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-13 16:50:32 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-13 23:55:08 +0000
commite775b5533b7137b18edcd6e414fd461d07018425 (patch)
treecab52d97c0e02d5d2f17b8db1da3ab3e800fb3ce /toxcore/ping_array.api.h
parent1e1efec34ad820fc65dcf98581a0d8f6fa1873a8 (diff)
Make Ping_Array a module-private type.
Diffstat (limited to 'toxcore/ping_array.api.h')
-rw-r--r--toxcore/ping_array.api.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/toxcore/ping_array.api.h b/toxcore/ping_array.api.h
new file mode 100644
index 00000000..55b80570
--- /dev/null
+++ b/toxcore/ping_array.api.h
@@ -0,0 +1,72 @@
1%{
2/*
3 * Implementation of an efficient array to store that we pinged something.
4 */
5
6/*
7 * Copyright © 2016-2017 The TokTok team.
8 * Copyright © 2013 Tox project.
9 *
10 * This file is part of Tox, the free peer to peer instant messenger.
11 *
12 * Tox is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Tox is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
24 */
25#ifndef PING_ARRAY_H
26#define PING_ARRAY_H
27
28#include "network.h"
29%}
30
31class ping_Array {
32
33struct this;
34
35/**
36 * Initialize a Ping_Array.
37 * size represents the total size of the array and should be a power of 2.
38 * timeout represents the maximum timeout in seconds for the entry.
39 *
40 * return 0 on success.
41 * return -1 on failure.
42 */
43static this new(uint32_t size, uint32_t timeout);
44
45/**
46 * Free all the allocated memory in a Ping_Array.
47 */
48void kill();
49
50/**
51 * Add a data with length to the Ping_Array list and return a ping_id.
52 *
53 * return ping_id on success.
54 * return 0 on failure.
55 */
56uint64_t add(const uint8_t *data, uint32_t length);
57
58/**
59 * Check if ping_id is valid and not timed out.
60 *
61 * On success, copies the data into data of length,
62 *
63 * return length of data copied on success.
64 * return -1 on failure.
65 */
66int32_t check(uint8_t[length] data, uint64_t ping_id);
67
68}
69
70%{
71#endif
72%}