2 * Copyright (c) 2009 Nicira Networks.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef OPENFLOW_OPENFLOW_MGMT_H
18 #define OPENFLOW_OPENFLOW_MGMT_H 1
20 #include "openflow/nicira-ext.h"
23 OFMPT_CAPABILITY_REQUEST,
24 OFMPT_CAPABILITY_REPLY,
25 OFMPT_RESOURCES_REQUEST,
26 OFMPT_RESOURCES_UPDATE,
29 OFMPT_CONFIG_UPDATE_ACK,
34 /* Header on all OpenFlow management packets. */
36 struct nicira_header header;
37 uint16_t type; /* One of OFMPT_* above. */
40 OFP_ASSERT(sizeof(struct ofmp_header) == sizeof(struct nicira_header) + 4);
43 /* Generic TLV header. */
45 uint16_t type; /* Type of value (one of OFMPTLV_*). */
46 uint16_t len; /* Length of TLV (includes this header). */
47 uint8_t data[0]; /* Value of data as defined by type and length. */
49 OFP_ASSERT(sizeof(struct ofmp_tlv) == 4);
51 /* Universal TLV terminator. Used to indicate end of TLV list. */
53 uint16_t type; /* Type is 0. */
54 uint16_t len; /* Length is 4. */
56 OFP_ASSERT(sizeof(struct ofmp_tlv_end) == 4);
59 /* Bitmask of capability description styles. */
60 enum ofmp_capability_format {
61 OFMPCAF_SIMPLE = 0 << 0, /* "ovs-vswitchd.conf" style. */
64 /* Body of capbility request.
66 * OFMPT_CAPABILITY_REQUEST (controller -> switch) */
67 struct ofmp_capability_request {
68 struct ofmp_header header;
69 uint32_t format; /* One of OFMPCAF_*. */
71 OFP_ASSERT(sizeof(struct ofmp_capability_request) == 24);
73 /* Body of reply to capability request.
75 * OFMPT_CAPABILITY_REPLY (switch -> controller). */
76 struct ofmp_capability_reply {
77 struct ofmp_header header;
78 uint32_t format; /* One of OFMPCAF_*. */
79 uint64_t mgmt_id; /* Management ID. */
82 OFP_ASSERT(sizeof(struct ofmp_capability_reply) == 32);
85 /* Resource TLV for datapath description. */
87 uint16_t type; /* OFMPTSR_DP. */
88 uint16_t len; /* 32. */
90 uint64_t dp_id; /* Datapath ID. */
91 uint8_t name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated name. */
93 OFP_ASSERT(sizeof(struct ofmptsr_dp) == 32);
95 /* UUIDs will be passed around as *non-terminated* strings in their
96 * canonical form (e.g., 550e8400-e29b-41d4-a716-446655440000).
98 #define OFMP_UUID_LEN 36
100 /* Resource TLV for XenServer UUIDs associated with this datapath. */
101 struct ofmptsr_dp_uuid {
102 uint16_t type; /* OFMPTSR_DP_UUID. */
103 uint16_t len; /* Length. */
105 uint64_t dp_id; /* Datapath ID. */
106 uint8_t uuid_list[0]; /* List of UUIDs associated with
109 OFP_ASSERT(sizeof(struct ofmptsr_dp_uuid) == 16);
111 /* Resource TLV for XenServer UUID associated with this managment
114 struct ofmptsr_mgmt_uuid {
115 uint16_t type; /* OFMPTSR_MGMT_UUID. */
116 uint16_t len; /* 52. */
118 uint64_t mgmt_id; /* Management ID. */
119 uint8_t uuid[OFMP_UUID_LEN]; /* System UUID. */
120 uint8_t pad2[4]; /* Pad for 64-bit systems. */
122 OFP_ASSERT(sizeof(struct ofmptsr_mgmt_uuid) == 56);
124 /* Resource TLV for details about this XenServer vif. */
126 uint16_t type; /* OFMPTSR_VIF. */
127 uint16_t len; /* 136. */
128 uint8_t name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated name. */
129 uint8_t vif_uuid[OFMP_UUID_LEN]; /* VIF UUID. */
130 uint8_t vm_uuid[OFMP_UUID_LEN]; /* VM UUID. */
131 uint8_t net_uuid[OFMP_UUID_LEN]; /* Network UUID. */
132 uint64_t vif_mac; /* Management ID. */
134 OFP_ASSERT(sizeof(struct ofmptsr_vif) == 136);
136 /* TLV types for switch resource descriptions. */
137 enum ofmp_switch_resources {
138 OFMPTSR_END = 0, /* Terminator. */
139 OFMPTSR_DP, /* Datapath. */
140 OFMPTSR_DP_UUID, /* Xen: datapath uuid's. */
141 OFMPTSR_MGMT_UUID, /* Xen: management uuid. */
142 OFMPTSR_VIF, /* Xen: vif details. */
145 /* Body of resources request.
147 * OFMPT_RESOURCES_REQUEST (controller -> switch) */
148 struct ofmp_resources_request {
149 struct ofmp_header header;
152 /* Body of capbility update. Sent in response to a resources request or
153 * sent asynchronously when resources change on the switch.
155 * OFMPT_RESOURCES_UPDATE (switch -> controller) */
156 struct ofmp_resources_update {
157 struct ofmp_header header;
160 OFP_ASSERT(sizeof(struct ofmp_resources_update) == 20);
163 /* Bitmask of capability description styles. */
164 enum ofmp_config_format {
165 OFMPCOF_SIMPLE = 0 << 0, /* "ovs-vswitchd.conf" style. */
168 #define CONFIG_COOKIE_LEN 20
170 /* Body of configuration request.
172 * OFMPT_CONFIG_REQUEST (controller -> switch) */
173 struct ofmp_config_request {
174 struct ofmp_header header;
175 uint32_t format; /* One of OFMPCOF_*. */
177 OFP_ASSERT(sizeof(struct ofmp_config_request) == 24);
179 /* Body of configuration update. Sent in response to a configuration
180 * request from the controller. May be sent asynchronously by either
181 * the controller or switch to modify configuration or notify of
182 * changes, respectively. If sent by the controller, the switch must
183 * respond with a OFMPT_CONFIG_UPDATE_ACK.
185 * OFMPT_CONFIG_UPDATE (switch <-> controller) */
186 struct ofmp_config_update {
187 struct ofmp_header header;
188 uint32_t format; /* One of OFMPCOF_*. */
189 uint8_t cookie[CONFIG_COOKIE_LEN]; /* Cookie of config attempting to be
190 * replaced by this update. */
193 OFP_ASSERT(sizeof(struct ofmp_config_update) == 44);
195 /* Bitmask of configuration update ack flags. */
196 enum ofmp_config_update_ack_flags {
197 OFMPCUAF_SUCCESS = 1 << 0, /* Config succeeded. */
200 /* Body of configuration update ack. Sent in response to a configuration
203 * OFMPT_CONFIG_UPDATE_ACK (switch -> controller) */
204 struct ofmp_config_update_ack {
205 struct ofmp_header header;
206 uint32_t format; /* One of OFMPCOF_*. */
207 uint32_t flags; /* One of OFMPCUAF_*. */
208 uint8_t cookie[CONFIG_COOKIE_LEN]; /* Cookie of current configuration
209 * being used in the switch. */
211 OFP_ASSERT(sizeof(struct ofmp_config_update_ack) == 48);
213 /* Values for 'type' in ofmp_error_msg. */
214 enum ofmp_error_type {
215 OFMPET_BAD_CONFIG /* Problem with configuration. */
218 /* ofmp_error_msg 'code' values for OFMPET_BAD_CONFIG. 'data' contains
219 * at least the first 64 bytes of the failed request. */
220 enum ofmp_bad_config_code {
221 OFMPBCC_BUSY, /* Config updating, try again. */
222 OFMPBCC_OLD_COOKIE, /* Config has changed. */
225 /* Body of error message. May be sent by either the switch or the
226 * controller to indicate some error condition.
228 * OFMPT_ERROR (switch <-> controller) */
229 struct ofmp_error_msg {
230 struct ofmp_header header;
232 uint16_t type; /* One of OFMPET_*. */
233 uint16_t code; /* Code depending on 'type'. */
234 uint8_t data[0]; /* Variable-length data. Interpreted based
235 on the type and code. */
237 OFP_ASSERT(sizeof(struct ofmp_error_msg) == 24);
239 /* Bitmask of extended data message flags. */
240 enum ofmp_extended_data_flags {
241 OFMPEDF_MORE_DATA = 1 << 0, /* More data follows. */
244 /* Body of extended data message. May be sent by either the switch or the
245 * controller to send messages that are greater than 65535 bytes in
248 * OFMPT_EXTENDED_DATA (switch <-> controller) */
249 struct ofmp_extended_data {
250 struct ofmp_header header;
252 uint16_t type; /* Type code of the encapsulated message. */
253 uint8_t flags; /* One of OFMPEDF_*. */
255 uint8_t data[0]; /* Variable-length data. */
257 OFP_ASSERT(sizeof(struct ofmp_extended_data) == 24);
259 #endif /* openflow/openflow-mgmt.h */