Merge into master from pull request #283:
remove dead code and speed up match deserialization (https://github.com/floodlight/loxigen/pull/283)
diff --git a/c_gen/templates/loci_show.h b/c_gen/templates/loci_show.h
index 4179b13..aff632f 100644
--- a/c_gen/templates/loci_show.h
+++ b/c_gen/templates/loci_show.h
@@ -220,6 +220,7 @@
#define LOCI_SHOW_u32_role(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
#define LOCI_SHOW_u16_total_len(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
#define LOCI_SHOW_port_no_port_no(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
+#define LOCI_SHOW_port_no_loopback_port_no(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
#define LOCI_SHOW_mac_hw_addr(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
#define LOCI_SHOW_u32_config(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
#define LOCI_SHOW_u32_advertise(writer, cookie, val) LOCI_SHOW_x32(writer, cookie, val)
diff --git a/c_gen/templates/of_wire_buf.h b/c_gen/templates/of_wire_buf.h
index dfec5c3..0922a69 100644
--- a/c_gen/templates/of_wire_buf.h
+++ b/c_gen/templates/of_wire_buf.h
@@ -119,12 +119,6 @@
#define OF_OBJECT_TO_WBUF(obj) ((obj)->wbuf)
-
-/**
- * Minimum allocation size for wire buffer object
- */
-#define OF_WIRE_BUFFER_MIN_ALLOC_BYTES 128
-
/**
* Allocate a wire buffer object and the underlying data buffer.
* The wire buffer is initally empty (current_bytes == 0).
@@ -142,10 +136,6 @@
}
MEMSET(wbuf, 0, sizeof(of_wire_buffer_t));
- if (a_bytes < OF_WIRE_BUFFER_MIN_ALLOC_BYTES) {
- a_bytes = OF_WIRE_BUFFER_MIN_ALLOC_BYTES;
- }
-
if ((wbuf->buf = (uint8_t *)MALLOC(a_bytes)) == NULL) {
FREE(wbuf);
return NULL;
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
index 1c5be86..5e4e818 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
@@ -1,7 +1,13 @@
package org.projectfloodlight.openflow.types;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+
import javax.annotation.Nonnull;
+import com.google.common.base.Preconditions;
+
public abstract class IPAddress<F extends IPAddress<F>> implements OFValueType<F> {
public abstract IPVersion getIpVersion();
@@ -66,9 +72,7 @@
*/
@Nonnull
public static IPAddress<?> of(@Nonnull String ip) {
- if (ip == null) {
- throw new NullPointerException("String ip must not be null");
- }
+ Preconditions.checkNotNull(ip, "ip must not be null");
if (ip.indexOf('.') != -1)
return IPv4Address.of(ip);
else if (ip.indexOf(':') != -1)
@@ -77,4 +81,21 @@
throw new IllegalArgumentException("IP Address not well formed: " + ip);
}
+ /**
+ * Factory function for InetAddress values.
+ * @param address the InetAddress you wish to parse into an IPAddress object.
+ * @return the IPAddress object.
+ * @throws NullPointerException if address is null
+ */
+ @Nonnull
+ public static IPAddress<?> fromInetAddress(@Nonnull InetAddress address) {
+ Preconditions.checkNotNull(address, "address must not be null");
+ byte [] bytes = address.getAddress();
+ if(address instanceof Inet4Address)
+ return IPv4Address.of(bytes);
+ else if (address instanceof Inet6Address)
+ return IPv6Address.of(bytes);
+ else
+ return IPAddress.of(address.getHostAddress());
+ }
}
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
index 25fc943..865df75 100644
--- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
+++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
@@ -1,6 +1,9 @@
package org.projectfloodlight.openflow.types;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.net.UnknownHostException;
import org.junit.Test;
@@ -51,4 +54,14 @@
}
}
+ @Test
+ public void testFromInetAddressException() throws UnknownHostException {
+ try {
+ IPAddress.fromInetAddress(null);
+ fail("Should have thrown NullPointerException");
+ } catch (NullPointerException e) {
+ assertNotNull(e.getMessage());
+ }
+ }
+
}
diff --git a/openflow_input/bsn_vport b/openflow_input/bsn_vport
index 82d9d33..4f06462 100644
--- a/openflow_input/bsn_vport
+++ b/openflow_input/bsn_vport
@@ -48,6 +48,8 @@
/* DSCP flags are mutually exclusive */
OF_BSN_VPORT_L2GRE_DSCP_ASSIGN = 0x2,
OF_BSN_VPORT_L2GRE_DSCP_COPY = 0x4,
+
+ OF_BSN_VPORT_L2GRE_LOOPBACK_IS_VALID = 0x8,
};
// BSN Virtual port object header
@@ -79,16 +81,17 @@
uint16_t type == 1;
uint16_t length;
enum ofp_bsn_vport_l2gre_flags flags;
- of_port_no_t port_no; /* OF port number of parent */
- of_mac_addr_t local_mac; /* Local MAC */
- of_mac_addr_t nh_mac; /* Next Hop MAC */
- of_ipv4_t src_ip; /* Source IP */
- of_ipv4_t dst_ip; /* Destination IP */
+ of_port_no_t port_no; /* OF port number of parent */
+ of_port_no_t loopback_port_no; /* OF port number of loopback */
+ of_mac_addr_t local_mac; /* Local MAC */
+ of_mac_addr_t nh_mac; /* Next Hop MAC */
+ of_ipv4_t src_ip; /* Source IP */
+ of_ipv4_t dst_ip; /* Destination IP */
uint8_t dscp;
uint8_t ttl;
pad(2);
- uint32_t vpn; /* VPN ID (for GRE Key) */
- of_port_name_t if_name; /* Virtual Interface Name */
+ uint32_t vpn; /* VPN ID (for GRE Key) */
+ of_port_name_t if_name; /* Virtual Interface Name */
};
diff --git a/test_data/of13/bsn_virtual_port_create_request__l2gre.data b/test_data/of13/bsn_virtual_port_create_request__l2gre.data
index b5fd5fa..9d90293 100644
--- a/test_data/of13/bsn_virtual_port_create_request__l2gre.data
+++ b/test_data/of13/bsn_virtual_port_create_request__l2gre.data
@@ -1,13 +1,14 @@
-- binary
04 04 # version, type
-00 48 # len
+00 4c # len
01 02 03 04 # xid
00 5c 16 c7 # experimenter
00 00 00 0f # subtype
00 01 # vport type
-00 38 # vport len
+00 3c # vport len
00 00 00 03 # vport flags
-00 00 00 01 # vport port no
+00 00 00 01 # parent port no
+00 00 00 02 # loopback port no
0a 0b 0c 0d 0e 0f # local mac
01 02 03 04 05 06 # next hop mac
c0 00 00 02 # src ip
@@ -20,6 +21,7 @@
xid=0x01020304, vport=ofp.bsn_vport_l2gre(
flags=ofp.OF_BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID | ofp.OF_BSN_VPORT_L2GRE_DSCP_ASSIGN,
port_no=1,
+loopback_port_no=2,
local_mac=[0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f],
nh_mac=[0x01, 0x02, 0x03, 0x04, 0x05, 0x06],
src_ip=0xc0000002,
@@ -42,6 +44,7 @@
OF_BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID |
OF_BSN_VPORT_L2GRE_DSCP_ASSIGN);
of_bsn_vport_l2gre_port_no_set(vport, 1);
+ of_bsn_vport_l2gre_loopback_port_no_set(vport, 2);
of_bsn_vport_l2gre_local_mac_set(vport, local_mac);
of_bsn_vport_l2gre_nh_mac_set(vport, nh_mac);
of_bsn_vport_l2gre_src_ip_set(vport, 0xc0000002);
@@ -65,6 +68,7 @@
)
)
.setPortNo(OFPort.of(1))
+ .setLoopbackPortNo(OFPort.of(2))
.setLocalMac(MacAddress.of("0a:0b:0c:0d:0e:0f"))
.setNhMac(MacAddress.of("01:02:03:04:05:06"))
.setSrcIp(IPv4Address.of("192.0.0.2"))