Changeset 84c20da in mainline for uspace/lib/net/tl/tl_common.c
- Timestamp:
- 2010-10-17T22:07:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b11576d
- Parents:
- 25171e5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/tl/tl_common.c
r25171e5 r84c20da 27 27 */ 28 28 29 /** @addtogroup net_tl30 * 29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Transport layer common functions implementation. 35 * @see tl_common.h 36 */ 34 * Transport layer common functions implementation. 35 * @see tl_common.h 36 */ 37 38 #include <tl_common.h> 39 #include <packet_client.h> 40 #include <packet_remote.h> 41 #include <icmp_interface.h> 42 #include <ip_remote.h> 43 #include <ip_interface.h> 44 #include <tl_interface.h> 37 45 38 46 #include <net/socket_codes.h> … … 40 48 #include <net/in6.h> 41 49 #include <net/inet.h> 50 #include <net/device.h> 51 #include <net/packet.h> 52 42 53 #include <async.h> 43 54 #include <ipc/services.h> … … 45 56 #include <err.h> 46 57 47 #include <net/packet.h>48 #include <packet_client.h>49 #include <packet_remote.h>50 #include <net/device.h>51 #include <icmp_interface.h>52 #include <ip_remote.h>53 #include <ip_interface.h>54 #include <tl_interface.h>55 #include <tl_common.h>56 57 58 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); 58 59 60 /** Gets the address port. 61 * 62 * Supports AF_INET and AF_INET6 address families. 63 * 64 * @param[in,out] addr The address to be updated. 65 * @param[in] addrlen The address length. 66 * @param[out] port The set port. 67 * @returns EOK on success. 68 * @returns EINVAL if the address length does not match the address 69 * family. 70 * @returns EAFNOSUPPORT if the address family is not supported. 71 */ 59 72 int 60 73 tl_get_address_port(const struct sockaddr *addr, int addrlen, uint16_t *port) … … 74 87 *port = ntohs(address_in->sin_port); 75 88 break; 89 76 90 case AF_INET6: 77 91 if (addrlen != sizeof(struct sockaddr_in6)) 78 92 return EINVAL; 79 93 80 94 address_in6 = (struct sockaddr_in6 *) addr; 81 95 *port = ntohs(address_in6->sin6_port); 82 96 break; 97 83 98 default: 84 99 return EAFNOSUPPORT; … … 93 108 * The reply is cached then. 94 109 * 95 * @param[in] ip_phoneThe IP moduel phone for (semi)remote calls.96 * @param[in] 97 * @param[in] device_idThe device identifier.98 * @param[out] packet_dimension 99 * 100 * @return EOK on success.101 * @return EBADMEM if the packet_dimension parameter is NULL.102 * @return ENOMEM if there is not enough memory left.103 * @return EINVAL if the packet_dimensions cache is not valid.104 * @return Other codes as defined for the ip_packet_size_req()function.105 * 106 */ 107 inttl_get_ip_packet_dimension(int ip_phone,110 * @param[in] ip_phone The IP moduel phone for (semi)remote calls. 111 * @param[in] packet_dimensions The packet dimensions cache. 112 * @param[in] device_id The device identifier. 113 * @param[out] packet_dimension The IP packet dimensions. 114 * @return EOK on success. 115 * @return EBADMEM if the packet_dimension parameter is NULL. 116 * @return ENOMEM if there is not enough memory left. 117 * @return EINVAL if the packet_dimensions cache is not valid. 118 * @return Other codes as defined for the ip_packet_size_req() 119 * function. 120 */ 121 int 122 tl_get_ip_packet_dimension(int ip_phone, 108 123 packet_dimensions_ref packet_dimensions, device_id_t device_id, 109 124 packet_dimension_ref *packet_dimension) … … 139 154 } 140 155 156 /** Updates IP device packet dimensions cache. 157 * 158 * @param[in,out] packet_dimensions The packet dimensions cache. 159 * @param[in] device_id The device identifier. 160 * @param[in] content The new maximum content size. 161 * @returns EOK on success. 162 * @return ENOENT if the packet dimension is not cached. 163 */ 141 164 int 142 165 tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, … … 148 171 if (!packet_dimension) 149 172 return ENOENT; 173 150 174 packet_dimension->content = content; 151 175 … … 160 184 packet_dimensions_exclude(packet_dimensions, 161 185 DEVICE_INVALID_ID); 162 163 186 } 164 187 } … … 167 190 } 168 191 192 /** Sets the address port. 193 * 194 * Supports AF_INET and AF_INET6 address families. 195 * 196 * @param[in,out] addr The address to be updated. 197 * @param[in] addrlen The address length. 198 * @param[in] port The port to be set. 199 * @returns EOK on success. 200 * @returns EINVAL if the address length does not match the address 201 * family. 202 * @returns EAFNOSUPPORT if the address family is not supported. 203 */ 169 204 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port) 170 205 { … … 187 222 address_in->sin_port = htons(port); 188 223 return EOK; 224 189 225 case AF_INET6: 190 226 if (length != sizeof(struct sockaddr_in6)) … … 193 229 address_in6->sin6_port = htons(port); 194 230 return EOK; 231 195 232 default: 196 233 return EAFNOSUPPORT; … … 198 235 } 199 236 237 /** Prepares the packet for ICMP error notification. 238 * 239 * Keeps the first packet and releases all the others. 240 * Releases all the packets on error. 241 * 242 * @param[in] packet_phone The packet server module phone. 243 * @param[in] icmp_phone The ICMP module phone. 244 * @param[in] packet The packet to be send. 245 * @param[in] error The packet error reporting service. Prefixes the 246 * received packet. 247 * @returns EOK on success. 248 * @returns ENOENT if no packet may be sent. 249 */ 200 250 int 201 251 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, … … 223 273 } 224 274 275 /** Receives data from the socket into a packet. 276 * 277 * @param[in] packet_phone The packet server module phone. 278 * @param[out] packet The new created packet. 279 * @param[in] prefix Reserved packet data prefix length. 280 * @param[in] dimension The packet dimension. 281 * @param[in] addr The destination address. 282 * @param[in] addrlen The address length. 283 * @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 287 * async_data_read_finalize() function. 288 */ 225 289 int 226 290 tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix,
Note:
See TracChangeset
for help on using the changeset viewer.