Changeset ae972834 in mainline for uspace/lib


Ignore:
Timestamp:
2010-10-08T21:47:40Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b278b4e
Parents:
c0e74b1 (diff), 368fb2c (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 from lp:~jakub/helenos/net.

Location:
uspace/lib
Files:
3 added
2 deleted
27 edited
6 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    rc0e74b1 rae972834  
    101101        generic/net/inet.c \
    102102        generic/net/modules.c \
     103        generic/net/packet.c \
    103104        generic/net/socket_client.c \
    104105        generic/net/socket_parse.c \
  • uspace/lib/c/include/ipc/packet.h

    rc0e74b1 rae972834  
    2727 */
    2828
    29 /** @addtogroup packet
     29/** @addtogroup libc
    3030 *  @{
    3131 */
     
    3535 */
    3636
    37 #ifndef __NET_PACKET_MESSAGES__
    38 #define __NET_PACKET_MESSAGES__
     37#ifndef LIBC_PACKET_MESSAGES_
     38#define LIBC_PACKET_MESSAGES_
    3939
    4040#include <ipc/ipc.h>
    4141#include <ipc/net.h>
    4242
    43 /** Packet server module messages.
    44  */
     43/** Packet server module messages. */
    4544typedef enum {
    4645        /** Create packet message with specified content length.
    47          *  @see packet_get_1()
     46         * @see packet_get_1()
    4847         */
    4948        NET_PACKET_CREATE_1 = NET_PACKET_FIRST,
    50         /** Create packet message with specified address length, prefix, content and suffix.
    51          *  @see packet_get_4()
     49       
     50        /**
     51         * Create packet message with specified address length, prefix, content
     52         * and suffix.
     53         * @see packet_get_4()
    5254         */
    5355        NET_PACKET_CREATE_4,
     56       
    5457        /** Get packet message.
    55          *  @see packet_return()
    56          */
     58         * @see packet_return() */
    5759        NET_PACKET_GET,
     60       
    5861        /** Get packet size message.
    59          *  @see packet_translate()
     62         * @see packet_translate()
    6063         */
    6164        NET_PACKET_GET_SIZE,
     65       
    6266        /** Release packet message.
    63          *  @see pq_release()
     67         * @see pq_release()
    6468         */
    6569        NET_PACKET_RELEASE
    6670} packet_messages;
    6771
    68 /** Returns the protocol service message parameter.
    69  */
    70 #define ARP_GET_PROTO(call)             (services_t) IPC_GET_ARG2(*call)
     72/** Returns the protocol service message parameter. */
     73#define ARP_GET_PROTO(call)     (services_t) IPC_GET_ARG2(*call)
    7174
    72 /** Returns the packet identifier message parameter.
    73  */
    74 #define IPC_GET_ID(call)                        (packet_id_t) IPC_GET_ARG1(*call)
     75/** Returns the packet identifier message parameter. */
     76#define IPC_GET_ID(call)        (packet_id_t) IPC_GET_ARG1(*call)
    7577
    76 /** Returns the maximal content length message parameter.
    77  */
    78 #define IPC_GET_CONTENT(call)           (size_t) IPC_GET_ARG1(*call)
     78/** Returns the maximal content length message parameter. */
     79#define IPC_GET_CONTENT(call)   (size_t) IPC_GET_ARG1(*call)
    7980
    80 /** Returns the maximal address length message parameter.
    81  */
     81/** Returns the maximal address length message parameter. */
    8282#define IPC_GET_ADDR_LEN(call)  (size_t) IPC_GET_ARG2(*call)
    8383
    84 /** Returns the maximal prefix length message parameter.
    85  */
    86 #define IPC_GET_PREFIX(call)            (size_t) IPC_GET_ARG3(*call)
     84/** Returns the maximal prefix length message parameter. */
     85#define IPC_GET_PREFIX(call)    (size_t) IPC_GET_ARG3(*call)
    8786
    88 /** Returns the maximal suffix length message parameter.
    89  */
    90 #define IPC_GET_SUFFIX(call)            (size_t) IPC_GET_ARG4(*call)
     87/** Returns the maximal suffix length message parameter. */
     88#define IPC_GET_SUFFIX(call)    (size_t) IPC_GET_ARG4(*call)
    9189
    9290#endif
  • uspace/lib/c/include/net/packet_header.h

    rc0e74b1 rae972834  
    2727 */
    2828
    29 /** @addtogroup packet
     29/** @addtogroup libc
    3030 *  @{
    3131 */
    3232
    3333/** @file
    34  *  Packet header.
     34 * Packet header.
    3535 */
    3636
    37 #ifndef __NET_PACKET_HEADER_H__
    38 #define __NET_PACKET_HEADER_H__
     37#ifndef LIBC_PACKET_HEADER_H_
     38#define LIBC_PACKET_HEADER_H_
    3939
    40 #include <packet/packet.h>
     40#include <net/packet.h>
    4141
    4242/** Returns the actual packet data length.
    43  *  @param[in] header The packet header.
     43 * @param[in] header    The packet header.
    4444 */
    45 #define PACKET_DATA_LENGTH(header)              ((header)->data_end - (header)->data_start)
     45#define PACKET_DATA_LENGTH(header) \
     46        ((header)->data_end - (header)->data_start)
    4647
    4748/** Returns the maximum packet address length.
    48  *  @param[in] header The packet header.
     49 * @param[in] header    The packet header.
    4950 */
    50 #define PACKET_MAX_ADDRESS_LENGTH(header)               ((header)->dest_addr - (header)->src_addr)
     51#define PACKET_MAX_ADDRESS_LENGTH(header) \
     52        ((header)->dest_addr - (header)->src_addr)
    5153
    5254/** Returns the minimum packet suffix.
    53  *  @param[in] header The packet header.
     55 *  @param[in] header   The packet header.
    5456 */
    55 #define PACKET_MIN_SUFFIX(header)               ((header)->length - (header)->data_start - (header)->max_content)
     57#define PACKET_MIN_SUFFIX(header) \
     58        ((header)->length - (header)->data_start - (header)->max_content)
    5659
    57 /** Packet integrity check magic value.
    58  */
     60/** Packet integrity check magic value. */
    5961#define PACKET_MAGIC_VALUE      0x11227788
    6062
    61 /** Packet header.
    62  */
    63 struct packet{
    64         /** Packet identifier.
    65          */
     63/** Packet header. */
     64struct packet {
     65        /** Packet identifier. */
    6666        packet_id_t packet_id;
    67         /** Packet queue sorting value.
    68          *  The packet queue is sorted the ascending order.
     67
     68        /**
     69         * Packet queue sorting value.
     70         * The packet queue is sorted the ascending order.
    6971         */
    7072        size_t order;
    71         /** Packet metric.
    72         */
     73
     74        /** Packet metric. */
    7375        size_t metric;
    74         /** Previous packet in the queue.
    75          */
     76        /** Previous packet in the queue. */
    7677        packet_id_t previous;
    77         /** Next packet in the queue.
    78          */
     78        /** Next packet in the queue. */
    7979        packet_id_t next;
    80         /** Total length of the packet.
    81          *  Contains the header, the addresses and the data of the packet.
    82          *  Corresponds to the mapped sharable memory block.
     80
     81        /**
     82         * Total length of the packet.
     83         * Contains the header, the addresses and the data of the packet.
     84         * Corresponds to the mapped sharable memory block.
    8385         */
    8486        size_t length;
    85         /** Stored source and destination addresses length.
    86         */
     87
     88        /** Stored source and destination addresses length. */
    8789        size_t addr_len;
    88         /** Souce address offset in bytes from the beginning of the packet header.
     90
     91        /**
     92         * Souce address offset in bytes from the beginning of the packet
     93         * header.
    8994         */
    9095        size_t src_addr;
    91         /** Destination address offset in bytes from the beginning of the packet header.
     96
     97        /**
     98         * Destination address offset in bytes from the beginning of the packet
     99         * header.
    92100         */
    93101        size_t dest_addr;
    94         /** Reserved data prefix length in bytes.
    95         */
     102
     103        /** Reserved data prefix length in bytes. */
    96104        size_t max_prefix;
    97         /** Reserved content length in bytes.
    98          */
     105        /** Reserved content length in bytes. */
    99106        size_t max_content;
    100         /** Actual data start offset in bytes from the beginning of the packet header.
     107
     108        /**
     109         * Actual data start offset in bytes from the beginning of the packet
     110         * header.
    101111         */
    102112        size_t data_start;
    103         /** Actual data end offset in bytes from the beginning of the packet header.
     113
     114        /**
     115         * Actual data end offset in bytes from the beginning of the packet
     116         * header.
    104117         */
    105118        size_t data_end;
    106         /** Integrity check magic value.
    107         */
     119
     120        /** Integrity check magic value. */
    108121        int magic_value;
    109122};
    110123
    111124/** Returns whether the packet is valid.
    112  *  @param[in] packet The packet to be checked.
    113  *  @returns true if the packet is not NULL and the magic value is correct.
    114  *  @returns false otherwise.
     125 * @param[in] packet    The packet to be checked.
     126 * @returns             True if the packet is not NULL and the magic value is
     127 *                      correct.
     128 * @returns             False otherwise.
    115129 */
    116 static inline int packet_is_valid(const packet_t packet){
     130static inline int packet_is_valid(const packet_t packet)
     131{
    117132        return packet && (packet->magic_value == PACKET_MAGIC_VALUE);
    118133}
  • uspace/lib/net/Makefile

    rc0e74b1 rae972834  
    3535        generic/net_remote.c \
    3636        generic/net_checksum.c \
     37        generic/packet_client.c \
    3738        generic/packet_remote.c \
     39        generic/socket_core.c \
    3840        adt/module_map.c \
    3941        netif/netif_local.c \
  • uspace/lib/net/generic/packet_client.c

    rc0e74b1 rae972834  
    4141#include <sys/mman.h>
    4242
     43#include <packet_client.h>
     44
    4345#include <net_messages.h>
    44 #include <packet/packet.h>
    45 #include <packet/packet_header.h>
    46 #include <packet/packet_client.h>
     46#include <net/packet.h>
     47#include <net/packet_header.h>
    4748
    4849int packet_copy_data(packet_t packet, const void * data, size_t length)
     
    181182
    182183        // get a new packet
    183         copy = packet_get_4_local(phone, PACKET_DATA_LENGTH(packet),
     184        copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet),
    184185            PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix,
    185186            PACKET_MIN_SUFFIX(packet));
     
    199200                return copy;
    200201        } else {
    201                 pq_release_local(phone, copy->packet_id);
     202                pq_release_remote(phone, copy->packet_id);
    202203                return NULL;
    203204        }
  • uspace/lib/net/generic/packet_remote.c

    rc0e74b1 rae972834  
    4040#include <err.h>
    4141#include <ipc/ipc.h>
     42#include <ipc/packet.h>
    4243#include <sys/mman.h>
    4344
    4445#include <net_messages.h>
    45 #include <packet/packet.h>
    46 #include <packet/packet_client.h>
    47 #include <packet/packet_header.h>
    48 #include <packet/packet_messages.h>
     46#include <packet_client.h>
    4947#include <packet_remote.h>
     48
     49#include <net/packet.h>
     50#include <net/packet_header.h>
    5051
    5152/** Obtain the packet from the packet server as the shared memory block.
  • uspace/lib/net/generic/socket_core.c

    rc0e74b1 rae972834  
    4646#include <adt/dynamic_fifo.h>
    4747#include <adt/int_map.h>
    48 #include <packet/packet.h>
    49 #include <packet/packet_client.h>
     48#include <net/packet.h>
     49#include <packet_client.h>
     50#include <packet_remote.h>
    5051#include <net/modules.h>
    5152#include <socket_core.h>
     
    9192        // release all received packets
    9293        while((packet_id = dyn_fifo_pop(&socket->received)) >= 0){
    93                 pq_release_local(packet_phone, packet_id);
     94                pq_release_remote(packet_phone, packet_id);
    9495        }
    9596        dyn_fifo_destroy(&socket->received);
  • uspace/lib/net/il/ip_client.c

    rc0e74b1 rae972834  
    4040
    4141#include <ip_client.h>
    42 #include <packet/packet.h>
    43 #include <packet/packet_client.h>
     42#include <packet_client.h>
    4443#include <ip_header.h>
     44
     45#include <net/packet.h>
    4546
    4647size_t ip_client_header_length(packet_t packet){
  • uspace/lib/net/il/ip_remote.c

    rc0e74b1 rae972834  
    4747#include <net/inet.h>
    4848#include <ip_interface.h>
    49 #include <packet/packet_client.h>
     49#include <packet_client.h>
    5050#include <il_messages.h>
    5151#include <ip_messages.h>
  • uspace/lib/net/include/icmp_client.h

    rc0e74b1 rae972834  
    3939
    4040#include <icmp_codes.h>
    41 #include <packet/packet.h>
     41#include <net/packet.h>
    4242
    4343/** Processes the received packet prefixed with an ICMP header.
  • uspace/lib/net/include/icmp_interface.h

    rc0e74b1 rae972834  
    3939#include <net_device.h>
    4040#include <adt/measured_strings.h>
    41 #include <packet/packet.h>
     41#include <net/packet.h>
    4242#include <net/inet.h>
    4343#include <ip_codes.h>
  • uspace/lib/net/include/il_interface.h

    rc0e74b1 rae972834  
    4545#include <net_messages.h>
    4646#include <net_device.h>
    47 #include <packet/packet.h>
    48 #include <packet/packet_client.h>
     47#include <net/packet.h>
     48#include <packet_client.h>
    4949#include <il_messages.h>
    5050
  • uspace/lib/net/include/ip_client.h

    rc0e74b1 rae972834  
    4141#include <sys/types.h>
    4242
    43 #include <packet/packet.h>
     43#include <net/packet.h>
    4444#include <ip_codes.h>
    4545#include <ip_interface.h>
  • uspace/lib/net/include/ip_interface.h

    rc0e74b1 rae972834  
    3939
    4040#include <net_device.h>
    41 #include <packet/packet.h>
     41#include <net/packet.h>
    4242
    4343#include <net/in.h>
  • uspace/lib/net/include/netif_interface.h

    rc0e74b1 rae972834  
    5353
    5454#include <netif_remote.h>
    55 #include <packet/packet_client.h>
     55#include <packet_client.h>
    5656
    5757#define netif_module_message    netif_module_message_standalone
  • uspace/lib/net/include/netif_local.h

    rc0e74b1 rae972834  
    4848#include <adt/measured_strings.h>
    4949#include <net_device.h>
    50 #include <packet/packet.h>
     50#include <net/packet.h>
    5151
    5252/** Network interface device specific data.
  • uspace/lib/net/include/nil_interface.h

    rc0e74b1 rae972834  
    4141#include <net_messages.h>
    4242#include <adt/measured_strings.h>
    43 #include <packet/packet.h>
     43#include <net/packet.h>
    4444#include <nil_messages.h>
    4545#include <net_device.h>
  • uspace/lib/net/include/packet_client.h

    rc0e74b1 rae972834  
    4545#define __NET_PACKET_CLIENT_H__
    4646
    47 #include <packet/packet.h>
     47#include <net/packet.h>
    4848
    4949/** @name Packet client interface
     
    172172 *  @returns Other error codes as defined for the packet_return() function.
    173173 */
    174 extern int packet_translate_local(int phone, packet_ref packet, packet_id_t packet_id);
     174extern int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id);
    175175
    176176/** Obtains the packet of the given dimensions.
     
    184184 *  @returns NULL on error.
    185185 */
    186 extern packet_t packet_get_4_local(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix);
     186extern packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix);
    187187
    188188/** Obtains the packet of the given content size.
     
    193193 *  @returns NULL on error.
    194194 */
    195 extern packet_t packet_get_1_local(int phone, size_t content);
     195extern packet_t packet_get_1_remote(int phone, size_t content);
    196196
    197197/** Releases the packet queue.
     
    202202 *  @param[in] packet_id The packet identifier.
    203203 */
    204 extern void pq_release_local(int phone, packet_id_t packet_id);
     204extern void pq_release_remote(int phone, packet_id_t packet_id);
    205205
    206206/** Returns the packet copy.
  • uspace/lib/net/include/packet_remote.h

    rc0e74b1 rae972834  
    3434#define __NET_PACKET_REMOTE_H__
    3535
    36 #include <packet/packet.h>
     36#include <net/packet.h>
    3737
    3838extern int packet_translate_remote(int, packet_ref, packet_id_t);
  • uspace/lib/net/include/socket_core.h

    rc0e74b1 rae972834  
    4545#include <adt/dynamic_fifo.h>
    4646#include <adt/int_map.h>
    47 #include <packet/packet.h>
     47#include <net/packet.h>
    4848
    4949/** Initial size of the received packet queue.
  • uspace/lib/net/include/tl_common.h

    rc0e74b1 rae972834  
    3939
    4040#include <net/socket_codes.h>
    41 
    42 #include <packet/packet.h>
     41#include <net/packet.h>
    4342#include <net_device.h>
    4443#include <net/inet.h>
  • uspace/lib/net/include/tl_interface.h

    rc0e74b1 rae972834  
    4343#include <net_messages.h>
    4444#include <net_device.h>
    45 #include <packet/packet.h>
    46 #include <packet/packet_client.h>
     45#include <net/packet.h>
     46#include <packet_client.h>
    4747#include <tl_messages.h>
    4848
  • uspace/lib/net/netif/netif_local.c

    rc0e74b1 rae972834  
    4646#include <net_messages.h>
    4747#include <net/modules.h>
    48 #include <packet/packet.h>
    49 #include <packet/packet_client.h>
     48#include <net/packet.h>
     49#include <packet_client.h>
    5050#include <packet/packet_server.h>
    5151#include <packet_remote.h>
  • uspace/lib/net/netif/netif_nil_bundle.c

    rc0e74b1 rae972834  
    4040#include <ipc/net.h>
    4141
    42 #include <packet/packet.h>
     42#include <net/packet.h>
    4343#include <netif_nil_bundle.h>
    4444#include <netif_local.h>
  • uspace/lib/net/netif/netif_remote.c

    rc0e74b1 rae972834  
    3939#include <net/modules.h>
    4040#include <adt/measured_strings.h>
    41 #include <packet/packet.h>
    42 #include <packet/packet_client.h>
     41#include <net/packet.h>
     42#include <packet_client.h>
    4343#include <net_device.h>
    4444#include <netif_remote.h>
  • uspace/lib/net/nil/nil_remote.c

    rc0e74b1 rae972834  
    3939#include <net_device.h>
    4040#include <nil_interface.h>
    41 #include <packet/packet.h>
    42 #include <packet/packet_client.h>
     41#include <net/packet.h>
     42#include <packet_client.h>
    4343#include <nil_messages.h>
    4444#include <nil_remote.h>
  • uspace/lib/net/tl/icmp_client.c

    rc0e74b1 rae972834  
    4545#include <icmp_codes.h>
    4646#include <icmp_client.h>
    47 #include <packet/packet.h>
    48 #include <packet/packet_client.h>
     47#include <net/packet.h>
     48#include <packet_client.h>
    4949#include <icmp_header.h>
    5050
  • uspace/lib/net/tl/icmp_remote.c

    rc0e74b1 rae972834  
    4545#include <net/modules.h>
    4646#include <icmp_interface.h>
    47 #include <packet/packet_client.h>
     47#include <packet_client.h>
    4848#include <icmp_messages.h>
    4949
  • uspace/lib/net/tl/tl_common.c

    rc0e74b1 rae972834  
    4545#include <err.h>
    4646
    47 #include <packet/packet.h>
    48 #include <packet/packet_client.h>
     47#include <net/packet.h>
     48#include <packet_client.h>
    4949#include <packet_remote.h>
    5050#include <net_device.h>
  • uspace/lib/socket/Makefile

    rc0e74b1 rae972834  
    3333
    3434SOURCES = \
    35         generic/socket_core.c \
    3635        generic/icmp_common.c \
    3736        generic/icmp_api.c \
    38         packet/packet.c \
    39         packet/packet_client.c \
    40         packet/packet_server.c
     37        packet/packet_server.c
    4138
    4239include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/socket/include/icmp_api.h

    rc0e74b1 rae972834  
    4444#include <net_device.h>
    4545#include <adt/measured_strings.h>
    46 #include <packet/packet.h>
     46#include <net/packet.h>
    4747#include <ip_codes.h>
    4848#include <icmp_codes.h>
  • uspace/lib/socket/include/net_messages.h

    rc0e74b1 rae972834  
    4444#include <net_device.h>
    4545#include <adt/measured_strings.h>
    46 #include <packet/packet.h>
     46#include <net/packet.h>
    4747
    4848/** @name Networking specific message arguments definitions
  • uspace/lib/socket/packet/packet_server.c

    rc0e74b1 rae972834  
    4242#include <fibril_synch.h>
    4343#include <unistd.h>
     44#include <sys/mman.h>
    4445
    4546#include <ipc/ipc.h>
    46 #include <sys/mman.h>
     47#include <ipc/packet.h>
     48#include <net/packet.h>
     49#include <net/packet_header.h>
     50#include <packet/packet_server.h>
    4751
    4852#include <net_messages.h>
    49 #include <packet/packet.h>
    50 #include <packet/packet_client.h>
    51 #include <packet/packet_header.h>
    52 #include <packet/packet_messages.h>
    53 #include <packet/packet_server.h>
     53#include <packet/packet_local.h>
    5454
    5555#define FREE_QUEUES_COUNT       7
Note: See TracChangeset for help on using the changeset viewer.