Changes in uspace/lib/net/tl/tl_common.c [84c20da:e526f08] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/tl/tl_common.c
r84c20da re526f08 27 27 */ 28 28 29 /** @addtogroup libnet30 * @{29 /** @addtogroup net_tl 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Transport layer common functions implementation. 35 * @see tl_common.h 36 */ 37 38 #include <tl_common.h> 34 * Transport layer common functions implementation. 35 * @see tl_common.h 36 */ 37 38 #include <net/socket_codes.h> 39 #include <net/in.h> 40 #include <net/in6.h> 41 #include <net/inet.h> 42 #include <async.h> 43 #include <ipc/services.h> 44 #include <errno.h> 45 #include <err.h> 46 47 #include <net/packet.h> 39 48 #include <packet_client.h> 40 49 #include <packet_remote.h> 50 #include <net/device.h> 41 51 #include <icmp_interface.h> 42 52 #include <ip_remote.h> 43 53 #include <ip_interface.h> 44 54 #include <tl_interface.h> 45 46 #include <net/socket_codes.h> 47 #include <net/in.h> 48 #include <net/in6.h> 49 #include <net/inet.h> 50 #include <net/device.h> 51 #include <net/packet.h> 52 53 #include <async.h> 54 #include <ipc/services.h> 55 #include <errno.h> 56 #include <err.h> 55 #include <tl_common.h> 57 56 58 57 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); 59 58 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 address69 * family.70 * @returns EAFNOSUPPORT if the address family is not supported.71 */72 59 int 73 60 tl_get_address_port(const struct sockaddr *addr, int addrlen, uint16_t *port) … … 87 74 *port = ntohs(address_in->sin_port); 88 75 break; 89 90 76 case AF_INET6: 91 77 if (addrlen != sizeof(struct sockaddr_in6)) 92 return EINVAL;78 return EINVAL; 93 79 94 80 address_in6 = (struct sockaddr_in6 *) addr; 95 81 *port = ntohs(address_in6->sin6_port); 96 82 break; 97 98 83 default: 99 84 return EAFNOSUPPORT; … … 108 93 * The reply is cached then. 109 94 * 110 * @param[in] ip_phoneThe IP moduel phone for (semi)remote calls.111 * @param[in] packet_dimensions The packet dimensions cache.112 * @param[in] device_idThe 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 * 120 * /121 int 122 tl_get_ip_packet_dimension(int ip_phone,95 * @param[in] ip_phone The IP moduel phone for (semi)remote calls. 96 * @param[in] packet_dimensions The packet dimensions cache. 97 * @param[in] device_id The device identifier. 98 * @param[out] packet_dimension The IP packet dimensions. 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 int tl_get_ip_packet_dimension(int ip_phone, 123 108 packet_dimensions_ref packet_dimensions, device_id_t device_id, 124 109 packet_dimension_ref *packet_dimension) … … 154 139 } 155 140 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 */164 141 int 165 142 tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, … … 171 148 if (!packet_dimension) 172 149 return ENOENT; 173 174 150 packet_dimension->content = content; 175 151 … … 184 160 packet_dimensions_exclude(packet_dimensions, 185 161 DEVICE_INVALID_ID); 162 186 163 } 187 164 } … … 190 167 } 191 168 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 address201 * family.202 * @returns EAFNOSUPPORT if the address family is not supported.203 */204 169 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port) 205 170 { … … 222 187 address_in->sin_port = htons(port); 223 188 return EOK; 224 225 189 case AF_INET6: 226 190 if (length != sizeof(struct sockaddr_in6)) … … 229 193 address_in6->sin6_port = htons(port); 230 194 return EOK; 231 232 195 default: 233 196 return EAFNOSUPPORT; … … 235 198 } 236 199 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 the246 * received packet.247 * @returns EOK on success.248 * @returns ENOENT if no packet may be sent.249 */250 200 int 251 201 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, … … 273 223 } 274 224 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 the287 * async_data_read_finalize() function.288 */289 225 int 290 226 tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix,
Note:
See TracChangeset
for help on using the changeset viewer.