Changeset 89c57b6 in mainline for uspace/lib/c/include/ipc/socket.h


Ignore:
Timestamp:
2011-04-13T14:45:41Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
88634420
Parents:
cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/ipc/socket.h

    rcefb126 r89c57b6  
    2727 */
    2828
    29 /** @addtogroup socket
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @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          */
     34 * Socket messages.
     35 */
     36
     37#ifndef LIBC_SOCKET_MESSAGES_H_
     38#define LIBC_SOCKET_MESSAGES_H_
     39
     40#include <ipc/net.h>
     41
     42/** Socket client messages. */
     43typedef enum {
     44        /** Creates a new socket. @see socket() */
    5345        NET_SOCKET = NET_SOCKET_FIRST,
    54         /** Binds the socket.
    55          *  @see bind()
    56          */
     46        /** Binds the socket. @see bind() */
    5747        NET_SOCKET_BIND,
    58         /** Creates a new socket.
    59          *  @see socket()
    60          */
     48        /** Creates a new socket. @see socket() */
    6149        NET_SOCKET_LISTEN,
    62         /** Accepts an incomming connection.
    63          *  @see accept()
    64          */
     50        /** Accepts an incomming connection. @see accept() */
    6551        NET_SOCKET_ACCEPT,
    66         /** Connects the socket.
    67          *  @see connect()
    68          */
     52        /** Connects the socket. @see connect() */
    6953        NET_SOCKET_CONNECT,
    70         /** Closes the socket.
    71          *  @see closesocket()
    72          */
     54        /** Closes the socket. @see closesocket() */
    7355        NET_SOCKET_CLOSE,
    74         /** Sends data via the stream socket.
    75          *  @see send()
    76          */
     56        /** Sends data via the stream socket. @see send() */
    7757        NET_SOCKET_SEND,
    78         /** Sends data via the datagram socket.
    79          *  @see sendto()
    80          */
     58        /** Sends data via the datagram socket. @see sendto() */
    8159        NET_SOCKET_SENDTO,
    82         /** Receives data from the stream socket.
    83          *  @see socket()
    84          */
     60        /** Receives data from the stream socket. @see socket() */
    8561        NET_SOCKET_RECV,
    86         /** Receives data from the datagram socket.
    87          *  @see socket()
    88          */
     62        /** Receives data from the datagram socket. @see socket() */
    8963        NET_SOCKET_RECVFROM,
    90         /** Gets the socket option.
    91          *  @see getsockopt()
    92          */
     64        /** Gets the socket option. @see getsockopt() */
    9365        NET_SOCKET_GETSOCKOPT,
    94         /** Sets the socket option.
    95          *  @see setsockopt()
    96          */
     66        /** Sets the socket option. @see setsockopt() */
    9767        NET_SOCKET_SETSOCKOPT,
    98         /** New socket for acceptence notification message.
    99          */
     68        /** New socket for acceptence notification message. */
    10069        NET_SOCKET_ACCEPTED,
    101         /** New data received notification message.
    102          */
     70        /** New data received notification message. */
    10371        NET_SOCKET_RECEIVED,
    104         /** New socket data fragment size notification message.
    105          */
     72        /** New socket data fragment size notification message. */
    10673        NET_SOCKET_DATA_FRAGMENT_SIZE
    10774} socket_messages;
     
    11279
    11380/** Sets the socket identifier in the message answer.
    114  *  @param[out] answer The message answer structure.
     81 * @param[out] answer   The message answer structure.
    11582 */
    11683#define SOCKET_SET_SOCKET_ID(answer, value) \
    117         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(answer, argument);}
     84        do { \
     85                sysarg_t argument = (sysarg_t) (value); \
     86                IPC_SET_ARG1(answer, argument); \
     87        } while (0)
    11888
    11989/** Returns the socket identifier message parameter.
    120  *  @param[in] call The message call structure.
     90 * @param[in] call      The message call structure.
    12191 */
    12292#define SOCKET_GET_SOCKET_ID(call) \
    123         ({int socket_id = (int) IPC_GET_ARG1(call); socket_id;})
     93        ({ \
     94                int socket_id = (int) IPC_GET_ARG1(call); \
     95                socket_id; \
     96        })
    12497
    12598/** Sets the read data length in the message answer.
    126  *  @param[out] answer The message answer structure.
     99 * @param[out] answer   The message answer structure.
    127100 */
    128101#define SOCKET_SET_READ_DATA_LENGTH(answer, value) \
    129         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(answer, argument);}
     102        do { \
     103                sysarg_t argument = (sysarg_t) (value); \
     104                IPC_SET_ARG1(answer, argument); \
     105        } while (0)
    130106
    131107/** Returns the read data length message parameter.
    132  *  @param[in] call The message call structure.
     108 * @param[in] call      The message call structure.
    133109 */
    134110#define SOCKET_GET_READ_DATA_LENGTH(call) \
    135         ({int data_length = (int) IPC_GET_ARG1(call); data_length;})
     111        ({ \
     112                int data_length = (int) IPC_GET_ARG1(call); \
     113                data_length; \
     114        })
    136115
    137116/** Returns the backlog message parameter.
    138  *  @param[in] call The message call structure.
     117 * @param[in] call      The message call structure.
    139118 */
    140119#define SOCKET_GET_BACKLOG(call) \
    141         ({int backlog = (int) IPC_GET_ARG2(call); backlog;})
     120        ({ \
     121                int backlog = (int) IPC_GET_ARG2(call); \
     122                backlog; \
     123        })
    142124
    143125/** Returns the option level message parameter.
    144  *  @param[in] call The message call structure.
     126 * @param[in] call      The message call structure.
    145127 */
    146128#define SOCKET_GET_OPT_LEVEL(call) \
    147         ({int opt_level = (int) IPC_GET_ARG2(call); opt_level;})
     129        ({ \
     130                int opt_level = (int) IPC_GET_ARG2(call); \
     131                opt_level; \
     132        })
    148133
    149134/** Returns the data fragment size message parameter.
    150  *  @param[in] call The message call structure.
     135 * @param[in] call      The message call structure.
    151136 */
    152137#define SOCKET_GET_DATA_FRAGMENT_SIZE(call) \
    153         ({size_t size = (size_t) IPC_GET_ARG2(call); size;})
     138        ({ \
     139                size_t size = (size_t) IPC_GET_ARG2(call); \
     140                size; \
     141        })
    154142
    155143/** Sets the data fragment size in the message answer.
    156  *  @param[out] answer The message answer structure.
     144 * @param[out] answer   The message answer structure.
    157145 */
    158146#define SOCKET_SET_DATA_FRAGMENT_SIZE(answer, value) \
    159         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG2(answer, argument);}
     147        do { \
     148                sysarg_t argument = (sysarg_t) (value); \
     149                IPC_SET_ARG2(answer, argument); \
     150        } while (0)
    160151
    161152/** Sets the address length in the message answer.
    162  *  @param[out] answer The message answer structure.
     153 * @param[out] answer   The message answer structure.
    163154 */
    164155#define SOCKET_SET_ADDRESS_LENGTH(answer, value) \
    165         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG3(answer, argument);}
     156        do { \
     157                sysarg_t argument = (sysarg_t) (value); \
     158                IPC_SET_ARG3(answer, argument);\
     159        } while (0)
    166160
    167161/** Returns the address length message parameter.
    168  *  @param[in] call The message call structure.
     162 * @param[in] call      The message call structure.
    169163 */
    170164#define SOCKET_GET_ADDRESS_LENGTH(call) \
    171         ({socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); address_length;})
     165        ({ \
     166                socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); \
     167                address_length; \
     168        })
    172169
    173170/** Sets the header size in the message answer.
    174  *  @param[out] answer The message answer structure.
     171 * @param[out] answer   The message answer structure.
    175172 */
    176173#define SOCKET_SET_HEADER_SIZE(answer, value) \
    177         \
    178         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG3(answer, argument);}
     174        do { \
     175                sysarg_t argument = (sysarg_t) (value); \
     176                IPC_SET_ARG3(answer, argument); \
     177        } while (0)
    179178
    180179/** Returns the header size message parameter.
    181  *  @param[in] call The message call structure.
     180 *  @param[in] call     The message call structure.
    182181 */
    183182#define SOCKET_GET_HEADER_SIZE(call) \
    184         ({size_t size = (size_t) IPC_GET_ARG3(call); size;})
     183        ({ \
     184                size_t size = (size_t) IPC_GET_ARG3(call); \
     185                size; \
     186        })
    185187
    186188/** Returns the flags message parameter.
    187  *  @param[in] call The message call structure.
     189 *  @param[in] call     The message call structure.
    188190 */
    189191#define SOCKET_GET_FLAGS(call) \
    190         ({int flags = (int) IPC_GET_ARG4(call); flags;})
     192        ({ \
     193                int flags = (int) IPC_GET_ARG4(call); \
     194                flags; \
     195        })
    191196
    192197/** Returns the option name message parameter.
    193  *  @param[in] call The message call structure.
     198 *  @param[in] call     The message call structure.
    194199 */
    195200#define SOCKET_GET_OPT_NAME(call) \
    196         ({int opt_name = (int) IPC_GET_ARG4(call); opt_name;})
     201        ({ \
     202                int opt_name = (int) IPC_GET_ARG4(call); \
     203                opt_name; \
     204        })
    197205
    198206/** Returns the data fragments message parameter.
    199  *  @param[in] call The message call structure.
     207 *  @param[in] call     The message call structure.
    200208 */
    201209#define SOCKET_GET_DATA_FRAGMENTS(call) \
    202         ({int fragments = (int) IPC_GET_ARG5(call); fragments;})
     210        ({ \
     211                int fragments = (int) IPC_GET_ARG5(call); \
     212                fragments; \
     213        })
    203214
    204215/** Returns the new socket identifier message parameter.
    205  *  @param[in] call The message call structure.
     216 *  @param[in] call     The message call structure.
    206217 */
    207218#define SOCKET_GET_NEW_SOCKET_ID(call) \
    208         ({int socket_id = (int) IPC_GET_ARG5(call); socket_id;})
     219        ({ \
     220                int socket_id = (int) IPC_GET_ARG5(call); \
     221                socket_id; \
     222        })
    209223
    210224/*@}*/
Note: See TracChangeset for help on using the changeset viewer.