Rev 4743 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 4578 | mejdrech | 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 |
||
| 4704 | mejdrech | 34 | * Socket messages. |
| 35 | * @see socket.h |
||
| 4578 | mejdrech | 36 | */ |
| 37 | |||
| 4704 | mejdrech | 38 | |
| 4578 | mejdrech | 39 | #ifndef __NET_SOCKET_MESSAGES_H__ |
| 40 | #define __NET_SOCKET_MESSAGES_H__ |
||
| 41 | |||
| 42 | #include <ipc/ipc.h> |
||
| 43 | |||
| 44 | #include "../messages.h" |
||
| 45 | |||
| 4712 | mejdrech | 46 | #include "../include/socket_codes.h" |
| 4708 | mejdrech | 47 | |
| 4756 | mejdrech | 48 | /** Socket client messages. |
| 49 | */ |
||
| 4578 | mejdrech | 50 | typedef enum{ |
| 4756 | mejdrech | 51 | /** Creates a new socket. |
| 52 | * @see socket() |
||
| 53 | */ |
||
| 4578 | mejdrech | 54 | NET_SOCKET = NET_SOCKET_FIRST, |
| 4756 | mejdrech | 55 | /** Binds the socket. |
| 56 | * @see bind() |
||
| 57 | */ |
||
| 4578 | mejdrech | 58 | NET_SOCKET_BIND, |
| 4756 | mejdrech | 59 | /** Creates a new socket. |
| 60 | * @see socket() |
||
| 61 | */ |
||
| 4578 | mejdrech | 62 | NET_SOCKET_LISTEN, |
| 4756 | mejdrech | 63 | /** Accepts an incomming connection. |
| 64 | * @see accept() |
||
| 65 | */ |
||
| 4578 | mejdrech | 66 | NET_SOCKET_ACCEPT, |
| 4756 | mejdrech | 67 | /** Connects the socket. |
| 68 | * @see connect() |
||
| 69 | */ |
||
| 4578 | mejdrech | 70 | NET_SOCKET_CONNECT, |
| 4756 | mejdrech | 71 | /** Closes the socket. |
| 72 | * @see closesocket() |
||
| 73 | */ |
||
| 4578 | mejdrech | 74 | NET_SOCKET_CLOSE, |
| 4756 | mejdrech | 75 | /** Sends data via the stream socket. |
| 76 | * @see send() |
||
| 77 | */ |
||
| 4578 | mejdrech | 78 | NET_SOCKET_SEND, |
| 4756 | mejdrech | 79 | /** Sends data via the datagram socket. |
| 80 | * @see sendto() |
||
| 81 | */ |
||
| 4578 | mejdrech | 82 | NET_SOCKET_SENDTO, |
| 4756 | mejdrech | 83 | /** Receives data from the stream socket. |
| 84 | * @see socket() |
||
| 85 | */ |
||
| 4578 | mejdrech | 86 | NET_SOCKET_RECV, |
| 4756 | mejdrech | 87 | /** Receives data from the datagram socket. |
| 88 | * @see socket() |
||
| 89 | */ |
||
| 4578 | mejdrech | 90 | NET_SOCKET_RECVFROM, |
| 4756 | mejdrech | 91 | /** Gets the socket option. |
| 92 | * @see getsockopt() |
||
| 93 | */ |
||
| 4578 | mejdrech | 94 | NET_SOCKET_GETSOCKOPT, |
| 4756 | mejdrech | 95 | /** Sets the socket option. |
| 96 | * @see setsockopt() |
||
| 97 | */ |
||
| 4578 | mejdrech | 98 | NET_SOCKET_SETSOCKOPT, |
| 4756 | mejdrech | 99 | /** New socket for acceptence notification message. |
| 100 | */ |
||
| 4578 | mejdrech | 101 | NET_SOCKET_ACCEPTED, |
| 4756 | mejdrech | 102 | /** New data received notification message. |
| 103 | */ |
||
| 4589 | mejdrech | 104 | NET_SOCKET_RECEIVED, |
| 4756 | mejdrech | 105 | /** New socket data fragment size notification message. |
| 106 | */ |
||
| 4589 | mejdrech | 107 | NET_SOCKET_DATA_FRAGMENT_SIZE |
| 4578 | mejdrech | 108 | } socket_messages; |
| 109 | |||
| 4704 | mejdrech | 110 | /** @name Socket specific message parameters definitions |
| 111 | */ |
||
| 112 | /*@{*/ |
||
| 4578 | mejdrech | 113 | |
| 4756 | mejdrech | 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 ) ( int * ) & IPC_GET_ARG1( answer ) |
||
| 4578 | mejdrech | 118 | |
| 4756 | mejdrech | 119 | /** Returns the socket identifier message parameter. |
| 120 | * @param[in] call The message call structure. |
||
| 121 | */ |
||
| 122 | #define SOCKET_GET_SOCKET_ID( call ) ( int ) IPC_GET_ARG1( call ) |
||
| 123 | |||
| 124 | /** Sets the read data length in the message answer. |
||
| 125 | * @param[out] answer The message answer structure. |
||
| 126 | */ |
||
| 127 | #define SOCKET_SET_READ_DATA_LENGTH( answer ) ( int * ) & IPC_GET_ARG1( answer ) |
||
| 128 | |||
| 129 | /** Returns the read data length message parameter. |
||
| 130 | * @param[in] call The message call structure. |
||
| 131 | */ |
||
| 132 | #define SOCKET_GET_READ_DATA_LENGTH( call ) ( int ) IPC_GET_ARG1( call ) |
||
| 133 | |||
| 134 | /** Returns the backlog message parameter. |
||
| 135 | * @param[in] call The message call structure. |
||
| 136 | */ |
||
| 137 | #define SOCKET_GET_BACKLOG( call ) ( int ) IPC_GET_ARG2( call ) |
||
| 138 | |||
| 139 | /** Returns the option level message parameter. |
||
| 140 | * @param[in] call The message call structure. |
||
| 141 | */ |
||
| 142 | #define SOCKET_GET_OPT_LEVEL( call ) ( int ) IPC_GET_ARG2( call ) |
||
| 143 | |||
| 144 | /** Sets the address length in the message answer. |
||
| 145 | * @param[out] answer The message answer structure. |
||
| 146 | */ |
||
| 147 | #define SOCKET_SET_ADDRESS_LENGTH( answer ) ( socklen_t * ) & IPC_GET_ARG2( answer ) |
||
| 148 | |||
| 149 | /** Returns the address length message parameter. |
||
| 150 | * @param[in] call The message call structure. |
||
| 151 | */ |
||
| 152 | #define SOCKET_GET_ADDRESS_LENGTH( call ) ( socklen_t ) IPC_GET_ARG2( call ) |
||
| 153 | |||
| 154 | /** Returns the data fragment size message parameter. |
||
| 155 | * @param[in] call The message call structure. |
||
| 156 | */ |
||
| 4726 | mejdrech | 157 | #define SOCKET_GET_DATA_FRAGMENT_SIZE( call ) ( size_t ) IPC_GET_ARG2( call ) |
| 4589 | mejdrech | 158 | |
| 4756 | mejdrech | 159 | /** Sets the data fragment size in the message answer. |
| 160 | * @param[out] answer The message answer structure. |
||
| 161 | */ |
||
| 162 | #define SOCKET_SET_DATA_FRAGMENT_SIZE( answer ) ( size_t * ) & IPC_GET_ARG2( answer ) |
||
| 4589 | mejdrech | 163 | |
| 4756 | mejdrech | 164 | /** Sets the header size in the message answer. |
| 165 | * @param[out] answer The message answer structure. |
||
| 166 | */ |
||
| 167 | #define SOCKET_SET_HEADER_SIZE( answer ) ( int * ) & IPC_GET_ARG3( answer ) |
||
| 4589 | mejdrech | 168 | |
| 4756 | mejdrech | 169 | /** Returns the header size message parameter. |
| 170 | * @param[in] call The message call structure. |
||
| 171 | */ |
||
| 172 | #define SOCKET_GET_HEADER_SIZE( call ) ( int ) IPC_GET_ARG3( call ) |
||
| 4726 | mejdrech | 173 | |
| 4756 | mejdrech | 174 | /** Returns the flags message parameter. |
| 175 | * @param[in] call The message call structure. |
||
| 176 | */ |
||
| 177 | #define SOCKET_GET_FLAGS( call ) ( int ) IPC_GET_ARG4( call ) |
||
| 178 | |||
| 179 | /** Returns the option name message parameter. |
||
| 180 | * @param[in] call The message call structure. |
||
| 181 | */ |
||
| 182 | #define SOCKET_GET_OPT_NAME( call ) ( int ) IPC_GET_ARG4( call ) |
||
| 183 | |||
| 184 | /** Returns the data fragments message parameter. |
||
| 185 | * @param[in] call The message call structure. |
||
| 186 | */ |
||
| 187 | #define SOCKET_GET_DATA_FRAGMENTS( call ) ( int ) IPC_GET_ARG5( call ) |
||
| 188 | |||
| 189 | /** Returns the new socket identifier message parameter. |
||
| 190 | * @param[in] call The message call structure. |
||
| 191 | */ |
||
| 192 | #define SOCKET_GET_NEW_SOCKET_ID( call ) ( int ) IPC_GET_ARG5( call ) |
||
| 193 | |||
| 4704 | mejdrech | 194 | /*@}*/ |
| 4589 | mejdrech | 195 | |
| 4578 | mejdrech | 196 | #endif |
| 197 | |||
| 198 | /** @} |
||
| 199 | */ |