source: mainline/uspace/lib/net/include/tl_common.h@ 849ed54

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 849ed54 was 849ed54, checked in by Martin Decky <martin@…>, 15 years ago

Networking work:
Split the networking stack into end-user library (libsocket) and two helper libraries (libnet and libnetif).
Don't use over-the-hand compiling and linking, but rather separation of conserns.
There might be still some issues and the non-modular networking architecture is currently broken, but this will be fixed soon.

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*
2 * Copyright (c) 2008 Lukas Mejdrech
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup net_tl
30 * @{
31 */
32
33/** @file
34 * Transport layer common functions.
35 */
36
37#ifndef __NET_TL_COMMON_H__
38#define __NET_TL_COMMON_H__
39
40#include <packet/packet.h>
41#include <net_device.h>
42#include <inet.h>
43#include <socket_codes.h>
44
45/** Device packet dimensions.
46 * Maps devices to the packet dimensions.
47 * @see device.h
48 */
49DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t);
50
51/** Gets the address port.
52 * Supports AF_INET and AF_INET6 address families.
53 * @param[in,out] addr The address to be updated.
54 * @param[in] addrlen The address length.
55 * @param[out] port The set port.
56 * @returns EOK on success.
57 * @returns EINVAL if the address length does not match the address family.
58 * @returns EAFNOSUPPORT if the address family is not supported.
59 */
60extern int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port);
61
62/** Gets IP packet dimensions.
63 * Tries to search a cache and queries the IP module if not found.
64 * The reply is cached then.
65 * @param[in] ip_phone The IP moduel phone for (semi)remote calls.
66 * @param[in] packet_dimensions The packet dimensions cache.
67 * @param[in] device_id The device identifier.
68 * @param[out] packet_dimension The IP packet dimensions.
69 * @returns EOK on success.
70 * @returns EBADMEM if the packet_dimension parameter is NULL.
71 * @return ENOMEM if there is not enough memory left.
72 * @returns EINVAL if the packet_dimensions cache is not valid.
73 * @returns Other codes as defined for the ip_packet_size_req() function.
74 */
75extern int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension);
76
77/** Updates IP device packet dimensions cache.
78 * @param[in,out] packet_dimensions The packet dimensions cache.
79 * @param[in] device_id The device identifier.
80 * @param[in] content The new maximum content size.
81 * @returns EOK on success.
82 * @returns ENOENT if the packet dimension is not cached.
83 */
84extern int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content);
85
86/** Sets the address port.
87 * Supports AF_INET and AF_INET6 address families.
88 * @param[in,out] addr The address to be updated.
89 * @param[in] addrlen The address length.
90 * @param[in] port The port to be set.
91 * @returns EOK on success.
92 * @returns EINVAL if the address length does not match the address family.
93 * @returns EAFNOSUPPORT if the address family is not supported.
94 */
95extern int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port);
96
97/** Prepares the packet for ICMP error notification.
98 * Keeps the first packet and releases all the others.
99 * Releases all the packets on error.
100 * @param[in] packet_phone The packet server module phone.
101 * @param[in] icmp_phone The ICMP module phone.
102 * @param[in] packet The packet to be send.
103 * @param[in] error The packet error reporting service. Prefixes the received packet.
104 * @returns EOK on success.
105 * @returns ENOENT if no packet may be sent.
106 */
107extern int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error);
108
109/** Receives data from the socket into a packet.
110 * @param[in] packet_phone The packet server module phone.
111 * @param[out] packet The new created packet.
112 * @param[in] prefix Reserved packet data prefix length.
113 * @param[in] dimension The packet dimension.
114 * @param[in] addr The destination address.
115 * @param[in] addrlen The address length.
116 * @returns Number of bytes received.
117 * @returns EINVAL if the client does not send data.
118 * @returns ENOMEM if there is not enough memory left.
119 * @returns Other error codes as defined for the async_data_read_finalize() function.
120 */
121extern int tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen);
122
123#endif
124
125/** @}
126 */
127
Note: See TracBrowser for help on using the repository browser.