summaryrefslogtreecommitdiffstats
path: root/src/guestfs.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-03 19:51:02 +0100
committerRichard Jones <rjones@redhat.com>2009-04-03 19:51:02 +0100
commit316bbc36662c0df6b3d0ad48790e0b551a291df6 (patch)
tree17c8240a4c6f46c71f84f4fcd12eb268f5be22bf /src/guestfs.c
parentff1f39794b2688f0fd6a0c367164e3d715136837 (diff)
downloadlibguestfs-316bbc36662c0df6b3d0ad48790e0b551a291df6.tar.gz
libguestfs-316bbc36662c0df6b3d0ad48790e0b551a291df6.tar.xz
libguestfs-316bbc36662c0df6b3d0ad48790e0b551a291df6.zip
Parses return values and returned errors properly.
Diffstat (limited to 'src/guestfs.c')
-rw-r--r--src/guestfs.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/guestfs.c b/src/guestfs.c
index d3594d3b..47af20ad 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -1053,6 +1053,38 @@ dispatch (guestfs_h *g, int proc_nr, xdrproc_t xdrp, char *args)
return -1;
}
+/* Check the return message from a call for validity. */
+static int
+check_reply_header (guestfs_h *g,
+ const struct guestfs_message_header *hdr,
+ int proc_nr, int serial)
+{
+ if (hdr->prog != GUESTFS_PROGRAM) {
+ error (g, "wrong program (%d/%d)", hdr->prog, GUESTFS_PROGRAM);
+ return -1;
+ }
+ if (hdr->vers != GUESTFS_PROTOCOL_VERSION) {
+ error (g, "wrong protocol version (%d/%d)",
+ hdr->vers, GUESTFS_PROTOCOL_VERSION);
+ return -1;
+ }
+ if (hdr->direction != GUESTFS_DIRECTION_REPLY) {
+ error (g, "unexpected message direction (%d/%d)",
+ hdr->direction, GUESTFS_DIRECTION_REPLY);
+ return -1;
+ }
+ if (hdr->proc != proc_nr) {
+ error (g, "unexpected procedure number (%d/%d)", hdr->proc, proc_nr);
+ return -1;
+ }
+ if (hdr->serial != serial) {
+ error (g, "unexpected serial (%d/%d)", hdr->serial, serial);
+ return -1;
+ }
+
+ return 0;
+}
+
/* The high-level actions are autogenerated by generator.ml. Include
* them here.
*/