+static bool
+recv_flow_stats_reply(struct vconn *vconn, ovs_be32 send_xid,
+ struct ofpbuf **replyp,
+ struct ofputil_flow_stats *fs, struct ofpbuf *ofpacts)
+{
+ struct ofpbuf *reply = *replyp;
+
+ for (;;) {
+ ovs_be16 flags;
+ int retval;
+
+ /* Get a flow stats reply message, if we don't already have one. */
+ if (!reply) {
+ const struct ofputil_msg_type *type;
+ enum ofputil_msg_code code;
+
+ do {
+ run(vconn_recv_block(vconn, &reply),
+ "OpenFlow packet receive failed");
+ } while (((struct ofp_header *) reply->data)->xid != send_xid);
+
+ ofputil_decode_msg_type(reply->data, &type);
+ code = ofputil_msg_type_code(type);
+ if (code != OFPUTIL_OFPST_FLOW_REPLY &&
+ code != OFPUTIL_NXST_FLOW_REPLY) {
+ ovs_fatal(0, "received bad reply: %s",
+ ofp_to_string(reply->data, reply->size,
+ verbosity + 1));
+ }
+ }
+
+ /* Pull an individual flow stats reply out of the message. */
+ retval = ofputil_decode_flow_stats_reply(fs, reply, false, ofpacts);
+ switch (retval) {
+ case 0:
+ *replyp = reply;
+ return true;
+
+ case EOF:
+ flags = ((const struct ofp_stats_msg *) reply->l2)->flags;
+ ofpbuf_delete(reply);
+ if (!(flags & htons(OFPSF_REPLY_MORE))) {
+ *replyp = NULL;
+ return false;
+ }
+ break;
+
+ default:
+ ovs_fatal(0, "parse error in reply (%s)",
+ ofperr_to_string(retval));
+ }
+ }
+}
+