Changeset 6b82009 in mainline for uspace/lib/net/generic
- Timestamp:
- 2011-06-22T20:41:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef09a7a
- Parents:
- 55091847
- Location:
- uspace/lib/net/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/generic/generic.c
r55091847 r6b82009 37 37 #include <generic.h> 38 38 #include <async.h> 39 #include <async_obsolete.h>40 39 #include <ipc/services.h> 41 40 #include <net/device.h> … … 45 44 /** Notify the module about the device state change. 46 45 * 47 * @param[in] phone The service module phone. 48 * @param[in] message The service specific message. 49 * @param[in] device_id The device identifier. 50 * @param[in] state The new device state. 51 * @param[in] target The target module service. 52 * @return EOK on success. 53 * 54 */ 55 int 56 generic_device_state_msg_remote(int phone, int message, device_id_t device_id, 57 int state, services_t target) 58 { 59 async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id, 60 (sysarg_t) state, target); 46 * @param[in] sess Service module session. 47 * @param[in] message Service specific message. 48 * @param[in] device_id Device identifier. 49 * @param[in] state New device state. 50 * @param[in] target Target module service. 51 * 52 * @return EOK on success. 53 * 54 */ 55 int generic_device_state_msg_remote(async_sess_t *sess, sysarg_t message, 56 device_id_t device_id, sysarg_t state, services_t target) 57 { 58 async_exch_t *exch = async_exchange_begin(sess); 59 async_msg_3(exch, message, (sysarg_t) device_id, state, target); 60 async_exchange_end(exch); 61 61 62 62 return EOK; … … 65 65 /** Notify a module about the device. 66 66 * 67 * @param[in] phone The service module phone. 68 * @param[in] message The service specific message. 69 * @param[in] device_id The device identifier. 70 * @param[in] arg2 The second argument of the message. 71 * @param[in] service The device module service. 72 * @return EOK on success. 73 * @return Other error codes as defined for the specific service 74 * message. 75 * 76 */ 77 int 78 generic_device_req_remote(int phone, int message, device_id_t device_id, 79 int arg2, services_t service) 80 { 81 return (int) async_obsolete_req_3_0(phone, (sysarg_t) message, 82 (sysarg_t) device_id, (sysarg_t) arg2, (sysarg_t) service); 67 * @param[in] sess Service module session. 68 * @param[in] message Service specific message. 69 * @param[in] device_id Device identifier. 70 * @param[in] arg2 Second argument of the message. 71 * @param[in] service Device module service. 72 * 73 * @return EOK on success. 74 * @return Other error codes as defined for the specific service 75 * message. 76 * 77 */ 78 int generic_device_req_remote(async_sess_t *sess, sysarg_t message, 79 device_id_t device_id, sysarg_t arg2, services_t service) 80 { 81 async_exch_t *exch = async_exchange_begin(sess); 82 int rc = async_req_3_0(exch, message, (sysarg_t) device_id, 83 arg2, (sysarg_t) service); 84 async_exchange_end(exch); 85 86 return rc; 83 87 } 84 88 85 89 /** Returns the address. 86 90 * 87 * @param[in] phone The service module phone. 88 * @param[in] message The service specific message. 89 * @param[in] device_id The device identifier. 90 * @param[out] address The desired address. 91 * @param[out] data The address data container. 92 * @return EOK on success. 93 * @return EBADMEM if the address parameter and/or the data 94 * parameter is NULL. 95 * @return Other error codes as defined for the specific service 96 * message. 97 */ 98 int 99 generic_get_addr_req(int phone, int message, device_id_t device_id, 100 measured_string_t **address, uint8_t **data) 101 { 102 aid_t message_id; 91 * @param[in] sess Service module session. 92 * @param[in] message Service specific message. 93 * @param[in] device_id Device identifier. 94 * @param[out] address Desired address. 95 * @param[out] data Address data container. 96 * 97 * @return EOK on success. 98 * @return EBADMEM if the address parameter and/or the data 99 * parameter is NULL. 100 * @return Other error codes as defined for the specific service 101 * message. 102 * 103 */ 104 int generic_get_addr_req(async_sess_t *sess, sysarg_t message, 105 device_id_t device_id, measured_string_t **address, uint8_t **data) 106 { 107 if ((!address) || (!data)) 108 return EBADMEM; 109 110 /* Request the address */ 111 async_exch_t *exch = async_exchange_begin(sess); 112 aid_t message_id = async_send_1(exch, message, (sysarg_t) device_id, 113 NULL); 114 int rc = measured_strings_return(exch, address, data, 1); 115 async_exchange_end(exch); 116 103 117 sysarg_t result; 104 int string;105 106 if (!address || !data)107 return EBADMEM;108 109 /* Request the address */110 message_id = async_obsolete_send_1(phone, (sysarg_t) message,111 (sysarg_t) device_id, NULL);112 string = measured_strings_return(phone, address, data, 1);113 118 async_wait_for(message_id, &result); 114 119 115 120 /* If not successful */ 116 if (( string== EOK) && (result != EOK)) {121 if ((rc == EOK) && (result != EOK)) { 117 122 /* Clear the data */ 118 123 free(*address); … … 125 130 /** Return the device packet dimension for sending. 126 131 * 127 * @param[in] phone The service module phone. 128 * @param[in] message The service specific message. 129 * @param[in] device_id The device identifier. 130 * @param[out] packet_dimension The packet dimension. 131 * @return EOK on success. 132 * @return EBADMEM if the packet_dimension parameter is NULL. 133 * @return Other error codes as defined for the specific service 134 * message. 135 */ 136 int 137 generic_packet_size_req_remote(int phone, int message, device_id_t device_id, 138 packet_dimension_t *packet_dimension) 132 * @param[in] sess Service module session. 133 * @param[in] message Service specific message. 134 * @param[in] device_id Device identifier. 135 * @param[out] packet_dimension Packet dimension. 136 * 137 * @return EOK on success. 138 * @return EBADMEM if the packet_dimension parameter is NULL. 139 * @return Other error codes as defined for the specific service 140 * message. 141 * 142 */ 143 int generic_packet_size_req_remote(async_sess_t *sess, sysarg_t message, 144 device_id_t device_id, packet_dimension_t *packet_dimension) 139 145 { 140 146 if (!packet_dimension) … … 146 152 sysarg_t suffix; 147 153 148 sysarg_t result = async_obsolete_req_1_4(phone, (sysarg_t) message, 149 (sysarg_t) device_id, &addr_len, &prefix, &content, &suffix); 154 async_exch_t *exch = async_exchange_begin(sess); 155 sysarg_t result = async_req_1_4(exch, message, (sysarg_t) device_id, 156 &addr_len, &prefix, &content, &suffix); 157 async_exchange_end(exch); 150 158 151 159 packet_dimension->prefix = (size_t) prefix; … … 159 167 /** Pass the packet queue to the module. 160 168 * 161 * @param[in] phone The service module phone. 162 * @param[in] message The service specific message. 163 * @param[in] device_id The device identifier. 164 * @param[in] packet_id The received packet or the received packet queue 165 * identifier. 166 * @param[in] target The target module service. 167 * @param[in] error The error module service. 168 * @return EOK on success. 169 */ 170 int 171 generic_received_msg_remote(int phone, int message, device_id_t device_id, 172 packet_id_t packet_id, services_t target, services_t error) 173 { 169 * @param[in] sess Service module session. 170 * @param[in] message Service specific message. 171 * @param[in] device_id Device identifier. 172 * @param[in] packet_id Received packet or the received packet queue 173 * identifier. 174 * @param[in] target Target module service. 175 * @param[in] error Error module service. 176 * 177 * @return EOK on success. 178 * 179 */ 180 int generic_received_msg_remote(async_sess_t *sess, sysarg_t message, 181 device_id_t device_id, packet_id_t packet_id, services_t target, 182 services_t error) 183 { 184 async_exch_t *exch = async_exchange_begin(sess); 185 174 186 if (error) { 175 async_ obsolete_msg_4(phone, (sysarg_t)message, (sysarg_t) device_id,187 async_msg_4(exch, message, (sysarg_t) device_id, 176 188 (sysarg_t) packet_id, (sysarg_t) target, (sysarg_t) error); 177 189 } else { 178 async_ obsolete_msg_3(phone, (sysarg_t)message, (sysarg_t) device_id,190 async_msg_3(exch, message, (sysarg_t) device_id, 179 191 (sysarg_t) packet_id, (sysarg_t) target); 180 192 } 181 193 194 async_exchange_end(exch); 195 182 196 return EOK; 183 197 } … … 185 199 /** Send the packet queue. 186 200 * 187 * @param[in] phone The service module phone. 188 * @param[in] message The service specific message. 189 * @param[in] device_id The device identifier. 190 * @param[in] packet_id The packet or the packet queue identifier. 191 * @param[in] sender The sending module service. 192 * @param[in] error The error module service. 193 * @return EOK on success. 194 * 195 */ 196 int 197 generic_send_msg_remote(int phone, int message, device_id_t device_id, 198 packet_id_t packet_id, services_t sender, services_t error) 199 { 201 * @param[in] sess Service module session. 202 * @param[in] message Service specific message. 203 * @param[in] device_id Device identifier. 204 * @param[in] packet_id Packet or the packet queue identifier. 205 * @param[in] sender Sending module service. 206 * @param[in] error Error module service. 207 * 208 * @return EOK on success. 209 * 210 */ 211 int generic_send_msg_remote(async_sess_t *sess, sysarg_t message, 212 device_id_t device_id, packet_id_t packet_id, services_t sender, 213 services_t error) 214 { 215 async_exch_t *exch = async_exchange_begin(sess); 216 200 217 if (error) { 201 async_ obsolete_msg_4(phone, (sysarg_t)message, (sysarg_t) device_id,218 async_msg_4(exch, message, (sysarg_t) device_id, 202 219 (sysarg_t) packet_id, (sysarg_t) sender, (sysarg_t) error); 203 220 } else { 204 async_ obsolete_msg_3(phone, (sysarg_t)message, (sysarg_t) device_id,221 async_msg_3(exch, message, (sysarg_t) device_id, 205 222 (sysarg_t) packet_id, (sysarg_t) sender); 206 223 } 207 224 225 async_exchange_end(exch); 226 208 227 return EOK; 209 228 } … … 213 232 * Allocates and returns the needed memory block as the data parameter. 214 233 * 215 * @param[in] phone The service module phone. 216 * @param[in] message The service specific message. 217 * @param[in] device_id The device identifier. 218 * @param[in] service The module service. 219 * @param[in] configuration The key strings. 220 * @param[in] count The number of configuration keys. 221 * @param[out] translation The translated values. 222 * @param[out] data The translation data container. 223 * @return EOK on success. 224 * @return EINVAL if the configuration parameter is NULL. 225 * @return EINVAL if the count parameter is zero. 226 * @return EBADMEM if the translation or the data parameters are 227 * NULL. 228 * @return Other error codes as defined for the specific service 229 * message. 230 */ 231 int 232 generic_translate_req(int phone, int message, device_id_t device_id, 233 services_t service, measured_string_t *configuration, size_t count, 234 * @param[in] sess Service module session. 235 * @param[in] message Service specific message. 236 * @param[in] device_id Device identifier. 237 * @param[in] service Module service. 238 * @param[in] configuration Key strings. 239 * @param[in] count Number of configuration keys. 240 * @param[out] translation Translated values. 241 * @param[out] data Translation data container. 242 * 243 * @return EOK on success. 244 * @return EINVAL if the configuration parameter is NULL. 245 * @return EINVAL if the count parameter is zero. 246 * @return EBADMEM if the translation or the data parameters are 247 * NULL. 248 * @return Other error codes as defined for the specific service 249 * message. 250 * 251 */ 252 int generic_translate_req(async_sess_t *sess, sysarg_t message, 253 device_id_t device_id, services_t service, 254 measured_string_t *configuration, size_t count, 234 255 measured_string_t **translation, uint8_t **data) 235 256 { 236 aid_t message_id; 257 if ((!configuration) || (count == 0)) 258 return EINVAL; 259 260 if ((!translation) || (!data)) 261 return EBADMEM; 262 263 /* Request the translation */ 264 async_exch_t *exch = async_exchange_begin(sess); 265 aid_t message_id = async_send_3(exch, message, (sysarg_t) device_id, 266 (sysarg_t) count, (sysarg_t) service, NULL); 267 measured_strings_send(exch, configuration, count); 268 int rc = measured_strings_return(exch, translation, data, count); 269 async_exchange_end(exch); 270 237 271 sysarg_t result; 238 int string;239 240 if (!configuration || (count == 0))241 return EINVAL;242 if (!translation || !data)243 return EBADMEM;244 245 /* Request the translation */246 message_id = async_obsolete_send_3(phone, (sysarg_t) message,247 (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);248 measured_strings_send(phone, configuration, count);249 string = measured_strings_return(phone, translation, data, count);250 272 async_wait_for(message_id, &result); 251 273 252 274 /* If not successful */ 253 if (( string== EOK) && (result != EOK)) {275 if ((rc == EOK) && (result != EOK)) { 254 276 /* Clear the data */ 255 277 free(*translation); 256 278 free(*data); 257 279 } 258 280 259 281 return (int) result; 260 282 } -
uspace/lib/net/generic/net_remote.c
r55091847 r6b82009 47 47 #include <adt/measured_strings.h> 48 48 49 /** Connect sto the networking module.49 /** Connect to the networking module. 50 50 * 51 * @return The networking module phone on success. 51 * @return Networking module session on success. 52 * 52 53 */ 53 intnet_connect_module(void)54 async_sess_t *net_connect_module(void) 54 55 { 55 56 return connect_to_service(SERVICE_NETWORKING); 56 57 } 57 58 58 /** Free sthe received settings.59 /** Free the received settings. 59 60 * 60 * @param[in] settings The received settings. 61 * @param[in] data The received settings data. 62 * @see net_get_device_conf_req() 61 * @param[in] settings Received settings. 62 * @param[in] data Received settings data. 63 * 64 * @see net_get_device_conf_req() 63 65 * @see net_get_conf_req() 66 * 64 67 */ 65 68 void net_free_settings(measured_string_t *settings, uint8_t *data) … … 71 74 } 72 75 73 /** Return sthe global configuration.76 /** Return the global configuration. 74 77 * 75 78 * The configuration names are read and the appropriate settings are set … … 77 80 * configuration. 78 81 * 79 * @param[in] net_phone The networking module phone. 80 * @param[in,out] configuration The requested configuration. The names are read 81 * and the appropriate settings are set instead. 82 * @param[in] sess Networking module session. 83 * @param[in,out] configuration Requested configuration. The names are 84 * read and the appropriate settings are set 85 * instead. 82 86 * 83 * @param[in] count The configuration entries count. 84 * @param[in,out] data The configuration and settings data. 85 * @return EOK on success. 86 * @return EINVAL if the configuration is NULL. 87 * @return EINVAL if the count is zero. 88 * @return Other error codes as defined for the 89 * generic_translate_req() function. 87 * @param[in] count Configuration entries count. 88 * @param[in,out] data Configuration and settings data. 89 * 90 * @return EOK on success. 91 * @return EINVAL if the configuration is NULL. 92 * @return EINVAL if the count is zero. 93 * @return Other error codes as defined for the 94 * generic_translate_req() function. 95 * 90 96 */ 91 int 92 net_get_conf_req(int net_phone, measured_string_t **configuration, 97 int net_get_conf_req(async_sess_t *sess, measured_string_t **configuration, 93 98 size_t count, uint8_t **data) 94 99 { 95 return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,100 return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF, 0, 0, 96 101 *configuration, count, configuration, data); 97 102 } 98 103 99 /** Return sthe device specific configuration.104 /** Return the device specific configuration. 100 105 * 101 * Return sthe global configuration if the device specific is not found.106 * Return the global configuration if the device specific is not found. 102 107 * The configuration names are read and the appropriate settings are set 103 108 * instead. Call net_free_settings() function to release the returned 104 109 * configuration. 105 110 * 106 * @param[in] net_phone The networking module phone. 107 * @param[in] device_id The device identifier. 108 * @param[in,out] configuration The requested device configuration. The names 109 * are read and the appropriate settings are set instead. 110 * @param[in] count The configuration entries count. 111 * @param[in,out] data The configuration and settings data. 112 * @return EOK on success. 113 * @return EINVAL if the configuration is NULL. 114 * @return EINVAL if the count is zero. 115 * @return Other error codes as defined for the 116 * generic_translate_req() function. 111 * @param[in] sess The networking module session. 112 * @param[in] device_id Device identifier. 113 * @param[in,out] configuration Requested device configuration. The names 114 * are read and the appropriate settings are 115 * set instead. 116 * @param[in] count Configuration entries count. 117 * @param[in,out] data Configuration and settings data. 118 * 119 * @return EOK on success. 120 * @return EINVAL if the configuration is NULL. 121 * @return EINVAL if the count is zero. 122 * @return Other error codes as defined for the 123 * generic_translate_req() function. 124 * 117 125 */ 118 int 119 net_get_device_conf_req(int net_phone, device_id_t device_id, 126 int net_get_device_conf_req(async_sess_t *sess, device_id_t device_id, 120 127 measured_string_t **configuration, size_t count, uint8_t **data) 121 128 { 122 return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF,129 return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF, 123 130 device_id, 0, *configuration, count, configuration, data); 124 131 } -
uspace/lib/net/generic/packet_client.c
r55091847 r6b82009 247 247 } 248 248 249 /** Returns the packet copy. 250 * 251 * Copies the addresses, data, order and metric values. 252 * Does not copy the queue placement. 253 * 254 * @param[in] phone The packet server module phone. 255 * @param[in] packet The original packet. 256 * @return The packet copy. 257 * @return NULL on error. 258 */ 259 packet_t *packet_get_copy(int phone, packet_t *packet) 260 { 261 packet_t *copy; 262 uint8_t * src = NULL; 263 uint8_t * dest = NULL; 264 size_t addrlen; 265 266 if (!packet_is_valid(packet)) 267 return NULL; 268 249 /** Return the packet copy. 250 * 251 * Copy the addresses, data, order and metric values. 252 * Queue placement is not copied. 253 * 254 * @param[in] sess Packet server module session. 255 * @param[in] packet Original packet. 256 * 257 * @return Packet copy. 258 * @return NULL on error. 259 * 260 */ 261 packet_t *packet_get_copy(async_sess_t *sess, packet_t *packet) 262 { 263 if (!packet_is_valid(packet)) 264 return NULL; 265 269 266 /* Get a new packet */ 270 copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet),267 packet_t *copy = packet_get_4_remote(sess, PACKET_DATA_LENGTH(packet), 271 268 PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix, 272 269 PACKET_MIN_SUFFIX(packet)); 270 273 271 if (!copy) 274 272 return NULL; 275 273 276 274 /* Get addresses */ 277 addrlen = packet_get_addr(packet, &src, &dest); 275 uint8_t *src = NULL; 276 uint8_t *dest = NULL; 277 size_t addrlen = packet_get_addr(packet, &src, &dest); 278 278 279 /* Copy data */ 279 280 if ((packet_copy_data(copy, packet_get_data(packet), … … 286 287 return copy; 287 288 } else { 288 pq_release_remote( phone, copy->packet_id);289 pq_release_remote(sess, copy->packet_id); 289 290 return NULL; 290 291 } -
uspace/lib/net/generic/packet_remote.c
r55091847 r6b82009 37 37 38 38 #include <async.h> 39 #include <async_obsolete.h>40 39 #include <errno.h> 41 40 #include <ipc/packet.h> … … 52 51 * Create the local packet mapping as well. 53 52 * 54 * @param[in] phone The packet server module phone.55 * @param[out] packet The packet reference pointer to store the received53 * @param[in] sess Packet server module session. 54 * @param[out] packet Packet reference pointer to store the received 56 55 * packet reference. 57 * @param[in] packet_id The packet identifier.58 * @param[in] size The packet total size in bytes.56 * @param[in] packet_id Packet identifier. 57 * @param[in] size Packet total size in bytes. 59 58 * 60 59 * @return EOK on success. 61 60 * @return Other error codes as defined for the pm_add() function. 62 * @return Other error codes as defined for the async_obsolete_share_in_start() function. 63 * 64 */ 65 static int 66 packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size) 67 { 61 * @return Other error codes as defined for the async_share_in_start() 62 * function. 63 * 64 */ 65 static int packet_return(async_sess_t *sess, packet_t **packet, 66 packet_id_t packet_id, size_t size) 67 { 68 *packet = (packet_t *) as_get_mappable_page(size); 69 70 async_exch_t *exch = async_exchange_begin(sess); 68 71 ipc_call_t answer; 69 aid_t message ;70 int rc ;71 72 message = async_obsolete_send_1(phone, NET_PACKET_GET, packet_id, &answer);73 74 *packet = (packet_t *) as_get_mappable_page(size);75 rc = async_obsolete_share_in_start_0_0(phone, *packet, size);72 aid_t message = async_send_1(exch, NET_PACKET_GET, packet_id, &answer); 73 int rc = async_share_in_start_0_0(exch, *packet, size); 74 async_exchange_end(exch); 75 76 sysarg_t result; 77 async_wait_for(message, &result); 78 76 79 if (rc != EOK) { 77 80 munmap(*packet, size); 78 async_wait_for(message, NULL);79 81 return rc; 80 82 } 83 81 84 rc = pm_add(*packet); 82 85 if (rc != EOK) { 83 86 munmap(*packet, size); 84 async_wait_for(message, NULL);85 87 return rc; 86 88 } 87 89 88 sysarg_t result;89 async_wait_for(message, &result);90 91 90 return result; 92 91 } 93 92 94 /** Translates the packet identifier to the packet reference. 95 * 96 * Tries to find mapping first. 97 * Contacts the packet server to share the packet if the mapping is not present. 98 * 99 * @param[in] phone The packet server module phone. 100 * @param[out] packet The packet reference. 101 * @param[in] packet_id The packet identifier. 102 * @return EOK on success. 103 * @return EINVAL if the packet parameter is NULL. 104 * @return Other error codes as defined for the NET_PACKET_GET_SIZE 105 * message. 106 * @return Other error codes as defined for the packet_return() 107 * function. 108 */ 109 int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id) 110 { 111 int rc; 112 93 /** Translate the packet identifier to the packet reference. 94 * 95 * Try to find mapping first. The packet server is asked to share 96 * the packet if the mapping is not present. 97 * 98 * @param[in] sess Packet server module session. 99 * @param[out] packet Packet reference. 100 * @param[in] packet_id Packet identifier. 101 * 102 * @return EOK on success. 103 * @return EINVAL if the packet parameter is NULL. 104 * @return Other error codes as defined for the NET_PACKET_GET_SIZE 105 * message. 106 * @return Other error codes as defined for the packet_return() 107 * function. 108 * 109 */ 110 int packet_translate_remote(async_sess_t *sess, packet_t **packet, 111 packet_id_t packet_id) 112 { 113 113 if (!packet) 114 114 return EINVAL; … … 116 116 *packet = pm_find(packet_id); 117 117 if (!*packet) { 118 async_exch_t *exch = async_exchange_begin(sess); 118 119 sysarg_t size; 120 int rc = async_req_1_1(exch, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 async_exchange_end(exch); 119 123 120 rc = async_obsolete_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,121 &size);122 124 if (rc != EOK) 123 125 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 126 127 rc = packet_return(sess, packet, packet_id, size); 125 128 if (rc != EOK) 126 129 return rc; 127 130 } 131 128 132 if ((*packet)->next) { 129 133 packet_t *next; 130 131 return packet_translate_remote(phone, &next, (*packet)->next); 134 return packet_translate_remote(sess, &next, (*packet)->next); 132 135 } 133 136 … … 135 138 } 136 139 137 /** Obtains the packet of the given dimensions. 138 * 139 * Contacts the packet server to return the appropriate packet. 140 * 141 * @param[in] phone The packet server module phone. 142 * @param[in] addr_len The source and destination addresses maximal length in 143 * bytes. 144 * @param[in] max_prefix The maximal prefix length in bytes. 145 * @param[in] max_content The maximal content length in bytes. 146 * @param[in] max_suffix The maximal suffix length in bytes. 147 * @return The packet reference. 148 * @return NULL on error. 149 */ 150 packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 151 size_t max_prefix, size_t max_suffix) 152 { 140 /** Obtain the packet of given dimensions. 141 * 142 * Contact the packet server to return the appropriate packet. 143 * 144 * @param[in] sess Packet server module session. 145 * @param[in] addr_len Source and destination addresses maximal length 146 * in bytes. 147 * @param[in] max_prefix Maximal prefix length in bytes. 148 * @param[in] max_content Maximal content length in bytes. 149 * @param[in] max_suffix Maximal suffix length in bytes. 150 * 151 * @return The packet reference. 152 * @return NULL on error. 153 * 154 */ 155 packet_t *packet_get_4_remote(async_sess_t *sess, size_t max_content, 156 size_t addr_len, size_t max_prefix, size_t max_suffix) 157 { 158 async_exch_t *exch = async_exchange_begin(sess); 153 159 sysarg_t packet_id; 154 160 sysarg_t size; 155 int rc; 156 157 rc = async_obsolete_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 161 int rc = async_req_4_2(exch, NET_PACKET_CREATE_4, max_content, addr_len, 158 162 max_prefix, max_suffix, &packet_id, &size); 163 async_exchange_end(exch); 164 159 165 if (rc != EOK) 160 166 return NULL; 161 167 162 163 168 packet_t *packet = pm_find(packet_id); 164 169 if (!packet) { 165 rc = packet_return( phone, &packet, packet_id, size);170 rc = packet_return(sess, &packet, packet_id, size); 166 171 if (rc != EOK) 167 172 return NULL; … … 171 176 } 172 177 173 /** Obtains the packet of the given content size. 174 * 175 * Contacts the packet server to return the appropriate packet. 176 * 177 * @param[in] phone The packet server module phone. 178 * @param[in] content The maximal content length in bytes. 179 * @return The packet reference. 180 * @return NULL on error. 181 */ 182 packet_t *packet_get_1_remote(int phone, size_t content) 183 { 178 /** Obtain the packet of given content size. 179 * 180 * Contact the packet server to return the appropriate packet. 181 * 182 * @param[in] sess Packet server module session. 183 * @param[in] content Maximal content length in bytes. 184 * 185 * @return The packet reference. 186 * @return NULL on error. 187 * 188 */ 189 packet_t *packet_get_1_remote(async_sess_t *sess, size_t content) 190 { 191 async_exch_t *exch = async_exchange_begin(sess); 184 192 sysarg_t packet_id; 185 193 sysarg_t size; 186 int rc; 187 188 rc = async_obsolete_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 194 int rc = async_req_1_2(exch, NET_PACKET_CREATE_1, content, &packet_id, 189 195 &size); 196 async_exchange_end(exch); 197 190 198 if (rc != EOK) 191 199 return NULL; … … 193 201 packet_t *packet = pm_find(packet_id); 194 202 if (!packet) { 195 rc = packet_return( phone, &packet, packet_id, size);203 rc = packet_return(sess, &packet, packet_id, size); 196 204 if (rc != EOK) 197 205 return NULL; … … 201 209 } 202 210 203 /** Release sthe packet queue.211 /** Release the packet queue. 204 212 * 205 213 * All packets in the queue are marked as free for use. … … 208 216 * received or obtained again. 209 217 * 210 * @param[in] phone The packet server module phone. 211 * @param[in] packet_id The packet identifier. 212 */ 213 void pq_release_remote(int phone, packet_id_t packet_id) 214 { 215 async_obsolete_msg_1(phone, NET_PACKET_RELEASE, packet_id); 218 * @param[in] sess Packet server module session. 219 * @param[in] packet_id Packet identifier. 220 * 221 */ 222 void pq_release_remote(async_sess_t *sess, packet_id_t packet_id) 223 { 224 async_exch_t *exch = async_exchange_begin(sess); 225 async_msg_1(exch, NET_PACKET_RELEASE, packet_id); 226 async_exchange_end(exch); 216 227 } 217 228
Note:
See TracChangeset
for help on using the changeset viewer.