Changeset f14291b in mainline for uspace/lib


Ignore:
Timestamp:
2010-10-19T20:55:53Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a93d79a
Parents:
1882525 (diff), a7a85d16 (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 mainline changes.

Location:
uspace/lib
Files:
31 added
27 deleted
45 edited
28 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r1882525 rf14291b  
    8484        generic/ipc.c \
    8585        generic/async.c \
     86        generic/async_rel.c \
    8687        generic/loader.c \
    8788        generic/getopt.c \
    8889        generic/adt/list.o \
    8990        generic/adt/hash_table.o \
     91        generic/adt/dynamic_fifo.c \
     92        generic/adt/measured_strings.c \
     93        generic/adt/char_map.c \
    9094        generic/time.c \
    9195        generic/err.c \
     
    9599        generic/vfs/vfs.c \
    96100        generic/vfs/canonify.c \
     101        generic/net/inet.c \
     102        generic/net/icmp_common.c \
     103        generic/net/icmp_api.c \
     104        generic/net/modules.c \
     105        generic/net/packet.c \
     106        generic/net/socket_client.c \
     107        generic/net/socket_parse.c \
    97108        generic/stacktrace.c \
    98109        generic/arg_parse.c \
  • uspace/lib/c/generic/ddi.c

    r1882525 rf14291b  
    9696}
    9797
    98 /** Interrupt control
    99  *
    100  * @param enable        1 - enable interrupts, 0 - disable interrupts
    101  */
    102 int preemption_control(int enable)
    103 {
    104         return __SYSCALL1(SYS_PREEMPT_CONTROL, (sysarg_t) enable);
    105 }
    106 
    10798/** Enable PIO for specified I/O range.
    10899 *
  • uspace/lib/c/generic/io/io.c

    r1882525 rf14291b  
    757757}
    758758
     759int fileno(FILE *stream)
     760{
     761        if (stream->klog) {
     762                errno = EBADF;
     763                return -1;
     764        }
     765       
     766        return stream->fd;
     767}
     768
    759769int fphone(FILE *stream)
    760770{
  • uspace/lib/c/generic/libc.c

    r1882525 rf14291b  
    5050#include <ipc/ipc.h>
    5151#include <async.h>
     52#include <async_rel.h>
    5253#include <as.h>
    5354#include <loader/pcb.h>
     
    6566        __heap_init();
    6667        __async_init();
     68        (void) async_rel_init();
    6769        fibril_t *fibril = fibril_setup();
    6870        __tcb_set(fibril->tcb);
  • uspace/lib/c/generic/net/icmp_common.c

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup icmp
     29/** @addtogroup libc
    3030 *  @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP common interface implementation.
    35  *  @see icmp_common.h
     34 * ICMP common interface implementation.
     35 * @see icmp_common.h
    3636 */
    3737
     38#include <net/modules.h>
     39#include <net/icmp_common.h>
     40
     41#include <ipc/services.h>
     42#include <ipc/icmp.h>
     43
     44#include <sys/time.h>
    3845#include <async.h>
    39 #include <ipc/services.h>
    4046
    41 #include <net_modules.h>
    42 #include <icmp_common.h>
    43 #include <icmp_messages.h>
    44 
    45 int icmp_connect_module(services_t service, suseconds_t timeout){
     47/** Connects to the ICMP module.
     48 *
     49 * @param service       The ICMP module service. Ignored parameter.
     50 * @param[in] timeout   The connection timeout in microseconds. No timeout if
     51 *                      set to zero.
     52 * @returns             The ICMP module phone on success.
     53 * @returns             ETIMEOUT if the connection timeouted.
     54 */
     55int icmp_connect_module(services_t service, suseconds_t timeout)
     56{
    4657        int phone;
    4758
    4859        phone = connect_to_service_timeout(SERVICE_ICMP, timeout);
    49         if(phone >= 0){
     60        if (phone >= 0)
    5061                async_req_0_0(phone, NET_ICMP_INIT);
    51         }
     62
    5263        return phone;
    5364}
  • uspace/lib/c/generic/net/socket_parse.c

    r1882525 rf14291b  
    3535 */
    3636
    37 #include <socket_parse.h>
     37#include <net/socket_parse.h>
     38#include <net/socket.h>
    3839#include <arg_parse.h>
    3940#include <errno.h>
    4041#include <str.h>
    41 #include <socket.h>
    4242
    4343/** Translate the character string to the address family number.
  • uspace/lib/c/include/byteorder.h

    r1882525 rf14291b  
    8080#endif
    8181
     82#define htons(n)        host2uint16_t_be((n))
     83#define htonl(n)        host2uint32_t_be((n))
     84#define ntohs(n)        uint16_t_be2host((n))
     85#define ntohl(n)        uint32_t_be2host((n))
     86
    8287static inline uint64_t uint64_t_byteorder_swap(uint64_t n)
    8388{
  • uspace/lib/c/include/ddi.h

    r1882525 rf14291b  
    4141extern int physmem_map(void *, void *, unsigned long, int);
    4242extern int iospace_enable(task_id_t, void *, unsigned long);
    43 extern int preemption_control(int);
    4443extern int pio_enable(void *, size_t, void **);
    4544
  • uspace/lib/c/include/err.h

    r1882525 rf14291b  
    3636#define LIBC_ERR_H_
    3737
     38#include <stdio.h>
     39#include <errno.h>
     40
     41#ifdef CONFIG_DEBUG
     42#include <str_error.h>
     43#endif
     44
    3845#define errx(status, fmt, ...) { \
    3946        printf((fmt), ##__VA_ARGS__); \
     
    4148}
    4249
     50
     51/** An actual stored error code.  */
     52#define ERROR_CODE  error_check_return_value
     53
     54/** An error processing routines declaration.
     55 *
     56 * This has to be declared in the block where the error processing
     57 * is desired.
     58 */
     59#define ERROR_DECLARE  int ERROR_CODE
     60
     61/** Store the value as an error code and checks if an error occurred.
     62 *
     63 * @param[in] value     The value to be checked. May be a function call.
     64 * @return              False if the value indicates success (EOK).
     65 * @return              True otherwise.
     66 */
     67#ifdef CONFIG_DEBUG
     68
     69#define ERROR_OCCURRED(value) \
     70        (((ERROR_CODE = (value)) != EOK) && \
     71        ({ \
     72                fprintf(stderr, "libsocket error at %s:%d (%s)\n", \
     73                __FILE__, __LINE__, str_error(ERROR_CODE)); \
     74                1; \
     75        }))
     76
     77#else
     78
     79#define ERROR_OCCURRED(value)   ((ERROR_CODE = (value)) != EOK)
     80
     81#endif
     82
     83#define ERROR_NONE(value)       !ERROR_OCCURRED((value))
     84
     85/** Error propagation
     86 *
     87 * Check if an error occurred and immediately exit the actual
     88 * function returning the error code.
     89 *
     90 * @param[in] value     The value to be checked. May be a function call.
     91 *
     92 */
     93
     94#define ERROR_PROPAGATE(value) \
     95        if (ERROR_OCCURRED(value)) \
     96                return ERROR_CODE
     97
    4398#endif
    4499
  • uspace/lib/c/include/errno.h

    r1882525 rf14291b  
    5656#define EMLINK        (-266)
    5757
     58/** An API function is called while another blocking function is in progress. */
     59#define EINPROGRESS     (-10036)
     60
     61/** The socket identifier is not valid. */
     62#define ENOTSOCK        (-10038)
     63
     64/** The destination address required. */
     65#define EDESTADDRREQ    (-10039)
     66
     67/** Protocol is not supported.  */
     68#define EPROTONOSUPPORT (-10043)
     69
     70/** Socket type is not supported. */
     71#define ESOCKTNOSUPPORT (-10044)
     72
     73/** Protocol family is not supported. */
     74#define EPFNOSUPPORT    (-10046)
     75
     76/** Address family is not supported. */
     77#define EAFNOSUPPORT    (-10047)
     78
     79/** Address is already in use. */
     80#define EADDRINUSE      (-10048)
     81
     82/** The socket is not connected or bound. */
     83#define ENOTCONN        (-10057)
     84
     85/** The requested operation was not performed.
     86 *  Try again later.
     87 */
     88#define TRY_AGAIN       (-11002)
     89
     90/** No data.
     91 */
     92#define NO_DATA         (-11004)
     93
    5894#endif
    5995
  • uspace/lib/c/include/fibril_synch.h

    r1882525 rf14291b  
    4747} fibril_mutex_t;
    4848
    49 #define FIBRIL_MUTEX_INITIALIZE(name) \
    50         fibril_mutex_t name = { \
     49#define FIBRIL_MUTEX_INITIALIZER(name) \
     50        { \
    5151                .counter = 1, \
    5252                .waiters = { \
     
    5555                } \
    5656        }
     57       
     58#define FIBRIL_MUTEX_INITIALIZE(name) \
     59        fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name)
    5760
    5861typedef struct {
     
    6265} fibril_rwlock_t;
    6366
    64 #define FIBRIL_RWLOCK_INITIALIZE(name) \
    65         fibril_rwlock_t name = { \
     67#define FIBRIL_RWLOCK_INITIALIZER(name) \
     68        { \
    6669                .readers = 0, \
    6770                .writers = 0, \
     
    7275        }
    7376
     77#define FIBRIL_RWLOCK_INITIALIZE(name) \
     78        fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name)
     79
    7480typedef struct {
    7581        link_t waiters;
    7682} fibril_condvar_t;
    7783
    78 #define FIBRIL_CONDVAR_INITIALIZE(name) \
    79         fibril_condvar_t name = { \
     84#define FIBRIL_CONDVAR_INITIALIZER(name) \
     85        { \
    8086                .waiters = { \
    8187                        .next = &name.waiters, \
     
    8389                } \
    8490        }
     91
     92#define FIBRIL_CONDVAR_INITIALIZE(name) \
     93        fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name)
    8594
    8695extern void fibril_mutex_initialize(fibril_mutex_t *);
  • uspace/lib/c/include/ipc/arp.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup arp
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  ARP module messages.
    35  *  @see arp_interface.h
     34 * ARP module messages.
     35 * @see arp_interface.h
    3636 */
    3737
    38 #ifndef __NET_ARP_MESSAGES__
    39 #define __NET_ARP_MESSAGES__
     38#ifndef LIBC_ARP_MESSAGES_
     39#define LIBC_ARP_MESSAGES_
    4040
    4141#include <ipc/ipc.h>
     42#include <ipc/net.h>
    4243
    43 #include <net_messages.h>
    44 
    45 /** ARP module messages.
    46  */
    47 typedef enum{
     44/** ARP module messages. */
     45typedef enum {
    4846        /** Clean cache message.
    49          *  @see arp_clean_cache()
     47         * @see arp_clean_cache()
    5048         */
    5149        NET_ARP_CLEAN_CACHE = NET_ARP_FIRST,
    5250        /** Clear address cache message.
    53          *  @see arp_clear_address_msg()
     51         * @see arp_clear_address_msg()
    5452         */
    5553        NET_ARP_CLEAR_ADDRESS,
    5654        /** Clear device cache message.
    57          *  @see arp_clear_device_req()
     55         * @see arp_clear_device_req()
    5856         */
    5957        NET_ARP_CLEAR_DEVICE,
    6058        /** New device message.
    61          *  @see arp_device_req()
     59         * @see arp_device_req()
    6260         */
    6361        NET_ARP_DEVICE,
    6462        /** Address translation message.
    65          *  @see arp_translate_req()
     63         * @see arp_translate_req()
    6664         */
    6765        NET_ARP_TRANSLATE
    6866} arp_messages;
    6967
    70 /** @name ARP specific message parameters definitions
    71  */
     68/** @name ARP specific message parameters definitions */
    7269/*@{*/
    7370
    7471/** Returns the protocol service message parameter.
    75  *  @param[in] call The message call structure.
     72 * @param[in] call The message call structure.
    7673 */
    7774#define ARP_GET_NETIF(call) \
    78         ({services_t service = (services_t) IPC_GET_ARG2(*call); service;})
     75        ({ \
     76                services_t service = (services_t) IPC_GET_ARG2(*call); \
     77                service; \
     78        })
    7979
    8080/*@}*/
  • uspace/lib/c/include/ipc/icmp.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup icmp
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP module messages.
    35  *  @see icmp_interface.h
     34 * ICMP module messages.
     35 * @see icmp_interface.h
    3636 */
    3737
    38 #ifndef __NET_ICMP_MESSAGES__
    39 #define __NET_ICMP_MESSAGES__
     38#ifndef LIBC_ICMP_MESSAGES_
     39#define LIBC_ICMP_MESSAGES_
    4040
    4141#include <ipc/ipc.h>
     42#include <ipc/net.h>
    4243#include <sys/types.h>
     44#include <sys/time.h>
    4345
    44 #include <icmp_codes.h>
    45 #include <net_messages.h>
     46#include <net/icmp_codes.h>
    4647
    47 /** ICMP module messages.
    48  */
    49 typedef enum{
    50         /** Sends echo request.
    51          *  @see icmp_echo()
    52          */
     48/** ICMP module messages. */
     49typedef enum {
     50        /** Sends echo request. @see icmp_echo() */
    5351        NET_ICMP_ECHO = NET_ICMP_FIRST,
    54         /** Sends destination unreachable error message.
    55          *  @see icmp_destination_unreachable_msg()
     52       
     53        /**
     54         * Sends destination unreachable error message.
     55         * @see icmp_destination_unreachable_msg()
    5656         */
    5757        NET_ICMP_DEST_UNREACH,
    58         /** Sends source quench error message.
    59          *  @see icmp_source_quench_msg()
     58       
     59        /**
     60         * Sends source quench error message.
     61         * @see icmp_source_quench_msg()
    6062         */
    6163        NET_ICMP_SOURCE_QUENCH,
    62         /** Sends time exceeded error message.
    63          *  @see icmp_time_exceeded_msg()
     64       
     65        /**
     66         * Sends time exceeded error message.
     67         * @see icmp_time_exceeded_msg()
    6468         */
    6569        NET_ICMP_TIME_EXCEEDED,
    66         /** Sends parameter problem error message.
    67          *  @see icmp_parameter_problem_msg()
     70       
     71        /**
     72         * Sends parameter problem error message.
     73         * @see icmp_parameter_problem_msg()
    6874         */
    6975        NET_ICMP_PARAMETERPROB,
    70         /** Initializes new connection.
    71         */
     76       
     77        /** Initializes new connection. */
    7278        NET_ICMP_INIT
    7379} icmp_messages;
    7480
    75 /** @name ICMP specific message parameters definitions
    76  */
     81/** @name ICMP specific message parameters definitions */
    7782/*@{*/
    7883
    7984/** Returns the ICMP code message parameter.
    80  *  @param[in] call The message call structure.
     85 *
     86 * @param[in] call      The message call structure.
    8187 */
    8288#define ICMP_GET_CODE(call) \
    83         ({icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); code;})
     89        ({ \
     90                icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); \
     91                code; \
     92        })
    8493
    8594/** Returns the ICMP link MTU message parameter.
    86  *  @param[in] call The message call structure.
     95 *
     96 * @param[in] call      The message call structure.
    8797 */
    8898#define ICMP_GET_MTU(call) \
    89         ({icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); mtu;})
     99        ({ \
     100                icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); \
     101                mtu; \
     102        })
    90103
    91104/** Returns the pointer message parameter.
    92  *  @param[in] call The message call structure.
     105 *
     106 * @param[in] call      The message call structure.
    93107 */
    94108#define ICMP_GET_POINTER(call) \
    95         ({icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); pointer;})
     109        ({ \
     110                icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); \
     111                pointer; \
     112        })
    96113
    97114/** Returns the size message parameter.
    98  *  @param[in] call The message call structure.
     115 *
     116 * @param[in] call      The message call structure.
    99117 */
    100118#define ICMP_GET_SIZE(call) \
    101         ({size_t size = (size_t) IPC_GET_ARG1(call); size;})
     119        ({ \
     120                size_t size = (size_t) IPC_GET_ARG1(call); \
     121                size; \
     122        })
    102123
    103124/** Returns the timeout message parameter.
    104  *  @param[in] call The message call structure.
     125 *
     126 * @param[in] call      The message call structure.
    105127 */
    106128#define ICMP_GET_TIMEOUT(call) \
    107         (({suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); timeout;}))
     129        ({ \
     130                suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); \
     131                timeout; \
     132        })
    108133
    109134/** Returns the time to live message parameter.
    110  *  @param[in] call The message call structure.
     135 *
     136 * @param[in] call      The message call structure.
    111137 */
    112138#define ICMP_GET_TTL(call) \
    113         ({ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); ttl;})
     139        ({ \
     140                ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); \
     141                ttl; \
     142        })
    114143
    115144/** Returns the type of service message parameter.
    116  *  @param[in] call The message call structure.
     145 *
     146 * @param[in] call      The message call structure.
    117147 */
    118148#define ICMP_GET_TOS(call) \
    119         ({ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); tos;})
     149        ({ \
     150                ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); \
     151                tos; \
     152        })
    120153
    121154/** Returns the dont fragment message parameter.
    122  *  @param[in] call The message call structure.
     155 *
     156 * @param[in] call      The message call structure.
    123157 */
    124158#define ICMP_GET_DONT_FRAGMENT(call) \
    125         ({int dont_fragment = (int) IPC_GET_ARG5(call); dont_fragment;})
     159        ({ \
     160                int dont_fragment = (int) IPC_GET_ARG5(call); \
     161                dont_fragment; \
     162        })
    126163
    127164/*@}*/
  • uspace/lib/c/include/ipc/il.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net_il
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3737 */
    3838
    39 #ifndef __NET_IL_MESSAGES_H__
    40 #define __NET_IL_MESSAGES_H__
     39#ifndef LIBC_IL_MESSAGES_H_
     40#define LIBC_IL_MESSAGES_H_
    4141
    4242#include <ipc/ipc.h>
     43#include <ipc/net.h>
    4344
    44 /** Internet layer modules messages.
    45  */
     45/** Internet layer modules messages. */
    4646typedef enum {
    4747        /** New device message.
    48          *  @see ip_device_req()
     48         * @see ip_device_req()
    4949         */
    5050        NET_IL_DEVICE = NET_IL_FIRST,
    5151        /** Device state changed message.
    52          *  @see il_device_state_msg()
     52         * @see il_device_state_msg()
    5353         */
    5454        NET_IL_DEVICE_STATE,
    5555        /** Device MTU changed message.
    56          *  @see il_mtu_changed_msg()
     56         * @see il_mtu_changed_msg()
    5757         */
    5858        NET_IL_MTU_CHANGED,
    5959        /** Packet size message.
    60          *  @see il_packet_size_req()
     60         * @see il_packet_size_req()
    6161         */
    6262        NET_IL_PACKET_SPACE,
    6363        /** Packet received message.
    64          *  @see il_received_msg()
     64         * @see il_received_msg()
    6565         */
    6666        NET_IL_RECEIVED,
    6767        /** Packet send message.
    68          *  @see il_send_msg()
     68         * @see il_send_msg()
    6969         */
    7070        NET_IL_SEND
    7171} il_messages;
    7272
    73 /** @name Internetwork layer specific message parameters definitions
    74  *
    75  */
     73/** @name Internetwork layer specific message parameters definitions */
    7674/*@{*/
    7775
    7876/** Return the protocol number message parameter.
    7977 * @param[in] call The message call structure.
    80  *
    8178 */
    82 #define IL_GET_PROTO(call)  (int) IPC_GET_ARG1(*call)
     79#define IL_GET_PROTO(call)      (int) IPC_GET_ARG1(*call)
    8380
    8481/** Return the registering service message parameter.
    8582 * @param[in] call The message call structure.
    86  *
    8783 */
    88 #define IL_GET_SERVICE(call)  (services_t) IPC_GET_ARG2(*call)
     84#define IL_GET_SERVICE(call)    (services_t) IPC_GET_ARG2(*call)
    8985
    9086/*@}*/
  • uspace/lib/c/include/ipc/ip.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup ip
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  IP module messages.
    35  *  @see ip_interface.h
     34 * IP module messages.
     35 * @see ip_interface.h
    3636 */
    3737
    38 #ifndef __NET_IP_MESSAGES_H__
    39 #define __NET_IP_MESSAGES_H__
     38#ifndef LIBC_IP_MESSAGES_H_
     39#define LIBC_IP_MESSAGES_H_
    4040
    4141#include <ipc/ipc.h>
     42#include <ipc/net.h>
    4243
    43 #include <in.h>
    44 #include <ip_codes.h>
     44#include <net/in.h>
     45#include <net/ip_codes.h>
    4546
    46 /** IP module messages.
    47  */
    48 typedef enum{
     47/** IP module messages. */
     48typedef enum {
    4949        /** Adds the routing entry.
    50          *  @see ip_add_route()
     50         * @see ip_add_route()
    5151         */
    5252        NET_IP_ADD_ROUTE = NET_IP_FIRST,
    5353        /** Gets the actual route information.
    54          *  @see ip_get_route()
     54         * @see ip_get_route()
    5555         */
    5656        NET_IP_GET_ROUTE,
    5757        /** Processes the received error notification.
    58          *  @see ip_received_error_msg()
     58         * @see ip_received_error_msg()
    5959         */
    6060        NET_IP_RECEIVED_ERROR,
    6161        /** Sets the default gateway.
    62          *  @see ip_set_default_gateway()
     62         * @see ip_set_default_gateway()
    6363         */
    6464        NET_IP_SET_GATEWAY
    6565} ip_messages;
    6666
    67 /** @name IP specific message parameters definitions
    68  */
     67/** @name IP specific message parameters definitions */
    6968/*@{*/
    7069
    7170/** Returns the address message parameter.
    72  *  @param[in] call The message call structure.
     71 * @param[in] call The message call structure.
    7372 */
    7473#define IP_GET_ADDRESS(call) \
    75         ({in_addr_t addr; addr.s_addr = IPC_GET_ARG3(*call); addr;})
     74        ({ \
     75                in_addr_t addr; \
     76                addr.s_addr = IPC_GET_ARG3(*call); \
     77                addr; \
     78        })
    7679
    7780/** Returns the gateway message parameter.
    78  *  @param[in] call The message call structure.
     81 * @param[in] call The message call structure.
    7982 */
    8083#define IP_GET_GATEWAY(call) \
    81         ({in_addr_t addr; addr.s_addr = IPC_GET_ARG2(*call); addr;})
     84        ({ \
     85                in_addr_t addr; \
     86                addr.s_addr = IPC_GET_ARG2(*call); \
     87                addr; \
     88        })
    8289
    8390/** Sets the header length in the message answer.
    84  *  @param[out] answer The message answer structure.
     91 * @param[out] answer The message answer structure.
    8592 */
    8693#define IP_SET_HEADERLEN(answer, value) \
    87         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG2(*answer, argument);}
     94        do { \
     95                ipcarg_t argument = (ipcarg_t) (value); \
     96                IPC_SET_ARG2(*answer, argument); \
     97        } while (0)
    8898
    8999/** Returns the network mask message parameter.
    90  *  @param[in] call The message call structure.
     100 * @param[in] call The message call structure.
    91101 */
    92102#define IP_GET_NETMASK(call) \
    93         ({in_addr_t addr; addr.s_addr = IPC_GET_ARG4(*call); addr;})
     103        ({ \
     104                in_addr_t addr; \
     105                addr.s_addr = IPC_GET_ARG4(*call); \
     106                addr; \
     107        })
    94108
    95109/** Returns the protocol message parameter.
    96  *  @param[in] call The message call structure.
     110 * @param[in] call The message call structure.
    97111 */
    98112#define IP_GET_PROTOCOL(call) \
    99         ({ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); protocol;})
     113        ({ \
     114                ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); \
     115                protocol; \
     116        })
    100117
    101118/*@}*/
  • uspace/lib/c/include/ipc/net_net.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Networking subsystem central module messages.
    35  *  @see net_interface.h
     34 * Networking subsystem central module messages.
     35 * @see net_interface.h
    3636 */
    3737
    38 #ifndef __NET_NET_MESSAGES_H__
    39 #define __NET_NET_MESSAGES_H__
     38#ifndef LIBC_NET_NET_MESSAGES_H_
     39#define LIBC_NET_NET_MESSAGES_H_
    4040
    4141#include <ipc/ipc.h>
     42#include <ipc/net.h>
    4243
    43 #include <net_messages.h>
    44 
    45 /** Networking subsystem central module messages.
    46  */
    47 typedef enum{
     44/** Networking subsystem central module messages. */
     45typedef enum {
    4846        /** Returns the general configuration
    49          *  @see net_get_conf_req()
     47         * @see net_get_conf_req()
    5048         */
    5149        NET_NET_GET_CONF = NET_FIRST,
    5250        /** Returns the device specific configuration
    53          *  @see net_get_device_conf_req()
     51         * @see net_get_device_conf_req()
    5452         */
    5553        NET_NET_GET_DEVICE_CONF,
    56         /** Starts the networking stack.
    57          */
     54        /** Starts the networking stack. */
    5855        NET_NET_STARTUP,
    5956} net_messages;
  • uspace/lib/c/include/ipc/netif.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup netif
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3535 */
    3636
    37 #ifndef __NET_NETIF_MESSAGES_H__
    38 #define __NET_NETIF_MESSAGES_H__
     37#ifndef LIBC_NETIF_MESSAGES_H_
     38#define LIBC_NETIF_MESSAGES_H_
    3939
    4040#include <ipc/ipc.h>
     41#include <ipc/net.h>
    4142
    42 #include <net_messages.h>
    43 
    44 /** Network interface common module messages.
    45  */
     43/** Network interface common module messages. */
    4644typedef enum {
    4745        /** Probe device message.
    48          *  @see netif_probe_req()
     46         * @see netif_probe_req()
    4947         */
    5048        NET_NETIF_PROBE = NET_NETIF_FIRST,
    5149        /** Send packet message.
    52          *  @see netif_send_msg()
     50         * @see netif_send_msg()
    5351         */
    5452        NET_NETIF_SEND,
    5553        /** Start device message.
    56          *  @see netif_start_req()
     54         * @see netif_start_req()
    5755         */
    5856        NET_NETIF_START,
    5957        /** Get device usage statistics message.
    60          *  @see netif_stats_req()
     58         * @see netif_stats_req()
    6159         */
    6260        NET_NETIF_STATS,
    6361        /** Stop device message.
    64          *  @see netif_stop_req()
     62         * @see netif_stop_req()
    6563         */
    6664        NET_NETIF_STOP,
    6765        /** Get device address message.
    68          *  @see netif_get_addr_req()
     66         * @see netif_get_addr_req()
    6967         */
    7068        NET_NETIF_GET_ADDR,
    7169} netif_messages;
    7270
    73 /** @name Network interface specific message parameters definitions
    74  */
     71/** @name Network interface specific message parameters definitions */
    7572/*@{*/
    7673
     
    7976 */
    8077#define NETIF_GET_IRQ(call) \
    81         ({int irq = (int) IPC_GET_ARG2(*call); irq;})
     78        ({ \
     79                int irq = (int) IPC_GET_ARG2(*call); \
     80                irq; \
     81        })
    8282
    8383/** Return the input/output address message parameter.
     
    8585 */
    8686#define NETIF_GET_IO(call) \
    87         ({int io = (int) IPC_GET_ARG3(*call); io;})
     87        ({ \
     88                int io = (int) IPC_GET_ARG3(*call); \
     89                io; \
     90        })
    8891
    8992/*@}*/
  • uspace/lib/c/include/ipc/nil.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net_nil
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3535 */
    3636
    37 #ifndef __NET_NIL_MESSAGES_H__
    38 #define __NET_NIL_MESSAGES_H__
     37#ifndef LIBC_NIL_MESSAGES_H_
     38#define LIBC_NIL_MESSAGES_H_
    3939
    4040#include <ipc/ipc.h>
     41#include <ipc/net.h>
    4142
    42 #include <net_messages.h>
    43 
    44 /** Network interface layer module messages.
    45  */
     43/** Network interface layer module messages. */
    4644typedef enum {
    4745        /** New device or update MTU message.
    48          *  @see nil_device_req()
     46         * @see nil_device_req()
    4947         */
    5048        NET_NIL_DEVICE = NET_NIL_FIRST,
    5149        /** New device state message.
    52          *  @see nil_device_state_msg()
     50         * @see nil_device_state_msg()
    5351         */
    5452        NET_NIL_DEVICE_STATE,
    5553        /** Received packet queue message.
    56          *  @see nil_received_msg()
     54         * @see nil_received_msg()
    5755         */
    5856        NET_NIL_RECEIVED,
    5957        /** Send packet queue message.
    60          *  @see nil_send_msg()
     58         * @see nil_send_msg()
    6159         */
    6260        NET_NIL_SEND,
    6361        /** Packet size message.
    64          *  @see nil_packet_size_req()
     62         * @see nil_packet_size_req()
    6563         */
    6664        NET_NIL_PACKET_SPACE,
    6765        /** Device local hardware address message.
    68          *  @see nil_get_addr()
     66         * @see nil_get_addr()
    6967         */
    7068        NET_NIL_ADDR,
    7169        /** Device broadcast hardware address message.
    72          *  @see nil_get_broadcast_addr()
     70         * @see nil_get_broadcast_addr()
    7371         */
    7472        NET_NIL_BROADCAST_ADDR,
    7573} nil_messages;
    7674
    77 /** @name Network interface layer specific message parameters definitions
    78  */
     75/** @name Network interface layer specific message parameters definitions */
    7976/*@{*/
    8077
    81 /** Return the protocol service message parameter.
    82  */
     78/** Return the protocol service message parameter. */
    8379#define NIL_GET_PROTO(call) \
    84         ({services_t service = (services_t) IPC_GET_ARG2(*call); service;})
     80        ({ \
     81                services_t service = (services_t) IPC_GET_ARG2(*call); \
     82                service; \
     83        })
    8584
    8685/*@}*/
  • uspace/lib/c/include/ipc/packet.h

    r1882525 rf14291b  
    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>
     41#include <ipc/net.h>
    4142
    42 #include <net_messages.h>
    43 
    44 /** Packet server module messages.
    45  */
     43/** Packet server module messages. */
    4644typedef enum {
    4745        /** Create packet message with specified content length.
    48          *  @see packet_get_1()
     46         * @see packet_get_1()
    4947         */
    5048        NET_PACKET_CREATE_1 = NET_PACKET_FIRST,
    51         /** Create packet message with specified address length, prefix, content and suffix.
    52          *  @see packet_get_4()
     49       
     50        /**
     51         * Create packet message with specified address length, prefix, content
     52         * and suffix.
     53         * @see packet_get_4()
    5354         */
    5455        NET_PACKET_CREATE_4,
     56       
    5557        /** Get packet message.
    56          *  @see packet_return()
    57          */
     58         * @see packet_return() */
    5859        NET_PACKET_GET,
     60       
    5961        /** Get packet size message.
    60          *  @see packet_translate()
     62         * @see packet_translate()
    6163         */
    6264        NET_PACKET_GET_SIZE,
     65       
    6366        /** Release packet message.
    64          *  @see pq_release()
     67         * @see pq_release()
    6568         */
    6669        NET_PACKET_RELEASE
    6770} packet_messages;
    6871
    69 /** Returns the protocol service message parameter.
    70  */
    71 #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)
    7274
    73 /** Returns the packet identifier message parameter.
    74  */
    75 #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)
    7677
    77 /** Returns the maximal content length message parameter.
    78  */
    79 #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)
    8080
    81 /** Returns the maximal address length message parameter.
    82  */
     81/** Returns the maximal address length message parameter. */
    8382#define IPC_GET_ADDR_LEN(call)  (size_t) IPC_GET_ARG2(*call)
    8483
    85 /** Returns the maximal prefix length message parameter.
    86  */
    87 #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)
    8886
    89 /** Returns the maximal suffix length message parameter.
    90  */
    91 #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)
    9289
    9390#endif
  • uspace/lib/c/include/ipc/socket.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup socket
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Socket messages.
    35  *  @see socket.h
    36  */
    37 
    38 
    39 #ifndef __NET_SOCKET_MESSAGES_H__
    40 #define __NET_SOCKET_MESSAGES_H__
     34 * Socket messages.
     35 */
     36
     37#ifndef LIBC_SOCKET_MESSAGES_H_
     38#define LIBC_SOCKET_MESSAGES_H_
    4139
    4240#include <ipc/ipc.h>
    43 
    44 #include <net_messages.h>
    45 #include <socket_codes.h>
    46 
    47 /** Socket client messages.
    48  */
    49 typedef enum{
    50         /** Creates a new socket.
    51          *  @see socket()
    52          */
     41#include <ipc/net.h>
     42
     43/** Socket client messages. */
     44typedef enum {
     45        /** Creates a new socket. @see socket() */
    5346        NET_SOCKET = NET_SOCKET_FIRST,
    54         /** Binds the socket.
    55          *  @see bind()
    56          */
     47        /** Binds the socket. @see bind() */
    5748        NET_SOCKET_BIND,
    58         /** Creates a new socket.
    59          *  @see socket()
    60          */
     49        /** Creates a new socket. @see socket() */
    6150        NET_SOCKET_LISTEN,
    62         /** Accepts an incomming connection.
    63          *  @see accept()
    64          */
     51        /** Accepts an incomming connection. @see accept() */
    6552        NET_SOCKET_ACCEPT,
    66         /** Connects the socket.
    67          *  @see connect()
    68          */
     53        /** Connects the socket. @see connect() */
    6954        NET_SOCKET_CONNECT,
    70         /** Closes the socket.
    71          *  @see closesocket()
    72          */
     55        /** Closes the socket. @see closesocket() */
    7356        NET_SOCKET_CLOSE,
    74         /** Sends data via the stream socket.
    75          *  @see send()
    76          */
     57        /** Sends data via the stream socket. @see send() */
    7758        NET_SOCKET_SEND,
    78         /** Sends data via the datagram socket.
    79          *  @see sendto()
    80          */
     59        /** Sends data via the datagram socket. @see sendto() */
    8160        NET_SOCKET_SENDTO,
    82         /** Receives data from the stream socket.
    83          *  @see socket()
    84          */
     61        /** Receives data from the stream socket. @see socket() */
    8562        NET_SOCKET_RECV,
    86         /** Receives data from the datagram socket.
    87          *  @see socket()
    88          */
     63        /** Receives data from the datagram socket. @see socket() */
    8964        NET_SOCKET_RECVFROM,
    90         /** Gets the socket option.
    91          *  @see getsockopt()
    92          */
     65        /** Gets the socket option. @see getsockopt() */
    9366        NET_SOCKET_GETSOCKOPT,
    94         /** Sets the socket option.
    95          *  @see setsockopt()
    96          */
     67        /** Sets the socket option. @see setsockopt() */
    9768        NET_SOCKET_SETSOCKOPT,
    98         /** New socket for acceptence notification message.
    99          */
     69        /** New socket for acceptence notification message. */
    10070        NET_SOCKET_ACCEPTED,
    101         /** New data received notification message.
    102          */
     71        /** New data received notification message. */
    10372        NET_SOCKET_RECEIVED,
    104         /** New socket data fragment size notification message.
    105          */
     73        /** New socket data fragment size notification message. */
    10674        NET_SOCKET_DATA_FRAGMENT_SIZE
    10775} socket_messages;
     
    11280
    11381/** Sets the socket identifier in the message answer.
    114  *  @param[out] answer The message answer structure.
     82 * @param[out] answer   The message answer structure.
    11583 */
    11684#define SOCKET_SET_SOCKET_ID(answer, value) \
    117         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(answer, argument);}
     85        do { \
     86                ipcarg_t argument = (ipcarg_t) (value); \
     87                IPC_SET_ARG1(answer, argument); \
     88        } while (0)
    11889
    11990/** Returns the socket identifier message parameter.
    120  *  @param[in] call The message call structure.
     91 * @param[in] call      The message call structure.
    12192 */
    12293#define SOCKET_GET_SOCKET_ID(call) \
    123         ({int socket_id = (int) IPC_GET_ARG1(call); socket_id;})
     94        ({ \
     95                int socket_id = (int) IPC_GET_ARG1(call); \
     96                socket_id; \
     97        })
    12498
    12599/** Sets the read data length in the message answer.
    126  *  @param[out] answer The message answer structure.
     100 * @param[out] answer   The message answer structure.
    127101 */
    128102#define SOCKET_SET_READ_DATA_LENGTH(answer, value) \
    129         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(answer, argument);}
     103        do { \
     104                ipcarg_t argument = (ipcarg_t) (value); \
     105                IPC_SET_ARG1(answer, argument); \
     106        } while (0)
    130107
    131108/** Returns the read data length message parameter.
    132  *  @param[in] call The message call structure.
     109 * @param[in] call      The message call structure.
    133110 */
    134111#define SOCKET_GET_READ_DATA_LENGTH(call) \
    135         ({int data_length = (int) IPC_GET_ARG1(call); data_length;})
     112        ({ \
     113                int data_length = (int) IPC_GET_ARG1(call); \
     114                data_length; \
     115        })
    136116
    137117/** Returns the backlog message parameter.
    138  *  @param[in] call The message call structure.
     118 * @param[in] call      The message call structure.
    139119 */
    140120#define SOCKET_GET_BACKLOG(call) \
    141         ({int backlog = (int) IPC_GET_ARG2(call); backlog;})
     121        ({ \
     122                int backlog = (int) IPC_GET_ARG2(call); \
     123                backlog; \
     124        })
    142125
    143126/** Returns the option level message parameter.
    144  *  @param[in] call The message call structure.
     127 * @param[in] call      The message call structure.
    145128 */
    146129#define SOCKET_GET_OPT_LEVEL(call) \
    147         ({int opt_level = (int) IPC_GET_ARG2(call); opt_level;})
     130        ({ \
     131                int opt_level = (int) IPC_GET_ARG2(call); \
     132                opt_level; \
     133        })
    148134
    149135/** Returns the data fragment size message parameter.
    150  *  @param[in] call The message call structure.
     136 * @param[in] call      The message call structure.
    151137 */
    152138#define SOCKET_GET_DATA_FRAGMENT_SIZE(call) \
    153         ({size_t size = (size_t) IPC_GET_ARG2(call); size;})
     139        ({ \
     140                size_t size = (size_t) IPC_GET_ARG2(call); \
     141                size; \
     142        })
    154143
    155144/** Sets the data fragment size in the message answer.
    156  *  @param[out] answer The message answer structure.
     145 * @param[out] answer   The message answer structure.
    157146 */
    158147#define SOCKET_SET_DATA_FRAGMENT_SIZE(answer, value) \
    159         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG2(answer, argument);}
     148        do { \
     149                ipcarg_t argument = (ipcarg_t) (value); \
     150                IPC_SET_ARG2(answer, argument); \
     151        } while (0)
    160152
    161153/** Sets the address length in the message answer.
    162  *  @param[out] answer The message answer structure.
     154 * @param[out] answer   The message answer structure.
    163155 */
    164156#define SOCKET_SET_ADDRESS_LENGTH(answer, value) \
    165         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG3(answer, argument);}
     157        do { \
     158                ipcarg_t argument = (ipcarg_t) (value); \
     159                IPC_SET_ARG3(answer, argument);\
     160        } while (0)
    166161
    167162/** Returns the address length message parameter.
    168  *  @param[in] call The message call structure.
     163 * @param[in] call      The message call structure.
    169164 */
    170165#define SOCKET_GET_ADDRESS_LENGTH(call) \
    171         ({socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); address_length;})
     166        ({ \
     167                socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); \
     168                address_length; \
     169        })
    172170
    173171/** Sets the header size in the message answer.
    174  *  @param[out] answer The message answer structure.
     172 * @param[out] answer   The message answer structure.
    175173 */
    176174#define SOCKET_SET_HEADER_SIZE(answer, value) \
    177         \
    178         {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG3(answer, argument);}
     175        do { \
     176                ipcarg_t argument = (ipcarg_t) (value); \
     177                IPC_SET_ARG3(answer, argument); \
     178        } while (0)
    179179
    180180/** Returns the header size message parameter.
    181  *  @param[in] call The message call structure.
     181 *  @param[in] call     The message call structure.
    182182 */
    183183#define SOCKET_GET_HEADER_SIZE(call) \
    184         ({size_t size = (size_t) IPC_GET_ARG3(call); size;})
     184        ({ \
     185                size_t size = (size_t) IPC_GET_ARG3(call); \
     186                size; \
     187        })
    185188
    186189/** Returns the flags message parameter.
    187  *  @param[in] call The message call structure.
     190 *  @param[in] call     The message call structure.
    188191 */
    189192#define SOCKET_GET_FLAGS(call) \
    190         ({int flags = (int) IPC_GET_ARG4(call); flags;})
     193        ({ \
     194                int flags = (int) IPC_GET_ARG4(call); \
     195                flags; \
     196        })
    191197
    192198/** Returns the option name message parameter.
    193  *  @param[in] call The message call structure.
     199 *  @param[in] call     The message call structure.
    194200 */
    195201#define SOCKET_GET_OPT_NAME(call) \
    196         ({int opt_name = (int) IPC_GET_ARG4(call); opt_name;})
     202        ({ \
     203                int opt_name = (int) IPC_GET_ARG4(call); \
     204                opt_name; \
     205        })
    197206
    198207/** Returns the data fragments message parameter.
    199  *  @param[in] call The message call structure.
     208 *  @param[in] call     The message call structure.
    200209 */
    201210#define SOCKET_GET_DATA_FRAGMENTS(call) \
    202         ({int fragments = (int) IPC_GET_ARG5(call); fragments;})
     211        ({ \
     212                int fragments = (int) IPC_GET_ARG5(call); \
     213                fragments; \
     214        })
    203215
    204216/** Returns the new socket identifier message parameter.
    205  *  @param[in] call The message call structure.
     217 *  @param[in] call     The message call structure.
    206218 */
    207219#define SOCKET_GET_NEW_SOCKET_ID(call) \
    208         ({int socket_id = (int) IPC_GET_ARG5(call); socket_id;})
     220        ({ \
     221                int socket_id = (int) IPC_GET_ARG5(call); \
     222                socket_id; \
     223        })
    209224
    210225/*@}*/
  • uspace/lib/c/include/ipc/tl.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net_tl
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Transport layer modules messages.
    35  *  @see tl_interface.h
     34 * Transport layer modules messages.
     35 * @see tl_interface.h
    3636 */
    3737
    38 #ifndef __NET_TL_MESSAGES_H__
    39 #define __NET_TL_MESSAGES_H__
     38#ifndef LIBC_TL_MESSAGES_H_
     39#define LIBC_TL_MESSAGES_H_
    4040
    4141#include <ipc/ipc.h>
     42#include <ipc/net.h>
    4243
    43 #include <net_messages.h>
    44 
    45 /** Transport layer modules messages.
    46  */
    47 typedef enum{
     44/** Transport layer modules messages. */
     45typedef enum {
    4846        /** Packet received message.
    49          *  @see tl_received_msg()
     47         * @see tl_received_msg()
    5048         */
    5149        NET_TL_RECEIVED = NET_TL_FIRST
  • uspace/lib/c/include/net/device.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup netif
    30  *  @{
     29/** @addtogroup libc
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Device identifier, state and usage statistics.
     34 * Device identifier, state and usage statistics.
    3535 */
    3636
    37 #ifndef __NET_DEVICE_ID_TYPE_H__
    38 #define __NET_DEVICE_ID_TYPE_H__
     37#ifndef LIBC_DEVICE_ID_TYPE_H_
     38#define LIBC_DEVICE_ID_TYPE_H_
    3939
    4040#include <adt/int_map.h>
    4141
    42 /** Device identifier to generic type map declaration.
    43  */
    44 #define DEVICE_MAP_DECLARE              INT_MAP_DECLARE
     42/** Device identifier to generic type map declaration. */
     43#define DEVICE_MAP_DECLARE      INT_MAP_DECLARE
    4544
    46 /** Device identifier to generic type map implementation.
    47  */
     45/** Device identifier to generic type map implementation. */
    4846#define DEVICE_MAP_IMPLEMENT    INT_MAP_IMPLEMENT
    4947
    50 /** Invalid device identifier.
    51  */
    52 #define DEVICE_INVALID_ID               (-1)
     48/** Invalid device identifier. */
     49#define DEVICE_INVALID_ID       (-1)
    5350
    54 /** Device identifier type.
    55  */
    56 typedef int     device_id_t;
     51/** Device identifier type. */
     52typedef int device_id_t;
    5753
    58 /** Device state type.
    59  */
    60 typedef enum device_state       device_state_t;
     54/** Device state type. */
     55typedef enum device_state device_state_t;
    6156
    6257/** Type definition of the device usage statistics.
    63  *  @see device_stats
     58 * @see device_stats
    6459 */
    65 typedef struct device_stats     device_stats_t;
     60typedef struct device_stats device_stats_t;
    6661
    6762/** Type definition of the device usage statistics pointer.
    68  *  @see device_stats
     63 * @see device_stats
    6964 */
    70 typedef device_stats_t *        device_stats_ref;
     65typedef device_stats_t *device_stats_ref;
    7166
    72 /** Device state.
    73  */
    74 enum    device_state{
    75         /** Device not present or not initialized.
    76          */
     67/** Device state. */
     68enum device_state {
     69        /** Device not present or not initialized. */
    7770        NETIF_NULL = 0,
    78         /** Device present and stopped.
    79          */
     71        /** Device present and stopped. */
    8072        NETIF_STOPPED,
    81         /** Device present and active.
    82          */
     73        /** Device present and active. */
    8374        NETIF_ACTIVE,
    84         /** Device present but unable to transmit.
    85          */
     75        /** Device present but unable to transmit. */
    8676        NETIF_CARRIER_LOST
    8777};
    8878
    89 /** Device usage statistics.
    90  */
    91 struct  device_stats{
    92         /** Total packets received.
    93          */
     79/** Device usage statistics. */
     80struct device_stats {
     81        /** Total packets received. */
    9482        unsigned long receive_packets;
    95         /** Total packets transmitted.
    96          */
     83        /** Total packets transmitted. */
    9784        unsigned long send_packets;
    98         /** Total bytes received.
    99          */
     85        /** Total bytes received. */
    10086        unsigned long receive_bytes;
    101         /** Total bytes transmitted.
    102          */
     87        /** Total bytes transmitted. */
    10388        unsigned long send_bytes;
    104         /** Bad packets received counter.
    105          */
     89        /** Bad packets received counter. */
    10690        unsigned long receive_errors;
    107         /** Packet transmition problems counter.
    108          */
     91        /** Packet transmition problems counter. */
    10992        unsigned long send_errors;
    110         /** No space in buffers counter.
    111          */
     93        /** No space in buffers counter. */
    11294        unsigned long receive_dropped;
    113         /** No space available counter.
    114          */
     95        /** No space available counter. */
    11596        unsigned long send_dropped;
    116         /** Total multicast packets received.
    117          */
     97        /** Total multicast packets received. */
    11898        unsigned long multicast;
    119         /** The number of collisions due to congestion on the medium.
    120          */
     99        /** The number of collisions due to congestion on the medium. */
    121100        unsigned long collisions;
    122101
    123         /* detailed receive_errors: */
    124         /** Received packet length error counter.
    125         */
     102        /* detailed receive_errors */
     103
     104        /** Received packet length error counter. */
    126105        unsigned long receive_length_errors;
    127         /** Receiver buffer overflow counter.
    128          */
     106        /** Receiver buffer overflow counter. */
    129107        unsigned long receive_over_errors;
    130         /** Received packet with crc error counter.
    131          */
     108        /** Received packet with crc error counter. */
    132109        unsigned long receive_crc_errors;
    133         /** Received frame alignment error counter.
    134          */
     110        /** Received frame alignment error counter. */
    135111        unsigned long receive_frame_errors;
    136         /** Receiver fifo overrun counter.
    137          */
     112        /** Receiver fifo overrun counter. */
    138113        unsigned long receive_fifo_errors;
    139         /** Receiver missed packet counter.
    140          */
     114        /** Receiver missed packet counter. */
    141115        unsigned long receive_missed_errors;
    142116
    143117        /* detailed send_errors */
    144         /** Transmitter aborted counter.
    145         */
     118
     119        /** Transmitter aborted counter. */
    146120        unsigned long send_aborted_errors;
    147         /** Transmitter carrier errors counter.
    148          */
     121        /** Transmitter carrier errors counter. */
    149122        unsigned long send_carrier_errors;
    150         /** Transmitter fifo overrun counter.
    151          */
     123        /** Transmitter fifo overrun counter. */
    152124        unsigned long send_fifo_errors;
    153         /** Transmitter carrier errors counter.
    154          */
     125        /** Transmitter carrier errors counter. */
    155126        unsigned long send_heartbeat_errors;
    156         /** Transmitter window errors counter.
    157          */
     127        /** Transmitter window errors counter. */
    158128        unsigned long send_window_errors;
    159129
    160130        /* for cslip etc */
    161         /** Total compressed packets received.
    162         */
     131       
     132        /** Total compressed packets received. */
    163133        unsigned long receive_compressed;
    164         /** Total compressed packet transmitted.
    165          */
     134        /** Total compressed packet transmitted. */
    166135        unsigned long send_compressed;
    167136};
     
    171140/** @}
    172141 */
    173 
  • uspace/lib/c/include/net/icmp_codes.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup icmp
     29/** @addtogroup libc
    3030 *  @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP types and codes according to the on-line IANA - ICMP Type Numbers - <http://http://www.iana.org/assignments/icmp-parameters>, cited September 14 2009.
    35  */
    36 
    37 #ifndef __NET_ICMP_CODES_H__
    38 #define __NET_ICMP_CODES_H__
    39 
    40 /** ICMP type type definition.
    41  */
    42 typedef uint8_t icmp_type_t;
    43 
    44 /** ICMP code type definition.
    45  */
    46 typedef uint8_t icmp_code_t;
    47 
    48 /** ICMP parameter type definition.
    49  */
    50 typedef uint16_t        icmp_param_t;
    51 
    52 /** @name ICMP types definitions
    53  */
    54 /*@{*/
    55 
    56 /** Echo Reply.
    57  */
     34 * ICMP types and codes according to the on-line IANA - ICMP Type Numbers
     35 *
     36 * http://www.iana.org/assignments/icmp-parameters>
     37 *
     38 * cited September 14 2009.
     39 */
     40
     41#ifndef LIBC_ICMP_CODES_H_
     42#define LIBC_ICMP_CODES_H_
     43
     44/** ICMP type type definition. */
     45typedef uint8_t icmp_type_t;
     46
     47/** ICMP code type definition. */
     48typedef uint8_t icmp_code_t;
     49
     50/** ICMP parameter type definition. */
     51typedef uint16_t icmp_param_t;
     52
     53/** @name ICMP types definitions */
     54/*@{*/
     55
     56/** Echo Reply. */
    5857#define ICMP_ECHOREPLY          0
    5958
    60 /** Destination Unreachable.
    61  */
     59/** Destination Unreachable. */
    6260#define ICMP_DEST_UNREACH       3
    6361
    64 /** Source Quench.
    65  */
     62/** Source Quench. */
    6663#define ICMP_SOURCE_QUENCH      4
    6764
    68 /** Redirect.
    69  */
     65/** Redirect. */
    7066#define ICMP_REDIRECT           5
    7167
    72 /** Alternate Host Address.
    73  */
     68/** Alternate Host Address. */
    7469#define ICMP_ALTERNATE_ADDR     6
    7570
    76 /** Echo Request.
    77  */
    78 #define ICMP_ECHO                       8
    79 
    80 /** Router Advertisement.
    81  */
     71/** Echo Request. */
     72#define ICMP_ECHO               8
     73
     74/** Router Advertisement. */
    8275#define ICMP_ROUTER_ADV         9
    8376
    84 /** Router solicitation.
    85  */
     77/** Router solicitation. */
    8678#define ICMP_ROUTER_SOL         10
    8779
    88 /** Time Exceeded.
    89  */
     80/** Time Exceeded. */
    9081#define ICMP_TIME_EXCEEDED      11
    9182
    92 /** Parameter Problem.
    93  */
     83/** Parameter Problem. */
    9484#define ICMP_PARAMETERPROB      12
    9585
    96 /** Timestamp Request.
    97  */
     86/** Timestamp Request. */
    9887#define ICMP_TIMESTAMP          13
    9988
    100 /** Timestamp Reply.
    101  */
     89/** Timestamp Reply. */
    10290#define ICMP_TIMESTAMPREPLY     14
    10391
    104 /** Information Request.
    105  */
     92/** Information Request. */
    10693#define ICMP_INFO_REQUEST       15
    10794
    108 /** Information Reply.
    109  */
     95/** Information Reply. */
    11096#define ICMP_INFO_REPLY         16
    11197
    112 /** Address Mask Request.
    113  */
     98/** Address Mask Request. */
    11499#define ICMP_ADDRESS            17
    115100
    116 /** Address Mask Reply.
    117  */
     101/** Address Mask Reply. */
    118102#define ICMP_ADDRESSREPLY       18
    119103
    120 /** Traceroute.
    121  */
     104/** Traceroute. */
    122105#define ICMP_TRACEROUTE         30
    123106
    124 /** Datagram Conversion Error.
    125  */
     107/** Datagram Conversion Error. */
    126108#define ICMP_CONVERSION_ERROR   31
    127109
    128 /** Mobile Host Redirect.
    129  */
     110/** Mobile Host Redirect. */
    130111#define ICMP_REDIRECT_MOBILE    32
    131112
    132 /** IPv6 Where-Are-You.
    133  */
     113/** IPv6 Where-Are-You. */
    134114#define ICMP_IPV6_WHERE_ARE_YOU 33
    135115
    136 /** IPv6 I-Am-Here.
    137  */
     116/** IPv6 I-Am-Here. */
    138117#define ICMP_IPV6_I_AM_HERE     34
    139118
    140 /** Mobile Registration Request.
    141  */
     119/** Mobile Registration Request. */
    142120#define ICMP_MOBILE_REQUEST     35
    143121
    144 /** Mobile Registration Reply.
    145  */
     122/** Mobile Registration Reply. */
    146123#define ICMP_MOBILE_REPLY       36
    147124
    148 /** Domain name request.
    149  */
     125/** Domain name request. */
    150126#define ICMP_DN_REQUEST         37
    151127
    152 /** Domain name reply.
    153  */
     128/** Domain name reply. */
    154129#define ICMP_DN_REPLY           38
    155130
    156 /** SKIP.
    157  */
    158 #define ICMP_SKIP                       39
    159 
    160 /** Photuris.
    161  */
     131/** SKIP. */
     132#define ICMP_SKIP               39
     133
     134/** Photuris. */
    162135#define ICMP_PHOTURIS           40
    163136
     
    168141/*@{*/
    169142
    170 /** Network Unreachable.
    171  */
     143/** Network Unreachable. */
    172144#define ICMP_NET_UNREACH        0
    173145
    174 /** Host Unreachable.
    175  */
     146/** Host Unreachable. */
    176147#define ICMP_HOST_UNREACH       1
    177148
    178 /** Protocol Unreachable.
    179  */
     149/** Protocol Unreachable. */
    180150#define ICMP_PROT_UNREACH       2
    181151
    182 /** Port Unreachable.
    183  */
     152/** Port Unreachable. */
    184153#define ICMP_PORT_UNREACH       3
    185154
    186 /** Fragmentation needed but the Do Not Fragment bit was set.
    187  */
     155/** Fragmentation needed but the Do Not Fragment bit was set. */
    188156#define ICMP_FRAG_NEEDED        4
    189157
    190 /** Source Route failed.
    191  */
     158/** Source Route failed. */
    192159#define ICMP_SR_FAILED          5
    193160
    194 /** Destination network unknown.
    195  */
     161/** Destination network unknown. */
    196162#define ICMP_NET_UNKNOWN        6
    197163
    198 /** Destination host unknown.
    199  */
     164/** Destination host unknown. */
    200165#define ICMP_HOST_UNKNOWN       7
    201166
    202 /** Source host isolated (obsolete).
    203  */
     167/** Source host isolated (obsolete). */
    204168#define ICMP_HOST_ISOLATED      8
    205169
    206 /** Destination network administratively prohibited.
    207  */
     170/** Destination network administratively prohibited. */
    208171#define ICMP_NET_ANO            9
    209172
    210 /** Destination host administratively prohibited.
    211  */
     173/** Destination host administratively prohibited. */
    212174#define ICMP_HOST_ANO           10
    213175
    214 /** Network unreachable for this type of service.
    215  */
     176/** Network unreachable for this type of service. */
    216177#define ICMP_NET_UNR_TOS        11
    217178
    218 /** Host unreachable for this type of service.
    219  */
     179/** Host unreachable for this type of service. */
    220180#define ICMP_HOST_UNR_TOS       12
    221181
    222 /** Communication administratively prohibited by filtering.
    223  */
     182/** Communication administratively prohibited by filtering. */
    224183#define ICMP_PKT_FILTERED       13
    225184
    226 /** Host precedence violation.
    227  */
     185/** Host precedence violation. */
    228186#define ICMP_PREC_VIOLATION     14
    229187
    230 /** Precedence cutoff in effect.
    231  */
     188/** Precedence cutoff in effect. */
    232189#define ICMP_PREC_CUTOFF        15
    233190
    234191/*@}*/
    235192
    236 /** @name ICMP_REDIRECT codes definitions
    237  */
    238 /*@{*/
    239 
    240 /** Network redirect (or subnet).
    241  */
     193/** @name ICMP_REDIRECT codes definitions */
     194/*@{*/
     195
     196/** Network redirect (or subnet). */
    242197#define ICMP_REDIR_NET          0
    243198
    244 /** Host redirect.
    245  */
     199/** Host redirect. */
    246200#define ICMP_REDIR_HOST         1
    247201
    248 /** Network redirect for this type of service.
    249  */
     202/** Network redirect for this type of service. */
    250203#define ICMP_REDIR_NETTOS       2
    251204
    252 /** Host redirect for this type of service.
    253  */
     205/** Host redirect for this type of service. */
    254206#define ICMP_REDIR_HOSTTOS      3
    255207
    256208/*@}*/
    257209
    258 /** @name ICMP_ALTERNATE_ADDRESS codes definitions
    259  */
    260 /*@{*/
    261 
    262 /** Alternate address for host.
    263  */
     210/** @name ICMP_ALTERNATE_ADDRESS codes definitions */
     211/*@{*/
     212
     213/** Alternate address for host. */
    264214#define ICMP_ALTERNATE_HOST     0
    265215
    266216/*@}*/
    267217
    268 /** @name ICMP_ROUTER_ADV codes definitions
    269  */
    270 /*@{*/
    271 
    272 /** Normal router advertisement.
    273  */
     218/** @name ICMP_ROUTER_ADV codes definitions */
     219/*@{*/
     220
     221/** Normal router advertisement. */
    274222#define ICMP_ROUTER_NORMAL      0
    275223
    276 /** Does not route common traffic.
    277  */
     224/** Does not route common traffic. */
    278225#define ICMP_ROUTER_NO_NORMAL_TRAFFIC   16
    279226
    280227/*@}*/
    281228
    282 /** @name ICMP_TIME_EXCEEDED codes definitions
    283  */
    284 /*@{*/
    285 
    286 /** Transit TTL exceeded.
    287  */
     229/** @name ICMP_TIME_EXCEEDED codes definitions */
     230/*@{*/
     231
     232/** Transit TTL exceeded. */
    288233#define ICMP_EXC_TTL            0
    289234
    290 /** Reassembly TTL exceeded.
    291  */
     235/** Reassembly TTL exceeded. */
    292236#define ICMP_EXC_FRAGTIME       1
    293237
    294238/*@}*/
    295239
    296 /** @name ICMP_PARAMETERPROB codes definitions
    297  */
    298 /*@{*/
    299 
    300 /** Pointer indicates the error.
    301  */
     240/** @name ICMP_PARAMETERPROB codes definitions */
     241/*@{*/
     242
     243/** Pointer indicates the error. */
    302244#define ICMP_PARAM_POINTER      0
    303245
    304 /** Missing required option.
    305  */
     246/** Missing required option. */
    306247#define ICMP_PARAM_MISSING      1
    307248
    308 /** Bad length.
    309  */
     249/** Bad length. */
    310250#define ICMP_PARAM_LENGTH       2
    311251
    312252/*@}*/
    313253
    314 /** @name ICMP_PHOTURIS codes definitions
    315  */
    316 /*@{*/
    317 
    318 /** Bad SPI.
    319  */
    320 #define ICMP_PHOTURIS_BAD_SPI   0
    321 
    322 /** Authentication failed.
    323  */
    324 #define ICMP_PHOTURIS_AUTHENTICATION    1
    325 
    326 /** Decompression failed.
    327  */
     254/** @name ICMP_PHOTURIS codes definitions */
     255/*@{*/
     256
     257/** Bad SPI. */
     258#define ICMP_PHOTURIS_BAD_SPI                   0
     259
     260/** Authentication failed. */
     261#define ICMP_PHOTURIS_AUTHENTICATION            1
     262
     263/** Decompression failed. */
    328264#define ICMP_PHOTURIS_DECOMPRESSION             2
    329265
    330 /** Decryption failed.
    331  */
    332 #define ICMP_PHOTURIS_DECRYPTION        3
    333 
    334 /** Need authentication.
    335  */
     266/** Decryption failed. */
     267#define ICMP_PHOTURIS_DECRYPTION                3
     268
     269/** Need authentication. */
    336270#define ICMP_PHOTURIS_NEED_AUTHENTICATION       4
    337271
    338 /** Need authorization.
    339  */
     272/** Need authorization. */
    340273#define ICMP_PHOTURIS_NEED_AUTHORIZATION        5
    341274
  • uspace/lib/c/include/net/icmp_common.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup icmp
     29/** @addtogroup libc
    3030 *  @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP module common interface.
     34 * ICMP module common interface.
    3535 */
    3636
    37 #ifndef __NET_ICMP_COMMON_H__
    38 #define __NET_ICMP_COMMON_H__
     37#ifndef LIBC_ICMP_COMMON_H_
     38#define LIBC_ICMP_COMMON_H_
    3939
    4040#include <ipc/services.h>
    41 
    4241#include <sys/time.h>
    4342
    44 /** Default timeout for incoming connections in microseconds.
    45  */
     43/** Default timeout for incoming connections in microseconds. */
    4644#define ICMP_CONNECT_TIMEOUT    (1 * 1000 * 1000)
    4745
    48 /** Connects to the ICMP module.
    49  *  @param service The ICMP module service. Ignored parameter.
    50  *  @param[in] timeout The connection timeout in microseconds. No timeout if set to zero (0).
    51  *  @returns The ICMP module phone on success.
    52  *  @returns The ICMP socket identifier if called by the bundle module.
    53  *  @returns ETIMEOUT if the connection timeouted.
    54  */
    55 extern int icmp_connect_module(services_t service, suseconds_t timeout);
     46extern int icmp_connect_module(services_t, suseconds_t);
    5647
    5748#endif
  • uspace/lib/c/include/net/in.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
     29/** @addtogroup libc
    3030 *  @{
    3131 */
     
    3535 */
    3636
    37 #ifndef __NET_IN_H__
    38 #define __NET_IN_H__
     37#ifndef LIBC_IN_H_
     38#define LIBC_IN_H_
    3939
     40#include <net/inet.h>
     41#include <net/ip_protocols.h>
    4042#include <sys/types.h>
    4143
    42 #include <ip_protocols.h>
    43 #include <inet.h>
    44 
    45 /** INET string address maximum length.
    46  */
     44/** INET string address maximum length. */
    4745#define INET_ADDRSTRLEN         (4 * 3 + 3 + 1)
    4846
    4947/** Type definition of the INET address.
    50  *  @see in_addr
     48 * @see in_addr
    5149 */
    5250typedef struct in_addr          in_addr_t;
    5351
    5452/** Type definition of the INET socket address.
    55  *  @see sockaddr_in
     53 * @see sockaddr_in
    5654 */
    5755typedef struct sockaddr_in      sockaddr_in_t;
    5856
    59 /** INET address.
    60  */
    61 struct in_addr{
    62         /** 4 byte IP address.
    63          */
     57/** INET address. */
     58struct in_addr {
     59        /** 4 byte IP address. */
    6460        uint32_t s_addr;
    6561};
    6662
    6763/** INET socket address.
    68  *  @see sockaddr
     64 * @see sockaddr
    6965 */
    70 struct sockaddr_in{
    71         /** Address family.
    72          *  Should be AF_INET.
    73          */
     66struct sockaddr_in {
     67        /** Address family. Should be AF_INET. */
    7468        uint16_t sin_family;
    75         /** Port number.
    76          */
     69        /** Port number. */
    7770        uint16_t sin_port;
    78         /** Internet address.
    79          */
     71        /** Internet address. */
    8072        struct in_addr sin_addr;
    81         /** Padding to meet the sockaddr size.
    82          */
     73        /** Padding to meet the sockaddr size. */
    8374        uint8_t sin_zero[8];
    8475};
  • uspace/lib/c/include/net/in6.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
     29/** @addtogroup libc
    3030 *  @{
    3131 */
     
    3535 */
    3636
    37 #ifndef __NET_IN6_H__
    38 #define __NET_IN6_H__
     37#ifndef LIBC_IN6_H_
     38#define LIBC_IN6_H_
    3939
     40#include <net/inet.h>
     41#include <net/ip_protocols.h>
    4042#include <sys/types.h>
    4143
    42 #include <ip_protocols.h>
    43 #include <inet.h>
    44 
    45 /** INET6 string address maximum length.
    46  */
     44/** INET6 string address maximum length. */
    4745#define INET6_ADDRSTRLEN        (8 * 4 + 7 + 1)
    4846
    4947/** Type definition of the INET6 address.
    50  *  @see in6_addr
     48 * @see in6_addr
    5149 */
    5250typedef struct in6_addr in6_addr_t;
    5351
    5452/** Type definition of the INET6 socket address.
    55  *  @see sockaddr_in6
     53 * @see sockaddr_in6
    5654 */
    5755typedef struct sockaddr_in6     sockaddr_in6_t;
    5856
    59 /** INET6 address.
    60  */
    61 struct in6_addr{
    62         /** 16 byte IPv6 address.
    63          */
     57/** INET6 address. */
     58struct in6_addr {
     59        /** 16 byte IPv6 address. */
    6460        unsigned char s6_addr[16];
    6561};
    6662
    6763/** INET6 socket address.
    68  *  @see sockaddr
     64 * @see sockaddr
    6965 */
    70 struct sockaddr_in6{
    71         /** Address family.
    72          *  Should be AF_INET6.
    73          */
     66struct sockaddr_in6 {
     67        /** Address family. Should be AF_INET6. */
    7468        uint16_t sin6_family;
    75         /** Port number.
    76          */
     69        /** Port number. */
    7770        uint16_t sin6_port;
    78         /** IPv6 flow information.
    79          */
     71        /** IPv6 flow information. */
    8072        uint32_t sin6_flowinfo;
    81         /** IPv6 address.
    82          */
     73        /** IPv6 address. */
    8374        struct in6_addr sin6_addr;
    84         /** Scope identifier.
    85          */
     75        /** Scope identifier. */
    8676        uint32_t sin6_scope_id;
    8777};
  • uspace/lib/c/include/net/packet_header.h

    r1882525 rf14291b  
    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/c/include/stdio.h

    r1882525 rf14291b  
    171171extern off64_t ftell(FILE *);
    172172extern int feof(FILE *);
     173extern int fileno(FILE *);
    173174
    174175extern int fflush(FILE *);
  • uspace/lib/c/include/sys/time.h

    r1882525 rf14291b  
    4343typedef long suseconds_t;
    4444
     45typedef uint32_t useconds_t;
     46typedef uint32_t mseconds_t;
     47
    4548struct timeval {
    4649        time_t tv_sec;        /* seconds */
  • uspace/lib/c/include/unistd.h

    r1882525 rf14291b  
    3737
    3838#include <sys/types.h>
     39#include <time.h>
    3940#include <libarch/config.h>
    4041
     
    5657        #define SEEK_END  2
    5758#endif
    58 
    59 typedef uint32_t useconds_t;
    6059
    6160extern int dup2(int oldfd, int newfd);
  • uspace/lib/net/Makefile

    r1882525 rf14291b  
    2929
    3030USPACE_PREFIX = ../..
    31 EXTRA_CFLAGS = -Iinclude -I$(LIBSOCKET_PREFIX)/include
     31EXTRA_CFLAGS = -Iinclude
    3232LIBRARY = libnet
    3333
    3434SOURCES = \
     35        generic/generic.c \
    3536        generic/net_remote.c \
    3637        generic/net_checksum.c \
     38        generic/packet_client.c \
    3739        generic/packet_remote.c \
     40        generic/socket_core.c \
    3841        adt/module_map.c \
    3942        netif/netif_local.c \
    4043        netif/netif_remote.c \
    41         netif/netif_nil_bundle.c \
    4244        nil/nil_remote.c \
    4345        il/ip_remote.c \
  • uspace/lib/net/adt/module_map.c

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Character string to module map implementation.
     34 * Character string to module map implementation.
    3535 */
    3636
     
    3838#include <task.h>
    3939#include <unistd.h>
     40#include <err.h>
    4041
    4142#include <ipc/services.h>
    4243
    43 #include <net_err.h>
    44 #include <net_modules.h>
     44#include <net/modules.h>
    4545
    4646#include <adt/generic_char_map.h>
     
    4949GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t)
    5050
    51 int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t connect_module){
     51/** Adds module to the module map.
     52 *
     53 * @param[out] module   The module structure added.
     54 * @param[in] modules   The module map.
     55 * @param[in] name      The module name.
     56 * @param[in] filename  The full path filename.
     57 * @param[in] service   The module service.
     58 * @param[in] task_id   The module current task identifier. Zero means not
     59 *                      running.
     60 * @param[in] connect_module The module connecting function.
     61 * @returns             EOK on success.
     62 * @returns             ENOMEM if there is not enough memory left.
     63 */
     64int
     65add_module(module_ref *module, modules_ref modules, const char *name,
     66    const char *filename, services_t service, task_id_t task_id,
     67    connect_module_t connect_module)
     68{
    5269        ERROR_DECLARE;
    5370
     
    5572
    5673        tmp_module = (module_ref) malloc(sizeof(module_t));
    57         if(! tmp_module){
     74        if (!tmp_module)
    5875                return ENOMEM;
    59         }
     76
    6077        tmp_module->task_id = task_id;
    6178        tmp_module->phone = 0;
     
    6582        tmp_module->service = service;
    6683        tmp_module->connect_module = connect_module;
    67         if(ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0, tmp_module))){
     84
     85        if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0,
     86            tmp_module))) {
    6887                free(tmp_module);
    6988                return ERROR_CODE;
    7089        }
    71         if(module){
     90        if (module)
    7291                *module = tmp_module;
    73         }
     92
    7493        return EOK;
    7594}
    7695
    77 module_ref get_running_module(modules_ref modules, char * name){
     96/** Searches and returns the specified module.
     97 *
     98 * If the module is not running, the module filaname is spawned.
     99 * If the module is not connected, the connect_function is called.
     100 *
     101 * @param[in] modules   The module map.
     102 * @param[in] name      The module name.
     103 * @returns             The running module found. It does not have to be
     104 *                      connected.
     105 * @returns             NULL if there is no such module.
     106 */
     107module_ref get_running_module(modules_ref modules, char *name)
     108{
    78109        module_ref module;
    79110
    80111        module = modules_find(modules, name, 0);
    81         if(! module){
     112        if (!module)
    82113                return NULL;
     114
     115        if (!module->task_id) {
     116                module->task_id = spawn(module->filename);
     117                if (!module->task_id)
     118                        return NULL;
    83119        }
    84         if(! module->task_id){
    85                 module->task_id = spawn(module->filename);
    86                 if(! module->task_id){
    87                         return NULL;
    88                 }
    89         }
    90         if(! module->phone){
     120        if (!module->phone)
    91121                module->phone = module->connect_module(module->service);
    92         }
     122
    93123        return module;
    94124}
    95125
     126/** Starts the given module.
     127 *
     128 * @param[in] fname     The module full or relative path filename.
     129 * @returns             The new module task identifier on success.
     130 * @returns             Zero if there is no such module.
     131 */
    96132task_id_t spawn(const char *fname)
    97133{
  • uspace/lib/net/generic/net_checksum.c

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  General CRC and checksum computation implementation.
     34 * General CRC and checksum computation implementation.
    3535 */
    3636
     
    3939#include <net_checksum.h>
    4040
    41 /** Big-endian encoding CRC divider.
    42  */
    43 #define CRC_DIVIDER_BE  0x04C11DB7
    44 
    45 /** Little-endian encoding CRC divider.
    46  */
    47 #define CRC_DIVIDER_LE  0xEDB88320
    48 
    49 uint16_t compact_checksum(uint32_t sum){
     41/** Big-endian encoding CRC divider. */
     42#define CRC_DIVIDER_BE  0x04c11db7
     43
     44/** Little-endian encoding CRC divider. */
     45#define CRC_DIVIDER_LE  0xedb88320
     46
     47/** Compacts the computed checksum to the 16 bit number adding the carries.
     48 *
     49 * @param[in] sum       Computed checksum.
     50 * @returns             Compacted computed checksum to the 16 bits.
     51 */
     52uint16_t compact_checksum(uint32_t sum)
     53{
    5054        // shorten to the 16 bits
    51         while(sum >> 16){
    52                 sum = (sum &0xFFFF) + (sum >> 16);
    53         }
     55        while (sum >> 16)
     56                sum = (sum & 0xffff) + (sum >> 16);
    5457
    5558        return (uint16_t) sum;
    5659}
    5760
    58 uint32_t compute_checksum(uint32_t seed, uint8_t * data, size_t length){
     61/** Computes sum of the 2 byte fields.
     62 *
     63 * Padds one zero (0) byte if odd.
     64 *
     65 * @param[in] seed      Initial value. Often used as 0 or ~0.
     66 * @param[in] data      Pointer to the beginning of data to process.
     67 * @param[in] length    Length of the data in bytes.
     68 * @returns             The computed checksum of the length bytes of the data.
     69 */
     70uint32_t compute_checksum(uint32_t seed, uint8_t *data, size_t length)
     71{
    5972        size_t index;
    6073
    6174        // sum all the 16 bit fields
    62         for(index = 0; index + 1 < length; index += 2){
     75        for (index = 0; index + 1 < length; index += 2)
    6376                seed += (data[index] << 8) + data[index + 1];
    64         }
    6577
    6678        // last odd byte with zero padding
    67         if(index + 1 == length){
     79        if (index + 1 == length)
    6880                seed += data[index] << 8;
    69         }
    7081
    7182        return seed;
    7283}
    7384
    74 uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length){
     85/** Computes CRC32 value in the big-endian environment.
     86 *
     87 * @param[in] seed      Initial value. Often used as 0 or ~0.
     88 * @param[in] data      Pointer to the beginning of data to process.
     89 * @param[in] length    Length of the data in bits.
     90 * @returns             The computed CRC32 of the length bits of the data.
     91 */
     92uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length)
     93{
    7594        size_t index;
    7695
    7796        // process full bytes
    78         while(length >= 8){
     97        while (length >= 8) {
    7998                // add the data
    8099                seed ^= (*data) << 24;
     100               
    81101                // for each added bit
    82                 for(index = 0; index < 8; ++ index){
     102                for (index = 0; index < 8; ++index) {
    83103                        // if the first bit is set
    84                         if(seed &0x80000000){
     104                        if (seed & 0x80000000) {
    85105                                // shift and divide the checksum
    86106                                seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
    87                         }else{
     107                        } else {
    88108                                // shift otherwise
    89109                                seed <<= 1;
    90110                        }
    91111                }
     112               
    92113                // move to the next byte
    93                 ++ data;
     114                ++data;
    94115                length -= 8;
    95116        }
    96117
    97118        // process the odd bits
    98         if(length > 0){
     119        if (length > 0) {
    99120                // add the data with zero padding
    100                 seed ^= ((*data) &(0xFF << (8 - length))) << 24;
     121                seed ^= ((*data) & (0xff << (8 - length))) << 24;
     122               
    101123                // for each added bit
    102                 for(index = 0; index < length; ++ index){
     124                for (index = 0; index < length; ++index) {
    103125                        // if the first bit is set
    104                         if(seed &0x80000000){
     126                        if (seed & 0x80000000) {
    105127                                // shift and divide the checksum
    106128                                seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
    107                         }else{
     129                        } else {
    108130                                // shift otherwise
    109131                                seed <<= 1;
     
    115137}
    116138
    117 uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length){
     139/** Computes CRC32 value in the little-endian environment.
     140 *
     141 * @param[in] seed      Initial value. Often used as 0 or ~0.
     142 * @param[in] data      Pointer to the beginning of data to process.
     143 * @param[in] length    Length of the data in bits.
     144 * @returns             The computed CRC32 of the length bits of the data.
     145 */
     146uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length)
     147{
    118148        size_t index;
    119149
    120150        // process full bytes
    121         while(length >= 8){
     151        while (length >= 8) {
    122152                // add the data
    123153                seed ^= (*data);
     154               
    124155                // for each added bit
    125                 for(index = 0; index < 8; ++ index){
     156                for (index = 0; index < 8; ++index) {
    126157                        // if the last bit is set
    127                         if(seed &1){
     158                        if (seed & 1) {
    128159                                // shift and divide the checksum
    129160                                seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
    130                         }else{
     161                        } else {
    131162                                // shift otherwise
    132163                                seed >>= 1;
    133164                        }
    134165                }
     166               
    135167                // move to the next byte
    136                 ++ data;
     168                ++data;
    137169                length -= 8;
    138170        }
    139171
    140172        // process the odd bits
    141         if(length > 0){
     173        if (length > 0) {
    142174                // add the data with zero padding
    143175                seed ^= (*data) >> (8 - length);
    144                 for(index = 0; index < length; ++ index){
     176               
     177                for (index = 0; index < length; ++index) {
    145178                        // if the last bit is set
    146                         if(seed &1){
     179                        if (seed & 1) {
    147180                                // shift and divide the checksum
    148181                                seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
    149                         }else{
     182                        } else {
    150183                                // shift otherwise
    151184                                seed >>= 1;
     
    157190}
    158191
    159 uint16_t flip_checksum(uint16_t checksum){
     192/** Returns or flips the checksum if zero.
     193 *
     194 * @param[in] checksum  The computed checksum.
     195 * @returns             The internet protocol header checksum.
     196 * @returns             0xFFFF if the computed checksum is zero.
     197 */
     198uint16_t flip_checksum(uint16_t checksum)
     199{
    160200        // flip, zero is returned as 0xFFFF (not flipped)
    161         checksum = ~ checksum;
     201        checksum = ~checksum;
    162202        return checksum ? checksum : IP_CHECKSUM_ZERO;
    163203}
    164204
    165 uint16_t ip_checksum(uint8_t * data, size_t length){
     205/** Computes the ip header checksum.
     206 *
     207 * To compute the checksum of a new packet, the checksum header field must be
     208 * zero. To check the checksum of a received packet, the checksum may be left
     209 * set. Zero will be returned in this case if valid.
     210 *
     211 * @param[in] data      The header data.
     212 * @param[in] length    The header length in bytes.
     213 * @returns             The internet protocol header checksum.
     214 * @returns             0xFFFF if the computed checksum is zero.
     215 */
     216uint16_t ip_checksum(uint8_t *data, size_t length)
     217{
    166218        // compute, compact and flip the data checksum
    167         return flip_checksum(compact_checksum(compute_checksum(0, data, length)));
     219        return flip_checksum(compact_checksum(compute_checksum(0, data,
     220            length)));
    168221}
    169222
  • uspace/lib/net/generic/net_remote.c

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Networking interface implementation for remote modules.
    35  *  @see net_interface.h
     34 * Networking interface implementation for remote modules.
     35 * @see net_interface.h
    3636 */
    3737
    3838#include <ipc/services.h>
     39#include <ipc/net_net.h>
    3940
    4041#include <malloc.h>
    4142
    42 #include <net_messages.h>
    43 #include <net_modules.h>
    44 #include <net_device.h>
     43#include <generic.h>
     44#include <net/modules.h>
     45#include <net/device.h>
    4546#include <net_interface.h>
    4647#include <adt/measured_strings.h>
    47 #include <net_net_messages.h>
    4848
    49 int net_connect_module(services_t service){
     49/** Connects to the networking module.
     50 *
     51 * @returns             The networking module phone on success.
     52 */
     53int net_connect_module(void)
     54{
    5055        return connect_to_service(SERVICE_NETWORKING);
    5156}
    5257
    53 void net_free_settings(measured_string_ref settings, char * data){
    54         if(settings){
     58/** Frees the received settings.
     59 *
     60 * @param[in] settings  The received settings.
     61 * @param[in] data      The received settings data.
     62 * @see net_get_device_conf_req()
     63 * @see net_get_conf_req()
     64 */
     65void net_free_settings(measured_string_ref settings, char *data)
     66{
     67        if (settings)
    5568                free(settings);
    56         }
    57         if(data){
     69        if (data)
    5870                free(data);
    59         }
    6071}
    6172
    62 int net_get_conf_req(int net_phone, measured_string_ref * configuration, size_t count, char ** data){
    63         return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, * configuration, count, configuration, data);
     73/** Returns the global configuration.
     74 *
     75 * The configuration names are read and the appropriate settings are set
     76 * instead. Call net_free_settings() function to release the returned
     77 * configuration.
     78 *
     79 * @param[in] net_phone The networking module phone.
     80 * @param[in,out] configuration The requested configuration. The names are read
     81 * and the appropriate settings are set instead.
     82 *
     83 * @param[in] count     The configuration entries count.
     84 * @param[in,out] data  The configuration and settings data.
     85 * @returns             EOK on success.
     86 * @returns             EINVAL if the configuration is NULL.
     87 * @returns             EINVAL if the count is zero.
     88 * @returns             Other error codes as defined for the
     89 *                      generic_translate_req() function.
     90 */
     91int
     92net_get_conf_req(int net_phone, measured_string_ref *configuration,
     93    size_t count, char **data)
     94{
     95        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,
     96            *configuration, count, configuration, data);
    6497}
    6598
    66 int net_get_device_conf_req(int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data){
    67         return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, device_id, 0, * configuration, count, configuration, data);
     99/** Returns the device specific configuration.
     100 *
     101 * Returns the global configuration if the device specific is not found.
     102 * The configuration names are read and the appropriate settings are set
     103 * instead. Call net_free_settings() function to release the returned
     104 * configuration.
     105 *
     106 * @param[in] net_phone The networking module phone.
     107 * @param[in] device_id The device identifier.
     108 * @param[in,out] configuration The requested device configuration. The names
     109 *                      are read and the appropriate settings are set instead.
     110 * @param[in] count     The configuration entries count.
     111 * @param[in,out] data  The configuration and settings data.
     112 * @returns             EOK on success.
     113 * @returns             EINVAL if the configuration is NULL.
     114 * @returns             EINVAL if the count is zero.
     115 * @returns             Other error codes as defined for the
     116 *                      generic_translate_req() function.
     117 */
     118int
     119net_get_device_conf_req(int net_phone, device_id_t device_id,
     120    measured_string_ref *configuration, size_t count, char **data)
     121{
     122        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
     123            device_id, 0, *configuration, count, configuration, data);
    68124}
    69125
  • uspace/lib/net/generic/packet_remote.c

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup packet
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Packet client interface implementation for remote modules.
    35  *  @see packet_client.h
     34 * Packet client interface implementation for remote modules.
     35 * @see packet_client.h
    3636 */
    3737
    3838#include <async.h>
    3939#include <errno.h>
     40#include <err.h>
    4041#include <ipc/ipc.h>
     42#include <ipc/packet.h>
    4143#include <sys/mman.h>
    4244
    43 #include <net_err.h>
    44 #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>
     45#include <packet_client.h>
    4946#include <packet_remote.h>
     47
     48#include <net/packet.h>
     49#include <net/packet_header.h>
    5050
    5151/** Obtain the packet from the packet server as the shared memory block.
     
    6464 *
    6565 */
    66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
     66static int
     67packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size)
     68{
    6769        ERROR_DECLARE;
    6870       
    6971        ipc_call_t answer;
    7072        aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     73
    7174        *packet = (packet_t) as_get_mappable_page(size);
    72         if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size))
    73             || ERROR_OCCURRED(pm_add(*packet))) {
     75        if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||
     76            ERROR_OCCURRED(pm_add(*packet))) {
    7477                munmap(*packet, size);
    7578                async_wait_for(message, NULL);
     
    8386}
    8487
     88/** Translates the packet identifier to the packet reference.
     89 *
     90 * Tries to find mapping first.
     91 * Contacts the packet server to share the packet if the mapping is not present.
     92 *
     93 * @param[in] phone     The packet server module phone.
     94 * @param[out] packet   The packet reference.
     95 * @param[in] packet_id The packet identifier.
     96 * @returns             EOK on success.
     97 * @returns             EINVAL if the packet parameter is NULL.
     98 * @returns             Other error codes as defined for the NET_PACKET_GET_SIZE
     99 *                      message.
     100 * @returns             Other error codes as defined for the packet_return()
     101 *                      function.
     102 */
    85103int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
    86104{
     
    91109       
    92110        *packet = pm_find(packet_id);
    93         if (!(*packet)) {
     111        if (!*packet) {
    94112                ipcarg_t size;
    95113               
    96                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
     114                ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE,
     115                    packet_id, &size));
    97116                ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
    98117        }
    99         if ((** packet).next) {
     118        if ((*packet)->next) {
    100119                packet_t next;
    101120               
    102                 return packet_translate_remote(phone, &next, (** packet).next);
     121                return packet_translate_remote(phone, &next, (*packet)->next);
    103122        }
    104123       
     
    106125}
    107126
     127/** Obtains the packet of the given dimensions.
     128 *
     129 * Contacts the packet server to return the appropriate packet.
     130 *
     131 * @param[in] phone     The packet server module phone.
     132 * @param[in] addr_len  The source and destination addresses maximal length in
     133 *                      bytes.
     134 * @param[in] max_prefix The maximal prefix length in bytes.
     135 * @param[in] max_content The maximal content length in bytes.
     136 * @param[in] max_suffix The maximal suffix length in bytes.
     137 * @returns             The packet reference.
     138 * @returns             NULL on error.
     139 */
    108140packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
    109141    size_t max_prefix, size_t max_suffix)
     
    114146        ipcarg_t size;
    115147       
    116         if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content,
    117             addr_len, max_prefix, max_suffix, &packet_id, &size)))
     148        if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4,
     149            max_content, addr_len, max_prefix, max_suffix, &packet_id, &size)))
    118150                return NULL;
    119151       
     
    121153        packet_t packet = pm_find(packet_id);
    122154        if (!packet) {
    123                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     155                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
     156                    size)))
    124157                        return NULL;
    125158        }
     
    128161}
    129162
     163/** Obtains the packet of the given content size.
     164 *
     165 * Contacts the packet server to return the appropriate packet.
     166 *
     167 * @param[in] phone     The packet server module phone.
     168 * @param[in] content   The maximal content length in bytes.
     169 * @returns             The packet reference.
     170 * @returns             NULL on error.
     171 */
    130172packet_t packet_get_1_remote(int phone, size_t content)
    131173{
     
    141183        packet_t packet = pm_find(packet_id);
    142184        if (!packet) {
    143                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     185                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
     186                    size)))
    144187                        return NULL;
    145188        }
     
    148191}
    149192
     193/** Releases the packet queue.
     194 *
     195 * All packets in the queue are marked as free for use.
     196 * The packet queue may be one packet only.
     197 * The module should not use the packets after this point until they are
     198 * received or obtained again.
     199 *
     200 * @param[in] phone     The packet server module phone.
     201 * @param[in] packet_id The packet identifier.
     202 */
    150203void pq_release_remote(int phone, packet_id_t packet_id)
    151204{
  • uspace/lib/net/il/arp_remote.c

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup arp
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  ARP interface implementation for remote modules.
    35  *  @see arp_interface.h
     34 * ARP interface implementation for remote modules.
     35 * @see arp_interface.h
    3636 */
     37
     38#include <arp_interface.h>
     39#include <generic.h>
    3740
    3841#include <async.h>
     
    4043#include <ipc/ipc.h>
    4144#include <ipc/services.h>
     45#include <ipc/arp.h>
    4246
    43 #include <net_messages.h>
    44 #include <net_modules.h>
    45 #include <net_device.h>
    46 #include <arp_interface.h>
     47#include <net/modules.h>
     48#include <net/device.h>
    4749#include <adt/measured_strings.h>
    48 #include <arp_messages.h>
    4950
    50 int arp_connect_module(services_t service){
    51         if(service != SERVICE_ARP){
     51/** Connects to the ARP module.
     52 *
     53 * @param service       The ARP module service. Ignored parameter.
     54 * @returns             The ARP module phone on success.
     55 */
     56int arp_connect_module(services_t service)
     57{
     58        if (service != SERVICE_ARP)
    5259                return EINVAL;
    53         }
     60
    5461        return connect_to_service(SERVICE_ARP);
    5562}
    5663
    57 int arp_clean_cache_req(int arp_phone){
     64/** Cleans the cache.
     65 *
     66 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     67 * @returns             EOK on success.
     68 */
     69int arp_clean_cache_req(int arp_phone)
     70{
    5871        return (int) async_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE);
    5972}
    6073
    61 int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address){
     74/** Clears the given protocol address from the cache.
     75 *
     76 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     77 * @param[in] device_id The device identifier.
     78 * @param[in] protocol  The requesting protocol service.
     79 * @param[in] address   The protocol address to be cleared.
     80 * @returns             EOK on success.
     81 * @returns             ENOENT if the mapping is not found.
     82 */
     83int
     84arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol,
     85    measured_string_ref address)
     86{
    6287        aid_t message_id;
    6388        ipcarg_t result;
    6489
    65         message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, (ipcarg_t) device_id, protocol, NULL);
     90        message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS,
     91            (ipcarg_t) device_id, protocol, NULL);
    6692        measured_strings_send(arp_phone, address, 1);
    6793        async_wait_for(message_id, &result);
     94
    6895        return (int) result;
    6996}
    7097
    71 int arp_clear_device_req(int arp_phone, device_id_t device_id){
    72         return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, (ipcarg_t) device_id);
     98/** Clears the device cache.
     99 *
     100 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     101 * @param[in] device_id The device identifier.
     102 * @returns             EOK on success.
     103 * @returns             ENOENT if the device is not found.
     104 */
     105int arp_clear_device_req(int arp_phone, device_id_t device_id)
     106{
     107        return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE,
     108            (ipcarg_t) device_id);
    73109}
    74110
    75 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){
     111/** Registers the new device and the requesting protocol service.
     112 *
     113 * Connects to the network interface layer service.
     114 * Determines the device broadcast address, its address lengths and packet size.
     115 *
     116 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     117 * @param[in] device_id The new device identifier.
     118 * @param[in] protocol  The requesting protocol service.
     119 * @param[in] netif     The underlying device network interface layer service.
     120 * @param[in] address   The local requesting protocol address of the device.
     121 * @returns             EOK on success.
     122 * @returns             EEXIST if the device is already used.
     123 * @returns             ENOMEM if there is not enough memory left.
     124 * @returns             ENOENT if the network interface service is not known.
     125 * @returns             EREFUSED if the network interface service is not
     126 *                      responding.
     127 * @returns             Other error codes as defined for the
     128 *                      nil_packet_get_size() function.
     129 * @returns             Other error codes as defined for the nil_get_addr()
     130 *                      function.
     131 * @returns             Other error codes as defined for the
     132 *                      nil_get_broadcast_addr() function.
     133 */
     134int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol,
     135    services_t netif, measured_string_ref address)
     136{
    76137        aid_t message_id;
    77138        ipcarg_t result;
    78139
    79         message_id = async_send_3(arp_phone, NET_ARP_DEVICE, (ipcarg_t) device_id, protocol, netif, NULL);
     140        message_id = async_send_3(arp_phone, NET_ARP_DEVICE,
     141            (ipcarg_t) device_id, protocol, netif, NULL);
    80142        measured_strings_send(arp_phone, address, 1);
    81143        async_wait_for(message_id, &result);
     144
    82145        return (int) result;
    83146}
    84147
    85 task_id_t arp_task_get_id(void){
    86         return 0;
    87 }
    88 
    89 int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){
    90         return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data);
     148/** Translates the given protocol address to the network interface address.
     149 *
     150 * Broadcasts the ARP request if the mapping is not found.
     151 * Allocates and returns the needed memory block as the data parameter.
     152 *
     153 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
     154 * @param[in] device_id The device identifier.
     155 * @param[in] protocol  The requesting protocol service.
     156 * @param[in] address   The local requesting protocol address.
     157 * @param[out] translation The translation of the local protocol address.
     158 * @param[out] data     The allocated raw translation data container.
     159 * @returns             EOK on success.
     160 * @returns             EINVAL if the address parameter is NULL.
     161 * @returns             EBADMEM if the translation or the data parameters are
     162 *                      NULL.
     163 * @returns             ENOENT if the mapping is not found.
     164 */
     165int
     166arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
     167    measured_string_ref address, measured_string_ref *translation, char **data)
     168{
     169        return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
     170            protocol, address, 1, translation, data);
    91171}
    92172
  • uspace/lib/net/il/ip_client.c

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup ip
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  IP client interface implementation.
    35  *  @see ip_client.h
     34 * IP client interface implementation.
     35 * @see ip_client.h
    3636 */
    3737
     
    4040
    4141#include <ip_client.h>
    42 #include <socket_errno.h>
    43 #include <packet/packet.h>
    44 #include <packet/packet_client.h>
     42#include <packet_client.h>
    4543#include <ip_header.h>
    4644
    47 size_t ip_client_header_length(packet_t packet){
     45#include <net/packet.h>
     46
     47/** Returns the IP header length.
     48 *
     49 * @param[in] packet    The packet.
     50 * @returns             The IP header length in bytes.
     51 * @returns             Zero if there is no IP header.
     52 */
     53size_t ip_client_header_length(packet_t packet)
     54{
    4855        ip_header_ref header;
    4956
    5057        header = (ip_header_ref) packet_get_data(packet);
    51         if((! header)
    52                 || (packet_get_data_length(packet) < sizeof(ip_header_t))){
     58        if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t)))
    5359                return 0;
    54         }
     60
    5561        return IP_HEADER_LENGTH(header);
    5662}
    5763
    58 int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, void **header, size_t * headerlen){
     64/** Constructs the IPv4 pseudo header.
     65 *
     66 * @param[in] protocol  The transport protocol.
     67 * @param[in] src       The source address.
     68 * @param[in] srclen    The source address length.
     69 * @param[in] dest      The destination address.
     70 * @param[in] destlen   The destination address length.
     71 * @param[in] data_length The data length to be set.
     72 * @param[out] header   The constructed IPv4 pseudo header.
     73 * @param[out] headerlen The length of the IP pseudo header in bytes.
     74 * @returns             EOK on success.
     75 * @returns             EBADMEM if the header and/or the headerlen parameter is
     76 *                      NULL.
     77 * @returns             EINVAL if the source address and/or the destination
     78 *                      address parameter is NULL.
     79 * @returns             EINVAL if the source address length is less than struct
     80 *                      sockaddr length.
     81 * @returns             EINVAL if the source address length differs from the
     82 *                      destination address length.
     83 * @returns             EINVAL if the source address family differs from the
     84 *                      destination family.
     85 * @returns             EAFNOSUPPORT if the address family is not supported.
     86 * @returns             ENOMEM if there is not enough memory left.
     87 */
     88int
     89ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr *src,
     90    socklen_t srclen, struct sockaddr *dest, socklen_t destlen,
     91    size_t data_length, void **header, size_t *headerlen)
     92{
    5993        ipv4_pseudo_header_ref header_in;
    60         struct sockaddr_in * address_in;
    61 
    62         if(!(header && headerlen)){
     94        struct sockaddr_in *address_in;
     95
     96        if (!header || !headerlen)
    6397                return EBADMEM;
    64         }
    65         if(!(src && dest && (srclen > 0) && ((size_t) srclen >= sizeof(struct sockaddr)) && (srclen == destlen) && (src->sa_family == dest->sa_family))){
     98
     99        if (!src || !dest || srclen <= 0 ||
     100            (((size_t) srclen < sizeof(struct sockaddr))) ||
     101            (srclen != destlen) || (src->sa_family != dest->sa_family)) {
    66102                return EINVAL;
    67103        }
    68104
    69         switch(src->sa_family){
    70                 case AF_INET:
    71                         if(srclen != sizeof(struct sockaddr_in)){
    72                                 return EINVAL;
    73                         }
    74                         *headerlen = sizeof(*header_in);
    75                         header_in = (ipv4_pseudo_header_ref) malloc(*headerlen);
    76                         if(! header_in){
    77                                 return ENOMEM;
    78                         }
    79                         bzero(header_in, * headerlen);
    80                         address_in = (struct sockaddr_in *) dest;
    81                         header_in->destination_address = address_in->sin_addr.s_addr;
    82                         address_in = (struct sockaddr_in *) src;
    83                         header_in->source_address = address_in->sin_addr.s_addr;
    84                         header_in->protocol = protocol;
    85                         header_in->data_length = htons(data_length);
    86                         *header = header_in;
    87                         return EOK;
    88                 // TODO IPv6
    89 /*              case AF_INET6:
    90                         if(addrlen != sizeof(struct sockaddr_in6)){
    91                                 return EINVAL;
    92                         }
    93                         address_in6 = (struct sockaddr_in6 *) addr;
    94                         return EOK;
    95 */              default:
    96                         return EAFNOSUPPORT;
    97         }
    98 }
    99 
    100 int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length){
     105        switch (src->sa_family) {
     106        case AF_INET:
     107                if (srclen != sizeof(struct sockaddr_in))
     108                        return EINVAL;
     109               
     110                *headerlen = sizeof(*header_in);
     111                header_in = (ipv4_pseudo_header_ref) malloc(*headerlen);
     112                if (!header_in)
     113                        return ENOMEM;
     114
     115                bzero(header_in, *headerlen);
     116                address_in = (struct sockaddr_in *) dest;
     117                header_in->destination_address = address_in->sin_addr.s_addr;
     118                address_in = (struct sockaddr_in *) src;
     119                header_in->source_address = address_in->sin_addr.s_addr;
     120                header_in->protocol = protocol;
     121                header_in->data_length = htons(data_length);
     122                *header = header_in;
     123                return EOK;
     124
     125        // TODO IPv6
     126/*      case AF_INET6:
     127                if (addrlen != sizeof(struct sockaddr_in6))
     128                        return EINVAL;
     129
     130                address_in6 = (struct sockaddr_in6 *) addr;
     131                return EOK;
     132*/
     133
     134        default:
     135                return EAFNOSUPPORT;
     136        }
     137}
     138
     139/** Prepares the packet to be transfered via IP.
     140 *
     141 * The IP header is prefixed.
     142 *
     143 * @param[in,out] packet The packet to be prepared.
     144 * @param[in] protocol  The transport protocol.
     145 * @param[in] ttl       The time to live counter. The IPDEFTTL is set if zero.
     146 * @param[in] tos       The type of service.
     147 * @param[in] dont_fragment The value indicating whether fragmentation is
     148 *                      disabled.
     149 * @param[in] ipopt_length The prefixed IP options length in bytes.
     150 * @returns             EOK on success.
     151 * @returns             ENOMEM if there is not enough memory left in the packet.
     152 */
     153int
     154ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl,
     155    ip_tos_t tos, int dont_fragment, size_t ipopt_length)
     156{
    101157        ip_header_ref header;
    102         uint8_t * data;
     158        uint8_t *data;
    103159        size_t padding;
    104160
     
    106162        // multiple of 4 bytes
    107163        padding =  ipopt_length % 4;
    108         if(padding){
     164        if (padding) {
    109165                padding = 4 - padding;
    110166                ipopt_length += padding;
     
    113169        // prefix the header
    114170        data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding);
    115         if(! data){
     171        if (!data)
    116172                return ENOMEM;
    117         }
    118173
    119174        // add the padding
    120         while(padding --){
     175        while (padding--)
    121176                data[sizeof(ip_header_t) + padding] = IPOPT_NOOP;
    122         }
    123177
    124178        // set the header
    125179        header = (ip_header_ref) data;
    126         header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length);
    127         header->ttl = (ttl ? ttl : IPDEFTTL); //(((ttl) <= MAXTTL) ? ttl : MAXTTL) : IPDEFTTL;
     180        header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) +
     181            ipopt_length);
     182        header->ttl = (ttl ? ttl : IPDEFTTL);
    128183        header->tos = tos;
    129184        header->protocol = protocol;
    130185
    131         if(dont_fragment){
     186        if (dont_fragment)
    132187                header->flags = IPFLAG_DONT_FRAGMENT;
    133         }
     188
    134189        return EOK;
    135190}
    136191
    137 int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length){
     192/** Processes the received IP packet.
     193 *
     194 * Fills set header fields.
     195 * Returns the prefixed IP header length.
     196 *
     197 * @param[in] packet    The received packet.
     198 * @param[out] protocol The transport protocol. May be NULL if not desired.
     199 * @param[out] ttl      The time to live counter. May be NULL if not desired.
     200 * @param[out] tos      The type of service. May be NULL if not desired.
     201 * @param[out] dont_fragment The value indicating whether the fragmentation is
     202 *                      disabled. May be NULL if not desired.
     203 * @param[out] ipopt_length The IP options length in bytes. May be NULL if not
     204 *                      desired.
     205 * @returns             The prefixed IP header length in bytes on success.
     206 * @returns             ENOMEM if the packet is too short to contain the IP
     207 *                      header.
     208 */
     209int
     210ip_client_process_packet(packet_t packet, ip_protocol_t *protocol,
     211    ip_ttl_t *ttl, ip_tos_t *tos, int *dont_fragment, size_t *ipopt_length)
     212{
    138213        ip_header_ref header;
    139214
    140215        header = (ip_header_ref) packet_get_data(packet);
    141         if((! header)
    142                 || (packet_get_data_length(packet) < sizeof(ip_header_t))){
     216        if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t)))
    143217                return ENOMEM;
    144         }
    145 
    146         if(protocol){
     218
     219        if (protocol)
    147220                *protocol = header->protocol;
    148         }
    149         if(ttl){
     221        if (ttl)
    150222                *ttl = header->ttl;
    151         }
    152         if(tos){
     223        if (tos)
    153224                *tos = header->tos;
    154         }
    155         if(dont_fragment){
    156                 *dont_fragment = header->flags &IPFLAG_DONT_FRAGMENT;
    157         }
    158         if(ipopt_length){
     225        if (dont_fragment)
     226                *dont_fragment = header->flags & IPFLAG_DONT_FRAGMENT;
     227        if (ipopt_length) {
    159228                *ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t);
    160229                return sizeof(ip_header_t);
    161         }else{
     230        } else {
    162231                return IP_HEADER_LENGTH(header);
    163232        }
    164233}
    165234
    166 int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length){
     235/** Updates the IPv4 pseudo header data length field.
     236 *
     237 * @param[in,out] header The IPv4 pseudo header to be updated.
     238 * @param[in] headerlen The length of the IP pseudo header in bytes.
     239 * @param[in] data_length The data length to be set.
     240 * @returns             EOK on success.
     241 * @returns             EBADMEM if the header parameter is NULL.
     242 * @returns             EINVAL if the headerlen parameter is not IPv4 pseudo
     243 *                      header length.
     244 */
     245int
     246ip_client_set_pseudo_header_data_length(void *header, size_t headerlen,
     247    size_t data_length)
     248{
    167249        ipv4_pseudo_header_ref header_in;
    168250
    169         if(! header){
     251        if (!header)
    170252                return EBADMEM;
    171         }
    172 
    173         if(headerlen == sizeof(ipv4_pseudo_header_t)){
     253
     254        if (headerlen == sizeof(ipv4_pseudo_header_t)) {
    174255                header_in = (ipv4_pseudo_header_ref) header;
    175256                header_in->data_length = htons(data_length);
    176257                return EOK;
    177258        // TODO IPv6
    178         }else{
     259        } else {
    179260                return EINVAL;
    180261        }
  • uspace/lib/net/il/ip_remote.c

    r1882525 rf14291b  
    4040 */
    4141
     42#include <ip_remote.h>
     43#include <ip_interface.h>
     44#include <packet_client.h>
     45#include <generic.h>
     46
    4247#include <ipc/services.h>
    43 
    44 #include <net_messages.h>
    45 #include <net_modules.h>
    46 #include <net_device.h>
    47 #include <inet.h>
    48 #include <ip_interface.h>
    49 #include <packet/packet_client.h>
    50 #include <il_messages.h>
    51 #include <ip_messages.h>
    52 #include <ip_remote.h>
     48#include <ipc/il.h>
     49#include <ipc/ip.h>
     50
     51#include <net/modules.h>
     52#include <net/device.h>
     53#include <net/inet.h>
    5354
    5455/** Add a route to the device routing table.
     
    7273
    7374int ip_bind_service(services_t service, int protocol, services_t me,
    74     async_client_conn_t receiver, tl_received_msg_t tl_received_msg)
     75    async_client_conn_t receiver)
    7576{
    7677        return (int) bind_service(service, (ipcarg_t) protocol, me, service,
     
    127128                return EINVAL;
    128129       
    129         if ((!device_id) || (header) || (headerlen))
     130        if ((!device_id) || (!header) || (!headerlen))
    130131                return EBADMEM;
    131132       
  • uspace/lib/net/include/adt/module_map.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Character string to module map.
     34 * Character string to module map.
    3535 */
    3636
    37 #ifndef __NET_MODULES_MAP_H__
    38 #define __NET_MODULES_MAP_H__
     37#ifndef LIBNET_MODULES_MAP_H_
     38#define LIBNET_MODULES_MAP_H_
    3939
    4040#include <task.h>
    41 
    4241#include <ipc/services.h>
    43 
    44 #include <net_modules.h>
    45 
     42#include <net/modules.h>
    4643#include <adt/generic_char_map.h>
    4744
    4845/** Type definition of the module structure.
    49  *  @see module_struct
     46 * @see module_struct
    5047 */
    51 typedef struct module_struct    module_t;
     48typedef struct module_struct module_t;
    5249
    5350/** Type definition of the module structure pointer.
    54  *  @see module_struct
     51 * @see module_struct
    5552 */
    56 typedef module_t *                              module_ref;
     53typedef module_t *module_ref;
    5754
    5855/** Module map.
    59  *  Sorted by module names.
    60  *  @see generic_char_map.h
     56 * Sorted by module names.
     57 * @see generic_char_map.h
    6158 */
    6259GENERIC_CHAR_MAP_DECLARE(modules, module_t)
    6360
    64 /** Module structure.
    65  */
    66 struct  module_struct{
    67         /** Module task identifier if running.
    68          */
     61/** Module structure. */
     62struct module_struct {
     63        /** Module task identifier if running. */
    6964        task_id_t task_id;
    70         /** Module service identifier.
    71          */
     65        /** Module service identifier. */
    7266        services_t service;
    73         /** Module phone if running and connected.
    74          */
     67        /** Module phone if running and connected. */
    7568        int phone;
    76         /** Usage counter.
    77          */
     69        /** Usage counter. */
    7870        int usage;
    79         /** Module name.
    80          */
    81         const char * name;
    82         /** Module full path filename.
    83          */
    84         const char * filename;
    85         /** Connecting function.
    86          */
    87         connect_module_t * connect_module;
     71        /** Module name. */
     72        const char *name;
     73        /** Module full path filename. */
     74        const char *filename;
     75        /** Connecting function. */
     76        connect_module_t *connect_module;
    8877};
    8978
    90 /** Adds module to the module map.
    91  *  @param[out] module The module structure added.
    92  *  @param[in] modules The module map.
    93  *  @param[in] name The module name.
    94  *  @param[in] filename The full path filename.
    95  *  @param[in] service The module service.
    96  *  @param[in] task_id The module current task identifier. Zero (0) means not running.
    97  *  @param[in] connect_module The module connecting function.
    98  *  @returns EOK on success.
    99  *  @returns ENOMEM if there is not enough memory left.
    100  */
    101 int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module);
    102 
    103 /** Searches and returns the specified module.
    104  *  If the module is not running, the module filaname is spawned.
    105  *  If the module is not connected, the connect_function is called.
    106  *  @param[in] modules The module map.
    107  *  @param[in] name The module name.
    108  *  @returns The running module found. It does not have to be connected.
    109  *  @returns NULL if there is no such module.
    110  */
    111 module_ref get_running_module(modules_ref modules, char * name);
    112 
    113 /** Starts the given module.
    114  *  @param[in] fname The module full or relative path filename.
    115  *  @returns The new module task identifier on success.
    116  *  @returns 0 if there is no such module.
    117  */
    118 task_id_t spawn(const char * fname);
     79extern int add_module(module_ref *, modules_ref, const char *, const char *,
     80    services_t, task_id_t, connect_module_t *);
     81extern module_ref get_running_module(modules_ref, char *);
     82extern task_id_t spawn(const char *);
    11983
    12084#endif
  • uspace/lib/net/include/arp_interface.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup arp
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    33 #ifndef __NET_ARP_INTERFACE_H__
    34 #define __NET_ARP_INTERFACE_H__
     33#ifndef LIBNET_ARP_INTERFACE_H_
     34#define LIBNET_ARP_INTERFACE_H_
    3535
    3636#include <adt/measured_strings.h>
    37 #include <net_device.h>
     37#include <task.h>
     38
     39#include <ipc/services.h>
     40
     41#include <net/device.h>
     42#include <net/socket.h>
    3843
    3944/** @name ARP module interface
    40  *  This interface is used by other modules.
     45 * This interface is used by other modules.
    4146 */
    4247/*@{*/
    4348
    44 /** Registers the new device and the requesting protocol service.
    45  *  Connects to the network interface layer service.
    46  *  Determines the device broadcast address, its address lengths and packet size.
    47  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    48  *  @param[in] device_id The new device identifier.
    49  *  @param[in] protocol The requesting protocol service.
    50  *  @param[in] netif The underlying device network interface layer service.
    51  *  @param[in] address The local requesting protocol address of the device.
    52  *  @returns EOK on success.
    53  *  @returns EEXIST if the device is already used.
    54  *  @returns ENOMEM if there is not enough memory left.
    55  *  @returns ENOENT if the network interface service is not known.
    56  *  @returns EREFUSED if the network interface service is not responding.
    57  *  @returns Other error codes as defined for the nil_packet_get_size() function.
    58  *  @returns Other error codes as defined for the nil_get_addr() function.
    59  *  @returns Other error codes as defined for the nil_get_broadcast_addr() function.
    60  */
    61 extern int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address);
    62 
    63 /** Translates the given protocol address to the network interface address.
    64  *  Broadcasts the ARP request if the mapping is not found.
    65  *  Allocates and returns the needed memory block as the data parameter.
    66  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    67  *  @param[in] device_id The device identifier.
    68  *  @param[in] protocol The requesting protocol service.
    69  *  @param[in] address The local requesting protocol address.
    70  *  @param[out] translation The translation of the local protocol address.
    71  *  @param[out] data The allocated raw translation data container.
    72  *  @returns EOK on success.
    73  *  @returns EINVAL if the address parameter is NULL.
    74  *  @returns EBADMEM if the translation or the data parameters are NULL.
    75  *  @returns ENOENT if the mapping is not found.
    76  */
    77 extern int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data);
    78 
    79 /** Clears the device cache.
    80  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    81  *  @param[in] device_id The device identifier.
    82  *  @returns EOK on success.
    83  *  @returns ENOENT if the device is not found.
    84  */
    85 extern int arp_clear_device_req(int arp_phone, device_id_t device_id);
    86 
    87 /** Clears the given protocol address from the cache.
    88  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    89  *  @param[in] device_id The device identifier.
    90  *  @param[in] protocol The requesting protocol service.
    91  *  @param[in] address The protocol address to be cleared.
    92  *  @returns EOK on success.
    93  *  @returns ENOENT if the mapping is not found.
    94  */
    95 extern int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address);
    96 
    97 /** Cleans the cache.
    98  *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    99  *  @returns EOK on success.
    100  */
    101 extern int arp_clean_cache_req(int arp_phone);
    102 
    103 /** Connects to the ARP module.
    104  *  @param service The ARP module service. Ignored parameter.
    105  *  @returns The ARP module phone on success.
    106  *  @returns 0 if called by the bundle module.
    107  */
    108 extern int arp_connect_module(services_t service);
    109 
    110 /** Returns the ARP task identifier.
    111  *  @returns The current task identifier if called by the bundle module.
    112  *  @returns 0 if called by the remote module.
    113  */
    114 extern task_id_t arp_task_get_id(void);
     49extern int arp_device_req(int, device_id_t, services_t, services_t,
     50    measured_string_ref);
     51extern int arp_translate_req(int, device_id_t, services_t, measured_string_ref,
     52    measured_string_ref *, char **);
     53extern int arp_clear_device_req(int, device_id_t);
     54extern int arp_clear_address_req(int, device_id_t, services_t,
     55    measured_string_ref);
     56extern int arp_clean_cache_req(int);
     57extern int arp_connect_module(services_t);
    11558
    11659/*@}*/
  • uspace/lib/net/include/generic.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup icmp
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP application interface implementation.
    35  *  @see icmp_api.h
     34 * Generic communication interfaces for networking.
    3635 */
    3736
     37#ifndef LIBNET_GENERIC_H_
     38#define LIBNET_GENERIC_H_
     39
    3840#include <async.h>
    39 
    4041#include <ipc/ipc.h>
    4142#include <ipc/services.h>
    4243
    43 #include <sys/types.h>
     44#include <net/device.h>
     45#include <adt/measured_strings.h>
     46#include <net/packet.h>
    4447
    45 #include <net_modules.h>
    46 #include <icmp_api.h>
    47 #include <inet.h>
    48 #include <ip_codes.h>
    49 #include <socket_codes.h>
    50 #include <icmp_messages.h>
     48extern int generic_device_state_msg_remote(int, int, device_id_t, int,
     49    services_t);
     50extern int generic_device_req_remote(int, int, device_id_t, int, services_t);
     51extern int generic_get_addr_req(int, int, device_id_t, measured_string_ref *,
     52    char **);
     53extern int generic_packet_size_req_remote(int, int, device_id_t,
     54    packet_dimension_ref);
     55extern int generic_received_msg_remote(int, int, device_id_t, packet_id_t,
     56    services_t, services_t);
     57extern int generic_send_msg_remote(int, int, device_id_t, packet_id_t,
     58    services_t, services_t);
     59extern int generic_translate_req(int, int, device_id_t, services_t,
     60    measured_string_ref, size_t, measured_string_ref *, char **);
    5161
    52 int icmp_echo_msg(int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen){
    53         aid_t message_id;
    54         ipcarg_t result;
    55 
    56         if(addrlen <= 0){
    57                 return EINVAL;
    58         }
    59         message_id = async_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, tos, (ipcarg_t) dont_fragment, NULL);
    60         // send the address
    61         async_data_write_start(icmp_phone, addr, (size_t) addrlen);
    62         // timeout version may cause inconsistency - there is also an inner timer
    63         // return async_wait_timeout(message_id, &result, timeout);
    64         async_wait_for(message_id, &result);
    65         return (int) result;
    66 }
     62#endif
    6763
    6864/** @}
  • uspace/lib/net/include/icmp_client.h

    r1882525 rf14291b  
    3838#define __NET_ICMP_CLIENT_H__
    3939
    40 #include <icmp_codes.h>
    41 #include <packet/packet.h>
     40#include <net/icmp_codes.h>
     41#include <net/packet.h>
    4242
    4343/** Processes the received packet prefixed with an ICMP header.
  • uspace/lib/net/include/icmp_header.h

    r1882525 rf14291b  
    4141#include <sys/types.h>
    4242
    43 #include <in.h>
    44 #include <icmp_codes.h>
     43#include <net/in.h>
     44#include <net/icmp_codes.h>
    4545
    4646/** ICMP header size in bytes.
  • uspace/lib/net/include/icmp_interface.h

    r1882525 rf14291b  
    3434#define __NET_ICMP_INTERFACE_H__
    3535
     36#include <net/socket_codes.h>
    3637#include <sys/types.h>
    3738
    38 #include <net_device.h>
     39#include <net/device.h>
    3940#include <adt/measured_strings.h>
    40 #include <packet/packet.h>
    41 #include <inet.h>
    42 #include <ip_codes.h>
    43 #include <socket_codes.h>
    44 #include <icmp_codes.h>
    45 #include <icmp_common.h>
     41#include <net/packet.h>
     42#include <net/inet.h>
     43#include <net/ip_codes.h>
     44#include <net/icmp_codes.h>
     45#include <net/icmp_common.h>
    4646
    4747/** @name ICMP module interface
  • uspace/lib/net/include/il_interface.h

    r1882525 rf14291b  
    3939#define __NET_IL_INTERFACE_H__
    4040
    41 #include <async.h>
     41#include <generic.h>
    4242
    4343#include <ipc/services.h>
     44#include <ipc/il.h>
    4445
    45 #include <net_messages.h>
    46 #include <net_device.h>
    47 #include <packet/packet.h>
    48 #include <packet/packet_client.h>
    49 #include <il_messages.h>
     46#include <net/device.h>
     47#include <net/packet.h>
     48
     49#include <packet_client.h>
    5050
    5151/** @name Internetwork layer module interface
  • uspace/lib/net/include/ip_client.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup ip
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  IP client interface.
     34 * IP client interface.
    3535 */
    3636
    37 #ifndef __NET_IP_CLIENT_H__
    38 #define __NET_IP_CLIENT_H__
     37#ifndef LIBNET_IP_CLIENT_H_
     38#define LIBNET_IP_CLIENT_H_
    3939
     40#include <net/socket_codes.h>
    4041#include <sys/types.h>
    4142
    42 #include <packet/packet.h>
    43 #include <ip_codes.h>
     43#include <net/packet.h>
     44#include <net/ip_codes.h>
    4445#include <ip_interface.h>
    45 #include <socket_codes.h>
    4646
    47 /** Prepares the packet to be transfered via IP.
    48  *  The IP header is prefixed.
    49  *  @param[in,out] packet The packet to be prepared.
    50  *  @param[in] protocol The transport protocol.
    51  *  @param[in] ttl The time to live counter. The IPDEFTTL is set if zero (0).
    52  *  @param[in] tos The type of service.
    53  *  @param[in] dont_fragment The value indicating whether fragmentation is disabled.
    54  *  @param[in] ipopt_length The prefixed IP options length in bytes.
    55  *  @returns EOK on success.
    56  *  @returns ENOMEM if there is not enough memory left in the packet.
    57  */
    58 extern int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length);
    59 
    60 /** Processes the received IP packet.
    61  *  Fills set header fields.
    62  *  Returns the prefixed IP header length.
    63  *  @param[in] packet The received packet.
    64  *  @param[out] protocol The transport protocol. May be NULL if not desired.
    65  *  @param[out] ttl The time to live counter. May be NULL if not desired.
    66  *  @param[out] tos The type of service. May be NULL if not desired.
    67  *  @param[out] dont_fragment The value indicating whether the fragmentation is disabled. May be NULL if not desired.
    68  *  @param[out] ipopt_length The IP options length in bytes. May be NULL if not desired.
    69  *  @returns The prefixed IP header length in bytes on success.
    70  *  @returns ENOMEM if the packet is too short to contain the IP header.
    71  */
    72 extern int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length);
    73 
    74 /** Returns the IP header length.
    75  *  @param[in] packet The packet.
    76  *  @returns The IP header length in bytes.
    77  *  @returns Zero (0) if there is no IP header.
    78  */
    79 extern size_t ip_client_header_length(packet_t packet);
    80 
    81 /** Updates the IPv4 pseudo header data length field.
    82  *  @param[in,out] header The IPv4 pseudo header to be updated.
    83  *  @param[in] headerlen The length of the IP pseudo header in bytes.
    84  *  @param[in] data_length The data length to be set.
    85  *  @returns EOK on success.
    86  *  @returns EBADMEM if the header parameter is NULL.
    87  *  @returns EINVAL if the headerlen parameter is not IPv4 pseudo header length.
    88  */
    89 extern int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length);
    90 
    91 /** Constructs the IPv4 pseudo header.
    92  *  @param[in] protocol The transport protocol.
    93  *  @param[in] src The source address.
    94  *  @param[in] srclen The source address length.
    95  *  @param[in] dest The destination address.
    96  *  @param[in] destlen The destination address length.
    97  *  @param[in] data_length The data length to be set.
    98  *  @param[out] header The constructed IPv4 pseudo header.
    99  *  @param[out] headerlen The length of the IP pseudo header in bytes.
    100  *  @returns EOK on success.
    101  *  @returns EBADMEM if the header and/or the headerlen parameter is NULL.
    102  *  @returns EINVAL if the source address and/or the destination address parameter is NULL.
    103  *  @returns EINVAL if the source address length is less than struct sockaddr length.
    104  *  @returns EINVAL if the source address length differs from the destination address length.
    105  *  @returns EINVAL if the source address family differs from the destination family.
    106  *  @returns EAFNOSUPPORT if the address family is not supported.
    107  *  @returns ENOMEM if there is not enough memory left.
    108  */
    109 extern int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, void **header, size_t * headerlen);
     47extern int ip_client_prepare_packet(packet_t, ip_protocol_t, ip_ttl_t, ip_tos_t,
     48    int, size_t);
     49extern int ip_client_process_packet(packet_t, ip_protocol_t *, ip_ttl_t *,
     50    ip_tos_t *, int *, size_t *);
     51extern size_t ip_client_header_length(packet_t);
     52extern int ip_client_set_pseudo_header_data_length(void *, size_t, size_t);
     53extern int ip_client_get_pseudo_header(ip_protocol_t, struct sockaddr *,
     54    socklen_t, struct sockaddr *, socklen_t, size_t, void **, size_t *);
    11055
    11156// TODO ipopt manipulation
  • uspace/lib/net/include/ip_interface.h

    r1882525 rf14291b  
    3434#define __NET_IP_INTERFACE_H__
    3535
     36#include <net/socket_codes.h>
    3637#include <async.h>
    3738#include <ipc/services.h>
    3839
    39 #include <net_device.h>
    40 #include <packet/packet.h>
     40#include <net/device.h>
     41#include <net/packet.h>
    4142
    42 #include <in.h>
    43 #include <ip_codes.h>
    44 #include <socket_codes.h>
    45 
    46 #ifdef CONFIG_IL_TL_BUNDLE
    47 
    48 #include <ip_local.h>
    49 
    50 #define ip_received_error_msg  ip_received_error_msg_local
    51 #define ip_set_gateway_req     ip_set_gateway_req_local
    52 #define ip_packet_size_req     ip_packet_size_req_local
    53 #define ip_device_req          ip_device_req_local
    54 #define ip_add_route_req       ip_add_route_req_local
    55 #define ip_send_msg            ip_send_msg_local
    56 #define ip_get_route_req       ip_get_route_req_local
    57 
    58 #else
     43#include <net/in.h>
     44#include <net/ip_codes.h>
    5945
    6046#include <ip_remote.h>
     
    6753#define ip_send_msg            ip_send_msg_remote
    6854#define ip_get_route_req       ip_get_route_req_remote
    69 
    70 #endif
    7155
    7256/** @name IP module interface
     
    9074 *  @param[in] me The requesting module service.
    9175 *  @param[in] receiver The message receiver. Used for remote connection.
    92  *  @param[in] tl_received_msg The message processing function. Used if bundled together.
    9376 *  @returns The phone of the needed service.
    9477 *  @returns EOK on success.
    9578 *  @returns Other error codes as defined for the bind_service() function.
    9679 */
    97 extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg);
     80extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver);
    9881
    9982/** Connects to the IP module.
    10083 *  @param service The IP module service. Ignored parameter.
    10184 *  @returns The IP module phone on success.
    102  *  @returns 0 if called by the bundle module.
    10385 */
    10486extern int ip_connect_module(services_t service);
  • uspace/lib/net/include/ip_remote.h

    r1882525 rf14291b  
    3434#define __NET_IP_REMOTE_H__
    3535
    36 #include <async.h>
    3736#include <ipc/services.h>
    3837
    39 #include <ip_codes.h>
    40 #include <inet.h>
    41 #include <in.h>
    42 #include <socket.h>
     38#include <net/ip_codes.h>
     39#include <net/inet.h>
     40#include <net/in.h>
     41#include <net/packet.h>
     42#include <net/device.h>
     43#include <net/socket.h>
    4344
    4445extern int ip_set_gateway_req_remote(int, device_id_t, in_addr_t);
  • uspace/lib/net/include/net_checksum.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  General CRC and checksum computation.
     34 * General CRC and checksum computation.
    3535 */
    3636
    37 #ifndef __NET_CHECKSUM_H__
    38 #define __NET_CHECKSUM_H__
     37#ifndef LIBNET_CHECKSUM_H_
     38#define LIBNET_CHECKSUM_H_
    3939
    4040#include <byteorder.h>
    41 
    4241#include <sys/types.h>
    4342
    4443/** IP checksum value for computed zero checksum.
    45  *  Zero is returned as 0xFFFF (not flipped)
     44 * Zero is returned as 0xFFFF (not flipped)
    4645 */
    47 #define IP_CHECKSUM_ZERO                        0xFFFFu
     46#define IP_CHECKSUM_ZERO        0xffffU
    4847
    49 /**     Computes CRC32 value.
    50  *  @param[in] seed Initial value. Often used as 0 or ~0.
    51  *  @param[in] data Pointer to the beginning of data to process.
    52  *  @param[in] length Length of the data in bits.
    53  *  @returns The computed CRC32 of the length bits of the data.
    54  */
    5548#ifdef ARCH_IS_BIG_ENDIAN
    56         #define compute_crc32(seed, data, length)       compute_crc32_be(seed, (uint8_t *) data, length)
     49#define compute_crc32(seed, data, length) \
     50        compute_crc32_be(seed, (uint8_t *) data, length)
    5751#else
    58         #define compute_crc32(seed, data, length)       compute_crc32_le(seed, (uint8_t *) data, length)
     52#define compute_crc32(seed, data, length) \
     53        compute_crc32_le(seed, (uint8_t *) data, length)
    5954#endif
    6055
    61 /**     Computes CRC32 value in the little-endian environment.
    62  *  @param[in] seed Initial value. Often used as 0 or ~0.
    63  *  @param[in] data Pointer to the beginning of data to process.
    64  *  @param[in] length Length of the data in bits.
    65  *  @returns The computed CRC32 of the length bits of the data.
    66  */
    67 extern uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length);
    68 
    69 /**     Computes CRC32 value in the big-endian environment.
    70  *  @param[in] seed Initial value. Often used as 0 or ~0.
    71  *  @param[in] data Pointer to the beginning of data to process.
    72  *  @param[in] length Length of the data in bits.
    73  *  @returns The computed CRC32 of the length bits of the data.
    74  */
    75 extern uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length);
    76 
    77 /** Computes sum of the 2 byte fields.
    78  *  Padds one zero (0) byte if odd.
    79  *  @param[in] seed Initial value. Often used as 0 or ~0.
    80  *  @param[in] data Pointer to the beginning of data to process.
    81  *  @param[in] length Length of the data in bytes.
    82  *  @returns The computed checksum of the length bytes of the data.
    83  */
    84 extern uint32_t compute_checksum(uint32_t seed, uint8_t * data, size_t length);
    85 
    86 /** Compacts the computed checksum to the 16 bit number adding the carries.
    87  *  @param[in] sum Computed checksum.
    88  *  @returns Compacted computed checksum to the 16 bits.
    89  */
    90 extern uint16_t compact_checksum(uint32_t sum);
    91 
    92 /** Returns or flips the checksum if zero.
    93  *  @param[in] checksum The computed checksum.
    94  *  @returns The internet protocol header checksum.
    95  *  @returns 0xFFFF if the computed checksum is zero.
    96  */
    97 extern uint16_t flip_checksum(uint16_t checksum);
    98 
    99 /** Computes the ip header checksum.
    100  *  To compute the checksum of a new packet, the checksum header field must be zero.
    101  *  To check the checksum of a received packet, the checksum may be left set.
    102  *  The zero (0) value will be returned in this case if valid.
    103  *  @param[in] data The header data.
    104  *  @param[in] length The header length in bytes.
    105  *  @returns The internet protocol header checksum.
    106  *  @returns 0xFFFF if the computed checksum is zero.
    107  */
    108 extern uint16_t ip_checksum(uint8_t * data, size_t length);
     56extern uint32_t compute_crc32_le(uint32_t, uint8_t *, size_t);
     57extern uint32_t compute_crc32_be(uint32_t, uint8_t *, size_t);
     58extern uint32_t compute_checksum(uint32_t, uint8_t *, size_t);
     59extern uint16_t compact_checksum(uint32_t);
     60extern uint16_t flip_checksum(uint16_t);
     61extern uint16_t ip_checksum(uint8_t *, size_t);
    10962
    11063#endif
  • uspace/lib/net/include/net_interface.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup net
     29/** @addtogroup libnet
    3030 *  @{
    3131 */
    3232
    33 #ifndef __NET_NET_INTERFACE_H__
    34 #define __NET_NET_INTERFACE_H__
     33#ifndef LIBNET_NET_INTERFACE_H_
     34#define LIBNET_NET_INTERFACE_H_
    3535
    3636#include <ipc/services.h>
    3737
    38 #include <net_device.h>
     38#include <net/device.h>
    3939#include <adt/measured_strings.h>
    4040
    4141/** @name Networking module interface
    42  *  This interface is used by other modules.
     42 * This interface is used by other modules.
    4343 */
    4444/*@{*/
    4545
    46 /** Returns the device specific configuration.
    47  *  Returns the global configuration if the device specific is not found.
    48  *  The configuration names are read and the appropriate settings are set instead.
    49  *  Call net_free_settings() function to release the returned configuration.
    50  *  @param[in] net_phone The networking module phone.
    51  *  @param[in] device_id The device identifier.
    52  *  @param[in,out] configuration The requested device configuration. The names are read and the appropriate settings are set instead.
    53  *  @param[in] count The configuration entries count.
    54  *  @param[in,out] data The configuration and settings data.
    55  *  @returns EOK on success.
    56  *  @returns EINVAL if the configuration is NULL.
    57  *  @returns EINVAL if the count is zero (0).
    58  *  @returns Other error codes as defined for the generic_translate_req() function.
    59  */
    60 extern int net_get_device_conf_req(int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data);
    61 
    62 /** Returns the global configuration.
    63  *  The configuration names are read and the appropriate settings are set instead.
    64  *  Call net_free_settings() function to release the returned configuration.
    65  *  @param[in] net_phone The networking module phone.
    66  *  @param[in,out] configuration The requested configuration. The names are read and the appropriate settings are set instead.
    67  *  @param[in] count The configuration entries count.
    68  *  @param[in,out] data The configuration and settings data.
    69  *  @returns EOK on success.
    70  *  @returns EINVAL if the configuration is NULL.
    71  *  @returns EINVAL if the count is zero (0).
    72  *  @returns Other error codes as defined for the generic_translate_req() function.
    73  */
    74 extern int net_get_conf_req(int net_phone, measured_string_ref * configuration, size_t count, char ** data);
    75 
    76 /** Frees the received settings.
    77  *  @param[in] settings The received settings.
    78  *  @param[in] data The received settings data.
    79  *  @see net_get_device_conf_req()
    80  *  @see net_get_conf_req()
    81  */
    82 extern void net_free_settings(measured_string_ref settings, char * data);
    83 
    84 /** Connects to the networking module.
    85  *  @param service The networking module service. Ignored parameter.
    86  *  @returns The networking module phone on success.
    87  *  @returns 0 if called by the bundle module.
    88  */
    89 extern int net_connect_module(services_t service);
     46extern int net_get_device_conf_req(int, device_id_t, measured_string_ref *,
     47    size_t, char **);
     48extern int net_get_conf_req(int, measured_string_ref *, size_t, char **);
     49extern void net_free_settings(measured_string_ref, char *);
     50extern int net_connect_module(void);
    9051
    9152/*@}*/
  • uspace/lib/net/include/netif_interface.h

    r1882525 rf14291b  
    3434#define __NET_NETIF_INTERFACE_H__
    3535
    36 #ifdef CONFIG_NETIF_NIL_BUNDLE
    37 
    38 #include <netif_local.h>
    39 #include <netif_nil_bundle.h>
    40 #include <packet/packet_server.h>
    41 
    42 #define netif_module_message    netif_nil_module_message
    43 #define netif_module_start      netif_nil_module_start
    44 #define netif_get_addr_req      netif_get_addr_req_local
    45 #define netif_probe_req         netif_probe_req_local
    46 #define netif_send_msg          netif_send_msg_local
    47 #define netif_start_req         netif_start_req_local
    48 #define netif_stop_req          netif_stop_req_local
    49 #define netif_stats_req         netif_stats_req_local
    50 #define netif_bind_service      netif_bind_service_local
    51 
    52 #else /* CONFIG_NETIF_NIL_BUNDLE */
    53 
    5436#include <netif_remote.h>
    55 #include <packet/packet_client.h>
     37#include <packet_client.h>
    5638
    5739#define netif_module_message    netif_module_message_standalone
     
    6547#define netif_bind_service      netif_bind_service_remote
    6648
    67 #endif /* CONFIG_NETIF_NIL_BUNDLE */
    68 
    6949#endif
    7050
  • uspace/lib/net/include/netif_local.h

    r1882525 rf14291b  
    3434 * Network interface module skeleton.
    3535 * The skeleton has to be part of each network interface module.
    36  * The skeleton can be also part of the module bundled with the network interface layer.
    3736 */
    3837
     
    4443#include <ipc/ipc.h>
    4544#include <ipc/services.h>
     45#include <err.h>
    4646
    4747#include <adt/measured_strings.h>
    48 #include <net_err.h>
    49 #include <net_device.h>
    50 #include <packet/packet.h>
     48#include <net/device.h>
     49#include <net/packet.h>
    5150
    5251/** Network interface device specific data.
  • uspace/lib/net/include/netif_remote.h

    r1882525 rf14291b  
    3434#define __NET_NETIF_REMOTE_H__
    3535
    36 #include <async.h>
    37 #include <fibril_synch.h>
    38 #include <ipc/ipc.h>
     36#include <ipc/services.h>
     37#include <adt/measured_strings.h>
     38#include <net/device.h>
    3939
    4040extern int netif_get_addr_req_remote(int, device_id_t, measured_string_ref *,
  • uspace/lib/net/include/nil_interface.h

    r1882525 rf14291b  
    3838
    3939#include <ipc/ipc.h>
     40#include <ipc/nil.h>
    4041
    41 #include <net_messages.h>
    42 #include <adt/measured_strings.h>
    43 #include <packet/packet.h>
    44 #include <nil_messages.h>
    45 #include <net_device.h>
     42#include <generic.h>
     43#include <nil_remote.h>
    4644
    4745#define nil_bind_service(service, device_id, me, receiver) \
     
    6765            netif_service)
    6866
    69 
    70 #ifdef CONFIG_NETIF_NIL_BUNDLE
    71 
    72 #include <nil_local.h>
    73 #include <packet/packet_server.h>
    74 
    75 #define nil_device_state_msg  nil_device_state_msg_local
    76 #define nil_received_msg      nil_received_msg_local
    77 
    78 #else /* CONFIG_NETIF_NIL_BUNDLE */
    79 
    80 #include <nil_remote.h>
    81 #include <packet/packet_server.h>
    82 
    8367#define nil_device_state_msg  nil_device_state_msg_remote
    8468#define nil_received_msg      nil_received_msg_remote
    85 
    86 #endif /* CONFIG_NETIF_NIL_BUNDLE */
    8769
    8870#endif
  • uspace/lib/net/include/nil_remote.h

    r1882525 rf14291b  
    3434#define __NET_NIL_REMOTE_H__
    3535
    36 #include <async.h>
    37 #include <fibril_synch.h>
    38 #include <ipc/ipc.h>
     36#include <ipc/services.h>
     37#include <net/device.h>
     38#include <net/packet.h>
    3939
    4040extern int nil_device_state_msg_remote(int, device_id_t, int);
  • uspace/lib/net/include/packet_remote.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup packet
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
    33 #ifndef __NET_PACKET_REMOTE_H__
    34 #define __NET_PACKET_REMOTE_H__
     33#ifndef LIBNET_PACKET_REMOTE_H_
     34#define LIBNET_PACKET_REMOTE_H_
    3535
    36 #include <packet/packet.h>
     36#include <net/packet.h>
     37#include <sys/types.h>
    3738
    3839extern int packet_translate_remote(int, packet_ref, packet_id_t);
  • uspace/lib/net/include/tl_common.h

    r1882525 rf14291b  
    3838#define __NET_TL_COMMON_H__
    3939
    40 #include <packet/packet.h>
    41 #include <net_device.h>
    42 #include <inet.h>
    43 #include <socket_codes.h>
     40#include <net/socket_codes.h>
     41#include <net/packet.h>
     42#include <net/device.h>
     43#include <net/inet.h>
    4444
    4545/** Device packet dimensions.
  • uspace/lib/net/include/tl_interface.h

    r1882525 rf14291b  
    4040#include <async.h>
    4141#include <ipc/services.h>
     42#include <ipc/tl.h>
    4243
    43 #include <net_messages.h>
    44 #include <net_device.h>
    45 #include <packet/packet.h>
    46 #include <packet/packet_client.h>
    47 #include <tl_messages.h>
     44#include <generic.h>
     45#include <net/device.h>
     46#include <net/packet.h>
     47#include <packet_client.h>
    4848
    4949/** @name Transport layer module interface
  • uspace/lib/net/netif/netif_local.c

    r1882525 rf14291b  
    4242#include <ipc/ipc.h>
    4343#include <ipc/services.h>
    44 
    45 #include <net_err.h>
    46 #include <net_messages.h>
    47 #include <net_modules.h>
    48 #include <packet/packet.h>
    49 #include <packet/packet_client.h>
    50 #include <packet/packet_server.h>
     44#include <ipc/netif.h>
     45#include <err.h>
     46
     47#include <generic.h>
     48#include <net/modules.h>
     49#include <net/packet.h>
     50#include <packet_client.h>
    5151#include <packet_remote.h>
    5252#include <adt/measured_strings.h>
    53 #include <net_device.h>
     53#include <net/device.h>
    5454#include <nil_interface.h>
    5555#include <netif_local.h>
    56 #include <netif_messages.h>
    5756#include <netif_interface.h>
    5857
     
    228227       
    229228        return ERROR_CODE;
    230 }
    231 
    232 /** Create bidirectional connection with the network interface module and registers the message receiver.
    233  *
    234  * @param[in] service   The network interface module service.
    235  * @param[in] device_id The device identifier.
    236  * @param[in] me        The requesting module service.
    237  * @param[in] receiver  The message receiver.
    238  *
    239  * @return The phone of the needed service.
    240  * @return EOK on success.
    241  * @return Other error codes as defined for the bind_service() function.
    242  *
    243  */
    244 int netif_bind_service_local(services_t service, device_id_t device_id,
    245     services_t me, async_client_conn_t receiver)
    246 {
    247         return EOK;
    248229}
    249230
  • uspace/lib/net/netif/netif_remote.c

    r1882525 rf14291b  
    3636
    3737#include <ipc/services.h>
     38#include <ipc/netif.h>
    3839
    39 #include <net_modules.h>
     40#include <net/modules.h>
    4041#include <adt/measured_strings.h>
    41 #include <packet/packet.h>
    42 #include <packet/packet_client.h>
    43 #include <net_device.h>
     42#include <net/packet.h>
     43#include <packet_client.h>
     44#include <net/device.h>
    4445#include <netif_remote.h>
    45 #include <netif_messages.h>
     46#include <generic.h>
    4647
    4748int netif_get_addr_req_remote(int netif_phone, device_id_t device_id,
     
    9091}
    9192
     93/** Create bidirectional connection with the network interface module and
     94 * registers the message receiver.
     95 *
     96 * @param[in] service   The network interface module service.
     97 * @param[in] device_id The device identifier.
     98 * @param[in] me        The requesting module service.
     99 * @param[in] receiver  The message receiver.
     100 *
     101 * @return The phone of the needed service.
     102 * @return EOK on success.
     103 * @return Other error codes as defined for the bind_service() function.
     104 *
     105 */
    92106int netif_bind_service_remote(services_t service, device_id_t device_id, services_t me,
    93107    async_client_conn_t receiver)
  • uspace/lib/net/nil/nil_remote.c

    r1882525 rf14291b  
    3636 */
    3737
    38 #include <net_messages.h>
    39 #include <net_device.h>
     38#include <nil_remote.h>
    4039#include <nil_interface.h>
    41 #include <packet/packet.h>
    42 #include <packet/packet_client.h>
    43 #include <nil_messages.h>
    44 #include <nil_remote.h>
     40#include <generic.h>
     41#include <net/device.h>
     42#include <net/packet.h>
     43#include <packet_client.h>
     44
     45#include <ipc/nil.h>
    4546
    4647/** Notify the network interface layer about the device state change.
  • uspace/lib/net/tl/icmp_client.c

    r1882525 rf14291b  
    4343#include <sys/types.h>
    4444
    45 #include <icmp_codes.h>
     45#include <net/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

    r1882525 rf14291b  
    4040#include <ipc/ipc.h>
    4141#include <ipc/services.h>
     42#include <ipc/icmp.h>
    4243#include <sys/types.h>
    4344
    44 #include <net_messages.h>
    45 #include <net_modules.h>
     45#include <net/modules.h>
    4646#include <icmp_interface.h>
    47 #include <packet/packet_client.h>
    48 #include <icmp_messages.h>
     47#include <packet_client.h>
    4948
    5049int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet){
  • uspace/lib/net/tl/tl_common.c

    r1882525 rf14291b  
    3636 */
    3737
     38#include <net/socket_codes.h>
     39#include <net/in.h>
     40#include <net/in6.h>
     41#include <net/inet.h>
    3842#include <async.h>
    3943#include <ipc/services.h>
    40 
    41 #include <net_err.h>
    42 #include <packet/packet.h>
    43 #include <packet/packet_client.h>
     44#include <errno.h>
     45#include <err.h>
     46
     47#include <net/packet.h>
     48#include <packet_client.h>
    4449#include <packet_remote.h>
    45 #include <net_device.h>
     50#include <net/device.h>
    4651#include <icmp_interface.h>
    47 #include <in.h>
    48 #include <in6.h>
    49 #include <inet.h>
    50 #include <ip_local.h>
    5152#include <ip_remote.h>
    52 #include <socket_codes.h>
    53 #include <socket_errno.h>
    5453#include <ip_interface.h>
    5554#include <tl_interface.h>
     
    5857DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t);
    5958
    60 int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port){
    61         const struct sockaddr_in * address_in;
    62         const struct sockaddr_in6 * address_in6;
    63 
    64         if((addrlen <= 0) || ((size_t) addrlen < sizeof(struct sockaddr))){
    65                 return EINVAL;
    66         }
    67         switch(addr->sa_family){
    68                 case AF_INET:
    69                         if(addrlen != sizeof(struct sockaddr_in)){
     59int
     60tl_get_address_port(const struct sockaddr *addr, int addrlen, uint16_t *port)
     61{
     62        const struct sockaddr_in *address_in;
     63        const struct sockaddr_in6 *address_in6;
     64
     65        if ((addrlen <= 0) || ((size_t) addrlen < sizeof(struct sockaddr)))
     66                return EINVAL;
     67
     68        switch (addr->sa_family) {
     69        case AF_INET:
     70                if (addrlen != sizeof(struct sockaddr_in))
     71                        return EINVAL;
     72
     73                address_in = (struct sockaddr_in *) addr;
     74                *port = ntohs(address_in->sin_port);
     75                break;
     76        case AF_INET6:
     77                if (addrlen != sizeof(struct sockaddr_in6))
    7078                                return EINVAL;
    71                         }
    72                         address_in = (struct sockaddr_in *) addr;
    73                         *port = ntohs(address_in->sin_port);
    74                         break;
    75                 case AF_INET6:
    76                         if(addrlen != sizeof(struct sockaddr_in6)){
    77                                 return EINVAL;
    78                         }
    79                         address_in6 = (struct sockaddr_in6 *) addr;
    80                         *port = ntohs(address_in6->sin6_port);
    81                         break;
    82                 default:
    83                         return EAFNOSUPPORT;
    84         }
     79
     80                address_in6 = (struct sockaddr_in6 *) addr;
     81                *port = ntohs(address_in6->sin6_port);
     82                break;
     83        default:
     84                return EAFNOSUPPORT;
     85        }
     86
    8587        return EOK;
    8688}
     
    112114                return EBADMEM;
    113115       
    114         *packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
     116        *packet_dimension = packet_dimensions_find(packet_dimensions,
     117            device_id);
    115118        if (!*packet_dimension) {
    116119                /* Ask for and remember them if not found */
     
    136139}
    137140
    138 int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content){
     141int
     142tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions,
     143    device_id_t device_id, size_t content)
     144{
    139145        packet_dimension_ref packet_dimension;
    140146
    141147        packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
    142         if(! packet_dimension){
     148        if (!packet_dimension)
    143149                return ENOENT;
    144         }
    145150        packet_dimension->content = content;
    146         if(device_id != DEVICE_INVALID_ID){
    147                 packet_dimension = packet_dimensions_find(packet_dimensions, DEVICE_INVALID_ID);
    148                 if(packet_dimension){
    149                         if(packet_dimension->content >= content){
     151
     152        if (device_id != DEVICE_INVALID_ID) {
     153                packet_dimension = packet_dimensions_find(packet_dimensions,
     154                    DEVICE_INVALID_ID);
     155
     156                if (packet_dimension) {
     157                        if (packet_dimension->content >= content)
    150158                                packet_dimension->content = content;
    151                         }else{
    152                                 packet_dimensions_exclude(packet_dimensions, DEVICE_INVALID_ID);
    153                         }
     159                        else
     160                                packet_dimensions_exclude(packet_dimensions,
     161                                    DEVICE_INVALID_ID);
     162
    154163                }
    155164        }
     165
    156166        return EOK;
    157167}
    158168
    159 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port){
    160         struct sockaddr_in * address_in;
    161         struct sockaddr_in6 * address_in6;
     169int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port)
     170{
     171        struct sockaddr_in *address_in;
     172        struct sockaddr_in6 *address_in6;
    162173        size_t length;
    163174
    164         if(addrlen < 0){
    165                 return EINVAL;
    166         }
     175        if (addrlen < 0)
     176                return EINVAL;
     177       
    167178        length = (size_t) addrlen;
    168         if(length < sizeof(struct sockaddr)){
    169                 return EINVAL;
    170         }
    171         switch(addr->sa_family){
    172                 case AF_INET:
    173                         if(length != sizeof(struct sockaddr_in)){
     179        if (length < sizeof(struct sockaddr))
     180                return EINVAL;
     181
     182        switch (addr->sa_family) {
     183        case AF_INET:
     184                if (length != sizeof(struct sockaddr_in))
     185                        return EINVAL;
     186                address_in = (struct sockaddr_in *) addr;
     187                address_in->sin_port = htons(port);
     188                return EOK;
     189        case AF_INET6:
     190                if (length != sizeof(struct sockaddr_in6))
    174191                                return EINVAL;
    175                         }
    176                         address_in = (struct sockaddr_in *) addr;
    177                         address_in->sin_port = htons(port);
    178                         return EOK;
    179                 case AF_INET6:
    180                         if(length != sizeof(struct sockaddr_in6)){
    181                                 return EINVAL;
    182                         }
    183                         address_in6 = (struct sockaddr_in6 *) addr;
    184                         address_in6->sin6_port = htons(port);
    185                         return EOK;
    186                 default:
    187                         return EAFNOSUPPORT;
    188         }
    189 }
    190 
    191 int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error){
     192                address_in6 = (struct sockaddr_in6 *) addr;
     193                address_in6->sin6_port = htons(port);
     194                return EOK;
     195        default:
     196                return EAFNOSUPPORT;
     197        }
     198}
     199
     200int
     201tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet,
     202    services_t error)
     203{
    192204        packet_t next;
    193         uint8_t * src;
     205        uint8_t *src;
    194206        int length;
    195207
     
    200212       
    201213        length = packet_get_addr(packet, &src, NULL);
    202         if((length > 0)
    203                 && (! error)
    204                 && (icmp_phone >= 0)
    205         // set both addresses to the source one (avoids the source address deletion before setting the destination one)
    206                 && (packet_set_addr(packet, src, src, (size_t) length) == EOK)){
     214        if ((length > 0) && (!error) && (icmp_phone >= 0) &&
     215            // set both addresses to the source one (avoids the source address
     216            // deletion before setting the destination one)
     217            (packet_set_addr(packet, src, src, (size_t) length) == EOK)) {
    207218                return EOK;
    208         }else{
     219        } else
    209220                pq_release_remote(packet_phone, packet_get_id(packet));
    210         }
     221
    211222        return ENOENT;
    212223}
    213224
    214 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){
     225int
     226tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix,
     227    const packet_dimension_ref dimension, const struct sockaddr *addr,
     228    socklen_t addrlen)
     229{
    215230        ERROR_DECLARE;
    216231
     
    219234        void * data;
    220235
    221         if(! dimension){
    222                 return EINVAL;
    223         }
     236        if (!dimension)
     237                return EINVAL;
     238
    224239        // get the data length
    225         if(! async_data_write_receive(&callid, &length)){
    226                 return EINVAL;
    227         }
     240        if (!async_data_write_receive(&callid, &length))
     241                return EINVAL;
     242
    228243        // get a new packet
    229         *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);
    230         if(! packet){
     244        *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len,
     245            prefix + dimension->prefix, dimension->suffix);
     246        if (!packet)
    231247                return ENOMEM;
    232         }
     248
    233249        // allocate space in the packet
    234250        data = packet_suffix(*packet, length);
    235         if(! data){
     251        if (!data) {
    236252                pq_release_remote(packet_phone, packet_get_id(*packet));
    237253                return ENOMEM;
    238254        }
     255
    239256        // read the data into the packet
    240         if(ERROR_OCCURRED(async_data_write_finalize(callid, data, length))
    241         // set the packet destination address
    242                 || ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen))){
     257        if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) ||
     258            // set the packet destination address
     259            ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr,
     260            addrlen))) {
    243261                pq_release_remote(packet_phone, packet_get_id(*packet));
    244262                return ERROR_CODE;
    245263        }
     264
    246265        return (int) length;
    247266}
  • uspace/lib/packet/Makefile

    r1882525 rf14291b  
    3030USPACE_PREFIX = ../..
    3131EXTRA_CFLAGS = -Iinclude
    32 LIBRARY = libsocket
     32LIBRARY = libpacket
    3333
    3434SOURCES = \
    35         generic/socket_client.c \
    36         generic/socket_core.c \
    37         generic/socket_parse.c \
    38         generic/inet.c \
    39         generic/net_modules.c \
    40         generic/icmp_common.c \
    41         generic/icmp_api.c \
    42         packet/packet.c \
    43         packet/packet_client.c \
    44         packet/packet_server.c \
    45         adt/dynamic_fifo.c \
    46         adt/measured_strings.c \
    47         adt/char_map.c
     35        generic/packet_server.c
    4836
    4937include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/packet/generic/packet_server.c

    r1882525 rf14291b  
    3939#include <async.h>
    4040#include <errno.h>
     41#include <err.h>
    4142#include <fibril_synch.h>
    4243#include <unistd.h>
     44#include <sys/mman.h>
    4345
    4446#include <ipc/ipc.h>
    45 #include <sys/mman.h>
    46 
    47 #include <net_err.h>
    48 #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>
     47#include <ipc/packet.h>
     48#include <ipc/net.h>
     49
     50#include <net/packet.h>
     51#include <net/packet_header.h>
     52
     53#include <packet_server.h>
     54#include <packet_local.h>
    5455
    5556#define FREE_QUEUES_COUNT       7
     
    8586        unsigned int count;
    8687} ps_globals = {
    87         .lock = {
    88                 .counter = 1,
    89                 .waiters = {
    90                         .prev = &ps_globals.lock.waiters,
    91                         .next = &ps_globals.lock.waiters,
    92                 }
    93         },
     88        .lock = FIBRIL_MUTEX_INITIALIZER(ps_globals.lock),
    9489        .free = {NULL, NULL, NULL, NULL, NULL, NULL, NULL},
    9590        .sizes = {PAGE_SIZE, PAGE_SIZE * 2, PAGE_SIZE * 4, PAGE_SIZE * 8, PAGE_SIZE * 16, PAGE_SIZE * 32, PAGE_SIZE * 64},
Note: See TracChangeset for help on using the changeset viewer.