]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/ofproto.h
vswitchd: Remove default controller config from Open_vSwitch table
[mirror_ovs.git] / ofproto / ofproto.h
CommitLineData
064af421 1/*
1a6f1e2a 2 * Copyright (c) 2009, 2010 Nicira Networks.
064af421 3 *
a14bc59f
BP
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:
064af421 7 *
a14bc59f
BP
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.
064af421
BP
15 */
16
17#ifndef OFPROTO_H
18#define OFPROTO_H 1
19
d2ede7bc
BP
20#include <sys/types.h>
21#include <netinet/in.h>
064af421
BP
22#include <stdbool.h>
23#include <stddef.h>
24#include <stdint.h>
25#include "flow.h"
0193b2af 26#include "netflow.h"
064af421
BP
27#include "tag.h"
28
03292c46
JG
29#ifdef __cplusplus
30extern "C" {
31#endif
32
064af421
BP
33struct odp_actions;
34struct ofhooks;
35struct ofproto;
36struct svec;
37
72b06300
BP
38enum {
39 DP_GROUP_FLOOD = 0,
40 DP_GROUP_ALL = 1
41};
42
064af421
BP
43struct ofexpired {
44 flow_t flow;
0193b2af
JG
45 uint64_t packet_count; /* Packets from subrules. */
46 uint64_t byte_count; /* Bytes from subrules. */
064af421 47 long long int used; /* Last-used time (0 if never used). */
064af421
BP
48};
49
72b06300
BP
50struct ofproto_sflow_options {
51 struct svec targets;
52 uint32_t sampling_rate;
53 uint32_t polling_interval;
54 uint32_t header_len;
55 uint32_t sub_id;
56 char *agent_device;
57 char *control_ip;
58};
59
79c9f2ee
BP
60/* How the switch should act if the controller cannot be contacted. */
61enum ofproto_fail_mode {
62 OFPROTO_FAIL_SECURE, /* Preserve flow table. */
63 OFPROTO_FAIL_STANDALONE /* Act as a standalone switch. */
64};
65
66enum ofproto_band {
67 OFPROTO_IN_BAND, /* In-band connection to controller. */
68 OFPROTO_OUT_OF_BAND /* Out-of-band connection to controller. */
69};
70
71struct ofproto_controller {
72 char *target; /* e.g. "tcp:127.0.0.1" */
73 int max_backoff; /* Maximum reconnection backoff, in seconds. */
74 int probe_interval; /* Max idle time before probing, in seconds. */
75 enum ofproto_fail_mode fail; /* Controller failure handling mode. */
76 enum ofproto_band band; /* In-band or out-of-band? */
77
78 /* Discovery options. */
79 char *accept_re; /* Regexp for acceptable controllers. */
80 bool update_resolv_conf; /* Update /etc/resolv.conf? */
81
82 /* OpenFlow packet-in rate-limiting. */
83 int rate_limit; /* Max packet-in rate in packets per second. */
84 int burst_limit; /* Limit on accumulating packet credits. */
85};
86
23ff2821
JP
87#define DEFAULT_MFR_DESC "Nicira Networks, Inc."
88#define DEFAULT_HW_DESC "Open vSwitch"
89#define DEFAULT_SW_DESC VERSION BUILDNR
90#define DEFAULT_SERIAL_DESC "None"
91#define DEFAULT_DP_DESC "None"
92
1a6f1e2a
JG
93int ofproto_create(const char *datapath, const char *datapath_type,
94 const struct ofhooks *, void *aux,
064af421
BP
95 struct ofproto **ofprotop);
96void ofproto_destroy(struct ofproto *);
97int ofproto_run(struct ofproto *);
98int ofproto_run1(struct ofproto *);
99int ofproto_run2(struct ofproto *, bool revalidate_all);
100void ofproto_wait(struct ofproto *);
101bool ofproto_is_alive(const struct ofproto *);
102
103/* Configuration. */
104void ofproto_set_datapath_id(struct ofproto *, uint64_t datapath_id);
76ce9432
BP
105void ofproto_set_controllers(struct ofproto *,
106 const struct ofproto_controller *, size_t n);
fa05809b 107void ofproto_reconnect_controllers(struct ofproto *);
917e50e1
BP
108void ofproto_set_extra_in_band_remotes(struct ofproto *,
109 const struct sockaddr_in *, size_t n);
064af421 110void ofproto_set_desc(struct ofproto *,
5a719c38
JP
111 const char *mfr_desc, const char *hw_desc,
112 const char *sw_desc, const char *serial_desc,
8abc4ed7 113 const char *dp_desc);
064af421
BP
114int ofproto_set_listeners(struct ofproto *, const struct svec *listeners);
115int ofproto_set_snoops(struct ofproto *, const struct svec *snoops);
0193b2af
JG
116int ofproto_set_netflow(struct ofproto *,
117 const struct netflow_options *nf_options);
72b06300 118void ofproto_set_sflow(struct ofproto *, const struct ofproto_sflow_options *);
064af421 119int ofproto_set_stp(struct ofproto *, bool enable_stp);
064af421
BP
120
121/* Configuration querying. */
122uint64_t ofproto_get_datapath_id(const struct ofproto *);
76ce9432 123bool ofproto_has_controller(const struct ofproto *);
064af421
BP
124void ofproto_get_listeners(const struct ofproto *, struct svec *);
125void ofproto_get_snoops(const struct ofproto *, struct svec *);
4f2cad2c 126void ofproto_get_all_flows(struct ofproto *p, struct ds *);
064af421
BP
127
128/* Functions for use by ofproto implementation modules, not by clients. */
129int ofproto_send_packet(struct ofproto *, const flow_t *,
130 const union ofp_action *, size_t n_actions,
131 const struct ofpbuf *);
132void ofproto_add_flow(struct ofproto *, const flow_t *, uint32_t wildcards,
133 unsigned int priority,
134 const union ofp_action *, size_t n_actions,
135 int idle_timeout);
136void ofproto_delete_flow(struct ofproto *, const flow_t *, uint32_t wildcards,
137 unsigned int priority);
138void ofproto_flush_flows(struct ofproto *);
139
140/* Hooks for ovs-vswitchd. */
141struct ofhooks {
142 void (*port_changed_cb)(enum ofp_port_reason, const struct ofp_phy_port *,
143 void *aux);
144 bool (*normal_cb)(const flow_t *, const struct ofpbuf *packet,
6a07af36
JG
145 struct odp_actions *, tag_type *,
146 uint16_t *nf_output_iface, void *aux);
064af421
BP
147 void (*account_flow_cb)(const flow_t *, const union odp_action *,
148 size_t n_actions, unsigned long long int n_bytes,
149 void *aux);
150 void (*account_checkpoint_cb)(void *aux);
151};
152void ofproto_revalidate(struct ofproto *, tag_type);
153struct tag_set *ofproto_get_revalidate_set(struct ofproto *);
154
03292c46
JG
155#ifdef __cplusplus
156}
157#endif
158
064af421 159#endif /* ofproto.h */