Global replace of Nicira Networks.
[sliver-openvswitch.git] / lib / packets.h
index 9e283a5..f9e5bb6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
 
 struct ofpbuf;
 struct ds;
+struct flow;
 
 bool dpid_from_string(const char *s, uint64_t *dpidp);
 
@@ -333,11 +334,23 @@ struct ip_header {
 };
 BUILD_ASSERT_DECL(IP_HEADER_LEN == sizeof(struct ip_header));
 
-#define ICMP_HEADER_LEN 4
+#define ICMP_HEADER_LEN 8
 struct icmp_header {
     uint8_t icmp_type;
     uint8_t icmp_code;
     ovs_be16 icmp_csum;
+    union {
+        struct {
+            ovs_be16 id;
+            ovs_be16 seq;
+        } echo;
+        struct {
+            ovs_be16 empty;
+            ovs_be16 mtu;
+        } frag;
+        ovs_be32 gateway;
+    } icmp_fields;
+    uint8_t icmp_data[0];
 };
 BUILD_ASSERT_DECL(ICMP_HEADER_LEN == sizeof(struct icmp_header));
 
@@ -357,6 +370,7 @@ BUILD_ASSERT_DECL(UDP_HEADER_LEN == sizeof(struct udp_header));
 #define TCP_ACK 0x10
 #define TCP_URG 0x20
 
+#define TCP_CTL(flags, offset) (htons((flags) | ((offset) << 12)))
 #define TCP_FLAGS(tcp_ctl) (ntohs(tcp_ctl) & 0x003f)
 #define TCP_OFFSET(tcp_ctl) (ntohs(tcp_ctl) >> 12)
 
@@ -450,5 +464,12 @@ void *eth_compose(struct ofpbuf *, const uint8_t eth_dst[ETH_ADDR_LEN],
 void *snap_compose(struct ofpbuf *, const uint8_t eth_dst[ETH_ADDR_LEN],
                    const uint8_t eth_src[ETH_ADDR_LEN],
                    unsigned int oui, uint16_t snap_type, size_t size);
+void packet_set_ipv4(struct ofpbuf *, ovs_be32 src, ovs_be32 dst, uint8_t tos,
+                     uint8_t ttl);
+void packet_set_tcp_port(struct ofpbuf *, ovs_be16 src, ovs_be16 dst);
+void packet_set_udp_port(struct ofpbuf *, ovs_be16 src, ovs_be16 dst);
+
+uint8_t packet_get_tcp_flags(const struct ofpbuf *, const struct flow *);
+void packet_format_tcp_flags(struct ds *, uint8_t);
 
 #endif /* packets.h */