Changes in uspace/lib/net/tl/tl_common.c [28a3e74:84c20da] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/tl/tl_common.c
r28a3e74 r84c20da 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 39 39 #include <packet_client.h> 40 40 #include <packet_remote.h> 41 #include <icmp_ remote.h>41 #include <icmp_interface.h> 42 42 #include <ip_remote.h> 43 43 #include <ip_interface.h> 44 #include <tl_ remote.h>44 #include <tl_interface.h> 45 45 46 46 #include <net/socket_codes.h> … … 54 54 #include <ipc/services.h> 55 55 #include <errno.h> 56 #include <err.h> 56 57 57 58 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); … … 64 65 * @param[in] addrlen The address length. 65 66 * @param[out] port The set port. 66 * @return EOK on success.67 * @return EINVAL if the address length does not match the address67 * @returns EOK on success. 68 * @returns EINVAL if the address length does not match the address 68 69 * family. 69 * @return EAFNOSUPPORT if the address family is not supported.70 * @returns EAFNOSUPPORT if the address family is not supported. 70 71 */ 71 72 int … … 120 121 int 121 122 tl_get_ip_packet_dimension(int ip_phone, 122 packet_dimensions_ t *packet_dimensions, device_id_t device_id,123 packet_dimension_ t **packet_dimension)124 { 125 int rc;123 packet_dimensions_ref packet_dimensions, device_id_t device_id, 124 packet_dimension_ref *packet_dimension) 125 { 126 ERROR_DECLARE; 126 127 127 128 if (!packet_dimension) … … 136 137 return ENOMEM; 137 138 138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension);139 if (rc != EOK) {139 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, 140 *packet_dimension))) { 140 141 free(*packet_dimension); 141 return rc;142 return ERROR_CODE; 142 143 } 143 144 144 rc= packet_dimensions_add(packet_dimensions, device_id,145 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, 145 146 *packet_dimension); 146 if ( rc< 0) {147 if (ERROR_CODE < 0) { 147 148 free(*packet_dimension); 148 return rc;149 return ERROR_CODE; 149 150 } 150 151 } … … 158 159 * @param[in] device_id The device identifier. 159 160 * @param[in] content The new maximum content size. 160 * @return EOK on success.161 * @returns EOK on success. 161 162 * @return ENOENT if the packet dimension is not cached. 162 163 */ 163 164 int 164 tl_update_ip_packet_dimension(packet_dimensions_ t *packet_dimensions,165 tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, 165 166 device_id_t device_id, size_t content) 166 167 { 167 packet_dimension_ t *packet_dimension;168 packet_dimension_ref packet_dimension; 168 169 169 170 packet_dimension = packet_dimensions_find(packet_dimensions, device_id); … … 182 183 else 183 184 packet_dimensions_exclude(packet_dimensions, 184 DEVICE_INVALID_ID , free);185 DEVICE_INVALID_ID); 185 186 } 186 187 } … … 196 197 * @param[in] addrlen The address length. 197 198 * @param[in] port The port to be set. 198 * @return EOK on success.199 * @return EINVAL if the address length does not match the address199 * @returns EOK on success. 200 * @returns EINVAL if the address length does not match the address 200 201 * family. 201 * @return EAFNOSUPPORT if the address family is not supported.202 * @returns EAFNOSUPPORT if the address family is not supported. 202 203 */ 203 204 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port) … … 244 245 * @param[in] error The packet error reporting service. Prefixes the 245 246 * 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,247 * @returns EOK on success. 248 * @returns ENOENT if no packet may be sent. 249 */ 250 int 251 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, 251 252 services_t error) 252 253 { 253 packet_t *next;254 packet_t next; 254 255 uint8_t *src; 255 256 int length; 256 257 257 / * Detach the first packet and release the others */258 // detach the first packet and release the others 258 259 next = pq_detach(packet); 259 260 if (next) … … 262 263 length = packet_get_addr(packet, &src, NULL); 263 264 if ((length > 0) && (!error) && (icmp_phone >= 0) && 264 /* 265 * Set both addresses to the source one (avoids the source address 266 * deletion before setting the destination one) 267 */ 265 // set both addresses to the source one (avoids the source address 266 // deletion before setting the destination one) 268 267 (packet_set_addr(packet, src, src, (size_t) length) == EOK)) { 269 268 return EOK; … … 282 281 * @param[in] addr The destination address. 283 282 * @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 the283 * @returns Number of bytes received. 284 * @returns EINVAL if the client does not send data. 285 * @returns ENOMEM if there is not enough memory left. 286 * @returns Other error codes as defined for the 288 287 * async_data_read_finalize() function. 289 288 */ 290 289 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,290 tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, 291 const packet_dimension_ref dimension, const struct sockaddr *addr, 293 292 socklen_t addrlen) 294 293 { 294 ERROR_DECLARE; 295 295 296 ipc_callid_t callid; 296 297 size_t length; 297 void *data; 298 int rc; 298 void * data; 299 299 300 300 if (!dimension) 301 301 return EINVAL; 302 302 303 / * Get the data length */303 // get the data length 304 304 if (!async_data_write_receive(&callid, &length)) 305 305 return EINVAL; 306 306 307 / * Get a new packet */307 // get a new packet 308 308 *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, 309 309 prefix + dimension->prefix, dimension->suffix); … … 311 311 return ENOMEM; 312 312 313 / * Allocate space in the packet */313 // allocate space in the packet 314 314 data = packet_suffix(*packet, length); 315 315 if (!data) { … … 318 318 } 319 319 320 /* Read the data into the packet */ 321 rc = async_data_write_finalize(callid, data, length); 322 if (rc != EOK) { 320 // read the data into the packet 321 if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) || 322 // set the packet destination address 323 ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, 324 addrlen))) { 323 325 pq_release_remote(packet_phone, packet_get_id(*packet)); 324 return rc; 325 } 326 327 /* Set the packet destination address */ 328 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 329 if (rc != EOK) { 330 pq_release_remote(packet_phone, packet_get_id(*packet)); 331 return rc; 326 return ERROR_CODE; 332 327 } 333 328
Note:
See TracChangeset
for help on using the changeset viewer.