Subversion Repositories HelenOS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (c) 2009 Lukas Mejdrech
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29. /** @addtogroup ip
  30.  *  @{
  31.  */
  32.  
  33. /** @file
  34.  *  \todo
  35.  */
  36.  
  37. #ifndef __NET_IP_CODES_H__
  38. #define __NET_IP_CODES_H__
  39.  
  40. #include <sys/types.h>
  41.  
  42. typedef uint8_t ip_ttl_t;
  43. typedef uint8_t ip_tos_t;
  44. typedef uint8_t ip_protocol_t;
  45.  
  46. #define IPVERSION   4
  47. #define MAXTTL      255
  48. #define IPDEFTTL    64
  49.  
  50. #define IPTOS_TOS_MASK              0x1E
  51. #define IPTOS_PRECEDENCE_SHIFT      5
  52. #define IPTOS_DELAY_SHIFT           4
  53. #define IPTOS_THROUGHPUT_SHIFT      3
  54. #define IPTOS_RELIABILITY_SHIFT     2
  55. #define IPTOS_COST_SHIFT            1
  56.  
  57. #define IPTOS_NORMALDELAY           ( 0x0 << IPTOS_DELAY_SHIFT )
  58. #define IPTOS_LOWDELAY              ( 0x1 << IPTOS_DELAY_SHIFT )
  59.  
  60. #define IPTOS_NORMALTHROUGHPUT      ( 0x0 << IPTOS_THROUGHPUT_SHIFT )
  61. #define IPTOS_THROUGHPUT            ( 0x1 << IPTOS_THROUGHPUT_SHIFT )
  62.  
  63. #define IPTOS_NORMALRELIABILITY     ( 0x0 << IPTOS_RELIABILITY_SHIFT )
  64. #define IPTOS_RELIABILITY           ( 0x1 << IPTOS_RELIABILITY_SHIFT )
  65.  
  66. #define IPTOS_NORMALCOST            ( 0x0 << IPTOS_COST_SHIFT )
  67. #define IPTOS_MICNCOST              ( 0x1 << IPTOS_COST_SHIFT )
  68.  
  69. #define IPTOS_PREC_MASK             0xE0
  70. #define IPTOS_PREC_ROUTINE          ( 0x0 << IPTOS_PRECEDENCE_SHIFT )
  71. #define IPTOS_PREC_PRIORITY         ( 0x1 << IPTOS_PRECEDENCE_SHIFT )
  72. #define IPTOS_PREC_IMMEDIATE        ( 0x2 << IPTOS_PRECEDENCE_SHIFT )
  73. #define IPTOS_PREC_FLASH            ( 0x3 << IPTOS_PRECEDENCE_SHIFT )
  74. #define IPTOS_PREC_FLASHOVERRIDE    ( 0x4 << IPTOS_PRECEDENCE_SHIFT )
  75. #define IPTOS_PREC_CRITIC_ECP       ( 0x5 << IPTOS_PRECEDENCE_SHIFT )
  76. #define IPTOS_PREC_INTERNETCONTROL  ( 0x6 << IPTOS_PRECEDENCE_SHIFT )
  77. #define IPTOS_PREC_NETCONTROL       ( 0x7 << IPTOS_PRECEDENCE_SHIFT )
  78.  
  79. #define IPOPT_COPY_SHIFT            7
  80. #define IPOPT_CLASS_SHIFT           5
  81. #define IPOPT_NUMBER_SHIFT          0
  82. #define IPOPT_CLASS_MASK            0x60
  83. #define IPOPT_NUMBER_MASK           0x1F
  84.  
  85. #define IPOPT_COPY                  ( 1 << IPOPT_COPY_SHIFT )
  86.  
  87. #define IPOPT_TYPE( copy, class, number )   ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK ))
  88.  
  89. #define IPOPT_COPIED( o )           (( o ) & IPOPT_COPY )
  90. #define IPOPT_CLASS( o )            (( o ) & IPOPT_CLASS_MASK )
  91. #define IPOPT_NUMBER( o )           (( o ) & IPOPT_NUMBER_MASK )
  92.  
  93. #define IPOPT_CONTROL               ( 0 << IPOPT_CLASS_SHIFT )
  94. #define IPOPT_RESERVED1             ( 1 << IPOPT_CLASS_SHIFT )
  95. #define IPOPT_MEASUREMENT           ( 2 << IPOPT_CLASS_SHIFT )
  96. #define IPOPT_RESERVED2             ( 3 << IPOPT_CLASS_SHIFT )
  97.  
  98. //#define IPOPT_END_OF_LIST     0x0
  99. #define IPOPT_END                   IPOPT_TYPE( 0, IPOPT_CONTROL, 0 )
  100. //#define IPOPT_NO_OPERATION        0x1
  101. #define IPOPT_NOOP                  IPOPT_TYPE( 0, IPOPT_CONTROL, 1 )
  102. //#define IPOPT_SECURITY            0x82
  103. #define IPOPT_SEC                   IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 )
  104. #define IPOPT_SEC_LENGTH            11
  105. #define IPOPT_SEC_UNCLASIFIED       0x0
  106. #define IPOPT_SEC_CONFIDENTIAL      0xF035
  107. #define IPOPT_SEC_EFTO              0x789A
  108. #define IPOPT_SEC_MMMM              0xBC4D
  109. #define IPOPT_SEC_PROG              0x5E26
  110. #define IPOPT_SEC_RESTRICTED        0xAF13
  111. #define IPOPT_SEC_SECRET            0xD788
  112. #define IPOPT_SEC_TOP_SECRET        0x6BC5
  113. //#define IPOPT_LOOSE_SOURCE        0x83
  114. #define IPOPT_LSRR                  IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 )
  115. //#define IPOPT_STRICT_SOURCE       0x89
  116. #define IPOPT_SSRR                  IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 )
  117. //#define IPOPT_RECORD_ROUTE        0x07
  118. #define IPOPT_RR                    IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 )
  119. //#define IPOPT_STREAM_IDENTIFIER   0x88
  120. #define IPOPT_SID                   IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 )
  121. #define IPOPT_SID_LENGTH            4
  122. //#define IPOPT_INTERNET_TIMESTAMP  0x44
  123. #define IPOPT_TIMESTAMP             IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 )
  124. #define IPOPT_CIPSO                 IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 )
  125.  
  126. #define IPOPT_NOP IPOPT_NOOP
  127. #define IPOPT_EOL IPOPT_END
  128. #define IPOPT_TS  IPOPT_TIMESTAMP
  129.  
  130. #define IPOPT_TS_TSONLY     0       /* timestamps only */
  131. #define IPOPT_TS_TSANDADDR  1       /* timestamps and addresses */
  132. #define IPOPT_TS_PRESPEC    3       /* specified modules only */
  133.  
  134. #endif
  135.  
  136. /** @}
  137.  */
  138.