return 0;
}
+/* This function will add one to uint48 x.
+ * Returns 0 on success, or -1 if the uint48 max limit
+ * has been reached.
+ */
+int
+_gnutls_uint48pp (uint48 * x)
+{
+ register int i, y = 0;
+
+ for (i = 5; i >= 0; i--)
+ {
+ y = 0;
+ if (x->i[i] == 0xff)
+ {
+ x->i[i] = 0;
+ y = 1;
+ }
+ else
+ x->i[i]++;
+
+ if (y == 0)
+ break;
+ }
+ if (y != 0)
+ return -1; /* over 48 bits! meh... */
+
+ return 0;
+}
+
uint32_t
_gnutls_uint24touint32 (uint24 num)
{
uint32_t _gnutls_uint64touint32 (const uint64 *);
int _gnutls_uint64pp (uint64 *);
-#define _gnutls_uint64zero(x) x.i[0] = x.i[1] = x.i[2] = x.i[3] = x.i[4] = x.i[5] = x.i[6] = x.i[7] = 0
-#define UINT64DATA(x) ((x).i)
+int _gnutls_uint48pp (uint48 *);
+# define _gnutls_uint64zero(x) x.i[0] = x.i[1] = x.i[2] = x.i[3] = x.i[4] = x.i[5] = x.i[6] = x.i[7] = 0
+# define UINT64DATA(x) ((x).i)
#endif /* GNUTLS_NUM_H */
}
}
+/* Increments the sequence value
+ */
+inline static int
+sequence_increment (gnutls_session_t session,
+ uint64 * value)
+{
+ if (_gnutls_is_dtls(session))
+ {
+ return _gnutls_uint48pp((uint48*)&value->i[2]);
+ }
+ else
+ {
+ return _gnutls_uint64pp(value);
+ }
+}
+
+/* Read epoch and sequence from a DTLS packet */
+inline static void
+sequence_read (uint64 * sequence,
+ opaque * data)
+{
+ memcpy(sequence->i, data, 8);
+}
+
+/* Write epoch and sequence to a DTLS packet */
+inline static void
+sequence_write (uint64 * sequence,
+ opaque * data)
+{
+ memcpy(data, sequence->i, 8);
+}
+
/* This function behaves exactly like write(). The only difference is
* that it accepts, the gnutls_session_t and the content_type_t of data to
* send (if called by the user the Content is specific)