Subversion Repositories HelenOS

Rev

Rev 4738 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4738 Rev 4756
Line 29... Line 29...
29
/** @addtogroup socket
29
/** @addtogroup socket
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 *  \todo
34
 *  Socket common core implementation.
35
 */
35
 */
36
 
36
 
37
#include "../err.h"
37
#include "../err.h"
38
 
38
 
39
#include "../include/in.h"
39
#include "../include/in.h"
Line 49... Line 49...
49
 
49
 
50
#include "../modules.h"
50
#include "../modules.h"
51
 
51
 
52
#include "socket_core.h"
52
#include "socket_core.h"
53
 
53
 
54
/** \todo
54
/** Bound port sockets.
55
 */
55
 */
56
struct socket_port{
56
struct socket_port{
-
 
57
    /** The bound sockets map.
-
 
58
     */
57
    socket_port_map_t   map;
59
    socket_port_map_t   map;
-
 
60
    /** The bound sockets count.
-
 
61
     */
58
    int                 count;
62
    int                 count;
59
};
63
};
60
 
64
 
61
/** \todo
65
/** Binds the socket to the port.
-
 
66
 *  The SOCKET_MAP_KEY_LISTENING key identifier is used.
-
 
67
 *  @param[in] global_sockets The global sockets to be updated.
-
 
68
 *  @param[in] socket The socket to be added.
-
 
69
 *  @param[in] port The port number to be bound to.
-
 
70
 *  @returns EOK on success.
-
 
71
 *  @returns ENOMEM if there is not enough memory left.
-
 
72
 *  @returns Other error codes as defined for the socket_ports_add() function.
62
 */
73
 */
63
int socket_bind_insert( socket_ports_ref global_sockets, socket_core_ref socket, int port );
74
int socket_bind_insert( socket_ports_ref global_sockets, socket_core_ref socket, int port );
64
 
75
 
65
/** \todo
76
/** Destroys the socket.
-
 
77
 *  If the socket is bound, the port is released.
-
 
78
 *  Releases all buffered packets, calls the release function and removes the socket from the local sockets.
-
 
79
 *  @param[in] packet_phone The packet server phone to release buffered packets.
-
 
80
 *  @param[in] socket The socket to be destroyed.
-
 
81
 *  @param[in,out] local_sockets The local sockets to be updated.
-
 
82
 *  @param[in,out] global_sockets The global sockets to be updated.
-
 
83
 *  @param[in] socket_release The client release callback function.
66
 */
84
 */
67
void    socket_destroy_core( int packet_phone, socket_core_ref socket, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void ( * socket_release )( socket_core_ref socket ));
85
void    socket_destroy_core( int packet_phone, socket_core_ref socket, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void ( * socket_release )( socket_core_ref socket ));
68
 
86
 
-
 
87
/** Adds the socket to a socket port.
-
 
88
 *  @param[in,out] socket_port The socket port structure.
-
 
89
 *  @param[in] socket The socket to be added.
-
 
90
 *  @param[in] key The socket key identifier.
-
 
91
 *  @param[in] key_length The socket key length.
69
/** \todo
92
 *  @returns EOK on success.
-
 
93
 *  @returns ENOMEM if there is not enough memory left.
70
 */
94
 */
71
int socket_port_add_core( socket_port_ref socket_port, socket_core_ref socket, const char * key, size_t key_length );
95
int socket_port_add_core( socket_port_ref socket_port, socket_core_ref socket, const char * key, size_t key_length );
72
 
96
 
73
INT_MAP_IMPLEMENT( socket_cores, socket_core_t );
97
INT_MAP_IMPLEMENT( socket_cores, socket_core_t );
74
 
98
 
Line 265... Line 289...
265
    packet_t        next_packet;
289
    packet_t        next_packet;
266
    size_t          fragments;
290
    size_t          fragments;
267
    size_t *        lengths;
291
    size_t *        lengths;
268
    size_t          index;
292
    size_t          index;
269
 
293
 
270
    if( ! length ){
294
    if( ! length ) return EBADMEM;
271
        return EINVAL;
-
 
272
    }
-
 
273
    next_packet = pq_next( packet );
295
    next_packet = pq_next( packet );
274
    if( ! next_packet ){
296
    if( ! next_packet ){
275
        // write all if only one fragment
297
        // write all if only one fragment
276
        ERROR_PROPAGATE( data_reply( packet_get_data( packet ), packet_get_data_length( packet )));
298
        ERROR_PROPAGATE( data_reply( packet_get_data( packet ), packet_get_data_length( packet )));
277
        // store the total length
299
        // store the total length