Changes in uspace/lib/net/tl/tl_common.c [28a3e74:609243f4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/tl/tl_common.c
r28a3e74 r609243f4 43 43 #include <ip_interface.h> 44 44 #include <tl_remote.h> 45 46 45 #include <net/socket_codes.h> 47 46 #include <net/in.h> … … 50 49 #include <net/device.h> 51 50 #include <net/packet.h> 52 53 51 #include <async.h> 54 52 #include <ipc/services.h> … … 107 105 * The reply is cached then. 108 106 * 109 * @param[in] ip_phone The IP moduel phone for (semi)remote calls. 110 * @param[in] packet_dimensions The packet dimensions cache. 111 * @param[in] device_id The device identifier. 112 * @param[out] packet_dimension The IP packet dimensions. 113 * @return EOK on success. 114 * @return EBADMEM if the packet_dimension parameter is NULL. 115 * @return ENOMEM if there is not enough memory left. 116 * @return EINVAL if the packet_dimensions cache is not valid. 117 * @return Other codes as defined for the ip_packet_size_req() 118 * function. 119 */ 120 int 121 tl_get_ip_packet_dimension(int ip_phone, 122 packet_dimensions_t *packet_dimensions, device_id_t device_id, 107 * @param[in] sess IP module session. 108 * @param[in] packet_dimensions Packet dimensions cache. 109 * @param[in] device_id Device identifier. 110 * @param[out] packet_dimension IP packet dimensions. 111 * 112 * @return EOK on success. 113 * @return EBADMEM if the packet_dimension parameter is NULL. 114 * @return ENOMEM if there is not enough memory left. 115 * @return EINVAL if the packet_dimensions cache is not valid. 116 * @return Other codes as defined for the ip_packet_size_req() 117 * function. 118 * 119 */ 120 int tl_get_ip_packet_dimension(async_sess_t *sess, 121 packet_dimensions_t *packet_dimensions, nic_device_id_t device_id, 123 122 packet_dimension_t **packet_dimension) 124 123 { 125 int rc;126 127 124 if (!packet_dimension) 128 125 return EBADMEM; … … 133 130 /* Ask for and remember them if not found */ 134 131 *packet_dimension = malloc(sizeof(**packet_dimension)); 135 if (!*packet_dimension)132 if (!*packet_dimension) 136 133 return ENOMEM; 137 134 138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension);135 int rc = ip_packet_size_req(sess, device_id, *packet_dimension); 139 136 if (rc != EOK) { 140 137 free(*packet_dimension); … … 163 160 int 164 161 tl_update_ip_packet_dimension(packet_dimensions_t *packet_dimensions, 165 device_id_t device_id, size_t content)162 nic_device_id_t device_id, size_t content) 166 163 { 167 164 packet_dimension_t *packet_dimension; … … 173 170 packet_dimension->content = content; 174 171 175 if (device_id != DEVICE_INVALID_ID) {172 if (device_id != NIC_DEVICE_INVALID_ID) { 176 173 packet_dimension = packet_dimensions_find(packet_dimensions, 177 DEVICE_INVALID_ID);174 NIC_DEVICE_INVALID_ID); 178 175 179 176 if (packet_dimension) { … … 182 179 else 183 180 packet_dimensions_exclude(packet_dimensions, 184 DEVICE_INVALID_ID, free);181 NIC_DEVICE_INVALID_ID, free); 185 182 } 186 183 } … … 236 233 /** Prepares the packet for ICMP error notification. 237 234 * 238 * Keeps the first packet and releases all the others. 239 * Releases all the packets on error. 240 * 241 * @param[in] packet_phone The packet server module phone. 242 * @param[in] icmp_phone The ICMP module phone. 243 * @param[in] packet The packet to be send. 244 * @param[in] error The packet error reporting service. Prefixes the 245 * received packet. 246 * @return EOK on success. 247 * @return ENOENT if no packet may be sent. 248 */ 249 int 250 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t *packet, 251 services_t error) 252 { 253 packet_t *next; 235 * Keep the first packet and release all the others. 236 * Release all the packets on error. 237 * 238 * @param[in] packet_sess Packet server module session. 239 * @param[in] icmp_sess ICMP module phone. 240 * @param[in] packet Packet to be send. 241 * @param[in] error Packet error reporting service. Prefixes the 242 * received packet. 243 * 244 * @return EOK on success. 245 * @return ENOENT if no packet may be sent. 246 * 247 */ 248 int tl_prepare_icmp_packet(async_sess_t *packet_sess, async_sess_t *icmp_sess, 249 packet_t *packet, services_t error) 250 { 251 /* Detach the first packet and release the others */ 252 packet_t *next = pq_detach(packet); 253 if (next) 254 pq_release_remote(packet_sess, packet_get_id(next)); 255 254 256 uint8_t *src; 255 int length; 256 257 /* Detach the first packet and release the others */ 258 next = pq_detach(packet); 259 if (next) 260 pq_release_remote(packet_phone, packet_get_id(next)); 261 262 length = packet_get_addr(packet, &src, NULL); 263 if ((length > 0) && (!error) && (icmp_phone >= 0) && 257 int length = packet_get_addr(packet, &src, NULL); 258 if ((length > 0) && (!error) && (icmp_sess) && 264 259 /* 265 260 * Set both addresses to the source one (avoids the source address … … 269 264 return EOK; 270 265 } else 271 pq_release_remote(packet_ phone, packet_get_id(packet));272 266 pq_release_remote(packet_sess, packet_get_id(packet)); 267 273 268 return ENOENT; 274 269 } … … 276 271 /** Receives data from the socket into a packet. 277 272 * 278 * @param[in] packet_phone The packet server module phone. 279 * @param[out] packet The new created packet. 280 * @param[in] prefix Reserved packet data prefix length. 281 * @param[in] dimension The packet dimension. 282 * @param[in] addr The destination address. 283 * @param[in] addrlen The address length. 284 * @return Number of bytes received. 285 * @return EINVAL if the client does not send data. 286 * @return ENOMEM if there is not enough memory left. 287 * @return Other error codes as defined for the 288 * async_data_read_finalize() function. 289 */ 290 int 291 tl_socket_read_packet_data(int packet_phone, packet_t **packet, size_t prefix, 292 const packet_dimension_t *dimension, const struct sockaddr *addr, 293 socklen_t addrlen) 273 * @param[in] sess Packet server module session. 274 * @param[out] packet New created packet. 275 * @param[in] prefix Reserved packet data prefix length. 276 * @param[in] dimension Packet dimension. 277 * @param[in] addr Destination address. 278 * @param[in] addrlen Address length. 279 * 280 * @return Number of bytes received. 281 * @return EINVAL if the client does not send data. 282 * @return ENOMEM if there is not enough memory left. 283 * @return Other error codes as defined for the 284 * async_data_read_finalize() function. 285 * 286 */ 287 int tl_socket_read_packet_data(async_sess_t *sess, packet_t **packet, 288 size_t prefix, const packet_dimension_t *dimension, 289 const struct sockaddr *addr, socklen_t addrlen) 294 290 { 295 291 ipc_callid_t callid; … … 306 302 307 303 /* Get a new packet */ 308 *packet = packet_get_4_remote( packet_phone, length, dimension->addr_len,304 *packet = packet_get_4_remote(sess, length, dimension->addr_len, 309 305 prefix + dimension->prefix, dimension->suffix); 310 306 if (!packet) … … 314 310 data = packet_suffix(*packet, length); 315 311 if (!data) { 316 pq_release_remote( packet_phone, packet_get_id(*packet));312 pq_release_remote(sess, packet_get_id(*packet)); 317 313 return ENOMEM; 318 314 } … … 321 317 rc = async_data_write_finalize(callid, data, length); 322 318 if (rc != EOK) { 323 pq_release_remote( packet_phone, packet_get_id(*packet));319 pq_release_remote(sess, packet_get_id(*packet)); 324 320 return rc; 325 321 } … … 328 324 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 329 325 if (rc != EOK) { 330 pq_release_remote( packet_phone, packet_get_id(*packet));326 pq_release_remote(sess, packet_get_id(*packet)); 331 327 return rc; 332 328 }
Note:
See TracChangeset
for help on using the changeset viewer.