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