forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ofp-util, ofp-parse: Break up into many separate modules.
ofp-util had been far too large and monolithic for a long time. This commit breaks it up into units that make some logical sense. It also moves the pieces of ofp-parse that were specific to each unit into the relevant unit. Most of this commit is just moving code around. Signed-off-by: Ben Pfaff <[email protected]> Reviewed-by: Yifeng Sun <[email protected]>
- Loading branch information
Showing
89 changed files
with
15,816 additions
and
14,805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (c) 2008-2017 Nicira, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef OPENVSWITCH_NAMEMAP_H | ||
#define OPENVSWITCH_NAMEMAP_H 1 | ||
|
||
#include "openvswitch/hmap.h" | ||
|
||
struct ds; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Name-number mapping. | ||
* | ||
* This data structure tracks and manages a mapping between names and 32-bit | ||
* unsigned integers, with provision for detecting names that are used more | ||
* than once. | ||
* | ||
* This structure is suitable for tracking mappings between OpenFlow port names | ||
* and numbers. OpenFlow doesn't require either these kinds of names to be | ||
* unique, and in OVS it's possible for two ports to appear to have the same | ||
* name if their names are longer than the maximum length supported by a given | ||
* version of OpenFlow. | ||
* | ||
* OpenFlow does require port numbers to be unique. We check for duplicate | ||
* ports numbers just in case a switch has a bug. | ||
* | ||
* This structure is also suitable for tracking mappings between OpenFlow table | ||
* names and number. OpenFlow doesn't require table names to be unique and | ||
* Open vSwitch doesn't try to make them unique. */ | ||
struct namemap_node { | ||
struct hmap_node name_node; | ||
struct hmap_node number_node; | ||
|
||
uint32_t number; | ||
char *name; | ||
|
||
bool duplicate; | ||
}; | ||
|
||
struct namemap { | ||
struct hmap by_name; | ||
struct hmap by_number; | ||
}; | ||
#define NAMEMAP_INITIALIZER(MAP) \ | ||
{ HMAP_INITIALIZER(&(MAP)->by_name), HMAP_INITIALIZER(&(MAP)->by_number) } | ||
|
||
void namemap_init(struct namemap *); | ||
struct namemap_node *namemap_find_by_name(const struct namemap *, | ||
const char *); | ||
struct namemap_node *namemap_find_by_number(const struct namemap *, uint32_t); | ||
void namemap_put(struct namemap *, uint32_t, const char *); | ||
void namemap_destroy(struct namemap *); | ||
|
||
void namemap_put_name(const char *, struct ds *); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* namemap.h */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2008-2017 Nicira, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef OPENVSWITCH_OFP_BUNDLE_H | ||
#define OPENVSWITCH_OFP_BUNDLE_H 1 | ||
|
||
#include "openflow/openflow.h" | ||
#include "openvswitch/ofp-flow.h" | ||
#include "openvswitch/ofp-group.h" | ||
#include "openvswitch/ofp-packet.h" | ||
#include "openvswitch/ofp-msgs.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
struct ofputil_bundle_ctrl_msg { | ||
uint32_t bundle_id; | ||
uint16_t type; | ||
uint16_t flags; | ||
}; | ||
|
||
struct ofputil_bundle_add_msg { | ||
uint32_t bundle_id; | ||
uint16_t flags; | ||
const struct ofp_header *msg; | ||
}; | ||
|
||
enum ofperr ofputil_decode_bundle_ctrl(const struct ofp_header *, | ||
struct ofputil_bundle_ctrl_msg *); | ||
|
||
struct ofpbuf *ofputil_encode_bundle_ctrl_request( | ||
enum ofp_version, struct ofputil_bundle_ctrl_msg *); | ||
struct ofpbuf *ofputil_encode_bundle_ctrl_reply( | ||
const struct ofp_header *, struct ofputil_bundle_ctrl_msg *); | ||
|
||
struct ofpbuf *ofputil_encode_bundle_add(enum ofp_version, | ||
struct ofputil_bundle_add_msg *); | ||
|
||
enum ofperr ofputil_decode_bundle_add(const struct ofp_header *, | ||
struct ofputil_bundle_add_msg *, | ||
enum ofptype *); | ||
|
||
/* Bundle message as produced by ofp-parse. */ | ||
struct ofputil_bundle_msg { | ||
enum ofptype type; | ||
union { | ||
struct ofputil_flow_mod fm; | ||
struct ofputil_group_mod gm; | ||
struct ofputil_packet_out po; | ||
}; | ||
}; | ||
|
||
void ofputil_encode_bundle_msgs(const struct ofputil_bundle_msg *, size_t n, | ||
struct ovs_list *requests, | ||
enum ofputil_protocol); | ||
void ofputil_free_bundle_msgs(struct ofputil_bundle_msg *, size_t n); | ||
|
||
char *parse_ofp_bundle_file(const char *file_name, | ||
const struct ofputil_port_map *, | ||
const struct ofputil_table_map *, | ||
struct ofputil_bundle_msg **, size_t *n_bms, | ||
enum ofputil_protocol *) | ||
OVS_WARN_UNUSED_RESULT; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ofp-bundle.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2008-2017 Nicira, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef OPENVSWITCH_OFP_CONNECTION_H | ||
#define OPENVSWITCH_OFP_CONNECTION_H 1 | ||
|
||
#include "openflow/openflow.h" | ||
#include "openvswitch/ofp-protocol.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Abstract ofp_role_request and reply. */ | ||
struct ofputil_role_request { | ||
enum ofp12_controller_role role; | ||
bool have_generation_id; | ||
uint64_t generation_id; | ||
}; | ||
|
||
struct ofputil_role_status { | ||
enum ofp12_controller_role role; | ||
enum ofp14_controller_role_reason reason; | ||
uint64_t generation_id; | ||
}; | ||
|
||
enum ofperr ofputil_decode_role_message(const struct ofp_header *, | ||
struct ofputil_role_request *); | ||
struct ofpbuf *ofputil_encode_role_reply(const struct ofp_header *, | ||
const struct ofputil_role_request *); | ||
|
||
struct ofpbuf *ofputil_encode_role_status(const struct ofputil_role_status *, | ||
enum ofputil_protocol); | ||
|
||
enum ofperr ofputil_decode_role_status(const struct ofp_header *, | ||
struct ofputil_role_status *); | ||
|
||
enum ofputil_async_msg_type { | ||
/* Standard asynchronous messages. */ | ||
OAM_PACKET_IN, /* OFPT_PACKET_IN or NXT_PACKET_IN. */ | ||
OAM_PORT_STATUS, /* OFPT_PORT_STATUS. */ | ||
OAM_FLOW_REMOVED, /* OFPT_FLOW_REMOVED or NXT_FLOW_REMOVED. */ | ||
OAM_ROLE_STATUS, /* OFPT_ROLE_STATUS. */ | ||
OAM_TABLE_STATUS, /* OFPT_TABLE_STATUS. */ | ||
OAM_REQUESTFORWARD, /* OFPT_REQUESTFORWARD. */ | ||
|
||
/* Extension asynchronous messages (none yet--coming soon!). */ | ||
#define OAM_EXTENSIONS 0 /* Bitmap of all extensions. */ | ||
|
||
OAM_N_TYPES | ||
}; | ||
const char *ofputil_async_msg_type_to_string(enum ofputil_async_msg_type); | ||
|
||
struct ofputil_async_cfg { | ||
uint32_t master[OAM_N_TYPES]; | ||
uint32_t slave[OAM_N_TYPES]; | ||
}; | ||
#define OFPUTIL_ASYNC_CFG_INIT (struct ofputil_async_cfg) { .master[0] = 0 } | ||
|
||
enum ofperr ofputil_decode_set_async_config(const struct ofp_header *, | ||
bool loose, | ||
const struct ofputil_async_cfg *, | ||
struct ofputil_async_cfg *); | ||
|
||
struct ofpbuf *ofputil_encode_get_async_reply( | ||
const struct ofp_header *, const struct ofputil_async_cfg *); | ||
struct ofpbuf *ofputil_encode_set_async_config( | ||
const struct ofputil_async_cfg *, uint32_t oams, enum ofp_version); | ||
|
||
struct ofputil_async_cfg ofputil_async_cfg_default(enum ofp_version); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ofp-connection.h */ |
Oops, something went wrong.