summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-13 15:12:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-13 15:12:40 +0000
commit651be58ca1824db42ffea1dad6f5bf0e41bebf8e (patch)
treec45dbdd3ae1509470c5d91e066c3269a653adc19
parent7569e53f92cc6c313c8642a8cc53dfacea63382b (diff)
downloadnuttx-651be58ca1824db42ffea1dad6f5bf0e41bebf8e.tar.gz
nuttx-651be58ca1824db42ffea1dad6f5bf0e41bebf8e.tar.bz2
nuttx-651be58ca1824db42ffea1dad6f5bf0e41bebf8e.zip
Add IP options
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2792 42af7a65-404d-4744-a932-0658087f49c3
-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 fd9373666..a651b68f6 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
****************************************************************************/