--- gvpe/src/util.h 2008/08/07 19:07:03 1.26 +++ gvpe/src/util.h 2011/03/08 17:33:31 1.29 @@ -2,7 +2,7 @@ util.h -- process management and other utility functions Copyright (C) 1998-2002 Ivo Timmermans 2000-2002 Guus Sliepen - 2003-2008 Marc Lehmann + 2003-2011 Marc Lehmann This file is part of GVPE. @@ -86,14 +86,13 @@ seq = seqno; } - bool recv_ok (u32 seqno) + // 0 == ok, 1 == far history, 2 == duplicate in-window, 3 == far future + int seqno_classify (u32 seqno) { if (seqno <= seq - WINDOWSIZE) - slog (L_ERR, _("received duplicate or outdated packet (received %08lx, expected %08lx)\n" - "possible replay attack, or just massive packet reordering"), seqno, seq + 1); - else if (seqno > seq + WINDOWSIZE * 4) - slog (L_ERR, _("received duplicate or out-of-sync packet (received %08lx, expected %08lx)\n" - "possible replay attack, or just massive packet loss"), seqno, seq + 1); + return 1; + else if (seqno > seq + WINDOWSIZE * 16) + return 3; else { while (seqno > seq) @@ -112,20 +111,17 @@ u32 mask = 1 << (s & 31); if (*cell & mask) - slog (L_ERR, _("received duplicate packet (received %08lx, expected %08lx)\n" - "possible replay attack, or just packet duplication"), seqno, seq + 1); + return 2; else { *cell |= mask; - return true; + return 0; } } - - return false; } }; -typedef callback run_script_cb; +typedef callback run_script_cb; // run a shell script (or actually an external program). pid_t run_script (const run_script_cb &cb, bool wait); @@ -156,5 +152,9 @@ key, RSA_PKCS1_OAEP_PADDING) > 0; } +/*****************************************************************************/ + +void async (callback work_cb, callback done_cb); + #endif