-/* ofproto supports two kinds of OpenFlow connections:
- *
- * - "Primary" connections to ordinary OpenFlow controllers. ofproto
- * maintains persistent connections to these controllers and by default
- * sends them asynchronous messages such as packet-ins.
- *
- * - "Service" connections, e.g. from ovs-ofctl. When these connections
- * drop, it is the other side's responsibility to reconnect them if
- * necessary. ofproto does not send them asynchronous messages by default.
- *
- * Currently, active (tcp, ssl, unix) connections are always "primary"
- * connections and passive (ptcp, pssl, punix) connections are always "service"
- * connections. There is no inherent reason for this, but it reflects the
- * common case.
- */
-enum ofconn_type {
- OFCONN_PRIMARY, /* An ordinary OpenFlow controller. */
- OFCONN_SERVICE /* A service connection, e.g. "ovs-ofctl". */
-};
-
-/* A listener for incoming OpenFlow "service" connections. */
-struct ofservice {
- struct hmap_node node; /* In struct ofproto's "services" hmap. */
- struct pvconn *pvconn; /* OpenFlow connection listener. */
-
- /* These are not used by ofservice directly. They are settings for
- * accepted "struct ofconn"s from the pvconn. */
- int probe_interval; /* Max idle time before probing, in seconds. */
- int rate_limit; /* Max packet-in rate in packets per second. */
- int burst_limit; /* Limit on accumulating packet credits. */
-};
-
-static struct ofservice *ofservice_lookup(struct ofproto *,
- const char *target);
-static int ofservice_create(struct ofproto *,
- const struct ofproto_controller *);
-static void ofservice_reconfigure(struct ofservice *,
- const struct ofproto_controller *);
-static void ofservice_destroy(struct ofproto *, struct ofservice *);
-
-/* An OpenFlow connection. */
-struct ofconn {
- struct ofproto *ofproto; /* The ofproto that owns this connection. */
- struct list node; /* In struct ofproto's "all_conns" list. */
- struct rconn *rconn; /* OpenFlow connection. */
- enum ofconn_type type; /* Type. */
- enum nx_flow_format flow_format; /* Currently selected flow format. */
-
- /* OFPT_PACKET_IN related data. */
- struct rconn_packet_counter *packet_in_counter; /* # queued on 'rconn'. */
-#define N_SCHEDULERS 2
- struct pinsched *schedulers[N_SCHEDULERS];
- struct pktbuf *pktbuf; /* OpenFlow packet buffers. */
- int miss_send_len; /* Bytes to send of buffered packets. */
-
- /* Number of OpenFlow messages queued on 'rconn' as replies to OpenFlow
- * requests, and the maximum number before we stop reading OpenFlow
- * requests. */
-#define OFCONN_REPLY_MAX 100
- struct rconn_packet_counter *reply_counter;
-
- /* type == OFCONN_PRIMARY only. */
- enum nx_role role; /* Role. */
- struct hmap_node hmap_node; /* In struct ofproto's "controllers" map. */
- enum ofproto_band band; /* In-band or out-of-band? */
-};
-
-
-static struct ofconn *ofconn_create(struct ofproto *, struct rconn *,
- enum ofconn_type);
-static void ofconn_destroy(struct ofconn *);
-static void ofconn_run(struct ofconn *);
-static void ofconn_wait(struct ofconn *);
-
-static bool ofconn_receives_async_msgs(const struct ofconn *);
-static char *ofconn_make_name(const struct ofproto *, const char *target);
-static void ofconn_set_rate_limit(struct ofconn *, int rate, int burst);
-
-static struct ofproto *ofconn_get_ofproto(struct ofconn *);
-
-static enum nx_flow_format ofconn_get_flow_format(struct ofconn *);
-static void ofconn_set_flow_format(struct ofconn *, enum nx_flow_format);
-
-static int ofconn_get_miss_send_len(const struct ofconn *);
-static void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len);
-
-static enum ofconn_type ofconn_get_type(const struct ofconn *);
-
-static enum nx_role ofconn_get_role(const struct ofconn *);
-static void ofconn_set_role(struct ofconn *, enum nx_role);
-
-static int ofconn_pktbuf_retrieve(struct ofconn *, uint32_t id,
- struct ofpbuf **bufferp, uint16_t *in_port);
-
-
-static void queue_tx(struct ofpbuf *msg, const struct ofconn *ofconn,
- struct rconn_packet_counter *counter);
-