+static struct ip_header *
+pull_ip(struct ofpbuf *packet)
+{
+ if (packet->size >= IP_HEADER_LEN) {
+ struct ip_header *ip = packet->data;
+ int ip_len = IP_IHL(ip->ip_ihl_ver) * 4;
+ if (ip_len >= IP_HEADER_LEN && packet->size >= ip_len) {
+ return ofpbuf_pull(packet, ip_len);
+ }
+ }
+ return NULL;
+}
+
+static struct tcp_header *
+pull_tcp(struct ofpbuf *packet)
+{
+ if (packet->size >= TCP_HEADER_LEN) {
+ struct tcp_header *tcp = packet->data;
+ int tcp_len = TCP_OFFSET(tcp->tcp_ctl) * 4;
+ if (tcp_len >= TCP_HEADER_LEN && packet->size >= tcp_len) {
+ return ofpbuf_pull(packet, tcp_len);
+ }
+ }
+ return NULL;
+}
+
+static struct udp_header *
+pull_udp(struct ofpbuf *packet)
+{
+ return ofpbuf_try_pull(packet, UDP_HEADER_LEN);
+}
+
+static struct eth_header *
+pull_eth(struct ofpbuf *packet)
+{
+ return ofpbuf_try_pull(packet, ETH_HEADER_LEN);
+}
+
+static struct vlan_header *
+pull_vlan(struct ofpbuf *packet)