36,9 → 36,19 |
#ifndef __NET_MESSAGES_H__ |
#define __NET_MESSAGES_H__ |
|
#include <async.h> |
|
#include <ipc/ipc.h> |
#include <ipc/services.h> |
|
#include "include/device.h" |
|
#include "structures/measured_strings.h" |
#include "structures/packet/packet.h" |
|
#define NET_NETIF_COUNT 8 |
#define NET_NET_COUNT 9 |
#define NET_NIL_COUNT 8 |
#define NET_NIL_COUNT 7 |
#define NET_ETH_COUNT 0 |
#define NET_IL_COUNT 3 |
#define NET_IP_COUNT 2 |
104,8 → 114,29 |
#define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST ) |
#define IS_NET_PACKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST ) |
|
/** Returns the device identifier message parameter. |
*/ |
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
|
/** Returns the packet identifier message parameter. |
*/ |
#define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call ) |
|
#define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
|
/** Returns the device driver service message parameter. |
*/ |
#define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call ) |
#define IPC_GET_TARGET( call ) ( services_t ) IPC_GET_ARG3( * call ) |
#define IPC_GET_SENDER( call ) ( services_t ) IPC_GET_ARG3( * call ) |
|
#define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
|
#define IPC_SET_ADDR( answer ) (( size_t * ) & IPC_GET_ARG1( * answer )) |
#define IPC_SET_PREFIX( answer ) (( size_t * ) & IPC_GET_ARG2( * answer )) |
#define IPC_SET_CONTENT( answer ) (( size_t * ) & IPC_GET_ARG3( * answer )) |
#define IPC_SET_SUFFIX( answer ) (( size_t * ) & IPC_GET_ARG4( * answer )) |
|
typedef enum { |
/* () not supported, registers new device */ |
NET_NET_DEVICE = NET_NET_FIRST, |
125,20 → 156,6 |
NET_NET_STOP, |
/* ( device_id ) ipc_data_read( stats ) */ |
NET_NET_STATS, |
/* ( device_id, driver_service, mtu ) */ |
NET_NIL_DEVICE = NET_NIL_FIRST, |
/* ( device_id, state ) */ |
NET_NIL_DEVICE_STATE, |
/* ( device_id ), packet_send */ |
NET_NIL_RECEIVED, |
/* ( device_id ), packet_send */ |
NET_NIL_SEND, |
/* ( device_id ) -> addr, prefix, content, suffix */ |
NET_NIL_PACKET_SPACE, |
/* ( device_id ), measured_strings_return( hardware address ) */ |
NET_NIL_ADDR, |
/* ( device_id ), measured_strings_return( broadcast address ) */ |
NET_NIL_BROADCAST_ADDR, |
/* ( device_id, nil_service ) */ |
NET_IL_DEVICE = NET_IL_FIRST, |
/* ( device_id, state ) */ |
165,6 → 182,43 |
NET_PACKET_RELEASE |
} net_messages; |
|
static inline int generic_get_addr( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){ |
aid_t message_id; |
// ipc_call_t answer; |
ipcarg_t result; |
int string; |
|
if( !( address && data )) return EBADMEM; |
message_id = async_send_1( phone, message, device_id, NULL /* & answer */ ); |
string = measured_strings_return( phone, address, data, 1 ); |
async_wait_for( message_id, & result ); |
if(( string == EOK ) && ( result != EOK )){ |
free( * address ); |
free( * data ); |
} |
return result; |
} |
|
static inline void generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender ){ |
async_msg_3( phone, message, device_id, packet_id, sender ); |
} |
|
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 ){ |
return async_req_1_4( phone, message, device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix ); |
} |
|
static inline void generic_device_state_msg( int phone, int message, device_id_t device_id, int state ){ |
async_msg_2( phone, message, device_id, state ); |
} |
|
static inline void generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target ){ |
async_msg_3( phone, message, device_id, packet_id, target ); |
} |
|
static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){ |
return async_req_3_0( phone, message, device_id, arg2, service ); |
} |
|
#endif |
|
/** @} |