PageRenderTime 28ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/raw_ethernet/src_wrappers/sys_socket_h.ads

http://opencvada.googlecode.com/
Ada | 272 lines | 113 code | 47 blank | 112 comment | 0 complexity | a161010aa5d1eb1b74771f20b3b39b31 MD5 | raw file
  1. with Interfaces.C; use Interfaces.C;
  2. with bits_socket_h;
  3. with System;
  4. with stddef_h;
  5. with sys_types_h;
  6. with Linux_If_Packet_H;
  7. generic
  8. type Buffer_Type_Ptr is private;
  9. package sys_socket_h is
  10. ETH_FRAME_LEN : constant Integer := 1518;
  11. -- subtype Byte is Integer range 0 .. 255;
  12. -- type Super_Buffer_Type is array (Positive range <>) of Byte;
  13. -- type Buffer_Type is new Super_Buffer_Type (1 .. ETH_FRAME_LEN);
  14. -- pragma Pack (Buffer_Type);
  15. -- type Buffer_Type_Ptr is access all Buffer_Type;
  16. -- unsupported macro: SHUT_RD SHUT_RD
  17. -- unsupported macro: SHUT_WR SHUT_WR
  18. -- unsupported macro: SHUT_RDWR SHUT_RDWR
  19. -- Declarations of socket constants, types, and functions.
  20. -- Copyright (C) 1991,92,1994-2001,2003,2005,2007,2008
  21. -- Free Software Foundation, Inc.
  22. -- This file is part of the GNU C Library.
  23. -- The GNU C Library is free software; you can redistribute it and/or
  24. -- modify it under the terms of the GNU Lesser General Public
  25. -- License as published by the Free Software Foundation; either
  26. -- version 2.1 of the License, or (at your option) any later version.
  27. -- The GNU C Library is distributed in the hope that it will be useful,
  28. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  30. -- Lesser General Public License for more details.
  31. -- You should have received a copy of the GNU Lesser General Public
  32. -- License along with the GNU C Library; if not, write to the Free
  33. -- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  34. -- 02111-1307 USA.
  35. -- Get the __sigset_t definition.
  36. -- This operating system-specific header file defines the SOCK_*, PF_*,
  37. -- AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',
  38. -- `struct msghdr', and `struct linger' types.
  39. -- This is the 4.3 BSD `struct sockaddr' format, which is used as wire
  40. -- format in the grotty old 4.3 `talk' protocol.
  41. type osockaddr_sa_data_array is array (0 .. 13) of aliased unsigned_char;
  42. type osockaddr is record
  43. sa_family : aliased unsigned_short; -- /usr/include/sys/socket.h:47:24
  44. sa_data : aliased osockaddr_sa_data_array; -- /usr/include/sys/socket.h:48:29
  45. end record;
  46. pragma Convention (C, osockaddr); -- /usr/include/sys/socket.h:46:3
  47. -- The following constants should be used for the second parameter of
  48. -- `shutdown'.
  49. -- No more receptions.
  50. -- No more transmissions.
  51. -- No more receptions or transmissions.
  52. -- This is the type we use for generic socket address arguments.
  53. -- With GCC 2.7 and later, the funky union causes redeclarations or
  54. -- uses with any of the listed types to be allowed without complaint.
  55. -- G++ 2.7 does not support transparent unions so there we want the
  56. -- old-style declaration, too.
  57. -- Add more `struct sockaddr_AF' types here as necessary.
  58. -- These are all the ones I found on NetBSD and Linux.
  59. -- Create a new socket of type TYPE in domain DOMAIN, using
  60. -- protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
  61. -- Returns a file descriptor for the new socket, or -1 for errors.
  62. function socket
  63. (uu_domain : int;
  64. uu_type : int;
  65. uu_protocol : int) return int; -- /usr/include/sys/socket.h:105:62
  66. pragma Import (C, socket, "socket");
  67. -- Create two new sockets, of type TYPE in domain DOMAIN and using
  68. -- protocol PROTOCOL, which are connected to each other, and put file
  69. -- descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
  70. -- one will be chosen automatically. Returns 0 on success, -1 for errors.
  71. function socketpair
  72. (uu_domain : int;
  73. uu_type : int;
  74. uu_protocol : int;
  75. uu_fds : access int) return int; -- /usr/include/sys/socket.h:112:24
  76. pragma Import (C, socketpair, "socketpair");
  77. -- Give the socket FD the local address ADDR (which is LEN bytes long).
  78. function bind
  79. (uu_fd : int;
  80. uu_addr : access constant bits_socket_h.sockaddr;
  81. uu_len : bits_socket_h.socklen_t) return int; -- /usr/include/sys/socket.h:116:6
  82. pragma Import (C, bind, "bind");
  83. -- Put the local address of FD into *ADDR and its length in *LEN.
  84. function getsockname
  85. (uu_fd : int;
  86. uu_addr : access bits_socket_h.sockaddr;
  87. uu_len : access bits_socket_h.socklen_t) return int; -- /usr/include/sys/socket.h:120:33
  88. pragma Import (C, getsockname, "getsockname");
  89. -- Open a connection on socket FD to peer at ADDR (which LEN bytes long).
  90. -- For connectionless socket types, just set the default address to send to
  91. -- and the only address from which to accept transmissions.
  92. -- Return 0 on success, -1 for errors.
  93. -- This function is a cancellation point and therefore not marked with
  94. -- __THROW.
  95. function connect
  96. (uu_fd : int;
  97. uu_addr : access constant bits_socket_h.sockaddr;
  98. uu_len : bits_socket_h.socklen_t) return int; -- /usr/include/sys/socket.h:129:75
  99. pragma Import (C, connect, "connect");
  100. -- Put the address of the peer connected to socket FD into *ADDR
  101. -- (which is *LEN bytes long), and its actual length into *LEN.
  102. function getpeername
  103. (uu_fd : int;
  104. uu_addr : access bits_socket_h.sockaddr;
  105. uu_len : access bits_socket_h.socklen_t) return int; -- /usr/include/sys/socket.h:134:33
  106. pragma Import (C, getpeername, "getpeername");
  107. -- Send N bytes of BUF to socket FD. Returns the number sent or -1.
  108. -- This function is a cancellation point and therefore not marked with
  109. -- __THROW.
  110. function send
  111. (uu_fd : int;
  112. uu_buf : System.Address;
  113. uu_n : stddef_h.size_t;
  114. uu_flags : int) return sys_types_h.ssize_t; -- /usr/include/sys/socket.h:141:76
  115. pragma Import (C, send, "send");
  116. -- Read N bytes into BUF from socket FD.
  117. -- Returns the number read or -1 for errors.
  118. -- This function is a cancellation point and therefore not marked with
  119. -- __THROW.
  120. function recv
  121. (uu_fd : int;
  122. uu_buf : System.Address;
  123. uu_n : stddef_h.size_t;
  124. uu_flags : int) return sys_types_h.ssize_t; -- /usr/include/sys/socket.h:148:68
  125. pragma Import (C, recv, "recv");
  126. -- Send N bytes of BUF on socket FD to peer at address ADDR (which is
  127. -- ADDR_LEN bytes long). Returns the number sent, or -1 for errors.
  128. -- This function is a cancellation point and therefore not marked with
  129. -- __THROW.
  130. function sendto
  131. (uu_fd : int;
  132. uu_buf : Buffer_Type_Ptr;
  133. uu_n : stddef_h.size_t;
  134. uu_flags : int;
  135. --uu_addr : access constant bits_socket_h.sockaddr;
  136. Uu_Addr : access constant Linux_If_Packet_H.Sockaddr_Ll;
  137. uu_addr_len : bits_socket_h.socklen_t) return sys_types_h.ssize_t; -- /usr/include/sys/socket.h:157:30
  138. pragma Import (C, sendto, "sendto");
  139. -- Read N bytes into BUF through socket FD.
  140. -- If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
  141. -- the sender, and store the actual size of the address in *ADDR_LEN.
  142. -- Returns the number of bytes read or -1 for errors.
  143. -- This function is a cancellation point and therefore not marked with
  144. -- __THROW.
  145. function recvfrom
  146. (uu_fd : int;
  147. Uu_Buf : Buffer_Type_Ptr;
  148. uu_n : stddef_h.size_t;
  149. uu_flags : int;
  150. uu_addr : access Linux_If_Packet_H.Sockaddr_Ll;
  151. Uu_Addr_Len : access Unsigned) return Sys_Types_H.Ssize_T; -- /usr/include/sys/socket.h:168:37
  152. pragma Import (C, recvfrom, "recvfrom");
  153. -- Send a message described MESSAGE on socket FD.
  154. -- Returns the number of bytes sent, or -1 for errors.
  155. -- This function is a cancellation point and therefore not marked with
  156. -- __THROW.
  157. function sendmsg
  158. (uu_fd : int;
  159. uu_message : access constant bits_socket_h.msghdr;
  160. uu_flags : int) return sys_types_h.ssize_t; -- /usr/include/sys/socket.h:177:15
  161. pragma Import (C, sendmsg, "sendmsg");
  162. -- Receive a message as described by MESSAGE from socket FD.
  163. -- Returns the number of bytes read or -1 for errors.
  164. -- This function is a cancellation point and therefore not marked with
  165. -- __THROW.
  166. function recvmsg
  167. (uu_fd : int;
  168. uu_message : access bits_socket_h.msghdr;
  169. uu_flags : int) return sys_types_h.ssize_t; -- /usr/include/sys/socket.h:184:72
  170. pragma Import (C, recvmsg, "recvmsg");
  171. -- Put the current value for socket FD's option OPTNAME at protocol level LEVEL
  172. -- into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
  173. -- actual length. Returns 0 on success, -1 for errors.
  174. function getsockopt
  175. (uu_fd : int;
  176. uu_level : int;
  177. uu_optname : int;
  178. uu_optval : System.Address;
  179. uu_optlen : access bits_socket_h.socklen_t) return int; -- /usr/include/sys/socket.h:192:42
  180. pragma Import (C, getsockopt, "getsockopt");
  181. -- Set socket FD's option OPTNAME at protocol level LEVEL
  182. -- to *OPTVAL (which is OPTLEN bytes long).
  183. -- Returns 0 on success, -1 for errors.
  184. function setsockopt
  185. (uu_fd : int;
  186. uu_level : int;
  187. uu_optname : int;
  188. uu_optval : System.Address;
  189. uu_optlen : bits_socket_h.socklen_t) return int; -- /usr/include/sys/socket.h:198:54
  190. pragma Import (C, setsockopt, "setsockopt");
  191. -- Prepare to accept connections on socket FD.
  192. -- N connection requests will be queued before further requests are refused.
  193. -- Returns 0 on success, -1 for errors.
  194. function listen (uu_fd : int; uu_n : int) return int; -- /usr/include/sys/socket.h:204:39
  195. pragma Import (C, listen, "listen");
  196. -- Await a connection on socket FD.
  197. -- When a connection arrives, open a new socket to communicate with it,
  198. -- set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
  199. -- peer and *ADDR_LEN to the address's actual length, and return the
  200. -- new socket's descriptor, or -1 for errors.
  201. -- This function is a cancellation point and therefore not marked with
  202. -- __THROW.
  203. function c_accept
  204. (uu_fd : int;
  205. uu_addr : access bits_socket_h.sockaddr;
  206. uu_addr_len : access bits_socket_h.socklen_t) return int; -- /usr/include/sys/socket.h:215:38
  207. pragma Import (C, c_accept, "accept");
  208. -- Shut down all or part of the connection open on socket FD.
  209. -- HOW determines what to shut down:
  210. -- SHUT_RD = No more receptions;
  211. -- SHUT_WR = No more transmissions;
  212. -- SHUT_RDWR = No more receptions or transmissions.
  213. -- Returns 0 on success, -1 for errors.
  214. function shutdown (uu_fd : int; uu_how : int) return int; -- /usr/include/sys/socket.h:223:43
  215. pragma Import (C, shutdown, "shutdown");
  216. -- Determine wheter socket is at a out-of-band mark.
  217. function sockatmark (uu_fd : int) return int; -- /usr/include/sys/socket.h:228:34
  218. pragma Import (C, sockatmark, "sockatmark");
  219. -- FDTYPE is S_IFSOCK or another S_IF* macro defined in <sys/stat.h>;
  220. -- returns 1 if FD is open on an object of the indicated type, 0 if not,
  221. -- or -1 for errors (setting errno).
  222. function isfdtype (uu_fd : int; uu_fdtype : int) return int; -- /usr/include/sys/socket.h:236:46
  223. pragma Import (C, isfdtype, "isfdtype");
  224. -- Define some macros helping to catch buffer overflows.
  225. end sys_socket_h;