chiark / gitweb /
bus: add API for querying the kdbus message sequence number
authorLennart Poettering <lennart@poettering.net>
Wed, 22 Jan 2014 09:57:12 +0000 (10:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 22 Jan 2014 10:19:26 +0000 (11:19 +0100)
src/libsystemd/libsystemd.sym
src/libsystemd/sd-bus/bus-dump.c
src/libsystemd/sd-bus/bus-kernel.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/bus-message.h
src/systemd/sd-bus.h

index cda10ea..723546a 100644 (file)
@@ -94,6 +94,7 @@ global:
         sd_bus_message_get_errno;
         sd_bus_message_get_monotonic_timestamp;
         sd_bus_message_get_realtime_timestamp;
+        sd_bus_message_get_seqnum;
         sd_bus_message_get_creds;
         sd_bus_message_is_signal;
         sd_bus_message_is_method_call;
index 78e7597..d2c0684 100644 (file)
@@ -100,8 +100,10 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
                         fprintf(f, "  Monotonic=%llu", (unsigned long long) m->monotonic);
                 if (m->realtime != 0)
                         fprintf(f, "  Realtime=%llu", (unsigned long long) m->realtime);
+                if (m->seqnum != 0)
+                        fprintf(f, "  SequenceNumber=%llu", (unsigned long long) m->seqnum);
 
-                if (m->monotonic != 0 || m->realtime != 0)
+                if (m->monotonic != 0 || m->realtime != 0 || m->seqnum != 0)
                         fputs("\n", f);
 
                 bus_creds_dump(&m->creds, f);
index 99ac5b1..fdb4dab 100644 (file)
@@ -501,6 +501,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
                 case KDBUS_ITEM_TIMESTAMP:
                         m->realtime = d->timestamp.realtime_ns / NSEC_PER_USEC;
                         m->monotonic = d->timestamp.monotonic_ns / NSEC_PER_USEC;
+                        m->seqnum = d->timestamp.seqnum;
                         break;
 
                 case KDBUS_ITEM_PID_COMM:
index 1a2039b..0c3913e 100644 (file)
@@ -898,6 +898,15 @@ _public_ int sd_bus_message_get_realtime_timestamp(sd_bus_message *m, uint64_t *
         return 0;
 }
 
+_public_ int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t *seqnum) {
+        assert_return(m, -EINVAL);
+        assert_return(seqnum, -EINVAL);
+        assert_return(m->seqnum > 0, -ENODATA);
+
+        *seqnum = m->seqnum;
+        return 0;
+}
+
 _public_ sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m) {
         assert_return(m, NULL);
 
index 5322375..0c90e72 100644 (file)
@@ -98,6 +98,7 @@ struct sd_bus_message {
 
         usec_t monotonic;
         usec_t realtime;
+        uint64_t seqnum;
 
         bool sealed:1;
         bool dont_send:1;
index a6c29d4..fc9a809 100644 (file)
@@ -202,6 +202,8 @@ int sd_bus_message_get_errno(sd_bus_message *m);
 
 int sd_bus_message_get_monotonic_timestamp(sd_bus_message *m, uint64_t *usec);
 int sd_bus_message_get_realtime_timestamp(sd_bus_message *m, uint64_t *usec);
+int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t* seqnum);
+
 sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m); /* do not unref the result */
 
 int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);