]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/connmgr.h
Better abstract OpenFlow error codes.
[mirror_ovs.git] / ofproto / connmgr.h
CommitLineData
19a87e36
BP
1/*
2 * Copyright (c) 2009, 2010, 2011 Nicira Networks.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef CONNMGR_H
18#define CONNMGR_H 1
19
20#include "hmap.h"
21#include "list.h"
90bf1e07 22#include "ofp-errors.h"
19a87e36
BP
23#include "ofproto.h"
24#include "openflow/nicira-ext.h"
25#include "openvswitch/types.h"
26
a946b636 27struct nlattr;
19a87e36 28struct ofconn;
7ee20df1 29struct ofopgroup;
19a87e36 30struct ofputil_flow_removed;
78bd1cd0 31struct ofputil_packet_in;
81e2083f 32struct sset;
19a87e36
BP
33
34/* ofproto supports two kinds of OpenFlow connections:
35 *
36 * - "Primary" connections to ordinary OpenFlow controllers. ofproto
37 * maintains persistent connections to these controllers and by default
38 * sends them asynchronous messages such as packet-ins.
39 *
40 * - "Service" connections, e.g. from ovs-ofctl. When these connections
41 * drop, it is the other side's responsibility to reconnect them if
42 * necessary. ofproto does not send them asynchronous messages by default.
43 *
44 * Currently, active (tcp, ssl, unix) connections are always "primary"
45 * connections and passive (ptcp, pssl, punix) connections are always "service"
46 * connections. There is no inherent reason for this, but it reflects the
47 * common case.
48 */
49enum ofconn_type {
50 OFCONN_PRIMARY, /* An ordinary OpenFlow controller. */
51 OFCONN_SERVICE /* A service connection, e.g. "ovs-ofctl". */
52};
53
54/* Basics. */
55struct connmgr *connmgr_create(struct ofproto *ofproto,
56 const char *dpif_name, const char *local_name);
57void connmgr_destroy(struct connmgr *);
58
59void connmgr_run(struct connmgr *,
7ee20df1 60 bool (*handle_openflow)(struct ofconn *,
19a87e36 61 struct ofpbuf *ofp_msg));
7ee20df1 62void connmgr_wait(struct connmgr *, bool handling_openflow);
19a87e36
BP
63
64struct ofproto *ofconn_get_ofproto(const struct ofconn *);
65
7ee20df1
BP
66void connmgr_retry(struct connmgr *);
67
19a87e36
BP
68/* OpenFlow configuration. */
69bool connmgr_has_controllers(const struct connmgr *);
70void connmgr_get_controller_info(struct connmgr *, struct shash *);
72ba2ed3 71void connmgr_free_controller_info(struct shash *);
19a87e36
BP
72void connmgr_set_controllers(struct connmgr *,
73 const struct ofproto_controller[], size_t n);
74void connmgr_reconnect(const struct connmgr *);
75
81e2083f
BP
76int connmgr_set_snoops(struct connmgr *, const struct sset *snoops);
77bool connmgr_has_snoops(const struct connmgr *);
78void connmgr_get_snoops(const struct connmgr *, struct sset *snoops);
19a87e36
BP
79
80/* Individual connections to OpenFlow controllers. */
81enum ofconn_type ofconn_get_type(const struct ofconn *);
82
83enum nx_role ofconn_get_role(const struct ofconn *);
84void ofconn_set_role(struct ofconn *, enum nx_role);
85
86enum nx_flow_format ofconn_get_flow_format(struct ofconn *);
87void ofconn_set_flow_format(struct ofconn *, enum nx_flow_format);
88
54834960
EJ
89enum nx_packet_in_format ofconn_get_packet_in_format(struct ofconn *);
90void ofconn_set_packet_in_format(struct ofconn *, enum nx_packet_in_format);
91
6c1491fb
BP
92bool ofconn_get_flow_mod_table_id(const struct ofconn *);
93void ofconn_set_flow_mod_table_id(struct ofconn *, bool enable);
94
19a87e36
BP
95int ofconn_get_miss_send_len(const struct ofconn *);
96void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len);
97
98void ofconn_send_reply(const struct ofconn *, struct ofpbuf *);
63f2140a 99void ofconn_send_replies(const struct ofconn *, struct list *);
1be5ff75 100void ofconn_send_error(const struct ofconn *, const struct ofp_header *request,
90bf1e07 101 enum ofperr);
19a87e36 102
90bf1e07
BP
103enum ofperr ofconn_pktbuf_retrieve(struct ofconn *, uint32_t id,
104 struct ofpbuf **bufferp, uint16_t *in_port);
19a87e36 105
7ee20df1
BP
106bool ofconn_has_pending_opgroups(const struct ofconn *);
107void ofconn_add_opgroup(struct ofconn *, struct list *);
108void ofconn_remove_opgroup(struct ofconn *, struct list *,
109 const struct ofp_header *request, int error);
110
19a87e36
BP
111/* Sending asynchronous messages. */
112void connmgr_send_port_status(struct connmgr *, const struct ofp_phy_port *,
113 uint8_t reason);
114void connmgr_send_flow_removed(struct connmgr *,
115 const struct ofputil_flow_removed *);
78bd1cd0 116void connmgr_send_packet_in(struct connmgr *, const struct ofputil_packet_in *,
29ebe880 117 const struct flow *);
19a87e36
BP
118
119/* Fail-open settings. */
120enum ofproto_fail_mode connmgr_get_fail_mode(const struct connmgr *);
121void connmgr_set_fail_mode(struct connmgr *, enum ofproto_fail_mode);
122
123/* Fail-open implementation. */
124int connmgr_get_max_probe_interval(const struct connmgr *);
125bool connmgr_is_any_controller_connected(const struct connmgr *);
126bool connmgr_is_any_controller_admitted(const struct connmgr *);
127int connmgr_failure_duration(const struct connmgr *);
128void connmgr_broadcast(struct connmgr *, struct ofpbuf *);
129
130/* In-band configuration. */
131void connmgr_set_extra_in_band_remotes(struct connmgr *,
132 const struct sockaddr_in *, size_t);
133void connmgr_set_in_band_queue(struct connmgr *, int queue_id);
134
135/* In-band implementation. */
136bool connmgr_msg_in_hook(struct connmgr *, const struct flow *,
137 const struct ofpbuf *packet);
138bool connmgr_may_set_up_flow(struct connmgr *, const struct flow *,
139 const struct nlattr *odp_actions,
140 size_t actions_len);
141
142/* Fail-open and in-band implementation. */
143void connmgr_flushed(struct connmgr *);
144
145#endif /* connmgr.h */