+/* "encode-error-reply ENUM REQUEST": Encodes an error reply to REQUEST for the
+ * error named ENUM and prints the error reply in hex. */
+static void
+ofctl_encode_error_reply(int argc OVS_UNUSED, char *argv[])
+{
+ const struct ofp_header *oh;
+ struct ofpbuf request, *reply;
+ enum ofperr error;
+
+ error = ofperr_from_name(argv[1]);
+ if (!error) {
+ ovs_fatal(0, "unknown error \"%s\"", argv[1]);
+ }
+
+ ofpbuf_init(&request, 0);
+ if (ofpbuf_put_hex(&request, argv[2], NULL)[0] != '\0') {
+ ovs_fatal(0, "Trailing garbage in hex data");
+ }
+ if (request.size < sizeof(struct ofp_header)) {
+ ovs_fatal(0, "Request too short");
+ }
+
+ oh = request.data;
+ if (request.size != ntohs(oh->length)) {
+ ovs_fatal(0, "Request size inconsistent");
+ }
+
+ reply = ofperr_encode_reply(error, request.data);
+ ofpbuf_uninit(&request);
+
+ ovs_hex_dump(stdout, reply->data, reply->size, 0, false);
+ ofpbuf_delete(reply);
+}
+