Rev 4703 | Rev 4715 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4703 | Rev 4707 | ||
---|---|---|---|
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 | * \todo |
34 | * \todo |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef __NET_MESSAGES_H__ |
37 | #ifndef __NET_MESSAGES_H__ |
38 | #define __NET_MESSAGES_H__ |
38 | #define __NET_MESSAGES_H__ |
39 | 39 | ||
40 | #include <async.h> |
40 | #include <async.h> |
41 | 41 | ||
42 | #include <ipc/ipc.h> |
42 | #include <ipc/ipc.h> |
43 | #include <ipc/services.h> |
43 | #include <ipc/services.h> |
44 | 44 | ||
45 | #include "include/device.h" |
45 | #include "include/device.h" |
46 | 46 | ||
47 | #include "structures/measured_strings.h" |
47 | #include "structures/measured_strings.h" |
48 | #include "structures/packet/packet.h" |
48 | #include "structures/packet/packet.h" |
49 | 49 | ||
50 | #define NET_NETIF_COUNT 6 |
50 | #define NET_NETIF_COUNT 6 |
51 | #define NET_NET_COUNT 9 |
51 | #define NET_NET_COUNT 9 |
52 | #define NET_NIL_COUNT 7 |
52 | #define NET_NIL_COUNT 7 |
53 | #define NET_ETH_COUNT 0 |
53 | #define NET_ETH_COUNT 0 |
54 | #define NET_IL_COUNT 6 |
54 | #define NET_IL_COUNT 6 |
55 | #define NET_IP_COUNT 2 |
55 | #define NET_IP_COUNT 3 |
56 | #define NET_ARP_COUNT 5 |
56 | #define NET_ARP_COUNT 5 |
57 | #define NET_RARP_COUNT 0 |
57 | #define NET_RARP_COUNT 0 |
58 | #define NET_ICMP_COUNT 0 |
58 | #define NET_ICMP_COUNT 6 |
59 | #define NET_TL_COUNT 1 |
59 | #define NET_TL_COUNT 1 |
60 | #define NET_UDP_COUNT 0 |
60 | #define NET_UDP_COUNT 0 |
61 | #define NET_TCP_COUNT 0 |
61 | #define NET_TCP_COUNT 0 |
62 | #define NET_PACKET_COUNT 5 |
62 | #define NET_PACKET_COUNT 5 |
63 | #define NET_SOCKET_COUNT 14 |
63 | #define NET_SOCKET_COUNT 14 |
64 | 64 | ||
65 | #define NET_FIRST 2000 |
65 | #define NET_FIRST 2000 |
66 | 66 | ||
67 | #define NET_NETIF_FIRST NET_FIRST |
67 | #define NET_NETIF_FIRST NET_FIRST |
68 | #define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT ) |
68 | #define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT ) |
69 | 69 | ||
70 | #define NET_NET_FIRST ( NET_NETIF_LAST + 0 ) |
70 | #define NET_NET_FIRST ( NET_NETIF_LAST + 0 ) |
71 | #define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT ) |
71 | #define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT ) |
72 | 72 | ||
73 | #define NET_NIL_FIRST ( NET_NET_LAST + 0 ) |
73 | #define NET_NIL_FIRST ( NET_NET_LAST + 0 ) |
74 | #define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT ) |
74 | #define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT ) |
75 | #define NET_ETH_FIRST ( NET_NIL_LAST + 0 ) |
75 | #define NET_ETH_FIRST ( NET_NIL_LAST + 0 ) |
76 | #define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT ) |
76 | #define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT ) |
77 | 77 | ||
78 | #define NET_IL_FIRST ( NET_ETH_LAST + 0 ) |
78 | #define NET_IL_FIRST ( NET_ETH_LAST + 0 ) |
79 | #define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT ) |
79 | #define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT ) |
80 | #define NET_IP_FIRST ( NET_IL_LAST + 0 ) |
80 | #define NET_IP_FIRST ( NET_IL_LAST + 0 ) |
81 | #define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT ) |
81 | #define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT ) |
82 | 82 | ||
83 | #define NET_ARP_FIRST ( NET_IP_LAST + 0 ) |
83 | #define NET_ARP_FIRST ( NET_IP_LAST + 0 ) |
84 | #define NET_ARP_LAST ( NET_ARP_FIRST + NET_ARP_COUNT ) |
84 | #define NET_ARP_LAST ( NET_ARP_FIRST + NET_ARP_COUNT ) |
85 | #define NET_RARP_FIRST ( NET_ARP_LAST + 0 ) |
85 | #define NET_RARP_FIRST ( NET_ARP_LAST + 0 ) |
86 | #define NET_RARP_LAST ( NET_RARP_FIRST + NET_RARP_COUNT ) |
86 | #define NET_RARP_LAST ( NET_RARP_FIRST + NET_RARP_COUNT ) |
87 | #define NET_ICMP_FIRST ( NET_RARP_LAST + 0 ) |
87 | #define NET_ICMP_FIRST ( NET_RARP_LAST + 0 ) |
88 | #define NET_ICMP_LAST ( NET_ICMP_FIRST + NET_ICMP_COUNT ) |
88 | #define NET_ICMP_LAST ( NET_ICMP_FIRST + NET_ICMP_COUNT ) |
89 | 89 | ||
90 | #define NET_TL_FIRST ( NET_ICMP_LAST + 0 ) |
90 | #define NET_TL_FIRST ( NET_ICMP_LAST + 0 ) |
91 | #define NET_TL_LAST ( NET_TL_FIRST + NET_TL_COUNT ) |
91 | #define NET_TL_LAST ( NET_TL_FIRST + NET_TL_COUNT ) |
92 | #define NET_UDP_FIRST ( NET_TL_LAST + 0 ) |
92 | #define NET_UDP_FIRST ( NET_TL_LAST + 0 ) |
93 | #define NET_UDP_LAST ( NET_UDP_FIRST + NET_UDP_COUNT ) |
93 | #define NET_UDP_LAST ( NET_UDP_FIRST + NET_UDP_COUNT ) |
94 | #define NET_TCP_FIRST ( NET_UDP_LAST + 0 ) |
94 | #define NET_TCP_FIRST ( NET_UDP_LAST + 0 ) |
95 | #define NET_TCP_LAST ( NET_TCP_FIRST + NET_TCP_COUNT ) |
95 | #define NET_TCP_LAST ( NET_TCP_FIRST + NET_TCP_COUNT ) |
96 | 96 | ||
97 | #define NET_SOCKET_FIRST ( NET_TCP_LAST + 0 ) |
97 | #define NET_SOCKET_FIRST ( NET_TCP_LAST + 0 ) |
98 | #define NET_SOCKET_LAST ( NET_SOCKET_FIRST + NET_SOCKET_COUNT ) |
98 | #define NET_SOCKET_LAST ( NET_SOCKET_FIRST + NET_SOCKET_COUNT ) |
99 | 99 | ||
100 | #define NET_PACKET_FIRST ( NET_SOCKET_LAST + 0 ) |
100 | #define NET_PACKET_FIRST ( NET_SOCKET_LAST + 0 ) |
101 | #define NET_PACKET_LAST ( NET_PACKET_FIRST + NET_PACKET_COUNT ) |
101 | #define NET_PACKET_LAST ( NET_PACKET_FIRST + NET_PACKET_COUNT ) |
102 | 102 | ||
103 | #define NET_LAST NET_PACKET_LAST |
103 | #define NET_LAST NET_PACKET_LAST |
104 | 104 | ||
105 | #define NET_COUNT ( NET_LAST - NET_FIRST ) |
105 | #define NET_COUNT ( NET_LAST - NET_FIRST ) |
106 | 106 | ||
107 | #define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive ))) |
107 | #define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive ))) |
108 | 108 | ||
109 | #define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST ) |
109 | #define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST ) |
110 | #define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST ) |
110 | #define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST ) |
111 | #define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST ) |
111 | #define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST ) |
112 | #define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST ) |
112 | #define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST ) |
113 | #define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST ) |
113 | #define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST ) |
114 | #define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST ) |
114 | #define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST ) |
115 | #define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST ) |
115 | #define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST ) |
116 | #define IS_NET_RARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_RARP_FIRST, NET_RARP_LAST ) |
116 | #define IS_NET_RARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_RARP_FIRST, NET_RARP_LAST ) |
- | 117 | #define IS_NET_ICMP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ICMP_FIRST, NET_ICMP_LAST ) |
|
117 | #define IS_NET_TL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TL_FIRST, NET_TL_LAST ) |
118 | #define IS_NET_TL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TL_FIRST, NET_TL_LAST ) |
118 | #define IS_NET_UDP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST ) |
119 | #define IS_NET_UDP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST ) |
119 | #define IS_NET_TCP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST ) |
120 | #define IS_NET_TCP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST ) |
120 | #define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST ) |
121 | #define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST ) |
121 | #define IS_NET_PACKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST ) |
122 | #define IS_NET_PACKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST ) |
122 | 123 | ||
123 | /** Returns the device identifier message parameter. |
124 | /** Returns the device identifier message parameter. |
124 | */ |
125 | */ |
125 | #define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
126 | #define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
126 | 127 | ||
127 | /** Returns the packet identifier message parameter. |
128 | /** Returns the packet identifier message parameter. |
128 | */ |
129 | */ |
129 | #define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call ) |
130 | #define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call ) |
130 | #define IPC_GET_COUNT( call ) ( size_t ) IPC_GET_ARG2( * call ) |
131 | #define IPC_GET_COUNT( call ) ( size_t ) IPC_GET_ARG2( * call ) |
131 | #define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
132 | #define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
132 | 133 | ||
133 | /** Returns the maximum transmission unit message parameter. |
134 | /** Returns the maximum transmission unit message parameter. |
134 | */ |
135 | */ |
135 | #define IPC_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call ) |
136 | #define IPC_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call ) |
136 | 137 | ||
137 | /** Returns the device driver service message parameter. |
138 | /** Returns the device driver service message parameter. |
138 | */ |
139 | */ |
139 | #define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call ) |
140 | #define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call ) |
140 | #define IPC_GET_TARGET( call ) ( services_t ) IPC_GET_ARG3( * call ) |
141 | #define IPC_GET_TARGET( call ) ( services_t ) IPC_GET_ARG3( * call ) |
141 | #define IPC_GET_SENDER( call ) ( services_t ) IPC_GET_ARG3( * call ) |
142 | #define IPC_GET_SENDER( call ) ( services_t ) IPC_GET_ARG3( * call ) |
142 | 143 | ||
- | 144 | #define IPC_GET_ERROR( call ) ( services_t ) IPC_GET_ARG4( * call ) |
|
- | 145 | ||
143 | #define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
146 | #define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
144 | 147 | ||
145 | #define IPC_SET_ADDR( answer ) (( size_t * ) & IPC_GET_ARG1( * answer )) |
148 | #define IPC_SET_ADDR( answer ) (( size_t * ) & IPC_GET_ARG1( * answer )) |
146 | #define IPC_SET_PREFIX( answer ) (( size_t * ) & IPC_GET_ARG2( * answer )) |
149 | #define IPC_SET_PREFIX( answer ) (( size_t * ) & IPC_GET_ARG2( * answer )) |
147 | #define IPC_SET_CONTENT( answer ) (( size_t * ) & IPC_GET_ARG3( * answer )) |
150 | #define IPC_SET_CONTENT( answer ) (( size_t * ) & IPC_GET_ARG3( * answer )) |
148 | #define IPC_SET_SUFFIX( answer ) (( size_t * ) & IPC_GET_ARG4( * answer )) |
151 | #define IPC_SET_SUFFIX( answer ) (( size_t * ) & IPC_GET_ARG4( * answer )) |
149 | 152 | ||
150 | typedef enum { |
153 | typedef enum { |
151 | /* () not supported, registers new device */ |
154 | /* () not supported, registers new device */ |
152 | NET_NET_DEVICE = NET_NET_FIRST, |
155 | NET_NET_DEVICE = NET_NET_FIRST, |
153 | /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
156 | /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
154 | NET_NET_GET_CONF, |
157 | NET_NET_GET_CONF, |
155 | /* ( device_id, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
158 | /* ( device_id, count ), measured_strings_send( names ), measured_strings_return( values ) */ |
156 | NET_NET_GET_DEVICE_CONF, |
159 | NET_NET_GET_DEVICE_CONF, |
157 | /* () not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
160 | /* () not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
158 | NET_NET_SET_CONF, |
161 | NET_NET_SET_CONF, |
159 | /* ( device_id, count ) not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
162 | /* ( device_id, count ) not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
160 | NET_NET_SET_DEVICE_CONF, |
163 | NET_NET_SET_DEVICE_CONF, |
161 | /* () */ |
164 | /* () */ |
162 | NET_NET_STARTUP, |
165 | NET_NET_STARTUP, |
163 | /* ( device_id ) */ |
166 | /* ( device_id ) */ |
164 | NET_NET_START, |
167 | NET_NET_START, |
165 | /* ( device_id ) */ |
168 | /* ( device_id ) */ |
166 | NET_NET_STOP, |
169 | NET_NET_STOP, |
167 | /* ( device_id ) ipc_data_read( stats ) */ |
170 | /* ( device_id ) ipc_data_read( stats ) */ |
168 | NET_NET_STATS, |
171 | NET_NET_STATS, |
169 | } net_messages; |
172 | } net_messages; |
170 | 173 | ||
171 | static inline int generic_get_addr( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){ |
174 | static inline int generic_get_addr( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){ |
172 | aid_t message_id; |
175 | aid_t message_id; |
173 | ipcarg_t result; |
176 | ipcarg_t result; |
174 | int string; |
177 | int string; |
175 | 178 | ||
176 | if( !( address && data )) return EBADMEM; |
179 | if( !( address && data )) return EBADMEM; |
177 | message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL ); |
180 | message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL ); |
178 | string = measured_strings_return( phone, address, data, 1 ); |
181 | string = measured_strings_return( phone, address, data, 1 ); |
179 | async_wait_for( message_id, & result ); |
182 | async_wait_for( message_id, & result ); |
180 | if(( string == EOK ) && ( result != EOK )){ |
183 | if(( string == EOK ) && ( result != EOK )){ |
181 | free( * address ); |
184 | free( * address ); |
182 | free( * data ); |
185 | free( * data ); |
183 | } |
186 | } |
184 | return ( int ) result; |
187 | return ( int ) result; |
185 | } |
188 | } |
186 | 189 | ||
187 | 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 ){ |
190 | 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 ){ |
188 | aid_t message_id; |
191 | aid_t message_id; |
189 | ipcarg_t result; |
192 | ipcarg_t result; |
190 | int string; |
193 | int string; |
191 | 194 | ||
192 | if( !( configuration && ( count > 0 ))) return EINVAL; |
195 | if( !( configuration && ( count > 0 ))) return EINVAL; |
193 | if( !( translation && data )) return EBADMEM; |
196 | if( !( translation && data )) return EBADMEM; |
194 | message_id = async_send_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) count, ( ipcarg_t ) service, NULL ); |
197 | message_id = async_send_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) count, ( ipcarg_t ) service, NULL ); |
195 | measured_strings_send( phone, configuration, count ); |
198 | measured_strings_send( phone, configuration, count ); |
196 | string = measured_strings_return( phone, translation, data, count ); |
199 | string = measured_strings_return( phone, translation, data, count ); |
197 | async_wait_for( message_id, & result ); |
200 | async_wait_for( message_id, & result ); |
198 | if(( string == EOK ) && ( result != EOK )){ |
201 | if(( string == EOK ) && ( result != EOK )){ |
199 | free( * translation ); |
202 | free( * translation ); |
200 | free( * data ); |
203 | free( * data ); |
201 | } |
204 | } |
202 | return ( int ) result; |
205 | return ( int ) result; |
203 | } |
206 | } |
204 | 207 | ||
205 | static inline int generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender ){ |
208 | static inline int generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender, services_t error ){ |
- | 209 | if( error ){ |
|
- | 210 | async_msg_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender, ( ipcarg_t ) error ); |
|
- | 211 | }else{ |
|
206 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender ); |
212 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender ); |
- | 213 | } |
|
207 | return EOK; |
214 | return EOK; |
208 | } |
215 | } |
209 | 216 | ||
210 | 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 ){ |
217 | 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 ){ |
211 | 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 ); |
218 | 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 ); |
212 | } |
219 | } |
213 | 220 | ||
214 | static inline int generic_device_state_msg( int phone, int message, device_id_t device_id, int state, services_t target ){ |
221 | static inline int generic_device_state_msg( int phone, int message, device_id_t device_id, int state, services_t target ){ |
215 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state, target ); |
222 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state, target ); |
216 | return EOK; |
223 | return EOK; |
217 | } |
224 | } |
218 | 225 | ||
219 | static inline int generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target ){ |
226 | static inline int generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target, services_t error ){ |
- | 227 | if( error ){ |
|
- | 228 | async_msg_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target, ( ipcarg_t ) error ); |
|
- | 229 | }else{ |
|
220 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target ); |
230 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target ); |
- | 231 | } |
|
221 | return EOK; |
232 | return EOK; |
222 | } |
233 | } |
223 | 234 | ||
224 | static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){ |
235 | static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){ |
225 | return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service ); |
236 | return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service ); |
226 | } |
237 | } |
227 | 238 | ||
228 | #endif |
239 | #endif |
229 | 240 | ||
230 | /** @} |
241 | /** @} |
231 | */ |
242 | */ |
232 | 243 |