Subversion Repositories HelenOS

Rev

Rev 4243 | Rev 4271 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4243 Rev 4261
Line 34... Line 34...
34
 */
34
 */
35
 
35
 
36
#ifndef __NET_MESSAGES_H__
36
#ifndef __NET_MESSAGES_H__
37
#define __NET_MESSAGES_H__
37
#define __NET_MESSAGES_H__
38
 
38
 
-
 
39
#include <async.h>
-
 
40
 
-
 
41
#include <ipc/ipc.h>
-
 
42
#include <ipc/services.h>
-
 
43
 
-
 
44
#include "include/device.h"
-
 
45
 
-
 
46
#include "structures/measured_strings.h"
-
 
47
#include "structures/packet/packet.h"
-
 
48
 
39
#define NET_NETIF_COUNT     8
49
#define NET_NETIF_COUNT     8
40
#define NET_NET_COUNT       9
50
#define NET_NET_COUNT       9
41
#define NET_NIL_COUNT       8
51
#define NET_NIL_COUNT       7
42
#define NET_ETH_COUNT       0
52
#define NET_ETH_COUNT       0
43
#define NET_IL_COUNT        3
53
#define NET_IL_COUNT        3
44
#define NET_IP_COUNT        2
54
#define NET_IP_COUNT        2
45
#define NET_ARP_COUNT       4
55
#define NET_ARP_COUNT       4
46
#define NET_RARP_COUNT      0
56
#define NET_RARP_COUNT      0
Line 102... Line 112...
102
#define IS_NET_UDP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST )
112
#define IS_NET_UDP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST )
103
#define IS_NET_TCP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST )
113
#define IS_NET_TCP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST )
104
#define IS_NET_SOCKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST )
114
#define IS_NET_SOCKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST )
105
#define IS_NET_PACKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST )
115
#define IS_NET_PACKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST )
106
 
116
 
-
 
117
/** Returns the device identifier message parameter.
-
 
118
 */
-
 
119
#define IPC_GET_DEVICE( call )      ( device_id_t ) IPC_GET_ARG1( * call )
-
 
120
 
-
 
121
/** Returns the packet identifier message parameter.
-
 
122
 */
-
 
123
#define IPC_GET_PACKET( call )      ( packet_id_t ) IPC_GET_ARG2( * call )
-
 
124
 
-
 
125
#define IPC_GET_STATE( call )       ( device_state_t ) IPC_GET_ARG2( * call )
-
 
126
 
-
 
127
/** Returns the device driver service message parameter.
-
 
128
 */
-
 
129
#define IPC_GET_SERVICE( call )     ( services_t ) IPC_GET_ARG3( * call )
-
 
130
#define IPC_GET_TARGET( call )      ( services_t ) IPC_GET_ARG3( * call )
-
 
131
#define IPC_GET_SENDER( call )      ( services_t ) IPC_GET_ARG3( * call )
-
 
132
 
107
#define IPC_GET_PHONE( call )       ( int ) IPC_GET_ARG5( * call )
133
#define IPC_GET_PHONE( call )       ( int ) IPC_GET_ARG5( * call )
108
 
134
 
-
 
135
#define IPC_SET_ADDR( answer )      (( size_t * ) & IPC_GET_ARG1( * answer ))
-
 
136
#define IPC_SET_PREFIX( answer )    (( size_t * ) & IPC_GET_ARG2( * answer ))
-
 
137
#define IPC_SET_CONTENT( answer )   (( size_t * ) & IPC_GET_ARG3( * answer ))
-
 
138
#define IPC_SET_SUFFIX( answer )    (( size_t * ) & IPC_GET_ARG4( * answer ))
-
 
139
 
109
typedef enum {
140
typedef enum {
110
    /* () not supported, registers new device */
141
    /* () not supported, registers new device */
111
    NET_NET_DEVICE = NET_NET_FIRST,
142
    NET_NET_DEVICE = NET_NET_FIRST,
112
    /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */
143
    /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */
113
    NET_NET_GET_CONF,
144
    NET_NET_GET_CONF,
Line 123... Line 154...
123
    NET_NET_START,
154
    NET_NET_START,
124
    /* ( device_id ) */
155
    /* ( device_id ) */
125
    NET_NET_STOP,
156
    NET_NET_STOP,
126
    /* ( device_id ) ipc_data_read( stats ) */
157
    /* ( device_id ) ipc_data_read( stats ) */
127
    NET_NET_STATS,
158
    NET_NET_STATS,
128
    /* ( device_id, driver_service, mtu ) */
-
 
129
    NET_NIL_DEVICE = NET_NIL_FIRST,
-
 
130
    /* ( device_id, state ) */
-
 
131
    NET_NIL_DEVICE_STATE,
-
 
132
    /* ( device_id ), packet_send */
-
 
133
    NET_NIL_RECEIVED,
-
 
134
    /* ( device_id ), packet_send */
-
 
135
    NET_NIL_SEND,
-
 
136
    /* ( device_id ) -> addr, prefix, content, suffix */
-
 
137
    NET_NIL_PACKET_SPACE,
-
 
138
    /* ( device_id ), measured_strings_return( hardware address ) */
-
 
139
    NET_NIL_ADDR,
-
 
140
    /* ( device_id ), measured_strings_return( broadcast address ) */
-
 
141
    NET_NIL_BROADCAST_ADDR,
-
 
142
    /* ( device_id, nil_service ) */
159
    /* ( device_id, nil_service ) */
143
    NET_IL_DEVICE = NET_IL_FIRST,
160
    NET_IL_DEVICE = NET_IL_FIRST,
144
    /* ( device_id, state ) */
161
    /* ( device_id, state ) */
145
    NET_IL_DEVICE_STATE,
162
    NET_IL_DEVICE_STATE,
146
    /* ( device_id ), packet_send */
163
    /* ( device_id ), packet_send */
Line 163... Line 180...
163
    NET_PACKET_GET,
180
    NET_PACKET_GET,
164
    NET_PACKET_GET_SIZE,
181
    NET_PACKET_GET_SIZE,
165
    NET_PACKET_RELEASE
182
    NET_PACKET_RELEASE
166
} net_messages;
183
} net_messages;
167
 
184
 
-
 
185
static inline int generic_get_addr( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){
-
 
186
    aid_t           message_id;
-
 
187
//  ipc_call_t      answer;
-
 
188
    ipcarg_t        result;
-
 
189
    int             string;
-
 
190
 
-
 
191
    if( !( address && data )) return EBADMEM;
-
 
192
    message_id = async_send_1( phone, message, device_id, NULL /* & answer */ );
-
 
193
    string = measured_strings_return( phone, address, data, 1 );
-
 
194
    async_wait_for( message_id, & result );
-
 
195
    if(( string == EOK ) && ( result != EOK )){
-
 
196
        free( * address );
-
 
197
        free( * data );
-
 
198
    }
-
 
199
    return result;
-
 
200
}
-
 
201
 
-
 
202
static inline void  generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender ){
-
 
203
    async_msg_3( phone, message, device_id, packet_id, sender );
-
 
204
}
-
 
205
 
-
 
206
static inline int   generic_packet_size_req( int phone, int message, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
-
 
207
    return async_req_1_4( phone, message, device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix );
-
 
208
}
-
 
209
 
-
 
210
static inline void  generic_device_state_msg( int phone, int message, device_id_t device_id, int state ){
-
 
211
    async_msg_2( phone, message, device_id, state );
-
 
212
}
-
 
213
 
-
 
214
static inline void  generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target ){
-
 
215
    async_msg_3( phone, message, device_id, packet_id, target );
-
 
216
}
-
 
217
 
-
 
218
static inline int   generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){
-
 
219
    return async_req_3_0( phone, message, device_id, arg2, service );
-
 
220
}
-
 
221
 
168
#endif
222
#endif
169
 
223
 
170
/** @}
224
/** @}
171
 */
225
 */