Rev 4726 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4726 | Rev 4731 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Lukas Mejdrech |
2 | * Copyright (c) 2008 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
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 |
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. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
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 |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 |
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. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup net_tl |
29 | /** @addtogroup net_tl |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | * Transport layer common functions. |
34 | * Transport layer common functions. |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef __NET_TL_COMMON_H__ |
37 | #ifndef __NET_TL_COMMON_H__ |
38 | #define __NET_TL_COMMON_H__ |
38 | #define __NET_TL_COMMON_H__ |
39 | 39 | ||
40 | #include "../structures/packet/packet.h" |
40 | #include "../structures/packet/packet.h" |
41 | 41 | ||
42 | #include "../include/inet.h" |
42 | #include "../include/inet.h" |
43 | #include "../include/socket_codes.h" |
43 | #include "../include/socket_codes.h" |
44 | 44 | ||
45 | /** Type definition of the packet dimension. |
45 | /** Type definition of the packet dimension. |
46 | * @see packet_dimension |
46 | * @see packet_dimension |
47 | */ |
47 | */ |
48 | typedef struct packet_dimension packet_dimension_t; |
48 | typedef struct packet_dimension packet_dimension_t; |
49 | 49 | ||
50 | /** Type definition of the packet dimension pointer. |
50 | /** Type definition of the packet dimension pointer. |
51 | * @see packet_dimension |
51 | * @see packet_dimension |
52 | */ |
52 | */ |
53 | typedef packet_dimension_t * packet_dimension_ref; |
53 | typedef packet_dimension_t * packet_dimension_ref; |
54 | 54 | ||
55 | /** Packet dimension. |
55 | /** Packet dimension. |
56 | */ |
56 | */ |
57 | struct packet_dimension{ |
57 | struct packet_dimension{ |
58 | /** Reserved packet prefix length. |
58 | /** Reserved packet prefix length. |
59 | */ |
59 | */ |
60 | size_t prefix; |
60 | size_t prefix; |
61 | /** Maximal packet content length. |
61 | /** Maximal packet content length. |
62 | */ |
62 | */ |
63 | size_t content; |
63 | size_t content; |
64 | /** Reserved packet suffix length. |
64 | /** Reserved packet suffix length. |
65 | */ |
65 | */ |
66 | size_t suffix; |
66 | size_t suffix; |
67 | /** Maximal packet address length. |
67 | /** Maximal packet address length. |
68 | */ |
68 | */ |
69 | size_t addr_len; |
69 | size_t addr_len; |
70 | }; |
70 | }; |
71 | 71 | ||
72 | /** Gets the address port. |
72 | /** Gets the address port. |
73 | * Supports AF_INET and AF_INET6 address families. |
73 | * Supports AF_INET and AF_INET6 address families. |
74 | * @param addr The address to be updated. Input/output parameter. |
74 | * @param addr The address to be updated. Input/output parameter. |
75 | * @param addrlen The address length. Input parameter. |
75 | * @param addrlen The address length. Input parameter. |
76 | * @param port The set port. Output parameter. |
76 | * @param port The set port. Output parameter. |
77 | * @returns EOK on success. |
77 | * @returns EOK on success. |
78 | * @returns EINVAL if the address length does not match the address family. |
78 | * @returns EINVAL if the address length does not match the address family. |
79 | * @returns EAFNOSUPPORT if the address family is not supported. |
79 | * @returns EAFNOSUPPORT if the address family is not supported. |
80 | */ |
80 | */ |
81 | int tl_get_address_port( const struct sockaddr * addr, int addrlen, uint16_t * port ); |
81 | int tl_get_address_port( const struct sockaddr * addr, int addrlen, uint16_t * port ); |
82 | 82 | ||
83 | /** Sets the address port. |
83 | /** Sets the address port. |
84 | * Supports AF_INET and AF_INET6 address families. |
84 | * Supports AF_INET and AF_INET6 address families. |
85 | * @param addr The address to be updated. Input/output parameter. |
85 | * @param addr The address to be updated. Input/output parameter. |
86 | * @param addrlen The address length. Input parameter. |
86 | * @param addrlen The address length. Input parameter. |
87 | * @param port The port to be set. Input parameter. |
87 | * @param port The port to be set. Input parameter. |
88 | * @returns EOK on success. |
88 | * @returns EOK on success. |
89 | * @returns EINVAL if the address length does not match the address family. |
89 | * @returns EINVAL if the address length does not match the address family. |
90 | * @returns EAFNOSUPPORT if the address family is not supported. |
90 | * @returns EAFNOSUPPORT if the address family is not supported. |
91 | */ |
91 | */ |
92 | int tl_set_address_port( struct sockaddr * addr, int addrlen, uint16_t port ); |
92 | int tl_set_address_port( struct sockaddr * addr, int addrlen, uint16_t port ); |
93 | 93 | ||
94 | /** Sends the port unreachable ICMP notification. |
94 | /** Prepares the packet for ICMP error notification. |
95 | * Sends the first packet and releases all the others. |
95 | * Keeps the first packet and releases all the others. |
96 | * Releases the packet queu on error. |
96 | * Releases all the packets on error. |
97 | * @param packet_phone The packet server module phone. Input parameter. |
97 | * @param packet_phone The packet server module phone. Input parameter. |
98 | * @param icmp_phone The ICMP module phone. Input parameter. |
98 | * @param icmp_phone The ICMP module phone. Input parameter. |
99 | * @param packet The packet to be send. Input parameter. |
99 | * @param packet The packet to be send. Input parameter. |
100 | * @param error The packet error reporting service. Prefixes the received packet. Input parameter. |
100 | * @param error The packet error reporting service. Prefixes the received packet. Input parameter. |
- | 101 | * @returns EOK on success. |
|
- | 102 | * @returns ENOENT if no packet may be sent. |
|
101 | */ |
103 | */ |
102 | void tl_send_icmp_port_unreachable( int packet_phone, int icmp_phone, packet_t packet, services_t error ); |
104 | int tl_prepare_icmp_packet( int packet_phone, int icmp_phone, packet_t packet, services_t error ); |
103 | 105 | ||
104 | /** Receives data from the socket into a packet. |
106 | /** Receives data from the socket into a packet. |
105 | * @param packet_phone The packet server module phone. Input parameter. |
107 | * @param packet_phone The packet server module phone. Input parameter. |
106 | * @param packet The new created packet. Output parameter. |
108 | * @param packet The new created packet. Output parameter. |
107 | * @param prefix Reserved packet data prefix length. Input parameter. |
109 | * @param prefix Reserved packet data prefix length. Input parameter. |
108 | * @param dimension The packet dimension. Input parameter. |
110 | * @param dimension The packet dimension. Input parameter. |
109 | * @param addr The destination address. Input parameter. |
111 | * @param addr The destination address. Input parameter. |
110 | * @param addrlen The address length. Input parameter. |
112 | * @param addrlen The address length. Input parameter. |
111 | * @returns Number of bytes received. |
113 | * @returns Number of bytes received. |
112 | * @returns EINVAL if the client does not send data. |
114 | * @returns EINVAL if the client does not send data. |
113 | * @returns ENOMEM if there is not enough memory left. |
115 | * @returns ENOMEM if there is not enough memory left. |
114 | * @returns Other error codes as defined for the ipc_data_read_finalize() function. |
116 | * @returns Other error codes as defined for the ipc_data_read_finalize() function. |
115 | */ |
117 | */ |
116 | 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 ); |
118 | 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 ); |
117 | 119 | ||
118 | #endif |
120 | #endif |
119 | 121 | ||
120 | /** @} |
122 | /** @} |
121 | */ |
123 | */ |
122 | 124 | ||
123 | 125 |