do_dump_flows(int argc, char *argv[])
{
struct ofp_flow_stats_request *req;
- uint16_t out_port;
+ struct parsed_flow pf;
struct ofpbuf *request;
req = alloc_stats_request(sizeof *req, OFPST_FLOW, &request);
- parse_ofp_str(argc > 2 ? argv[2] : "", &req->match, NULL,
- &req->table_id, &out_port, NULL, NULL, NULL, NULL);
+ parse_ofp_str(&pf, NULL, argc > 2 ? argv[2] : "");
+ flow_to_match(&pf.rule.flow, pf.rule.wc.wildcards, NXFF_OPENFLOW10,
+ &req->match);
memset(&req->pad, 0, sizeof req->pad);
- req->out_port = htons(out_port);
+ req->out_port = htons(pf.out_port);
dump_stats_transaction(argv[1], request);
}
{
struct ofp_aggregate_stats_request *req;
struct ofpbuf *request;
- uint16_t out_port;
+ struct parsed_flow pf;
req = alloc_stats_request(sizeof *req, OFPST_AGGREGATE, &request);
- parse_ofp_str(argc > 2 ? argv[2] : "", &req->match, NULL,
- &req->table_id, &out_port, NULL, NULL, NULL, NULL);
+ parse_ofp_str(&pf, NULL, argc > 2 ? argv[2] : "");
+ flow_to_match(&pf.rule.flow, pf.rule.wc.wildcards, NXFF_OPENFLOW10,
+ &req->match);
memset(&req->pad, 0, sizeof req->pad);
- req->out_port = htons(out_port);
+ req->out_port = htons(pf.out_port);
dump_stats_transaction(argv[1], request);
}
{
struct vconn *vconn;
struct ofpbuf *buffer;
- struct ofp_flow_mod *ofm;
- uint16_t priority, idle_timeout, hard_timeout;
- uint64_t cookie;
- struct ofp_match match;
-
- /* Parse and send. parse_ofp_str() will expand and reallocate the
- * data in 'buffer', so we can't keep pointers to across the
- * parse_ofp_str() call. */
- make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer);
- parse_ofp_str(argv[2], &match, buffer,
- NULL, NULL, &priority, &idle_timeout, &hard_timeout,
- &cookie);
- ofm = buffer->data;
- ofm->match = match;
- ofm->command = htons(OFPFC_ADD);
- ofm->cookie = htonll(cookie);
- ofm->idle_timeout = htons(idle_timeout);
- ofm->hard_timeout = htons(hard_timeout);
- ofm->buffer_id = htonl(UINT32_MAX);
- ofm->priority = htons(priority);
+
+ buffer = parse_ofp_flow_mod_str(argv[2], OFPFC_ADD);
open_vconn(argv[1], &vconn);
send_openflow_buffer(vconn, buffer);
static void
do_mod_flows(int argc OVS_UNUSED, char *argv[])
{
- uint16_t priority, idle_timeout, hard_timeout;
- uint64_t cookie;
struct vconn *vconn;
struct ofpbuf *buffer;
- struct ofp_flow_mod *ofm;
- struct ofp_match match;
-
- /* Parse and send. parse_ofp_str() will expand and reallocate the
- * data in 'buffer', so we can't keep pointers to across the
- * parse_ofp_str() call. */
- make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer);
- parse_ofp_str(argv[2], &match, buffer,
- NULL, NULL, &priority, &idle_timeout, &hard_timeout,
- &cookie);
- ofm = buffer->data;
- ofm->match = match;
- if (strict) {
- ofm->command = htons(OFPFC_MODIFY_STRICT);
- } else {
- ofm->command = htons(OFPFC_MODIFY);
- }
- ofm->idle_timeout = htons(idle_timeout);
- ofm->hard_timeout = htons(hard_timeout);
- ofm->cookie = htonll(cookie);
- ofm->buffer_id = htonl(UINT32_MAX);
- ofm->priority = htons(priority);
+ uint16_t command;
+ command = strict ? OFPFC_MODIFY_STRICT : OFPFC_MODIFY;
+ buffer = parse_ofp_flow_mod_str(argv[2], command);
open_vconn(argv[1], &vconn);
send_openflow_buffer(vconn, buffer);
vconn_close(vconn);
static void do_del_flows(int argc, char *argv[])
{
struct vconn *vconn;
- uint16_t priority;
- uint16_t out_port;
struct ofpbuf *buffer;
- struct ofp_flow_mod *ofm;
-
- /* Parse and send. */
- ofm = make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer);
- parse_ofp_str(argc > 2 ? argv[2] : "", &ofm->match, NULL, NULL,
- &out_port, &priority, NULL, NULL, NULL);
- if (strict) {
- ofm->command = htons(OFPFC_DELETE_STRICT);
- } else {
- ofm->command = htons(OFPFC_DELETE);
- }
- ofm->idle_timeout = htons(0);
- ofm->hard_timeout = htons(0);
- ofm->buffer_id = htonl(UINT32_MAX);
- ofm->out_port = htons(out_port);
- ofm->priority = htons(priority);
+ uint16_t command;
+
+ command = strict ? OFPFC_DELETE_STRICT : OFPFC_DELETE;
+ buffer = parse_ofp_flow_mod_str(argc > 2 ? argv[2] : "", command);
open_vconn(argv[1], &vconn);
send_openflow_buffer(vconn, buffer);