]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/connmgr.h
classifier: New function cls_rule_hash().
[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"
22#include "ofproto.h"
23#include "openflow/nicira-ext.h"
24#include "openvswitch/types.h"
25
19a87e36
BP
26struct ofconn;
27struct ofputil_flow_removed;
78bd1cd0 28struct ofputil_packet_in;
81e2083f 29struct sset;
19a87e36
BP
30
31/* ofproto supports two kinds of OpenFlow connections:
32 *
33 * - "Primary" connections to ordinary OpenFlow controllers. ofproto
34 * maintains persistent connections to these controllers and by default
35 * sends them asynchronous messages such as packet-ins.
36 *
37 * - "Service" connections, e.g. from ovs-ofctl. When these connections
38 * drop, it is the other side's responsibility to reconnect them if
39 * necessary. ofproto does not send them asynchronous messages by default.
40 *
41 * Currently, active (tcp, ssl, unix) connections are always "primary"
42 * connections and passive (ptcp, pssl, punix) connections are always "service"
43 * connections. There is no inherent reason for this, but it reflects the
44 * common case.
45 */
46enum ofconn_type {
47 OFCONN_PRIMARY, /* An ordinary OpenFlow controller. */
48 OFCONN_SERVICE /* A service connection, e.g. "ovs-ofctl". */
49};
50
51/* Basics. */
52struct connmgr *connmgr_create(struct ofproto *ofproto,
53 const char *dpif_name, const char *local_name);
54void connmgr_destroy(struct connmgr *);
55
56void connmgr_run(struct connmgr *,
57 void (*handle_openflow)(struct ofconn *,
58 struct ofpbuf *ofp_msg));
59void connmgr_wait(struct connmgr *);
60
61struct ofproto *ofconn_get_ofproto(const struct ofconn *);
62
63/* OpenFlow configuration. */
64bool connmgr_has_controllers(const struct connmgr *);
65void connmgr_get_controller_info(struct connmgr *, struct shash *);
66void connmgr_set_controllers(struct connmgr *,
67 const struct ofproto_controller[], size_t n);
68void connmgr_reconnect(const struct connmgr *);
69
81e2083f
BP
70int connmgr_set_snoops(struct connmgr *, const struct sset *snoops);
71bool connmgr_has_snoops(const struct connmgr *);
72void connmgr_get_snoops(const struct connmgr *, struct sset *snoops);
19a87e36
BP
73
74/* Individual connections to OpenFlow controllers. */
75enum ofconn_type ofconn_get_type(const struct ofconn *);
76
77enum nx_role ofconn_get_role(const struct ofconn *);
78void ofconn_set_role(struct ofconn *, enum nx_role);
79
80enum nx_flow_format ofconn_get_flow_format(struct ofconn *);
81void ofconn_set_flow_format(struct ofconn *, enum nx_flow_format);
82
6c1491fb
BP
83bool ofconn_get_flow_mod_table_id(const struct ofconn *);
84void ofconn_set_flow_mod_table_id(struct ofconn *, bool enable);
85
19a87e36
BP
86int ofconn_get_miss_send_len(const struct ofconn *);
87void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len);
88
89void ofconn_send_reply(const struct ofconn *, struct ofpbuf *);
63f2140a 90void ofconn_send_replies(const struct ofconn *, struct list *);
19a87e36
BP
91
92int ofconn_pktbuf_retrieve(struct ofconn *, uint32_t id,
93 struct ofpbuf **bufferp, uint16_t *in_port);
94
95/* Sending asynchronous messages. */
96void connmgr_send_port_status(struct connmgr *, const struct ofp_phy_port *,
97 uint8_t reason);
98void connmgr_send_flow_removed(struct connmgr *,
99 const struct ofputil_flow_removed *);
78bd1cd0 100void connmgr_send_packet_in(struct connmgr *, const struct ofputil_packet_in *,
19a87e36
BP
101 const struct flow *, struct ofpbuf *rw_packet);
102
103/* Fail-open settings. */
104enum ofproto_fail_mode connmgr_get_fail_mode(const struct connmgr *);
105void connmgr_set_fail_mode(struct connmgr *, enum ofproto_fail_mode);
106
107/* Fail-open implementation. */
108int connmgr_get_max_probe_interval(const struct connmgr *);
109bool connmgr_is_any_controller_connected(const struct connmgr *);
110bool connmgr_is_any_controller_admitted(const struct connmgr *);
111int connmgr_failure_duration(const struct connmgr *);
112void connmgr_broadcast(struct connmgr *, struct ofpbuf *);
113
114/* In-band configuration. */
115void connmgr_set_extra_in_band_remotes(struct connmgr *,
116 const struct sockaddr_in *, size_t);
117void connmgr_set_in_band_queue(struct connmgr *, int queue_id);
118
119/* In-band implementation. */
120bool connmgr_msg_in_hook(struct connmgr *, const struct flow *,
121 const struct ofpbuf *packet);
122bool connmgr_may_set_up_flow(struct connmgr *, const struct flow *,
123 const struct nlattr *odp_actions,
124 size_t actions_len);
125
126/* Fail-open and in-band implementation. */
127void connmgr_flushed(struct connmgr *);
128
129#endif /* connmgr.h */