Subversion Repositories HelenOS

Rev

Rev 4589 | 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. /**
  34.  * @file
  35.  */
  36.  
  37. #ifndef __NET_IP_CLIENT_H__
  38. #define __NET_IP_CLIENT_H__
  39.  
  40. #include "../structures/packet/packet.h"
  41.  
  42. #define IPVERSION   4
  43. #define MAXTTL      255
  44. #define IPDEFTTL    64
  45.  
  46. #define IPTOS_TOS_MASK              0x1E
  47. #define IPTOS_PRECEDENCE_SHIFT      5
  48. #define IPTOS_DELAY_SHIFT           4
  49. #define IPTOS_THROUGHPUT_SHIFT      3
  50. #define IPTOS_RELIABILITY_SHIFT     2
  51. #define IPTOS_COST_SHIFT            1
  52.  
  53. #define IPTOS_NORMALDELAY           ( 0x0 << IPTOS_DELAY_SHIFT )
  54. #define IPTOS_LOWDELAY              ( 0x1 << IPTOS_DELAY_SHIFT )
  55.  
  56. #define IPTOS_NORMALTHROUGHPUT      ( 0x0 << IPTOS_THROUGHPUT_SHIFT )
  57. #define IPTOS_THROUGHPUT            ( 0x1 << IPTOS_THROUGHPUT_SHIFT )
  58.  
  59. #define IPTOS_NORMALRELIABILITY     ( 0x0 << IPTOS_RELIABILITY_SHIFT )
  60. #define IPTOS_RELIABILITY           ( 0x1 << IPTOS_RELIABILITY_SHIFT )
  61.  
  62. #define IPTOS_NORMALCOST            ( 0x0 << IPTOS_COST_SHIFT )
  63. #define IPTOS_MICNCOST              ( 0x1 << IPTOS_COST_SHIFT )
  64.  
  65. #define IPTOS_PREC_MASK             0xE0
  66. #define IPTOS_PREC_ROUTINE          ( 0x0 << IPTOS_PRECEDENCE_SHIFT )
  67. #define IPTOS_PREC_PRIORITY         ( 0x1 << IPTOS_PRECEDENCE_SHIFT )
  68. #define IPTOS_PREC_IMMEDIATE        ( 0x2 << IPTOS_PRECEDENCE_SHIFT )
  69. #define IPTOS_PREC_FLASH            ( 0x3 << IPTOS_PRECEDENCE_SHIFT )
  70. #define IPTOS_PREC_FLASHOVERRIDE    ( 0x4 << IPTOS_PRECEDENCE_SHIFT )
  71. #define IPTOS_PREC_CRITIC_ECP       ( 0x5 << IPTOS_PRECEDENCE_SHIFT )
  72. #define IPTOS_PREC_INTERNETCONTROL  ( 0x6 << IPTOS_PRECEDENCE_SHIFT )
  73. #define IPTOS_PREC_NETCONTROL       ( 0x7 << IPTOS_PRECEDENCE_SHIFT )
  74.  
  75. #define IPOPT_COPY_SHIFT            7
  76. #define IPOPT_CLASS_SHIFT           5
  77. #define IPOPT_NUMBER_SHIFT          0
  78. #define IPOPT_CLASS_MASK            0x60
  79. #define IPOPT_NUMBER_MASK           0x1F
  80.  
  81. #define IPOPT_COPY                  ( 1 << IPOPT_COPY_SHIFT )
  82.  
  83. #define IPOPT_TYPE( copy, class, number )   ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK ))
  84.  
  85. #define IPOPT_COPIED( o )           (( o ) & IPOPT_COPY )
  86. #define IPOPT_CLASS( o )            (( o ) & IPOPT_CLASS_MASK )
  87. #define IPOPT_NUMBER( o )           (( o ) & IPOPT_NUMBER_MASK )
  88.  
  89. #define IPOPT_CONTROL               ( 0 << IPOPT_CLASS_SHIFT )
  90. #define IPOPT_RESERVED1             ( 1 << IPOPT_CLASS_SHIFT )
  91. #define IPOPT_MEASUREMENT           ( 2 << IPOPT_CLASS_SHIFT )
  92. #define IPOPT_RESERVED2             ( 3 << IPOPT_CLASS_SHIFT )
  93.  
  94. //#define IPOPT_END_OF_LIST     0x0
  95. #define IPOPT_END                   IPOPT_TYPE( 0, IPOPT_CONTROL, 0 )
  96. //#define IPOPT_NO_OPERATION        0x1
  97. #define IPOPT_NOOP                  IPOPT_TYPE( 0, IPOPT_CONTROL, 1 )
  98. //#define IPOPT_SECURITY            0x82
  99. #define IPOPT_SEC                   IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 )
  100. #define IPOPT_SEC_LENGTH            11
  101. #define IPOPT_SEC_UNCLASIFIED       0x0
  102. #define IPOPT_SEC_CONFIDENTIAL      0xF035
  103. #define IPOPT_SEC_EFTO              0x789A
  104. #define IPOPT_SEC_MMMM              0xBC4D
  105. #define IPOPT_SEC_PROG              0x5E26
  106. #define IPOPT_SEC_RESTRICTED        0xAF13
  107. #define IPOPT_SEC_SECRET            0xD788
  108. #define IPOPT_SEC_TOP_SECRET        0x6BC5
  109. //#define IPOPT_LOOSE_SOURCE        0x83
  110. #define IPOPT_LSRR                  IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 )
  111. //#define IPOPT_STRICT_SOURCE       0x89
  112. #define IPOPT_SSRR                  IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 )
  113. //#define IPOPT_RECORD_ROUTE        0x07
  114. #define IPOPT_RR                    IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 )
  115. //#define IPOPT_STREAM_IDENTIFIER   0x88
  116. #define IPOPT_SID                   IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 )
  117. #define IPOPT_SID_LENGTH            4
  118. //#define IPOPT_INTERNET_TIMESTAMP  0x44
  119. #define IPOPT_TIMESTAMP             IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 )
  120. #define IPOPT_CIPSO                 IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 )
  121.  
  122. #define IPOPT_NOP IPOPT_NOOP
  123. #define IPOPT_EOL IPOPT_END
  124. #define IPOPT_TS  IPOPT_TIMESTAMP
  125.  
  126. #define IPOPT_TS_TSONLY     0       /* timestamps only */
  127. #define IPOPT_TS_TSANDADDR  1       /* timestamps and addresses */
  128. #define IPOPT_TS_PRESPEC    3       /* specified modules only */
  129.  
  130. int ip_client_prepare_packet( packet_t packet, int protocol, int ttl, int tos, int dont_fragment, int ipopt_length );
  131.  
  132. // TODO ipopt manipulation
  133.  
  134. #endif
  135.  
  136. /** @}
  137.  */
  138.