--- gvpe/src/util.h 2004/05/10 20:13:10 1.12 +++ gvpe/src/util.h 2007/12/02 00:09:36 1.22 @@ -2,9 +2,11 @@ util.h -- process management and other utility functions Copyright (C) 1998-2002 Ivo Timmermans 2000-2002 Guus Sliepen - 2003 Marc Lehmann + 2003 Marc Lehmann - This program is free software; you can redistribute it and/or modify + This file is part of GVPE. + + GVPE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -15,8 +17,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + along with gvpe; if not, write to the Free Software + Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef UTIL_H__ @@ -27,15 +29,18 @@ #include "gettext.h" #include "slog.h" -#include "iom.h" +#include "ev_cpp.h" +#include "callback.h" + +typedef ev_tstamp tstamp; /* - * check for an existing vped for this net, and write pid to pidfile + * check for an existing gvpe for this net, and write pid to pidfile */ extern int write_pidfile (void); /* - * kill older vped + * kill older gvpe */ extern int kill_other (int signal); @@ -57,7 +62,8 @@ #define mac2id(p) ((p)[0] & 0x01 ? 0 : ((p)[4] << 8) | (p)[5]) -struct sliding_window { +struct sliding_window +{ u32 v[(WINDOWSIZE + 31) / 32]; u32 seq; @@ -71,10 +77,10 @@ { 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);//D - else if (seqno > seq + WINDOWSIZE) + "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);//D + "possible replay attack, or just massive packet loss"), seqno, seq + 1); else { while (seqno > seq) @@ -93,24 +99,23 @@ 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);//D - return false; - } + slog (L_ERR, _("received duplicate packet (received %08lx, expected %08lx)\n" + "possible replay attack, or just packet duplication"), seqno, seq + 1); else { *cell |= mask; return true; } } + + return false; } }; typedef callback0 run_script_cb; // run a shell script (or actually an external program). -void run_script (const run_script_cb &cb, bool wait); +bool run_script (const run_script_cb &cb, bool wait); #if ENABLE_HTTP_PROXY u8 *base64_encode (const u8 *data, unsigned int len);