Changeset b5e68c8 in mainline for uspace/lib/net/tl/tl_common.c
- Timestamp:
- 2011-05-12T16:49:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f36787d7
- Parents:
- e80329d6 (diff), 750636a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/tl/tl_common.c
re80329d6 rb5e68c8 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_ interface.h>41 #include <icmp_remote.h> 42 42 #include <ip_remote.h> 43 43 #include <ip_interface.h> 44 #include <tl_ interface.h>44 #include <tl_remote.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>57 56 58 57 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); … … 65 64 * @param[in] addrlen The address length. 66 65 * @param[out] port The set port. 67 * @return sEOK on success.68 * @return sEINVAL if the address length does not match the address66 * @return EOK on success. 67 * @return EINVAL if the address length does not match the address 69 68 * family. 70 * @return sEAFNOSUPPORT if the address family is not supported.69 * @return EAFNOSUPPORT if the address family is not supported. 71 70 */ 72 71 int … … 121 120 int 122 121 tl_get_ip_packet_dimension(int ip_phone, 123 packet_dimensions_ refpacket_dimensions, device_id_t device_id,124 packet_dimension_ ref*packet_dimension)125 { 126 ERROR_DECLARE;122 packet_dimensions_t *packet_dimensions, device_id_t device_id, 123 packet_dimension_t **packet_dimension) 124 { 125 int rc; 127 126 128 127 if (!packet_dimension) … … 137 136 return ENOMEM; 138 137 139 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,140 *packet_dimension))) {138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension); 139 if (rc != EOK) { 141 140 free(*packet_dimension); 142 return ERROR_CODE;141 return rc; 143 142 } 144 143 145 ERROR_CODE= packet_dimensions_add(packet_dimensions, device_id,144 rc = packet_dimensions_add(packet_dimensions, device_id, 146 145 *packet_dimension); 147 if ( ERROR_CODE< 0) {146 if (rc < 0) { 148 147 free(*packet_dimension); 149 return ERROR_CODE;148 return rc; 150 149 } 151 150 } … … 159 158 * @param[in] device_id The device identifier. 160 159 * @param[in] content The new maximum content size. 161 * @return sEOK on success.160 * @return EOK on success. 162 161 * @return ENOENT if the packet dimension is not cached. 163 162 */ 164 163 int 165 tl_update_ip_packet_dimension(packet_dimensions_ refpacket_dimensions,164 tl_update_ip_packet_dimension(packet_dimensions_t *packet_dimensions, 166 165 device_id_t device_id, size_t content) 167 166 { 168 packet_dimension_ refpacket_dimension;167 packet_dimension_t *packet_dimension; 169 168 170 169 packet_dimension = packet_dimensions_find(packet_dimensions, device_id); … … 183 182 else 184 183 packet_dimensions_exclude(packet_dimensions, 185 DEVICE_INVALID_ID );184 DEVICE_INVALID_ID, free); 186 185 } 187 186 } … … 197 196 * @param[in] addrlen The address length. 198 197 * @param[in] port The port to be set. 199 * @return sEOK on success.200 * @return sEINVAL if the address length does not match the address198 * @return EOK on success. 199 * @return EINVAL if the address length does not match the address 201 200 * family. 202 * @return sEAFNOSUPPORT if the address family is not supported.201 * @return EAFNOSUPPORT if the address family is not supported. 203 202 */ 204 203 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port) … … 245 244 * @param[in] error The packet error reporting service. Prefixes the 246 245 * received packet. 247 * @return sEOK on success.248 * @return sENOENT if no packet may be sent.249 */ 250 int 251 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t 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, 252 251 services_t error) 253 252 { 254 packet_t next;253 packet_t *next; 255 254 uint8_t *src; 256 255 int length; 257 256 258 / / detach the first packet and release the others257 /* Detach the first packet and release the others */ 259 258 next = pq_detach(packet); 260 259 if (next) … … 263 262 length = packet_get_addr(packet, &src, NULL); 264 263 if ((length > 0) && (!error) && (icmp_phone >= 0) && 265 // set both addresses to the source one (avoids the source address 266 // deletion before setting the destination one) 264 /* 265 * Set both addresses to the source one (avoids the source address 266 * deletion before setting the destination one) 267 */ 267 268 (packet_set_addr(packet, src, src, (size_t) length) == EOK)) { 268 269 return EOK; … … 281 282 * @param[in] addr The destination address. 282 283 * @param[in] addrlen The address length. 283 * @return sNumber of bytes received.284 * @return sEINVAL if the client does not send data.285 * @return sENOMEM if there is not enough memory left.286 * @return sOther error codes as defined for the284 * @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 287 288 * async_data_read_finalize() function. 288 289 */ 289 290 int 290 tl_socket_read_packet_data(int packet_phone, packet_ refpacket, size_t prefix,291 const packet_dimension_ refdimension, const struct sockaddr *addr,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, 292 293 socklen_t addrlen) 293 294 { 294 ERROR_DECLARE;295 296 295 ipc_callid_t callid; 297 296 size_t length; 298 void * data; 297 void *data; 298 int rc; 299 299 300 300 if (!dimension) 301 301 return EINVAL; 302 302 303 / / get the data length303 /* Get the data length */ 304 304 if (!async_data_write_receive(&callid, &length)) 305 305 return EINVAL; 306 306 307 / / get a new packet307 /* 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 packet313 /* 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 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))) { 320 /* Read the data into the packet */ 321 rc = async_data_write_finalize(callid, data, length); 322 if (rc != EOK) { 325 323 pq_release_remote(packet_phone, packet_get_id(*packet)); 326 return ERROR_CODE; 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; 327 332 } 328 333
Note:
See TracChangeset
for help on using the changeset viewer.