summaryrefslogtreecommitdiffstats
path: root/src/methods/common.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-05-28 04:52:58 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-05-28 04:52:58 +0200
commitd5da100c55d80391d2e941a41c0e0dccf2a6e33e (patch)
tree1aca67556ed8ea1e2f9fa2a73ebf1a84e8cd34a7 /src/methods/common.c
parentd859894f7a88e07e7beae8dc355278cfd6c185e2 (diff)
downloadfastd-d5da100c55d80391d2e941a41c0e0dccf2a6e33e.tar
fastd-d5da100c55d80391d2e941a41c0e0dccf2a6e33e.zip
Still more documentation
Diffstat (limited to 'src/methods/common.c')
-rw-r--r--src/methods/common.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/methods/common.c b/src/methods/common.c
index 3fb8561..d26f009 100644
--- a/src/methods/common.c
+++ b/src/methods/common.c
@@ -23,10 +23,17 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ \file
+
+ Definitions for the common packet format used by most methods
+*/
+
#include "common.h"
+/** Common initialization for a new session */
void fastd_method_common_init(fastd_method_common_t *session, bool initiator) {
memset(session, 0, sizeof(*session));
@@ -42,6 +49,7 @@ void fastd_method_common_init(fastd_method_common_t *session, bool initiator) {
}
}
+/** Checks if a received nonce is valid */
bool fastd_method_is_nonce_valid(const fastd_method_common_t *session, const uint8_t nonce[COMMON_NONCEBYTES], int64_t *age) {
if ((nonce[0] & 1) != (session->receive_nonce[0] & 1))
return false;
@@ -67,6 +75,7 @@ bool fastd_method_is_nonce_valid(const fastd_method_common_t *session, const uin
return true;
}
+/** Checks if a possibly reordered packet should be accepted */
bool fastd_method_reorder_check(fastd_peer_t *peer, fastd_method_common_t *session, const uint8_t nonce[COMMON_NONCEBYTES], int64_t age) {
if (age < 0) {
size_t shift = age < (-64) ? 64 : ((size_t)-age);