00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00037 #include <generic.h>
00038 #include <async.h>
00039 #include <ipc/services.h>
00040 #include <net/device.h>
00041 #include <adt/measured_strings.h>
00042 #include <net/packet.h>
00043
00054 int
00055 generic_device_state_msg_remote(int phone, int message, device_id_t device_id,
00056 int state, services_t target)
00057 {
00058 async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
00059 (sysarg_t) state, target);
00060
00061 return EOK;
00062 }
00063
00076 int
00077 generic_device_req_remote(int phone, int message, device_id_t device_id,
00078 int arg2, services_t service)
00079 {
00080 return (int) async_req_3_0(phone, (sysarg_t) message,
00081 (sysarg_t) device_id, (sysarg_t) arg2, (sysarg_t) service);
00082 }
00083
00097 int
00098 generic_get_addr_req(int phone, int message, device_id_t device_id,
00099 measured_string_t **address, uint8_t **data)
00100 {
00101 aid_t message_id;
00102 sysarg_t result;
00103 int string;
00104
00105 if (!address || !data)
00106 return EBADMEM;
00107
00108
00109 message_id = async_send_1(phone, (sysarg_t) message,
00110 (sysarg_t) device_id, NULL);
00111 string = measured_strings_return(phone, address, data, 1);
00112 async_wait_for(message_id, &result);
00113
00114
00115 if ((string == EOK) && (result != EOK)) {
00116
00117 free(*address);
00118 free(*data);
00119 }
00120
00121 return (int) result;
00122 }
00123
00135 int
00136 generic_packet_size_req_remote(int phone, int message, device_id_t device_id,
00137 packet_dimension_t *packet_dimension)
00138 {
00139 if (!packet_dimension)
00140 return EBADMEM;
00141
00142 sysarg_t addr_len;
00143 sysarg_t prefix;
00144 sysarg_t content;
00145 sysarg_t suffix;
00146
00147 sysarg_t result = async_req_1_4(phone, (sysarg_t) message,
00148 (sysarg_t) device_id, &addr_len, &prefix, &content, &suffix);
00149
00150 packet_dimension->prefix = (size_t) prefix;
00151 packet_dimension->content = (size_t) content;
00152 packet_dimension->suffix = (size_t) suffix;
00153 packet_dimension->addr_len = (size_t) addr_len;
00154
00155 return (int) result;
00156 }
00157
00169 int
00170 generic_received_msg_remote(int phone, int message, device_id_t device_id,
00171 packet_id_t packet_id, services_t target, services_t error)
00172 {
00173 if (error) {
00174 async_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
00175 (sysarg_t) packet_id, (sysarg_t) target, (sysarg_t) error);
00176 } else {
00177 async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
00178 (sysarg_t) packet_id, (sysarg_t) target);
00179 }
00180
00181 return EOK;
00182 }
00183
00195 int
00196 generic_send_msg_remote(int phone, int message, device_id_t device_id,
00197 packet_id_t packet_id, services_t sender, services_t error)
00198 {
00199 if (error) {
00200 async_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
00201 (sysarg_t) packet_id, (sysarg_t) sender, (sysarg_t) error);
00202 } else {
00203 async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
00204 (sysarg_t) packet_id, (sysarg_t) sender);
00205 }
00206
00207 return EOK;
00208 }
00209
00230 int
00231 generic_translate_req(int phone, int message, device_id_t device_id,
00232 services_t service, measured_string_t *configuration, size_t count,
00233 measured_string_t **translation, uint8_t **data)
00234 {
00235 aid_t message_id;
00236 sysarg_t result;
00237 int string;
00238
00239 if (!configuration || (count == 0))
00240 return EINVAL;
00241 if (!translation || !data)
00242 return EBADMEM;
00243
00244
00245 message_id = async_send_3(phone, (sysarg_t) message,
00246 (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);
00247 measured_strings_send(phone, configuration, count);
00248 string = measured_strings_return(phone, translation, data, count);
00249 async_wait_for(message_id, &result);
00250
00251
00252 if ((string == EOK) && (result != EOK)) {
00253
00254 free(*translation);
00255 free(*data);
00256 }
00257
00258 return (int) result;
00259 }
00260