socket-constants.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Socket constants which vary among Linux architectures.
  17. Copyright (C) 2019-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _SYS_SOCKET_H
  31. # error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
  32. #endif
  33. #include <bits/timesize.h>
  34. #define SOL_SOCKET 1
  35. #define SO_ACCEPTCONN 30
  36. #define SO_BROADCAST 6
  37. #define SO_DONTROUTE 5
  38. #define SO_ERROR 4
  39. #define SO_KEEPALIVE 9
  40. #define SO_LINGER 13
  41. #define SO_OOBINLINE 10
  42. #define SO_RCVBUF 8
  43. #define SO_RCVLOWAT 18
  44. #define SO_REUSEADDR 2
  45. #define SO_SNDBUF 7
  46. #define SO_SNDLOWAT 19
  47. #define SO_TYPE 3
  48. #if (__TIMESIZE == 64 && __WORDSIZE == 32 \
  49. && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
  50. # define SO_RCVTIMEO 66
  51. # define SO_SNDTIMEO 67
  52. # define SO_TIMESTAMP 63
  53. # define SO_TIMESTAMPNS 64
  54. # define SO_TIMESTAMPING 65
  55. #else
  56. # if __TIMESIZE == 64
  57. # define SO_RCVTIMEO 20
  58. # define SO_SNDTIMEO 21
  59. # define SO_TIMESTAMP 29
  60. # define SO_TIMESTAMPNS 35
  61. # define SO_TIMESTAMPING 37
  62. # else
  63. # define SO_RCVTIMEO_OLD 20
  64. # define SO_SNDTIMEO_OLD 21
  65. # define SO_RCVTIMEO_NEW 66
  66. # define SO_SNDTIMEO_NEW 67
  67. # define SO_TIMESTAMP_OLD 29
  68. # define SO_TIMESTAMPNS_OLD 35
  69. # define SO_TIMESTAMPING_OLD 37
  70. # define SO_TIMESTAMP_NEW 63
  71. # define SO_TIMESTAMPNS_NEW 64
  72. # define SO_TIMESTAMPING_NEW 65
  73. # ifdef __USE_TIME64_REDIRECTS
  74. # define SO_RCVTIMEO SO_RCVTIMEO_NEW
  75. # define SO_SNDTIMEO SO_SNDTIMEO_NEW
  76. # define SO_TIMESTAMP SO_TIMESTAMP_NEW
  77. # define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
  78. # define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
  79. # else
  80. # define SO_RCVTIMEO SO_RCVTIMEO_OLD
  81. # define SO_SNDTIMEO SO_SNDTIMEO_OLD
  82. # define SO_TIMESTAMP SO_TIMESTAMP_OLD
  83. # define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
  84. # define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
  85. # endif
  86. # endif
  87. #endif