source: mainline/uspace/srv/net/socket/socket_messages.h@ 3db8889

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