ip.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * INET An implementation of the TCP/IP protocol suite for the LINUX
  3. * operating system. INET is implemented using the BSD Socket
  4. * interface as the means of communication with the user level.
  5. *
  6. * Definitions for the IP protocol.
  7. *
  8. * Version: @(#)ip.h 1.0.2 04/28/93
  9. *
  10. * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version
  15. * 2 of the License, or (at your option) any later version.
  16. */
  17. #ifndef _LINUX_IP_H
  18. #define _LINUX_IP_H
  19. #include <linux/types.h>
  20. #include <asm/byteorder.h>
  21. #define IPTOS_TOS_MASK 0x1E
  22. #define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
  23. #define IPTOS_LOWDELAY 0x10
  24. #define IPTOS_THROUGHPUT 0x08
  25. #define IPTOS_RELIABILITY 0x04
  26. #define IPTOS_MINCOST 0x02
  27. #define IPTOS_PREC_MASK 0xE0
  28. #define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
  29. #define IPTOS_PREC_NETCONTROL 0xe0
  30. #define IPTOS_PREC_INTERNETCONTROL 0xc0
  31. #define IPTOS_PREC_CRITIC_ECP 0xa0
  32. #define IPTOS_PREC_FLASHOVERRIDE 0x80
  33. #define IPTOS_PREC_FLASH 0x60
  34. #define IPTOS_PREC_IMMEDIATE 0x40
  35. #define IPTOS_PREC_PRIORITY 0x20
  36. #define IPTOS_PREC_ROUTINE 0x00
  37. /* IP options */
  38. #define IPOPT_COPY 0x80
  39. #define IPOPT_CLASS_MASK 0x60
  40. #define IPOPT_NUMBER_MASK 0x1f
  41. #define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
  42. #define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
  43. #define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
  44. #define IPOPT_CONTROL 0x00
  45. #define IPOPT_RESERVED1 0x20
  46. #define IPOPT_MEASUREMENT 0x40
  47. #define IPOPT_RESERVED2 0x60
  48. #define IPOPT_END (0 |IPOPT_CONTROL)
  49. #define IPOPT_NOOP (1 |IPOPT_CONTROL)
  50. #define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY)
  51. #define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY)
  52. #define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT)
  53. #define IPOPT_CIPSO (6 |IPOPT_CONTROL|IPOPT_COPY)
  54. #define IPOPT_RR (7 |IPOPT_CONTROL)
  55. #define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY)
  56. #define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY)
  57. #define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY)
  58. #define IPVERSION 4
  59. #define MAXTTL 255
  60. #define IPDEFTTL 64
  61. #define IPOPT_OPTVAL 0
  62. #define IPOPT_OLEN 1
  63. #define IPOPT_OFFSET 2
  64. #define IPOPT_MINOFF 4
  65. #define MAX_IPOPTLEN 40
  66. #define IPOPT_NOP IPOPT_NOOP
  67. #define IPOPT_EOL IPOPT_END
  68. #define IPOPT_TS IPOPT_TIMESTAMP
  69. #define IPOPT_TS_TSONLY 0 /* timestamps only */
  70. #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
  71. #define IPOPT_TS_PRESPEC 3 /* specified modules only */
  72. #define IPV4_BEET_PHMAXLEN 8
  73. struct iphdr {
  74. #if defined(__LITTLE_ENDIAN_BITFIELD)
  75. __u8 ihl:4,
  76. version:4;
  77. #elif defined (__BIG_ENDIAN_BITFIELD)
  78. __u8 version:4,
  79. ihl:4;
  80. #else
  81. #error "Please fix <asm/byteorder.h>"
  82. #endif
  83. __u8 tos;
  84. __be16 tot_len;
  85. __be16 id;
  86. __be16 frag_off;
  87. __u8 ttl;
  88. __u8 protocol;
  89. __sum16 check;
  90. __be32 saddr;
  91. __be32 daddr;
  92. /*The options start here. */
  93. };
  94. struct ip_auth_hdr {
  95. __u8 nexthdr;
  96. __u8 hdrlen; /* This one is measured in 32 bit units! */
  97. __be16 reserved;
  98. __be32 spi;
  99. __be32 seq_no; /* Sequence number */
  100. __u8 auth_data[0]; /* Variable len but >=4. Mind the 64 bit alignment! */
  101. };
  102. struct ip_esp_hdr {
  103. __be32 spi;
  104. __be32 seq_no; /* Sequence number */
  105. __u8 enc_data[0]; /* Variable len but >=8. Mind the 64 bit alignment! */
  106. };
  107. struct ip_comp_hdr {
  108. __u8 nexthdr;
  109. __u8 flags;
  110. __be16 cpi;
  111. };
  112. struct ip_beet_phdr {
  113. __u8 nexthdr;
  114. __u8 hdrlen;
  115. __u8 padlen;
  116. __u8 reserved;
  117. };
  118. #endif /* _LINUX_IP_H */