]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/connmgr.h
Global replace of Nicira Networks.
[mirror_ovs.git] / ofproto / connmgr.h
CommitLineData
19a87e36 1/*
e0edde6f 2 * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
19a87e36
BP
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;
9e1fd49b 32struct ofputil_phy_port;
81e2083f 33struct sset;
19a87e36
BP
34
35/* ofproto supports two kinds of OpenFlow connections:
36 *
37 * - "Primary" connections to ordinary OpenFlow controllers. ofproto
38 * maintains persistent connections to these controllers and by default
39 * sends them asynchronous messages such as packet-ins.
40 *
41 * - "Service" connections, e.g. from ovs-ofctl. When these connections
42 * drop, it is the other side's responsibility to reconnect them if
43 * necessary. ofproto does not send them asynchronous messages by default.
44 *
45 * Currently, active (tcp, ssl, unix) connections are always "primary"
46 * connections and passive (ptcp, pssl, punix) connections are always "service"
47 * connections. There is no inherent reason for this, but it reflects the
48 * common case.
49 */
50enum ofconn_type {
51 OFCONN_PRIMARY, /* An ordinary OpenFlow controller. */
52 OFCONN_SERVICE /* A service connection, e.g. "ovs-ofctl". */
53};
54
80d5aefd
BP
55/* The type of an OpenFlow asynchronous message. */
56enum ofconn_async_msg_type {
57 OAM_PACKET_IN, /* OFPT_PACKET_IN or NXT_PACKET_IN. */
58 OAM_PORT_STATUS, /* OFPT_PORT_STATUS. */
59 OAM_FLOW_REMOVED, /* OFPT_FLOW_REMOVED or NXT_FLOW_REMOVED. */
60 OAM_N_TYPES
61};
62
19a87e36
BP
63/* Basics. */
64struct connmgr *connmgr_create(struct ofproto *ofproto,
65 const char *dpif_name, const char *local_name);
66void connmgr_destroy(struct connmgr *);
67
68void connmgr_run(struct connmgr *,
7ee20df1 69 bool (*handle_openflow)(struct ofconn *,
19a87e36 70 struct ofpbuf *ofp_msg));
7ee20df1 71void connmgr_wait(struct connmgr *, bool handling_openflow);
19a87e36
BP
72
73struct ofproto *ofconn_get_ofproto(const struct ofconn *);
74
7ee20df1
BP
75void connmgr_retry(struct connmgr *);
76
19a87e36
BP
77/* OpenFlow configuration. */
78bool connmgr_has_controllers(const struct connmgr *);
79void connmgr_get_controller_info(struct connmgr *, struct shash *);
72ba2ed3 80void connmgr_free_controller_info(struct shash *);
19a87e36
BP
81void connmgr_set_controllers(struct connmgr *,
82 const struct ofproto_controller[], size_t n);
83void connmgr_reconnect(const struct connmgr *);
84
81e2083f
BP
85int connmgr_set_snoops(struct connmgr *, const struct sset *snoops);
86bool connmgr_has_snoops(const struct connmgr *);
87void connmgr_get_snoops(const struct connmgr *, struct sset *snoops);
19a87e36
BP
88
89/* Individual connections to OpenFlow controllers. */
90enum ofconn_type ofconn_get_type(const struct ofconn *);
91
92enum nx_role ofconn_get_role(const struct ofconn *);
93void ofconn_set_role(struct ofconn *, enum nx_role);
94
27527aa0
BP
95enum ofputil_protocol ofconn_get_protocol(struct ofconn *);
96void ofconn_set_protocol(struct ofconn *, enum ofputil_protocol);
19a87e36 97
54834960
EJ
98enum nx_packet_in_format ofconn_get_packet_in_format(struct ofconn *);
99void ofconn_set_packet_in_format(struct ofconn *, enum nx_packet_in_format);
100
a7349929
BP
101void ofconn_set_controller_id(struct ofconn *, uint16_t controller_id);
102
f0fd1a17
PS
103void ofconn_set_invalid_ttl_to_controller(struct ofconn *, bool);
104bool ofconn_get_invalid_ttl_to_controller(struct ofconn *);
105
19a87e36
BP
106int ofconn_get_miss_send_len(const struct ofconn *);
107void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len);
108
80d5aefd
BP
109void ofconn_set_async_config(struct ofconn *,
110 const uint32_t master_masks[OAM_N_TYPES],
111 const uint32_t slave_masks[OAM_N_TYPES]);
112
19a87e36 113void ofconn_send_reply(const struct ofconn *, struct ofpbuf *);
63f2140a 114void ofconn_send_replies(const struct ofconn *, struct list *);
1be5ff75 115void ofconn_send_error(const struct ofconn *, const struct ofp_header *request,
90bf1e07 116 enum ofperr);
19a87e36 117
90bf1e07
BP
118enum ofperr ofconn_pktbuf_retrieve(struct ofconn *, uint32_t id,
119 struct ofpbuf **bufferp, uint16_t *in_port);
19a87e36 120
7ee20df1
BP
121bool ofconn_has_pending_opgroups(const struct ofconn *);
122void ofconn_add_opgroup(struct ofconn *, struct list *);
123void ofconn_remove_opgroup(struct ofconn *, struct list *,
124 const struct ofp_header *request, int error);
125
19a87e36 126/* Sending asynchronous messages. */
9e1fd49b
BP
127void connmgr_send_port_status(struct connmgr *,
128 const struct ofputil_phy_port *, uint8_t reason);
19a87e36
BP
129void connmgr_send_flow_removed(struct connmgr *,
130 const struct ofputil_flow_removed *);
d8653c38
BP
131void connmgr_send_packet_in(struct connmgr *,
132 const struct ofputil_packet_in *);
19a87e36
BP
133
134/* Fail-open settings. */
135enum ofproto_fail_mode connmgr_get_fail_mode(const struct connmgr *);
136void connmgr_set_fail_mode(struct connmgr *, enum ofproto_fail_mode);
137
138/* Fail-open implementation. */
139int connmgr_get_max_probe_interval(const struct connmgr *);
140bool connmgr_is_any_controller_connected(const struct connmgr *);
141bool connmgr_is_any_controller_admitted(const struct connmgr *);
142int connmgr_failure_duration(const struct connmgr *);
19a87e36
BP
143
144/* In-band configuration. */
145void connmgr_set_extra_in_band_remotes(struct connmgr *,
146 const struct sockaddr_in *, size_t);
147void connmgr_set_in_band_queue(struct connmgr *, int queue_id);
148
149/* In-band implementation. */
150bool connmgr_msg_in_hook(struct connmgr *, const struct flow *,
151 const struct ofpbuf *packet);
152bool connmgr_may_set_up_flow(struct connmgr *, const struct flow *,
153 const struct nlattr *odp_actions,
154 size_t actions_len);
155
156/* Fail-open and in-band implementation. */
157void connmgr_flushed(struct connmgr *);
158
159#endif /* connmgr.h */