struct ofpbuf * flow_mod_conjunction(enum ofputil_protocol proto) { struct ofputil_flow_mod fm; struct ofpbuf acts; struct ofpact_conjunction *a_conj; memset(&fm, 0, sizeof(fm)); fm.command = OFPFC_ADD; fm.table_id = 4; fm.new_cookie = htonll(0x123456789abcdef0); fm.cookie_mask = OVS_BE64_MAX; fm.importance = 0x9878; fill_match(&fm.match); ofpbuf_init(&acts, 64); a_conj = ofpact_put_CONJUNCTION(&acts); a_conj->id = 0xabcdef; a_conj->clause = 1; a_conj->n_clauses = 2; fm.ofpacts = acts.data; fm.ofpacts_len = acts.size; return ofputil_encode_flow_mod(&fm, proto); }
struct ofpbuf * flow_mod(enum ofputil_protocol proto) { struct ofputil_flow_mod fm; struct ofpbuf acts; struct ofpact_ipv4 *a_set_field; struct ofpact_goto_table *a_goto; memset(&fm, 0, sizeof(fm)); fm.command = OFPFC_ADD; fm.table_id = 2; fm.new_cookie = htonll(0x123456789abcdef0); fm.cookie_mask = OVS_BE64_MAX; fm.importance = 0x9878; fill_match(&fm.match); ofpbuf_init(&acts, 64); ofpact_put_STRIP_VLAN(&acts); a_set_field = ofpact_put_SET_IPV4_DST(&acts); a_set_field->ipv4 = inet_addr("192.168.2.9"); a_goto = ofpact_put_GOTO_TABLE(&acts); a_goto->table_id = 100; fm.ofpacts = acts.data; fm.ofpacts_len = acts.size; return ofputil_encode_flow_mod(&fm, proto); }
struct ofpbuf * flow_mod(enum ofputil_protocol proto) { struct ofputil_flow_mod fm; struct ofpbuf acts; struct ofpact_ipv4 *a_set_field; struct ofpact_goto_table *a_goto; char *error; /* * Taken from neutron OVS-agent, * modified for OF>=1.3. (NXM -> OXM) * NOTE(yamamoto): This needs to be writable. learn_parse() modifies it. */ char learn_args[] = "table=99," "priority=1," "hard_timeout=300," "OXM_OF_VLAN_VID[0..11]," "OXM_OF_ETH_DST[]=OXM_OF_ETH_SRC[]," "load:0->OXM_OF_VLAN_VID[]," "load:OXM_OF_TUNNEL_ID[]->OXM_OF_TUNNEL_ID[]," "output:OXM_OF_IN_PORT[]"; memset(&fm, 0, sizeof(fm)); fm.command = OFPFC_ADD; fm.table_id = 2; fm.new_cookie = htonll(0x123456789abcdef0); fm.cookie_mask = OVS_BE64_MAX; fm.importance = 0x9878; fill_match(&fm.match); ofpbuf_init(&acts, 64); ofpact_put_STRIP_VLAN(&acts); a_set_field = ofpact_put_SET_IPV4_DST(&acts); a_set_field->ipv4 = inet_addr("192.168.2.9"); error = learn_parse(learn_args, &acts); assert(error == NULL); a_goto = ofpact_put_GOTO_TABLE(&acts); a_goto->table_id = 100; fm.ofpacts = acts.data; fm.ofpacts_len = acts.size; return ofputil_encode_flow_mod(&fm, proto); }
struct ofpbuf * packet_in(enum ofputil_protocol proto) { struct ofputil_packet_in pin; struct match match; struct ofpbuf *buf; memset(&pin, 0, sizeof(pin)); pin.packet = "hoge"; pin.packet_len = 4; pin.total_len = 1000; pin.table_id = 100; pin.buffer_id = 200; fill_match(&match); flow_get_metadata(&match.flow, &pin.fmd); return ofputil_encode_packet_in(&pin, proto, NXPIF_OPENFLOW10); }
struct ofpbuf * flow_removed(enum ofputil_protocol proto) { struct ofputil_flow_removed fr; memset(&fr, 0, sizeof(fr)); fill_match(&fr.match); fr.cookie = htonll(0x123456789abcdef0); fr.priority = 100; fr.reason = 0; // OFPRR_IDLE_TIMEOUT fr.table_id = 1; fr.duration_sec = 600; fr.duration_nsec = 500; fr.idle_timeout = 400; fr.hard_timeout = 300; fr.packet_count = 200; fr.byte_count = 100; return ofputil_encode_flow_removed(&fr, proto); }