Skip to content

Commit

Permalink
ofp-util.c: Enable packet-in messages for OpenFlow 1.4 and 1.5.
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com>
[blp@nicira.com added simple test]
Signed-off-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
Jean Tourrilhes authored and blp committed Nov 22, 2014
1 parent 98bb428 commit b6a3dd9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ofp-msgs.h
Expand Up @@ -148,7 +148,7 @@ enum ofpraw {
OFPRAW_OFPT11_PACKET_IN,
/* OFPT 1.2 (10): struct ofp12_packet_in, uint8_t[]. */
OFPRAW_OFPT12_PACKET_IN,
/* OFPT 1.3 (10): struct ofp13_packet_in, uint8_t[]. */
/* OFPT 1.3+ (10): struct ofp13_packet_in, uint8_t[]. */
OFPRAW_OFPT13_PACKET_IN,
/* NXT 1.0+ (17): struct nx_packet_in, uint8_t[]. */
OFPRAW_NXT_PACKET_IN,
Expand Down
4 changes: 2 additions & 2 deletions lib/ofp-util.c
Expand Up @@ -3527,7 +3527,7 @@ ofputil_encode_ofp12_packet_in(const struct ofputil_packet_in *pin,
packet_in_size = sizeof (struct ofp12_packet_in);
} else {
packet_in_raw = OFPRAW_OFPT13_PACKET_IN;
packet_in_version = OFP13_VERSION;
packet_in_version = ofputil_protocol_to_ofp_version(protocol);
packet_in_size = sizeof (struct ofp13_packet_in);
}

Expand All @@ -3547,7 +3547,7 @@ ofputil_encode_ofp12_packet_in(const struct ofputil_packet_in *pin,
opi->pi.total_len = htons(pin->total_len);
opi->pi.reason = pin->reason;
opi->pi.table_id = pin->table_id;
if (protocol == OFPUTIL_P_OF13_OXM) {
if (protocol != OFPUTIL_P_OF12_OXM) {
opi->cookie = pin->cookie;
}

Expand Down
30 changes: 30 additions & 0 deletions tests/ofp-print.at
Expand Up @@ -530,6 +530,36 @@ rarp,in_port=0,vlan_tci=0x0000,dl_src=00:23:20:83:c1:5f,dl_dst=ff:ff:ff:ff:ff:ff
])
AT_CLEANUP

AT_SETUP([OFPT_PACKET_IN - OF1.4])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
05 0a 00 54 00 00 00 00 ff ff ff 00 00 2a 00 00 \
01 02 03 04 05 06 07 08 00 01 00 0c 80 00 00 04 \
ff ff ff fe 00 00 00 00 00 00 ff ff ff ff ff ff \
00 23 20 83 c1 5f 80 35 00 01 08 00 06 04 00 03 \
00 23 20 83 c1 5f 00 00 00 00 00 23 20 83 c1 5f \
00 00 00 00 \
"], [0], [dnl
OFPT_PACKET_IN (OF1.4) (xid=0x0): cookie=0x102030405060708 total_len=42 in_port=LOCAL (via no_match) data_len=42 buffer=0xffffff00
rarp,in_port=0,vlan_tci=0x0000,dl_src=00:23:20:83:c1:5f,dl_dst=ff:ff:ff:ff:ff:ff,arp_spa=0.0.0.0,arp_tpa=0.0.0.0,arp_op=3,arp_sha=00:23:20:83:c1:5f,arp_tha=00:23:20:83:c1:5f
])
AT_CLEANUP

AT_SETUP([OFPT_PACKET_IN - OF1.5])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
06 0a 00 54 00 00 00 00 ff ff ff 00 00 2a 00 00 \
01 02 03 04 05 06 07 08 00 01 00 0c 80 00 00 04 \
ff ff ff fe 00 00 00 00 00 00 ff ff ff ff ff ff \
00 23 20 83 c1 5f 80 35 00 01 08 00 06 04 00 03 \
00 23 20 83 c1 5f 00 00 00 00 00 23 20 83 c1 5f \
00 00 00 00 \
"], [0], [dnl
OFPT_PACKET_IN (OF1.5) (xid=0x0): cookie=0x102030405060708 total_len=42 in_port=LOCAL (via no_match) data_len=42 buffer=0xffffff00
rarp,in_port=0,vlan_tci=0x0000,dl_src=00:23:20:83:c1:5f,dl_dst=ff:ff:ff:ff:ff:ff,arp_spa=0.0.0.0,arp_tpa=0.0.0.0,arp_op=3,arp_sha=00:23:20:83:c1:5f,arp_tha=00:23:20:83:c1:5f
])
AT_CLEANUP

AT_SETUP([OFPT_PACKET_IN - OF1.3, with hex output of packet data])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
Expand Down

0 comments on commit b6a3dd9

Please sign in to comment.