chiark / gitweb /
sigkey handling: Introduce serialt type
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 8 Oct 2019 14:51:41 +0000 (15:51 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 13:15:49 +0000 (13:15 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
secnet.h

index f7bb3e5685128c7fdf0290f93e1ac17bb824ebca..24894f2759579a7b8410cfc332a4e7cdb070e531 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -87,6 +87,15 @@ static inline bool_t sigkeyid_equal(const struct sigkeyid *a,
     return !memcmp(a->b, b->b, KEYIDSZ);
 }
 
+#define SERIALSZ 4
+typedef uint32_t serialt;
+static inline int serial_cmp(serialt a, serialt b) {
+    if (a==b) return 0;
+    if (!a) return -1;
+    if (!b) return +1;
+    return b-a <= (serialt)0x7fffffffUL ? +1 : -1;
+}
+
 #define ASSERT(x) do { if (!(x)) { fatal("assertion failed line %d file " \
                                         __FILE__,__LINE__); } } while(0)