#include "packet-libvirt.h"
#include "internal.h"
+#ifndef LIBVIRT_PORT
+# define LIBVIRT_PORT 16509
+#endif
+
+#define VIR_HEADER_LEN 28
+
+#ifdef DEBUG
+# define dbg(fmt, ...) \
+ g_print("[LIBVIRT] " fmt " at " __FILE__ " line %d\n", ##__VA_ARGS__, __LINE__)
+#else
+# define dbg(fmt, ...)
+#endif
+
/* Wireshark 1.12 brings API change */
#define WIRESHARK_VERSION \
((VERSION_MAJOR * 1000 * 1000) + \
XDR_PRIMITIVE_DISSECTOR(double, gdouble, double)
XDR_PRIMITIVE_DISSECTOR(bool, bool_t, boolean)
+typedef gboolean (*vir_xdr_dissector_t)(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
+
+typedef struct vir_dissector_index vir_dissector_index_t;
+struct vir_dissector_index {
+ guint32 proc;
+ vir_xdr_dissector_t args;
+ vir_xdr_dissector_t ret;
+ vir_xdr_dissector_t msg;
+};
+
+enum vir_net_message_type {
+ VIR_NET_CALL = 0,
+ VIR_NET_REPLY = 1,
+ VIR_NET_MESSAGE = 2,
+ VIR_NET_STREAM = 3,
+ VIR_NET_CALL_WITH_FDS = 4,
+ VIR_NET_REPLY_WITH_FDS = 5,
+ VIR_NET_STREAM_HOLE = 6,
+};
+
+enum vir_net_message_status {
+ VIR_NET_OK = 0,
+ VIR_NET_ERROR = 1,
+ VIR_NET_CONTINUE = 2,
+};
+
+enum vir_program_data_index {
+ VIR_PROGRAM_PROCHFVAR,
+ VIR_PROGRAM_PROCSTRINGS,
+ VIR_PROGRAM_DISSECTORS,
+ VIR_PROGRAM_DISSECTORS_LEN,
+ VIR_PROGRAM_LAST,
+};
+
+static const value_string type_strings[] = {
+ { VIR_NET_CALL, "CALL" },
+ { VIR_NET_REPLY, "REPLY" },
+ { VIR_NET_MESSAGE, "MESSAGE" },
+ { VIR_NET_STREAM, "STREAM" },
+ { VIR_NET_CALL_WITH_FDS, "CALL_WITH_FDS" },
+ { VIR_NET_REPLY_WITH_FDS, "REPLY_WITH_FDS" },
+ { VIR_NET_STREAM_HOLE, "STREAM_HOLE" },
+ { -1, NULL }
+};
+
+static const value_string status_strings[] = {
+ { VIR_NET_OK, "OK" },
+ { VIR_NET_ERROR, "ERROR" },
+ { VIR_NET_CONTINUE, "CONTINUE" },
+ { -1, NULL }
+};
+
static gboolean
dissect_xdr_string(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf,
guint32 maxlen)
return TRUE;
}
+#include "libvirt/protocol.h"
+
static void
dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
guint32 prog, guint32 proc, guint32 type, guint32 status)
goto unknown;
dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, xd);
} else if (status == VIR_NET_ERROR) {
- dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, VIR_ERROR_MESSAGE_DISSECTOR);
+ dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, dissect_xdr_remote_error);
} else if (type == VIR_NET_STREAM) { /* implicitly, status == VIR_NET_CONTINUE */
dissect_libvirt_stream(tvb, tree, payload_length);
} else if (type == VIR_NET_STREAM_HOLE) {
#ifndef LIBVIRT_PACKET_LIBVIRT_H
# define LIBVIRT_PACKET_LIBVIRT_H
-# include "libvirt/libvirt.h"
-
-# ifndef LIBVIRT_PORT
-# define LIBVIRT_PORT 16509
-# endif
-
-# define VIR_HEADER_LEN 28
-
-# ifdef DEBUG
-# define dbg(fmt, ...) \
- g_print("[LIBVIRT] " fmt " at " __FILE__ " line %d\n", ##__VA_ARGS__, __LINE__)
-# else
-# define dbg(fmt, ...)
-# endif
-
-typedef gboolean (*vir_xdr_dissector_t)(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-
-typedef struct vir_dissector_index vir_dissector_index_t;
-struct vir_dissector_index {
- guint32 proc;
- vir_xdr_dissector_t args;
- vir_xdr_dissector_t ret;
- vir_xdr_dissector_t msg;
-};
-
-enum vir_net_message_type {
- VIR_NET_CALL = 0,
- VIR_NET_REPLY = 1,
- VIR_NET_MESSAGE = 2,
- VIR_NET_STREAM = 3,
- VIR_NET_CALL_WITH_FDS = 4,
- VIR_NET_REPLY_WITH_FDS = 5,
- VIR_NET_STREAM_HOLE = 6,
-};
-
-enum vir_net_message_status {
- VIR_NET_OK = 0,
- VIR_NET_ERROR = 1,
- VIR_NET_CONTINUE = 2,
-};
-
-enum vir_program_data_index {
- VIR_PROGRAM_PROCHFVAR,
- VIR_PROGRAM_PROCSTRINGS,
- VIR_PROGRAM_DISSECTORS,
- VIR_PROGRAM_DISSECTORS_LEN,
- VIR_PROGRAM_LAST,
-};
-
-static const value_string type_strings[] = {
- { VIR_NET_CALL, "CALL" },
- { VIR_NET_REPLY, "REPLY" },
- { VIR_NET_MESSAGE, "MESSAGE" },
- { VIR_NET_STREAM, "STREAM" },
- { VIR_NET_CALL_WITH_FDS, "CALL_WITH_FDS" },
- { VIR_NET_REPLY_WITH_FDS, "REPLY_WITH_FDS" },
- { VIR_NET_STREAM_HOLE, "STREAM_HOLE" },
- { -1, NULL }
-};
-
-static const value_string status_strings[] = {
- { VIR_NET_OK, "OK" },
- { VIR_NET_ERROR, "ERROR" },
- { VIR_NET_CONTINUE, "CONTINUE" },
- { -1, NULL }
-};
-
-# define VIR_ERROR_MESSAGE_DISSECTOR dissect_xdr_remote_error
-
-static gboolean dissect_xdr_int(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_u_int(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_short(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_u_short(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_char(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_u_char(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_hyper(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_u_hyper(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_float(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_double(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_bool(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf);
-static gboolean dissect_xdr_string(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, guint32 maxlen);
-static gboolean dissect_xdr_opaque(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, guint32 size);
-static gboolean dissect_xdr_bytes(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, guint32 maxlen);
-static gboolean dissect_xdr_pointer(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf,
- vir_xdr_dissector_t dp);
-static gboolean dissect_xdr_vector(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
- int rhf, const gchar *rtype, guint32 size, vir_xdr_dissector_t dp);
-static gboolean dissect_xdr_array(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, gint ett,
- int rhf, const gchar *rtype, guint32 maxlen, vir_xdr_dissector_t dp);
-
-# include "libvirt/protocol.h"
+void proto_register_libvirt(void);
+void proto_reg_handoff_libvirt(void);
#endif /* LIBVIRT_PACKET_LIBVIRT_H */