Rev 4578 | Rev 4703 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4578 | Rev 4695 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2009 Lukas Mejdrech |
2 | * Copyright (c) 2009 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
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 |
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. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
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 |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 |
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. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup net |
29 | /** @addtogroup net |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
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> |
39 | #include <async.h> |
40 | 40 | ||
41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
42 | #include <ipc/services.h> |
42 | #include <ipc/services.h> |
43 | 43 | ||
44 | #include "include/device.h" |
44 | #include "include/device.h" |
45 | 45 | ||
46 | #include "structures/measured_strings.h" |
46 | #include "structures/measured_strings.h" |
47 | #include "structures/packet/packet.h" |
47 | #include "structures/packet/packet.h" |
48 | 48 | ||
49 | #define NET_NETIF_COUNT 8 |
49 | #define NET_NETIF_COUNT 8 |
50 | #define NET_NET_COUNT 9 |
50 | #define NET_NET_COUNT 9 |
51 | #define NET_NIL_COUNT 7 |
51 | #define NET_NIL_COUNT 7 |
52 | #define NET_ETH_COUNT 0 |
52 | #define NET_ETH_COUNT 0 |
53 | #define NET_IL_COUNT 5 |
53 | #define NET_IL_COUNT 6 |
54 | #define NET_IP_COUNT 2 |
54 | #define NET_IP_COUNT 2 |
55 | #define NET_ARP_COUNT 4 |
55 | #define NET_ARP_COUNT 5 |
56 | #define NET_RARP_COUNT 0 |
56 | #define NET_RARP_COUNT 0 |
57 | #define NET_ICMP_COUNT 0 |
57 | #define NET_ICMP_COUNT 0 |
58 | #define NET_TL_COUNT 1 |
58 | #define NET_TL_COUNT 1 |
59 | #define NET_UDP_COUNT 0 |
59 | #define NET_UDP_COUNT 0 |
60 | #define NET_TCP_COUNT 0 |
60 | #define NET_TCP_COUNT 0 |
61 | #define NET_PACKET_COUNT 5 |
61 | #define NET_PACKET_COUNT 5 |
62 | #define NET_SOCKET_COUNT 14 |
62 | #define NET_SOCKET_COUNT 14 |
63 | 63 | ||
64 | #define NET_FIRST 2000 |
64 | #define NET_FIRST 2000 |
65 | 65 | ||
66 | #define NET_NETIF_FIRST NET_FIRST |
66 | #define NET_NETIF_FIRST NET_FIRST |
67 | #define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT ) |
67 | #define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT ) |
68 | 68 | ||
69 | #define NET_NET_FIRST ( NET_NETIF_LAST + 0 ) |
69 | #define NET_NET_FIRST ( NET_NETIF_LAST + 0 ) |
70 | #define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT ) |
70 | #define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT ) |
71 | 71 | ||
72 | #define NET_NIL_FIRST ( NET_NET_LAST + 0 ) |
72 | #define NET_NIL_FIRST ( NET_NET_LAST + 0 ) |
73 | #define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT ) |
73 | #define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT ) |
74 | #define NET_ETH_FIRST ( NET_NIL_LAST + 0 ) |
74 | #define NET_ETH_FIRST ( NET_NIL_LAST + 0 ) |
75 | #define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT ) |
75 | #define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT ) |
76 | 76 | ||
77 | #define NET_IL_FIRST ( NET_ETH_LAST + 0 ) |
77 | #define NET_IL_FIRST ( NET_ETH_LAST + 0 ) |
78 | #define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT ) |
78 | #define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT ) |
79 | #define NET_IP_FIRST ( NET_IL_LAST + 0 ) |
79 | #define NET_IP_FIRST ( NET_IL_LAST + 0 ) |
80 | #define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT ) |
80 | #define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT ) |
81 | 81 | ||
82 | #define NET_ARP_FIRST ( NET_IP_LAST + 0 ) |
82 | #define NET_ARP_FIRST ( NET_IP_LAST + 0 ) |
83 | #define NET_ARP_LAST ( NET_ARP_FIRST + NET_ARP_COUNT ) |
83 | #define NET_ARP_LAST ( NET_ARP_FIRST + NET_ARP_COUNT ) |
84 | #define NET_RARP_FIRST ( NET_ARP_LAST + 0 ) |
84 | #define NET_RARP_FIRST ( NET_ARP_LAST + 0 ) |
85 | #define NET_RARP_LAST ( NET_RARP_FIRST + NET_RARP_COUNT ) |
85 | #define NET_RARP_LAST ( NET_RARP_FIRST + NET_RARP_COUNT ) |
86 | #define NET_ICMP_FIRST ( NET_RARP_LAST + 0 ) |
86 | #define NET_ICMP_FIRST ( NET_RARP_LAST + 0 ) |
87 | #define NET_ICMP_LAST ( NET_ICMP_FIRST + NET_ICMP_COUNT ) |
87 | #define NET_ICMP_LAST ( NET_ICMP_FIRST + NET_ICMP_COUNT ) |
88 | 88 | ||
89 | #define NET_TL_FIRST ( NET_ICMP_LAST + 0 ) |
89 | #define NET_TL_FIRST ( NET_ICMP_LAST + 0 ) |
90 | #define NET_TL_LAST ( NET_TL_FIRST + NET_TL_COUNT ) |
90 | #define NET_TL_LAST ( NET_TL_FIRST + NET_TL_COUNT ) |
91 | #define NET_UDP_FIRST ( NET_TL_LAST + 0 ) |
91 | #define NET_UDP_FIRST ( NET_TL_LAST + 0 ) |
92 | #define NET_UDP_LAST ( NET_UDP_FIRST + NET_UDP_COUNT ) |
92 | #define NET_UDP_LAST ( NET_UDP_FIRST + NET_UDP_COUNT ) |
93 | #define NET_TCP_FIRST ( NET_UDP_LAST + 0 ) |
93 | #define NET_TCP_FIRST ( NET_UDP_LAST + 0 ) |
94 | #define NET_TCP_LAST ( NET_TCP_FIRST + NET_TCP_COUNT ) |
94 | #define NET_TCP_LAST ( NET_TCP_FIRST + NET_TCP_COUNT ) |
95 | 95 | ||
96 | #define NET_SOCKET_FIRST ( NET_TCP_LAST + 0 ) |
96 | #define NET_SOCKET_FIRST ( NET_TCP_LAST + 0 ) |
97 | #define NET_SOCKET_LAST ( NET_SOCKET_FIRST + NET_SOCKET_COUNT ) |
97 | #define NET_SOCKET_LAST ( NET_SOCKET_FIRST + NET_SOCKET_COUNT ) |
98 | 98 | ||
99 | #define NET_PACKET_FIRST ( NET_SOCKET_LAST + 0 ) |
99 | #define NET_PACKET_FIRST ( NET_SOCKET_LAST + 0 ) |
100 | #define NET_PACKET_LAST ( NET_PACKET_FIRST + NET_PACKET_COUNT ) |
100 | #define NET_PACKET_LAST ( NET_PACKET_FIRST + NET_PACKET_COUNT ) |
101 | 101 | ||
102 | #define NET_LAST NET_PACKET_LAST |
102 | #define NET_LAST NET_PACKET_LAST |
103 | 103 | ||
104 | #define NET_COUNT ( NET_LAST - NET_FIRST ) |
104 | #define NET_COUNT ( NET_LAST - NET_FIRST ) |
105 | 105 | ||
106 | #define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive ))) |
106 | #define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive ))) |
107 | 107 | ||
108 | #define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST ) |
108 | #define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST ) |
109 | #define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST ) |
109 | #define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST ) |
110 | #define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST ) |
110 | #define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST ) |
111 | #define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST ) |
111 | #define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST ) |
112 | #define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST ) |
112 | #define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST ) |
113 | #define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST ) |
113 | #define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST ) |
114 | #define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST ) |
114 | #define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST ) |
115 | #define IS_NET_RARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_RARP_FIRST, NET_RARP_LAST ) |
115 | #define IS_NET_RARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_RARP_FIRST, NET_RARP_LAST ) |
116 | #define IS_NET_TL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TL_FIRST, NET_TL_LAST ) |
116 | #define IS_NET_TL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TL_FIRST, NET_TL_LAST ) |
117 | #define IS_NET_UDP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST ) |
117 | #define IS_NET_UDP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST ) |
118 | #define IS_NET_TCP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST ) |
118 | #define IS_NET_TCP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST ) |
119 | #define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST ) |
119 | #define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST ) |
120 | #define IS_NET_PACKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST ) |
120 | #define IS_NET_PACKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST ) |
121 | 121 | ||
122 | /** Returns the device identifier message parameter. |
122 | /** Returns the device identifier message parameter. |
123 | */ |
123 | */ |
124 | #define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
124 | #define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
125 | 125 | ||
126 | /** Returns the packet identifier message parameter. |
126 | /** Returns the packet identifier message parameter. |
127 | */ |
127 | */ |
128 | #define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call ) |
128 | #define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call ) |
129 | #define IPC_GET_COUNT( call ) ( size_t ) IPC_GET_ARG2( * call ) |
129 | #define IPC_GET_COUNT( call ) ( size_t ) IPC_GET_ARG2( * call ) |
130 | #define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
130 | #define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
131 | 131 | ||
- | 132 | /** Returns the maximum transmission unit message parameter. |
|
- | 133 | */ |
|
- | 134 | #define IPC_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call ) |
|
- | 135 | ||
132 | /** Returns the device driver service message parameter. |
136 | /** Returns the device driver service message parameter. |
133 | */ |
137 | */ |
134 | #define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call ) |
138 | #define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call ) |
135 | #define IPC_GET_TARGET( call ) ( services_t ) IPC_GET_ARG3( * call ) |
139 | #define IPC_GET_TARGET( call ) ( services_t ) IPC_GET_ARG3( * call ) |
136 | #define IPC_GET_SENDER( call ) ( services_t ) IPC_GET_ARG3( * call ) |
140 | #define IPC_GET_SENDER( call ) ( services_t ) IPC_GET_ARG3( * call ) |
137 | 141 | ||
138 | #define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
142 | #define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
139 | 143 | ||
140 | #define IPC_SET_ADDR( answer ) (( size_t * ) & IPC_GET_ARG1( * answer )) |
144 | #define IPC_SET_ADDR( answer ) (( size_t * ) & IPC_GET_ARG1( * answer )) |
141 | #define IPC_SET_PREFIX( answer ) (( size_t * ) & IPC_GET_ARG2( * answer )) |
145 | #define IPC_SET_PREFIX( answer ) (( size_t * ) & IPC_GET_ARG2( * answer )) |
142 | #define IPC_SET_CONTENT( answer ) (( size_t * ) & IPC_GET_ARG3( * answer )) |
146 | #define IPC_SET_CONTENT( answer ) (( size_t * ) & IPC_GET_ARG3( * answer )) |
143 | #define IPC_SET_SUFFIX( answer ) (( size_t * ) & IPC_GET_ARG4( * answer )) |
147 | #define IPC_SET_SUFFIX( answer ) (( size_t * ) & IPC_GET_ARG4( * answer )) |
144 | 148 | ||
145 | typedef enum { |
149 | typedef enum { |
146 | /* () not supported, registers new device */ |
150 | /* () not supported, registers new device */ |
147 | NET_NET_DEVICE = NET_NET_FIRST, |
151 | NET_NET_DEVICE = NET_NET_FIRST, |
148 | /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
152 | /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
149 | NET_NET_GET_CONF, |
153 | NET_NET_GET_CONF, |
150 | /* ( device_id, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
154 | /* ( device_id, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
151 | NET_NET_GET_DEVICE_CONF, |
155 | NET_NET_GET_DEVICE_CONF, |
152 | /* () not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
156 | /* () not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
153 | NET_NET_SET_CONF, |
157 | NET_NET_SET_CONF, |
154 | /* ( device_id, count ) not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
158 | /* ( device_id, count ) not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
155 | NET_NET_SET_DEVICE_CONF, |
159 | NET_NET_SET_DEVICE_CONF, |
156 | /* () */ |
160 | /* () */ |
157 | NET_NET_STARTUP, |
161 | NET_NET_STARTUP, |
158 | /* ( device_id ) */ |
162 | /* ( device_id ) */ |
159 | NET_NET_START, |
163 | NET_NET_START, |
160 | /* ( device_id ) */ |
164 | /* ( device_id ) */ |
161 | NET_NET_STOP, |
165 | NET_NET_STOP, |
162 | /* ( device_id ) ipc_data_read( stats ) */ |
166 | /* ( device_id ) ipc_data_read( stats ) */ |
163 | NET_NET_STATS, |
167 | NET_NET_STATS, |
164 | } net_messages; |
168 | } net_messages; |
165 | 169 | ||
166 | static inline int generic_get_addr( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){ |
170 | static inline int generic_get_addr( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){ |
167 | aid_t message_id; |
171 | aid_t message_id; |
168 | ipcarg_t result; |
172 | ipcarg_t result; |
169 | int string; |
173 | int string; |
170 | 174 | ||
171 | if( !( address && data )) return EBADMEM; |
175 | if( !( address && data )) return EBADMEM; |
172 | message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL ); |
176 | message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL ); |
173 | string = measured_strings_return( phone, address, data, 1 ); |
177 | string = measured_strings_return( phone, address, data, 1 ); |
174 | async_wait_for( message_id, & result ); |
178 | async_wait_for( message_id, & result ); |
175 | if(( string == EOK ) && ( result != EOK )){ |
179 | if(( string == EOK ) && ( result != EOK )){ |
176 | free( * address ); |
180 | free( * address ); |
177 | free( * data ); |
181 | free( * data ); |
178 | } |
182 | } |
179 | return ( int ) result; |
183 | return ( int ) result; |
180 | } |
184 | } |
181 | 185 | ||
182 | static inline int generic_translate_req( int phone, int message, device_id_t device_id, services_t service, measured_string_ref configuration, size_t count, measured_string_ref * translation, char ** data ){ |
186 | static inline int generic_translate_req( int phone, int message, device_id_t device_id, services_t service, measured_string_ref configuration, size_t count, measured_string_ref * translation, char ** data ){ |
183 | aid_t message_id; |
187 | aid_t message_id; |
184 | ipcarg_t result; |
188 | ipcarg_t result; |
185 | int string; |
189 | int string; |
186 | 190 | ||
187 | if( !( configuration && ( count > 0 ))) return EINVAL; |
191 | if( !( configuration && ( count > 0 ))) return EINVAL; |
188 | if( !( translation && data )) return EBADMEM; |
192 | if( !( translation && data )) return EBADMEM; |
189 | message_id = async_send_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) count, ( ipcarg_t ) service, NULL ); |
193 | message_id = async_send_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) count, ( ipcarg_t ) service, NULL ); |
190 | measured_strings_send( phone, configuration, count ); |
194 | measured_strings_send( phone, configuration, count ); |
191 | string = measured_strings_return( phone, translation, data, count ); |
195 | string = measured_strings_return( phone, translation, data, count ); |
192 | async_wait_for( message_id, & result ); |
196 | async_wait_for( message_id, & result ); |
193 | if(( string == EOK ) && ( result != EOK )){ |
197 | if(( string == EOK ) && ( result != EOK )){ |
194 | free( * translation ); |
198 | free( * translation ); |
195 | free( * data ); |
199 | free( * data ); |
196 | } |
200 | } |
197 | return ( int ) result; |
201 | return ( int ) result; |
198 | } |
202 | } |
199 | 203 | ||
200 | static inline int generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender ){ |
204 | static inline int generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender ){ |
201 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender ); |
205 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender ); |
202 | return EOK; |
206 | return EOK; |
203 | } |
207 | } |
204 | 208 | ||
205 | 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 ){ |
209 | 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 ){ |
206 | return ( int ) async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix ); |
210 | return ( int ) async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix ); |
207 | } |
211 | } |
208 | 212 | ||
209 | static inline int generic_device_state_msg( int phone, int message, device_id_t device_id, int state, services_t target ){ |
213 | static inline int generic_device_state_msg( int phone, int message, device_id_t device_id, int state, services_t target ){ |
210 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state, target ); |
214 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state, target ); |
211 | return EOK; |
215 | return EOK; |
212 | } |
216 | } |
213 | 217 | ||
214 | static inline int generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target ){ |
218 | static inline int 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, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target ); |
219 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target ); |
216 | return EOK; |
220 | return EOK; |
217 | } |
221 | } |
218 | 222 | ||
219 | static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){ |
223 | static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){ |
220 | return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service ); |
224 | return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service ); |
221 | } |
225 | } |
222 | 226 | ||
223 | #endif |
227 | #endif |
224 | 228 | ||
225 | /** @} |
229 | /** @} |
226 | */ |
230 | */ |
227 | 231 |