Annotation of embedaddon/hping2/relid.c, revision 1.1.1.1
1.1 misho 1: /*
2: * $smu-mark$
3: * $name: relid.c$
4: * $author: Salvatore Sanfilippo <antirez@invece.org>$
5: * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
6: * $license: This software is under GPL version 2 of license$
7: * $date: Fri Nov 5 11:55:49 MET 1999$
8: * $rev: 3$
9: */
10:
11: /* FIXME: maybe it's better to avoid division per seq_diff and
12: at least add an option to switch on/off this feature */
13:
14: #include "hping2.h"
15: #include "globals.h"
16:
17: int relativize_id(int seqnum, int *ip_id)
18: {
19: int seq_diff, backup_id;
20: static int last_seq = 0, last_id = -1;
21:
22: backup_id = *ip_id;
23:
24: if (last_id == -1) {
25: last_id = *ip_id;
26: last_seq = seqnum;
27: }
28: else
29: {
30: if ( (seq_diff=(seqnum-last_seq)) > 0)
31: {
32: if (last_id > *ip_id) /* rew */
33: *ip_id = ((65535-last_id)
34: + *ip_id)/seq_diff;
35: else
36: *ip_id = (*ip_id-last_id)
37: /seq_diff;
38: last_id = backup_id;
39: last_seq = seqnum;
40: return TRUE;
41: } else {
42: out_of_sequence_pkt++;
43: }
44: }
45: return FALSE;
46: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>