Changeset 0c37135 in mainline for uspace/lib


Ignore:
Timestamp:
2012-04-18T07:32:58Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5f67cd61
Parents:
3d93289a (diff), 63920b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with mainline

Location:
uspace/lib
Files:
6 added
51 deleted
8 edited
6 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r3d93289a r0c37135  
    8787        generic/task.c \
    8888        generic/futex.c \
     89        generic/inet.c \
     90        generic/inetcfg.c \
     91        generic/inetping.c \
    8992        generic/io/asprintf.c \
    9093        generic/io/io.c \
     
    97100        generic/io/printf_core.c \
    98101        generic/io/console.c \
     102        generic/iplink.c \
     103        generic/iplink_srv.c \
    99104        generic/malloc.c \
    100105        generic/sysinfo.c \
     
    108113        generic/adt/hash_set.c \
    109114        generic/adt/dynamic_fifo.c \
    110         generic/adt/measured_strings.c \
    111115        generic/adt/char_map.c \
    112116        generic/adt/prodcons.c \
     
    118122        generic/vfs/canonify.c \
    119123        generic/net/inet.c \
    120         generic/net/icmp_common.c \
    121         generic/net/icmp_api.c \
    122124        generic/net/modules.c \
    123         generic/net/packet.c \
    124125        generic/net/socket_client.c \
    125126        generic/net/socket_parse.c \
  • uspace/lib/c/generic/io/printf_core.c

    r3d93289a r0c37135  
    283283        /* Print leading spaces. */
    284284        size_t strw = str_length(str);
    285         if (precision == 0)
     285        if ((precision == 0) || (precision > strw))
    286286                precision = strw;
    287287       
     
    331331        /* Print leading spaces. */
    332332        size_t strw = wstr_length(str);
    333         if (precision == 0)
     333        if ((precision == 0) || (precision > strw))
    334334                precision = strw;
    335335       
  • uspace/lib/c/include/inet/inet.h

    r3d93289a r0c37135  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
     29/** @addtogroup libc
    3030 * @{
    3131 */
    32 
    3332/** @file
    34  * Hardware types according to the on-line IANA - Address Resolution Protocol
    35  * (ARP) Parameters
    36  * http://www.iana.org/assignments/arp-parameters/arp-parameters.xml,
    37  * cited January 14 2009.
    3833 */
    3934
    40 #ifndef LIBNET_NET_HARDWARE_H_
    41 #define LIBNET_NET_HARDWARE_H_
     35#ifndef LIBC_INET_INET_H_
     36#define LIBC_INET_INET_H_
    4237
    4338#include <sys/types.h>
    4439
    45 /** Network interface layer type type definition. */
    46 typedef uint8_t hw_type_t;
     40#define INET_TTL_MAX 255
    4741
    48 /** @name Network interface layer types definitions */
    49 /*@{*/
     42typedef struct {
     43        uint32_t ipv4;
     44} inet_addr_t;
    5045
    51 /** Ethernet (10Mb) hardware type. */
    52 #define HW_ETHER                1
     46typedef struct {
     47        inet_addr_t src;
     48        inet_addr_t dest;
     49        uint8_t tos;
     50        void *data;
     51        size_t size;
     52} inet_dgram_t;
    5353
    54 /*@}*/
     54typedef struct {
     55        int (*recv)(inet_dgram_t *);
     56} inet_ev_ops_t;
     57
     58typedef enum {
     59        INET_DF = 1
     60} inet_df_t;
     61
     62extern int inet_init(uint8_t, inet_ev_ops_t *);
     63extern int inet_send(inet_dgram_t *, uint8_t, inet_df_t);
     64extern int inet_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
    5565
    5666#endif
     
    5868/** @}
    5969 */
    60 
  • uspace/lib/c/include/inet/inetping.h

    r3d93289a r0c37135  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup libc
    30  *  @{
     30 * @{
     31 */
     32/** @file
    3133 */
    3234
    33 /** @file
    34  * ICMP common interface implementation.
    35  * @see icmp_common.h
    36  */
     35#ifndef LIBC_INET_INETPING_H_
     36#define LIBC_INET_INETPING_H_
    3737
    38 #include <net/modules.h>
    39 #include <net/icmp_common.h>
    40 #include <ipc/services.h>
    41 #include <ipc/icmp.h>
    42 #include <sys/time.h>
    43 #include <async.h>
     38#include <inet/inet.h>
     39#include <sys/types.h>
    4440
    45 /** Connect to the ICMP module.
    46  *
    47  * @return ICMP module session.
    48  *
    49  */
    50 async_sess_t *icmp_connect_module(void)
    51 {
    52         return connect_to_service(SERVICE_ICMP);
    53 }
     41typedef struct {
     42        inet_addr_t src;
     43        inet_addr_t dest;
     44        uint16_t seq_no;
     45        void *data;
     46        size_t size;
     47} inetping_sdu_t;
     48
     49typedef struct inetping_ev_ops {
     50        int (*recv)(inetping_sdu_t *);
     51} inetping_ev_ops_t;
     52
     53extern int inetping_init(inetping_ev_ops_t *);
     54extern int inetping_send(inetping_sdu_t *);
     55extern int inetping_get_srcaddr(inet_addr_t *, inet_addr_t *);
     56
     57
     58#endif
    5459
    5560/** @}
  • uspace/lib/c/include/inet/iplink.h

    r3d93289a r0c37135  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
    30  *  @{
     29/** @addtogroup libc
     30 * @{
     31 */
     32/** @file
    3133 */
    3234
    33 #ifndef LIBNET_ICMP_REMOTE_H_
    34 #define LIBNET_ICMP_REMOTE_H_
     35#ifndef LIBC_INET_IPLINK_H_
     36#define LIBC_INET_IPLINK_H_
    3537
    36 #include <net/socket_codes.h>
     38#include <async.h>
    3739#include <sys/types.h>
    38 #include <net/device.h>
    39 #include <adt/measured_strings.h>
    40 #include <net/packet.h>
    41 #include <net/inet.h>
    42 #include <net/ip_codes.h>
    43 #include <net/icmp_codes.h>
    44 #include <net/icmp_common.h>
    45 #include <async.h>
    4640
    47 /** @name ICMP module interface
    48  * This interface is used by other modules.
    49  */
    50 /*@{*/
     41struct iplink_ev_ops;
    5142
    52 extern int icmp_destination_unreachable_msg(async_sess_t *, icmp_code_t,
    53     icmp_param_t, packet_t *);
    54 extern int icmp_source_quench_msg(async_sess_t *, packet_t *);
    55 extern int icmp_time_exceeded_msg(async_sess_t *, icmp_code_t, packet_t *);
    56 extern int icmp_parameter_problem_msg(async_sess_t *, icmp_code_t, icmp_param_t,
    57     packet_t *);
     43typedef struct {
     44        async_sess_t *sess;
     45        struct iplink_ev_ops *ev_ops;
     46} iplink_t;
    5847
    59 /*@}*/
     48typedef struct {
     49        uint32_t ipv4;
     50} iplink_addr_t;
     51
     52/** IP link Service Data Unit */
     53typedef struct {
     54        /** Local source address */
     55        iplink_addr_t lsrc;
     56        /** Local destination address */
     57        iplink_addr_t ldest;
     58        /** Serialized IP packet */
     59        void *data;
     60        /** Size of @c data in bytes */
     61        size_t size;
     62} iplink_sdu_t;
     63
     64typedef struct iplink_ev_ops {
     65        int (*recv)(iplink_t *, iplink_sdu_t *);
     66} iplink_ev_ops_t;
     67
     68extern int iplink_open(async_sess_t *, iplink_ev_ops_t *, iplink_t **);
     69extern void iplink_close(iplink_t *);
     70extern int iplink_send(iplink_t *, iplink_sdu_t *);
     71extern int iplink_addr_add(iplink_t *, iplink_addr_t *);
     72extern int iplink_addr_remove(iplink_t *, iplink_addr_t *);
     73extern int iplink_get_mtu(iplink_t *, size_t *);
    6074
    6175#endif
  • uspace/lib/c/include/inet/iplink_srv.h

    r3d93289a r0c37135  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup libc
    30  *  @{
     30 * @{
     31 */
     32/** @file
    3133 */
    3234
    33 /** @file
    34  * Character string with measured length.
    35  * The structure has been designed for serialization of character strings
    36  * between modules.
    37  */
     35#ifndef LIBC_INET_IPLINK_SRV_H_
     36#define LIBC_INET_IPLINK_SRV_H_
    3837
    39 #ifndef LIBC_MEASURED_STRINGS_H_
    40 #define LIBC_MEASURED_STRINGS_H_
     38#include <async.h>
     39#include <fibril_synch.h>
     40#include <bool.h>
     41#include <sys/types.h>
    4142
    42 #include <sys/types.h>
    43 #include <async.h>
     43struct iplink_ops;
    4444
    45 /** Type definition of the character string with measured length.
    46  * @see measured_string
    47  */
    48 typedef struct measured_string measured_string_t;
     45typedef struct {
     46        fibril_mutex_t lock;
     47        bool connected;
     48        struct iplink_ops *ops;
     49        void *arg;
     50        async_sess_t *client_sess;
     51} iplink_srv_t;
    4952
    50 /** Character string with measured length.
    51  *
    52  * This structure has been designed for serialization of character strings
    53  * between modules.
    54  */
    55 struct measured_string {
    56         /** Character string data. */
    57         uint8_t *value;
    58         /** Character string length. */
    59         size_t length;
    60 };
     53typedef struct {
     54        uint32_t ipv4;
     55} iplink_srv_addr_t;
    6156
    62 extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t);
    63 extern measured_string_t *measured_string_copy(measured_string_t *);
     57/** IP link Service Data Unit */
     58typedef struct {
     59        /** Local source address */
     60        iplink_srv_addr_t lsrc;
     61        /** Local destination address */
     62        iplink_srv_addr_t ldest;
     63        /** Serialized IP packet */
     64        void *data;
     65        /** Size of @c data in bytes */
     66        size_t size;
     67} iplink_srv_sdu_t;
    6468
    65 extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t);
    66 extern int measured_strings_reply(const measured_string_t *, size_t);
     69typedef struct iplink_ops {
     70        int (*open)(iplink_srv_t *);
     71        int (*close)(iplink_srv_t *);
     72        int (*send)(iplink_srv_t *, iplink_srv_sdu_t *);
     73        int (*get_mtu)(iplink_srv_t *, size_t *);
     74        int (*addr_add)(iplink_srv_t *, iplink_srv_addr_t *);
     75        int (*addr_remove)(iplink_srv_t *, iplink_srv_addr_t *);
     76} iplink_ops_t;
    6777
    68 extern int measured_strings_return(async_exch_t *, measured_string_t **,
    69     uint8_t **, size_t);
    70 extern int measured_strings_send(async_exch_t *, const measured_string_t *,
    71     size_t);
     78extern void iplink_srv_init(iplink_srv_t *);
     79
     80extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *);
     81extern int iplink_ev_recv(iplink_srv_t *, iplink_srv_sdu_t *);
    7282
    7383#endif
  • uspace/lib/c/include/ipc/inet.h

    r3d93289a r0c37135  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
    3  * Copyright (c) 2011 Radim Vansa
     2 * Copyright (c) 2012 Jiri Svoboda
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup libpacket
     29/** @addtogroup libcipc
    3130 * @{
    3231 */
    33 
    3432/** @file
    35  * Packet server.
    36  * The hosting module has to be compiled with both the packet.c and the
    37  * packet_server.c source files. To function correctly, initialization of the
    38  * packet map by the pm_init() function has to happen at the first place. Then
    39  * the packet messages have to be processed by the packet_server_message()
    40  * function. The packet map should be released by the pm_destroy() function
    41  * during the module termination.
    42  * @see IS_NET_PACKET_MESSAGE()
    4333 */
    4434
    45 #ifndef NET_PACKET_SERVER_H_
    46 #define NET_PACKET_SERVER_H_
     35#ifndef LIBC_IPC_INET_H_
     36#define LIBC_IPC_INET_H_
    4737
    4838#include <ipc/common.h>
    4939
    50 extern int packet_server_init(void);
    51 extern int packet_server_message(ipc_callid_t, ipc_call_t *, ipc_call_t *,
    52     size_t *);
     40/** Inet ports */
     41typedef enum {
     42        /** Default port */
     43        INET_PORT_DEFAULT = 1,
     44        /** Configuration port */
     45        INET_PORT_CFG,
     46        /** Ping service port */
     47        INET_PORT_PING
     48} inet_port_t;
     49
     50/** Requests on Inet default port */
     51typedef enum {
     52        INET_CALLBACK_CREATE = IPC_FIRST_USER_METHOD,
     53        INET_GET_SRCADDR,
     54        INET_SEND,
     55        INET_SET_PROTO
     56} inet_request_t;
     57
     58/** Events on Inet default port */
     59typedef enum {
     60        INET_EV_RECV = IPC_FIRST_USER_METHOD
     61} inet_event_t;
     62
     63/** Requests on Inet configuration port */
     64typedef enum {
     65        INETCFG_ADDR_CREATE_STATIC = IPC_FIRST_USER_METHOD,
     66        INETCFG_ADDR_DELETE,
     67        INETCFG_ADDR_GET,
     68        INETCFG_ADDR_GET_ID,
     69        INETCFG_GET_ADDR_LIST,
     70        INETCFG_GET_LINK_LIST,
     71        INETCFG_GET_SROUTE_LIST,
     72        INETCFG_LINK_GET,
     73        INETCFG_SROUTE_CREATE,
     74        INETCFG_SROUTE_DELETE,
     75        INETCFG_SROUTE_GET,
     76        INETCFG_SROUTE_GET_ID
     77} inetcfg_request_t;
     78
     79/** Events on Inet ping port */
     80typedef enum {
     81        INETPING_EV_RECV = IPC_FIRST_USER_METHOD
     82} inetping_event_t;
     83
     84/** Requests on Inet ping port */
     85typedef enum {
     86        INETPING_SEND = IPC_FIRST_USER_METHOD,
     87        INETPING_GET_SRCADDR
     88} inetping_request_t;
    5389
    5490#endif
    5591
    56 /** @}
     92/**
     93 * @}
    5794 */
  • uspace/lib/c/include/ipc/iplink.h

    r3d93289a r0c37135  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup libcipc
    3030 * @{
    3131 */
    32 
    3332/** @file
    34  * Transport layer modules messages.
    35  * @see tl_interface.h
    3633 */
    3734
    38 #ifndef LIBC_TL_MESSAGES_H_
    39 #define LIBC_TL_MESSAGES_H_
     35#ifndef LIBC_IPC_IPLINK_H_
     36#define LIBC_IPC_IPLINK_H_
    4037
    41 #include <ipc/net.h>
     38#include <ipc/common.h>
    4239
    43 /** Transport layer modules messages. */
    4440typedef enum {
    45         /** Packet received message.
    46          * @see tl_received_msg()
    47          */
    48         NET_TL_RECEIVED = NET_TL_FIRST
    49 } tl_messages;
     41        IPLINK_GET_MTU = IPC_FIRST_USER_METHOD,
     42        IPLINK_SEND,
     43        IPLINK_ADDR_ADD,
     44        IPLINK_ADDR_REMOVE
     45} iplink_request_t;
     46
     47typedef enum {
     48        IPLINK_EV_RECV = IPC_FIRST_USER_METHOD
     49} iplink_event_t;
    5050
    5151#endif
    5252
    53 /** @}
     53/**
     54 * @}
    5455 */
  • uspace/lib/c/include/ipc/services.h

    r3d93289a r0c37135  
    4848        SERVICE_IRC        = FOURCC('i', 'r', 'c', ' '),
    4949        SERVICE_CLIPBOARD  = FOURCC('c', 'l', 'i', 'p'),
    50         SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '),
    51         SERVICE_ETHERNET   = FOURCC('e', 't', 'h', ' '),
    52         SERVICE_NILDUMMY   = FOURCC('n', 'i', 'l', 'd'),
    53         SERVICE_IP         = FOURCC('i', 'p', 'v', '4'),
    54         SERVICE_ARP        = FOURCC('a', 'r', 'p', ' '),
    55         SERVICE_ICMP       = FOURCC('i', 'c', 'm', 'p'),
    5650        SERVICE_UDP        = FOURCC('u', 'd', 'p', ' '),
    5751        SERVICE_TCP        = FOURCC('t', 'c', 'p', ' ')
    5852} services_t;
     53
     54#define SERVICE_NAME_INET     "net/inet"
     55#define SERVICE_NAME_INETCFG  "net/inetcfg"
     56#define SERVICE_NAME_INETPING "net/inetping"
    5957
    6058#endif
  • uspace/lib/c/include/ipc/socket.h

    r3d93289a r0c37135  
    3838#define LIBC_SOCKET_MESSAGES_H_
    3939
    40 #include <ipc/net.h>
    41 
    4240/** Socket client messages. */
    4341typedef enum {
    4442        /** Creates a new socket. @see socket() */
    45         NET_SOCKET = NET_SOCKET_FIRST,
     43        NET_SOCKET = IPC_FIRST_USER_METHOD,
    4644        /** Binds the socket. @see bind() */
    4745        NET_SOCKET_BIND,
  • uspace/lib/c/include/net/in.h

    r3d93289a r0c37135  
    4545#define INET_ADDRSTRLEN  (4 * 3 + 3 + 1)
    4646
     47#define INADDR_ANY 0
     48
    4749/** Type definition of the INET address.
    4850 * @see in_addr
  • uspace/lib/net/Makefile

    r3d93289a r0c37135  
    3333
    3434SOURCES = \
    35         generic/generic.c \
    36         generic/net_remote.c \
    37         generic/net_checksum.c \
    38         generic/packet_client.c \
    39         generic/packet_remote.c \
    40         generic/protocol_map.c \
    41         adt/module_map.c \
    42         nil/nil_remote.c \
    43         nil/nil_skel.c \
    44         il/il_remote.c \
    45         il/il_skel.c \
    46         il/ip_remote.c \
    47         il/ip_client.c \
    48         il/arp_remote.c \
    49         tl/icmp_remote.c \
    50         tl/icmp_client.c \
    51         tl/socket_core.c \
    52         tl/tl_common.c \
    53         tl/tl_remote.c \
    54         tl/tl_skel.c
     35        tl/socket_core.c
    5536
    5637include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/net/include/socket_core.h

    r3d93289a r0c37135  
    4444#include <net/in.h>
    4545#include <net/device.h>
    46 #include <net/packet.h>
    4746#include <async.h>
    4847
     
    8079        /** Bound port. */
    8180        int port;
    82         /** Received packets queue. */
    83         dyn_fifo_t received;
    8481        /** Sockets for acceptance queue. */
    8582        dyn_fifo_t accepted;
     
    118115extern int socket_destroy(async_sess_t *, int, socket_cores_t *,
    119116    socket_ports_t *, void (*)(socket_core_t *));
    120 extern int socket_reply_packets(packet_t *, size_t *);
    121117extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *,
    122118    size_t);
  • uspace/lib/net/tl/socket_core.c

    r3d93289a r0c37135  
    3636
    3737#include <socket_core.h>
    38 #include <packet_client.h>
    39 #include <packet_remote.h>
    4038#include <net/socket_codes.h>
    4139#include <net/in.h>
    4240#include <net/inet.h>
    43 #include <net/packet.h>
    4441#include <net/modules.h>
    4542#include <stdint.h>
     
    9289        }
    9390       
    94         /* Release all received packets */
    95         int packet_id;
    96         while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)
    97                 pq_release_remote(sess, packet_id);
    98        
    99         dyn_fifo_destroy(&socket->received);
    10091        dyn_fifo_destroy(&socket->accepted);
    10192       
     
    448439        socket->key_length = 0;
    449440        socket->specific_data = specific_data;
    450         rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);
     441       
     442        rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);
    451443        if (rc != EOK) {
    452444                free(socket);
    453445                return rc;
    454446        }
    455        
    456         rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);
    457         if (rc != EOK) {
    458                 dyn_fifo_destroy(&socket->received);
    459                 free(socket);
    460                 return rc;
    461         }
    462447        socket->socket_id = *socket_id;
    463448        rc = socket_cores_add(local_sockets, socket->socket_id, socket);
    464449        if (rc < 0) {
    465                 dyn_fifo_destroy(&socket->received);
    466450                dyn_fifo_destroy(&socket->accepted);
    467451                free(socket);
     
    506490        socket_destroy_core(sess, socket, local_sockets, global_sockets,
    507491            socket_release);
    508        
    509         return EOK;
    510 }
    511 
    512 /** Replies the packet or the packet queue data to the application via the
    513  * socket.
    514  *
    515  * Uses the current message processing fibril.
    516  *
    517  * @param[in] packet    The packet to be transfered.
    518  * @param[out] length   The total data length.
    519  * @return              EOK on success.
    520  * @return              EBADMEM if the length parameter is NULL.
    521  * @return              ENOMEM if there is not enough memory left.
    522  * @return              Other error codes as defined for the data_reply()
    523  *                      function.
    524  */
    525 int socket_reply_packets(packet_t *packet, size_t *length)
    526 {
    527         packet_t *next_packet;
    528         size_t fragments;
    529         size_t *lengths;
    530         size_t index;
    531         int rc;
    532 
    533         if (!length)
    534                 return EBADMEM;
    535 
    536         next_packet = pq_next(packet);
    537         if (!next_packet) {
    538                 /* Write all if only one fragment */
    539                 rc = data_reply(packet_get_data(packet),
    540                     packet_get_data_length(packet));
    541                 if (rc != EOK)
    542                         return rc;
    543                 /* Store the total length */
    544                 *length = packet_get_data_length(packet);
    545         } else {
    546                 /* Count the packet fragments */
    547                 fragments = 1;
    548                 next_packet = pq_next(packet);
    549                 while ((next_packet = pq_next(next_packet)))
    550                         ++fragments;
    551                
    552                 /* Compute and store the fragment lengths */
    553                 lengths = (size_t *) malloc(sizeof(size_t) * fragments +
    554                     sizeof(size_t));
    555                 if (!lengths)
    556                         return ENOMEM;
    557                
    558                 lengths[0] = packet_get_data_length(packet);
    559                 lengths[fragments] = lengths[0];
    560                 next_packet = pq_next(packet);
    561                
    562                 for (index = 1; index < fragments; ++index) {
    563                         lengths[index] = packet_get_data_length(next_packet);
    564                         lengths[fragments] += lengths[index];
    565                         next_packet = pq_next(packet);
    566                 }
    567                
    568                 /* Write the fragment lengths */
    569                 rc = data_reply(lengths, sizeof(int) * (fragments + 1));
    570                 if (rc != EOK) {
    571                         free(lengths);
    572                         return rc;
    573                 }
    574                 next_packet = packet;
    575                
    576                 /* Write the fragments */
    577                 for (index = 0; index < fragments; ++index) {
    578                         rc = data_reply(packet_get_data(next_packet),
    579                             lengths[index]);
    580                         if (rc != EOK) {
    581                                 free(lengths);
    582                                 return rc;
    583                         }
    584                         next_packet = pq_next(next_packet);
    585                 }
    586                
    587                 /* Store the total length */
    588                 *length = lengths[fragments];
    589                 free(lengths);
    590         }
    591492       
    592493        return EOK;
Note: See TracChangeset for help on using the changeset viewer.