From: Ben Pfaff Date: Fri, 16 Jan 2009 17:45:43 +0000 (-0800) Subject: New functions make_flow_mod(), make_del_flow(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41bf64fb03bceec4c522678be49ab2effc4b45cc;p=openvswitch New functions make_flow_mod(), make_del_flow(). --- diff --git a/lib/vconn.c b/lib/vconn.c index f22d7feb..c9269b5f 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -859,8 +859,7 @@ update_openflow_length(struct ofpbuf *buffer) } struct ofpbuf * -make_add_flow(const struct flow *flow, uint32_t buffer_id, - uint16_t idle_timeout, size_t actions_len) +make_flow_mod(uint16_t command, const struct flow *flow, size_t actions_len) { struct ofp_flow_mod *ofm; size_t size = sizeof *ofm + actions_len; @@ -880,13 +879,31 @@ make_add_flow(const struct flow *flow, uint32_t buffer_id, ofm->match.nw_proto = flow->nw_proto; ofm->match.tp_src = flow->tp_src; ofm->match.tp_dst = flow->tp_dst; - ofm->command = htons(OFPFC_ADD); + ofm->command = htons(command); + return out; +} + +struct ofpbuf * +make_add_flow(const struct flow *flow, uint32_t buffer_id, + uint16_t idle_timeout, size_t actions_len) +{ + struct ofpbuf *out = make_flow_mod(OFPFC_ADD, flow, actions_len); + struct ofp_flow_mod *ofm = out->data; ofm->idle_timeout = htons(idle_timeout); ofm->hard_timeout = htons(OFP_FLOW_PERMANENT); ofm->buffer_id = htonl(buffer_id); return out; } +struct ofpbuf * +make_del_flow(const struct flow *flow) +{ + struct ofpbuf *out = make_flow_mod(OFPFC_DELETE_STRICT, flow, 0); + struct ofp_flow_mod *ofm = out->data; + ofm->out_port = htons(OFPP_NONE); + return out; +} + struct ofpbuf * make_add_simple_flow(const struct flow *flow, uint32_t buffer_id, uint16_t out_port, diff --git a/lib/vconn.h b/lib/vconn.h index c5123f97..fd384752 100644 --- a/lib/vconn.h +++ b/lib/vconn.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -87,8 +87,11 @@ void *put_openflow(size_t openflow_len, uint8_t type, struct ofpbuf *); void *put_openflow_xid(size_t openflow_len, uint8_t type, uint32_t xid, struct ofpbuf *); void update_openflow_length(struct ofpbuf *); +struct ofpbuf *make_flow_mod(uint16_t command, const struct flow *, + size_t actions_len); struct ofpbuf *make_add_flow(const struct flow *, uint32_t buffer_id, uint16_t max_idle, size_t actions_len); +struct ofpbuf *make_del_flow(const struct flow *); struct ofpbuf *make_add_simple_flow(const struct flow *, uint32_t buffer_id, uint16_t out_port, uint16_t max_idle);