aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/SequenceQueue.h
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-04-15 12:41:23 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-04-15 12:41:23 +0200
commit9547a28faa9b4a9df02bea3cd55b011d615532e9 (patch)
tree8a51a34b718db91fd726bbaf1c0c8285e42af949 /nxcomp/SequenceQueue.h
parent6236266d4e18d4d264fab94643f9473ec3458e47 (diff)
downloadnx-libs-9547a28faa9b4a9df02bea3cd55b011d615532e9.tar.gz
nx-libs-9547a28faa9b4a9df02bea3cd55b011d615532e9.tar.bz2
nx-libs-9547a28faa9b4a9df02bea3cd55b011d615532e9.zip
Add BIGREQUEST extension support to nxproxy/nxcomp.feature/nxcomp-bigreq-support
This work has been started by Paul Szarbo but has been discontinued before final completion. So, this is work in progress. For reference / communication history, see [1]. [1] https://bugs.debian.org/766299
Diffstat (limited to 'nxcomp/SequenceQueue.h')
-rw-r--r--nxcomp/SequenceQueue.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/nxcomp/SequenceQueue.h b/nxcomp/SequenceQueue.h
index b243c4c9f..7a88717f7 100644
--- a/nxcomp/SequenceQueue.h
+++ b/nxcomp/SequenceQueue.h
@@ -18,6 +18,22 @@
#ifndef SequenceQueue_H
#define SequenceQueue_H
+inline int SequenceNumber_x_gt_y(unsigned int x, unsigned int y)
+{
+ // For two sequence numbers x and y, determine whether (x > y).
+ // Sequence numbers are the trailing 16 bits of a bigger number:
+ // need to handle wraparound, e.g. 0 is 65536, just after 65535.
+ if (x != (x & 0x00ffff)) return 0;
+ if (y != (y & 0x00ffff)) return 0;
+ // Closeness when comparison makes sense: arbitrarily set at 16*1024
+ if ((x > y) && ((x-y) < 16*1024)) return 1;
+ // Wrapped value
+ unsigned int w = x + 64*1024;
+ // We know that w>y but test left for symmetry
+ if ((w > y) && ((w-y) < 16*1024)) return 1;
+ return 0;
+}
+
//
// List of outstanding request messages which
// are waiting for a reply. This class is used