summaryrefslogtreecommitdiffstats
path: root/nuttx/include/net
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2010-07-13 15:12:40 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2010-07-13 15:12:40 +0000
commit6c4dff07a2806f7dbd3d06302ffeb84d44515ddd (patch)
treec45dbdd3ae1509470c5d91e066c3269a653adc19 /nuttx/include/net
parent1fce3114030e89bddec00f0b1b38b126f9a3f6c6 (diff)
Add IP options
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@2792 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/include/net')
-rw-r--r--nuttx/include/net/uip/uip.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/nuttx/include/net/uip/uip.h b/nuttx/include/net/uip/uip.h
index fd93736661..a651b68f63 100644
--- a/nuttx/include/net/uip/uip.h
+++ b/nuttx/include/net/uip/uip.h
@@ -150,6 +150,62 @@
# define UIP_IPH_LEN 20 /* Size of IP header */
#endif
+/* IP Header Options:
+ *
+ * The basic 20-byte IP header can be extended by up to another 40 bytes
+ * (in units of 4 bytes) to provide IP options. The format of a single IP
+ * option is as follows:
+ *
+ * Single byte options:
+ *
+ * Type: 8-bits
+ *
+ * Multi-byte options:
+ *
+ * Type: 8-bits
+ * Length: 8-bits
+ * Pointer: 8-bits:
+ * Option Data: (depends on Length)
+ *
+ * The IP Option Type byte consists of the following subfields:
+ */
+
+#define IPOPT_TYPE_OPTION_SHIFT (0) /* Bits 0-5: Option number*/
+#define IPOPT_TYPE_OPTION_MASK (0x1f << IPOPT_TYPE_OPTION_SHIFT)
+# define IPOPT_TYPE_OPTION_END (0 << IPOPT_TYPE_OPTION_SHIFT) /* End of options list */
+# define IPOPT_TYPE_OPTION_NOOP (1 << IPOPT_TYPE_OPTION_SHIFT) /* No operation */
+# define IPOPT_TYPE_OPTION_SEC (2 << IPOPT_TYPE_OPTION_SHIFT) /* Security */
+# define IPOPT_TYPE_OPTION_LSRR (3 << IPOPT_TYPE_OPTION_SHIFT) /* Loose source and record route */
+# define IPOPT_TYPE_OPTION_TIMESTAMP (4 << IPOPT_TYPE_OPTION_SHIFT) /* Timestamp */
+# define IPOPT_TYPE_OPTION_RR (7 << IPOPT_TYPE_OPTION_SHIFT) /* Record route */
+# define IPOPT_TYPE_OPTION_SSID (8 << IPOPT_TYPE_OPTION_SHIFT) /* Stream ID */
+# define IPOPT_TYPE_OPTION_SSRR (9 << IPOPT_TYPE_OPTION_SHIFT) /* Strict source and record route */
+# define IPOPT_TYPE_OPTION_RA (20 << IPOPT_TYPE_OPTION_SHIFT) /* Router alert */
+#define IPOPT_TYPE_CLASS_SHIFT (5) /* Bits 5-6: Class */
+#define IPOPT_TYPE_CLASS_MASK (3 << IPOPT_TYPE_CLASS_SHIFT)
+# define IPOPT_TYPE_CLASS_CTRL (0 << IPOPT_TYPE_CLASS_SHIFT) /* Control */
+# define IPOPT_TYPE_CLASS_MEASURE (2 << IPOPT_TYPE_CLASS_SHIFT) /* Debugging and measurement */
+#define IPOPT_TYPE_COPIED (1 << 7) /* Bit 7: IP layer must copy option to each fragment */
+
+/* IP Option encoding macros */
+
+#define IPOPT_MKTYPE(copied,class,option) (copied|class|option)
+
+#define IPOPT_MKOPTION8(copied,class,option) \
+ ((uint8_t)IPOPT_MKTYPE(copied,class,option))
+#define IPOPT_MKOPTION32(copied,class,option,len,ptr,data) \
+ ((uint32_t)IPORT_MKTYPE(copied,class,option) << 24 | \
+ (uint32_t)len << 16) | (uint32_t)data << 8 | (uint32_t)data)
+
+/* Some useful pre-defined IP options */
+
+#define IPOPT_END \
+ IPOPT_MKOPTION8(0, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_END)
+#define IPOPT_NOOP \
+ IPOPT_MKOPTION8(0, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_NOOP)
+#define IPOPT_RA \
+ IPOPT_MKOPTION32(IPOPT_TYPE_COPIED, IPOPT_TYPE_CLASS_CTRL, IPOPT_TYPE_OPTION_RA, 4, 0, 0)
+
/****************************************************************************
* Public Type Definitions
****************************************************************************/