#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000
#define GNUNET_CADET_LOCAL_CHANNEL_ID_SERV 0xB0000000
-#define HIGH_PID 0xFFFF0000
-#define LOW_PID 0x0000FFFF
+#define HIGH_PID 0xFF000000
+#define LOW_PID 0x00FFFFFF
-#define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID)
+/**
+ * Test if the two PIDs (of type `uint32_t`) are in the range where we
+ * have to worry about overflows. This is the case when @a pid is
+ * large and @a max is small, useful when comparing @a pid smaller
+ * than @a max.
+ */
+#define PID_OVERFLOW(pid, max) (((pid) > HIGH_PID) && ((max) < LOW_PID))
/******************************************************************************/
/************************** MESSAGES ******************************/
}
}
+
+/**
+ * Test if @a bigger is larger than @a smaller.
+ * Considers the case that @a bigger just overflowed
+ * and is thus tiny while @a smaller is still below
+ * `UINT32_MAX`.
+ */
int
-GC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
+GC_is_pid_bigger (uint32_t bigger,
+ uint32_t smaller)
{
- return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) ||
- (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller)));
+ return (PID_OVERFLOW (smaller, bigger) ||
+ ( (bigger > smaller) &&
+ (! PID_OVERFLOW (bigger, smaller))) );
}