socket.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009 Lukas Mejdrech
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00037 #ifndef LIBC_SOCKET_MESSAGES_H_
00038 #define LIBC_SOCKET_MESSAGES_H_
00039 
00040 #include <ipc/net.h>
00041 
00043 typedef enum {
00045         NET_SOCKET = NET_SOCKET_FIRST,
00047         NET_SOCKET_BIND,
00049         NET_SOCKET_LISTEN,
00051         NET_SOCKET_ACCEPT,
00053         NET_SOCKET_CONNECT,
00055         NET_SOCKET_CLOSE,
00057         NET_SOCKET_SEND,
00059         NET_SOCKET_SENDTO,
00061         NET_SOCKET_RECV,
00063         NET_SOCKET_RECVFROM,
00065         NET_SOCKET_GETSOCKOPT,
00067         NET_SOCKET_SETSOCKOPT,
00069         NET_SOCKET_ACCEPTED,
00071         NET_SOCKET_RECEIVED,
00073         NET_SOCKET_DATA_FRAGMENT_SIZE
00074 } socket_messages;
00075 
00079 
00083 #define SOCKET_SET_SOCKET_ID(answer, value) \
00084         do { \
00085                 sysarg_t argument = (sysarg_t) (value); \
00086                 IPC_SET_ARG1(answer, argument); \
00087         } while (0)
00088 
00092 #define SOCKET_GET_SOCKET_ID(call) \
00093         ({ \
00094                 int socket_id = (int) IPC_GET_ARG1(call); \
00095                 socket_id; \
00096         })
00097 
00101 #define SOCKET_SET_READ_DATA_LENGTH(answer, value) \
00102         do { \
00103                 sysarg_t argument = (sysarg_t) (value); \
00104                 IPC_SET_ARG1(answer, argument); \
00105         } while (0)
00106 
00110 #define SOCKET_GET_READ_DATA_LENGTH(call) \
00111         ({ \
00112                 int data_length = (int) IPC_GET_ARG1(call); \
00113                 data_length; \
00114         })
00115 
00119 #define SOCKET_GET_BACKLOG(call) \
00120         ({ \
00121                 int backlog = (int) IPC_GET_ARG2(call); \
00122                 backlog; \
00123         })
00124 
00128 #define SOCKET_GET_OPT_LEVEL(call) \
00129         ({ \
00130                 int opt_level = (int) IPC_GET_ARG2(call); \
00131                 opt_level; \
00132         })
00133 
00137 #define SOCKET_GET_DATA_FRAGMENT_SIZE(call) \
00138         ({ \
00139                 size_t size = (size_t) IPC_GET_ARG2(call); \
00140                 size; \
00141         })
00142 
00146 #define SOCKET_SET_DATA_FRAGMENT_SIZE(answer, value) \
00147         do { \
00148                 sysarg_t argument = (sysarg_t) (value); \
00149                 IPC_SET_ARG2(answer, argument); \
00150         } while (0)
00151 
00155 #define SOCKET_SET_ADDRESS_LENGTH(answer, value) \
00156         do { \
00157                 sysarg_t argument = (sysarg_t) (value); \
00158                 IPC_SET_ARG3(answer, argument);\
00159         } while (0)
00160 
00164 #define SOCKET_GET_ADDRESS_LENGTH(call) \
00165         ({ \
00166                 socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); \
00167                 address_length; \
00168         })
00169 
00173 #define SOCKET_SET_HEADER_SIZE(answer, value) \
00174         do { \
00175                 sysarg_t argument = (sysarg_t) (value); \
00176                 IPC_SET_ARG3(answer, argument); \
00177         } while (0)
00178 
00182 #define SOCKET_GET_HEADER_SIZE(call) \
00183         ({ \
00184                 size_t size = (size_t) IPC_GET_ARG3(call); \
00185                 size; \
00186         })
00187 
00191 #define SOCKET_GET_FLAGS(call) \
00192         ({ \
00193                 int flags = (int) IPC_GET_ARG4(call); \
00194                 flags; \
00195         })
00196 
00200 #define SOCKET_GET_OPT_NAME(call) \
00201         ({ \
00202                 int opt_name = (int) IPC_GET_ARG4(call); \
00203                 opt_name; \
00204         })
00205 
00209 #define SOCKET_GET_DATA_FRAGMENTS(call) \
00210         ({ \
00211                 int fragments = (int) IPC_GET_ARG5(call); \
00212                 fragments; \
00213         })
00214 
00218 #define SOCKET_GET_NEW_SOCKET_ID(call) \
00219         ({ \
00220                 int socket_id = (int) IPC_GET_ARG5(call); \
00221                 socket_id; \
00222         })
00223 
00226 #endif
00227 

Generated on Thu Jun 2 07:45:47 2011 for HelenOS/USB by  doxygen 1.4.7