source: mainline/uspace/lib/c/include/ipc/socket.h@ c8916d15

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c8916d15 was c8916d15, checked in by Jiri Svoboda <jiri@…>, 13 years ago

More cleanup.

  • Property mode set to 100644
File size: 6.4 KB
RevLine 
[21580dd]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
[88e127ee]29/** @addtogroup libc
30 * @{
[21580dd]31 */
32
33/** @file
[88e127ee]34 * Socket messages.
[21580dd]35 */
36
[88e127ee]37#ifndef LIBC_SOCKET_MESSAGES_H_
38#define LIBC_SOCKET_MESSAGES_H_
[21580dd]39
[88e127ee]40/** Socket client messages. */
41typedef enum {
42 /** Creates a new socket. @see socket() */
[c8916d15]43 NET_SOCKET = IPC_FIRST_USER_METHOD,
[88e127ee]44 /** Binds the socket. @see bind() */
[21580dd]45 NET_SOCKET_BIND,
[88e127ee]46 /** Creates a new socket. @see socket() */
[21580dd]47 NET_SOCKET_LISTEN,
[88e127ee]48 /** Accepts an incomming connection. @see accept() */
[21580dd]49 NET_SOCKET_ACCEPT,
[88e127ee]50 /** Connects the socket. @see connect() */
[21580dd]51 NET_SOCKET_CONNECT,
[88e127ee]52 /** Closes the socket. @see closesocket() */
[21580dd]53 NET_SOCKET_CLOSE,
[88e127ee]54 /** Sends data via the stream socket. @see send() */
[21580dd]55 NET_SOCKET_SEND,
[88e127ee]56 /** Sends data via the datagram socket. @see sendto() */
[21580dd]57 NET_SOCKET_SENDTO,
[88e127ee]58 /** Receives data from the stream socket. @see socket() */
[21580dd]59 NET_SOCKET_RECV,
[88e127ee]60 /** Receives data from the datagram socket. @see socket() */
[21580dd]61 NET_SOCKET_RECVFROM,
[88e127ee]62 /** Gets the socket option. @see getsockopt() */
[21580dd]63 NET_SOCKET_GETSOCKOPT,
[88e127ee]64 /** Sets the socket option. @see setsockopt() */
[21580dd]65 NET_SOCKET_SETSOCKOPT,
[88e127ee]66 /** New socket for acceptence notification message. */
[21580dd]67 NET_SOCKET_ACCEPTED,
[88e127ee]68 /** New data received notification message. */
[21580dd]69 NET_SOCKET_RECEIVED,
[88e127ee]70 /** New socket data fragment size notification message. */
[21580dd]71 NET_SOCKET_DATA_FRAGMENT_SIZE
72} socket_messages;
73
74/** @name Socket specific message parameters definitions
75 */
76/*@{*/
77
78/** Sets the socket identifier in the message answer.
[88e127ee]79 * @param[out] answer The message answer structure.
[21580dd]80 */
[e417b96]81#define SOCKET_SET_SOCKET_ID(answer, value) \
[88e127ee]82 do { \
[96b02eb9]83 sysarg_t argument = (sysarg_t) (value); \
[88e127ee]84 IPC_SET_ARG1(answer, argument); \
85 } while (0)
[21580dd]86
87/** Returns the socket identifier message parameter.
[88e127ee]88 * @param[in] call The message call structure.
[21580dd]89 */
[e417b96]90#define SOCKET_GET_SOCKET_ID(call) \
[88e127ee]91 ({ \
92 int socket_id = (int) IPC_GET_ARG1(call); \
93 socket_id; \
94 })
[21580dd]95
96/** Sets the read data length in the message answer.
[88e127ee]97 * @param[out] answer The message answer structure.
[21580dd]98 */
[e417b96]99#define SOCKET_SET_READ_DATA_LENGTH(answer, value) \
[88e127ee]100 do { \
[96b02eb9]101 sysarg_t argument = (sysarg_t) (value); \
[88e127ee]102 IPC_SET_ARG1(answer, argument); \
103 } while (0)
[21580dd]104
105/** Returns the read data length message parameter.
[88e127ee]106 * @param[in] call The message call structure.
[21580dd]107 */
[e417b96]108#define SOCKET_GET_READ_DATA_LENGTH(call) \
[88e127ee]109 ({ \
110 int data_length = (int) IPC_GET_ARG1(call); \
111 data_length; \
112 })
[21580dd]113
114/** Returns the backlog message parameter.
[88e127ee]115 * @param[in] call The message call structure.
[21580dd]116 */
[e417b96]117#define SOCKET_GET_BACKLOG(call) \
[88e127ee]118 ({ \
119 int backlog = (int) IPC_GET_ARG2(call); \
120 backlog; \
121 })
[21580dd]122
123/** Returns the option level message parameter.
[88e127ee]124 * @param[in] call The message call structure.
[21580dd]125 */
[e417b96]126#define SOCKET_GET_OPT_LEVEL(call) \
[88e127ee]127 ({ \
128 int opt_level = (int) IPC_GET_ARG2(call); \
129 opt_level; \
130 })
[21580dd]131
132/** Returns the data fragment size message parameter.
[88e127ee]133 * @param[in] call The message call structure.
[21580dd]134 */
[e417b96]135#define SOCKET_GET_DATA_FRAGMENT_SIZE(call) \
[88e127ee]136 ({ \
137 size_t size = (size_t) IPC_GET_ARG2(call); \
138 size; \
139 })
[21580dd]140
141/** Sets the data fragment size in the message answer.
[88e127ee]142 * @param[out] answer The message answer structure.
[21580dd]143 */
[e417b96]144#define SOCKET_SET_DATA_FRAGMENT_SIZE(answer, value) \
[88e127ee]145 do { \
[96b02eb9]146 sysarg_t argument = (sysarg_t) (value); \
[88e127ee]147 IPC_SET_ARG2(answer, argument); \
148 } while (0)
[21580dd]149
[ede63e4]150/** Sets the address length in the message answer.
[88e127ee]151 * @param[out] answer The message answer structure.
[ede63e4]152 */
[e417b96]153#define SOCKET_SET_ADDRESS_LENGTH(answer, value) \
[88e127ee]154 do { \
[96b02eb9]155 sysarg_t argument = (sysarg_t) (value); \
[88e127ee]156 IPC_SET_ARG3(answer, argument);\
157 } while (0)
[ede63e4]158
159/** Returns the address length message parameter.
[88e127ee]160 * @param[in] call The message call structure.
[ede63e4]161 */
[e417b96]162#define SOCKET_GET_ADDRESS_LENGTH(call) \
[88e127ee]163 ({ \
164 socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); \
165 address_length; \
166 })
[ede63e4]167
[21580dd]168/** Sets the header size in the message answer.
[88e127ee]169 * @param[out] answer The message answer structure.
[21580dd]170 */
[e417b96]171#define SOCKET_SET_HEADER_SIZE(answer, value) \
[88e127ee]172 do { \
[96b02eb9]173 sysarg_t argument = (sysarg_t) (value); \
[88e127ee]174 IPC_SET_ARG3(answer, argument); \
175 } while (0)
[21580dd]176
177/** Returns the header size message parameter.
[88e127ee]178 * @param[in] call The message call structure.
[21580dd]179 */
[e417b96]180#define SOCKET_GET_HEADER_SIZE(call) \
[88e127ee]181 ({ \
182 size_t size = (size_t) IPC_GET_ARG3(call); \
183 size; \
184 })
[21580dd]185
186/** Returns the flags message parameter.
[88e127ee]187 * @param[in] call The message call structure.
[21580dd]188 */
[e417b96]189#define SOCKET_GET_FLAGS(call) \
[88e127ee]190 ({ \
191 int flags = (int) IPC_GET_ARG4(call); \
192 flags; \
193 })
[21580dd]194
195/** Returns the option name message parameter.
[88e127ee]196 * @param[in] call The message call structure.
[21580dd]197 */
[e417b96]198#define SOCKET_GET_OPT_NAME(call) \
[88e127ee]199 ({ \
200 int opt_name = (int) IPC_GET_ARG4(call); \
201 opt_name; \
202 })
[21580dd]203
204/** Returns the data fragments message parameter.
[88e127ee]205 * @param[in] call The message call structure.
[21580dd]206 */
[e417b96]207#define SOCKET_GET_DATA_FRAGMENTS(call) \
[88e127ee]208 ({ \
209 int fragments = (int) IPC_GET_ARG5(call); \
210 fragments; \
211 })
[21580dd]212
213/** Returns the new socket identifier message parameter.
[88e127ee]214 * @param[in] call The message call structure.
[21580dd]215 */
[e417b96]216#define SOCKET_GET_NEW_SOCKET_ID(call) \
[88e127ee]217 ({ \
218 int socket_id = (int) IPC_GET_ARG5(call); \
219 socket_id; \
220 })
[21580dd]221
222/*@}*/
223
224#endif
225
226/** @}
227 */
Note: See TracBrowser for help on using the repository browser.