Changeset 4687a26c in mainline for uspace/lib/c


Ignore:
Timestamp:
2010-11-02T18:29:01Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4f35b9ff
Parents:
76e1121f (diff), 28f4adb (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/c
Files:
33 added
28 edited
20 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r76e1121f r4687a26c  
    5757        generic/clipboard.c \
    5858        generic/devmap.c \
     59        generic/devman.c \
     60        generic/device/hw_res.c \
     61        generic/device/char.c \
    5962        generic/event.c \
    6063        generic/errno.c \
     
    8992        generic/adt/list.o \
    9093        generic/adt/hash_table.o \
     94        generic/adt/dynamic_fifo.c \
     95        generic/adt/measured_strings.c \
     96        generic/adt/char_map.c \
    9197        generic/time.c \
    9298        generic/err.c \
     
    96102        generic/vfs/vfs.c \
    97103        generic/vfs/canonify.c \
     104        generic/net/inet.c \
     105        generic/net/icmp_common.c \
     106        generic/net/icmp_api.c \
     107        generic/net/modules.c \
     108        generic/net/packet.c \
     109        generic/net/socket_client.c \
     110        generic/net/socket_parse.c \
    98111        generic/stacktrace.c \
    99112        generic/arg_parse.c \
  • uspace/lib/c/arch/abs32le/include/fibril.h

    r76e1121f r4687a26c  
    4444                (ctx)->pc = (uintptr_t) (_pc); \
    4545                (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
     46                (ctx)->fp = 0; \
    4647                (ctx)->tls = ((uintptr_t) (ptls)) + sizeof(tcb_t); \
    4748        } while (0)
     
    5354typedef struct {
    5455        uintptr_t sp;
     56        uintptr_t fp;
    5557        uintptr_t pc;
    5658        uintptr_t tls;
    5759} context_t;
     60
     61static inline uintptr_t context_get_fp(context_t *ctx)
     62{
     63        /* On real hardware, this function returns the frame pointer. */
     64        return ctx->fp;
     65}
    5866
    5967#endif
  • uspace/lib/c/arch/abs32le/include/istate.h

    r76e1121f r4687a26c  
    3636#define LIBC_abs32le__ISTATE_H_
    3737
    38 #include <sys/types.h>
    39 
    40 /** Interrupt context.
    41  *
    42  * On real hardware this stores the registers which
    43  * need to be preserved during interupts.
    44  */
    45 typedef struct istate {
    46         uintptr_t ip;
    47         uintptr_t fp;
    48         uint32_t stack[];
    49 } istate_t;
    50 
    51 static inline uintptr_t istate_get_pc(istate_t *istate)
    52 {
    53         return istate->ip;
    54 }
    55 
    56 static inline uintptr_t istate_get_fp(istate_t *istate)
    57 {
    58         return istate->fp;
    59 }
     38#include <arch/istate.h>
    6039
    6140#endif
  • uspace/lib/c/arch/amd64/include/fibril.h

    r76e1121f r4687a26c  
    5656 */
    5757typedef struct {
    58     uint64_t sp;
    59     uint64_t pc;
    60    
    61     uint64_t rbx;
    62     uint64_t rbp;
     58        uint64_t sp;
     59        uint64_t pc;
    6360
    64     uint64_t r12;
    65     uint64_t r13;
    66     uint64_t r14;
    67     uint64_t r15;
     61        uint64_t rbx;
     62        uint64_t rbp;
    6863
    69     uint64_t tls;
     64        uint64_t r12;
     65        uint64_t r13;
     66        uint64_t r14;
     67        uint64_t r15;
     68
     69        uint64_t tls;
    7070} context_t;
     71
     72static inline uintptr_t context_get_fp(context_t *ctx)
     73{
     74        return ctx->rbp;
     75}
    7176
    7277#endif
  • uspace/lib/c/arch/amd64/include/istate.h

    r76e1121f r4687a26c  
    3636#define LIBC_amd64_ISTATE_H_
    3737
    38 #include <sys/types.h>
    39 
    40 /** Interrupt context.
    41  *
    42  * This is a copy of the kernel definition with which it must be kept in sync.
    43  */
    44 typedef struct istate {
    45         uint64_t rax;
    46         uint64_t rcx;
    47         uint64_t rdx;
    48         uint64_t rsi;
    49         uint64_t rdi;
    50         uint64_t r8;
    51         uint64_t r9;
    52         uint64_t r10;
    53         uint64_t r11;
    54         uint64_t rbp;
    55         uint64_t error_word;
    56         uint64_t rip;
    57         uint64_t cs;
    58         uint64_t rflags;
    59         uint64_t stack[]; /* Additional data on stack */
    60 } istate_t;
    61 
    62 static inline uintptr_t istate_get_pc(istate_t *istate)
    63 {
    64         return istate->rip;
    65 }
    66 
    67 static inline uintptr_t istate_get_fp(istate_t *istate)
    68 {
    69         return istate->rbp;
    70 }
     38#include <arch/istate.h>
    7139
    7240#endif
  • uspace/lib/c/arch/arm32/include/fibril.h

    r76e1121f r4687a26c  
    8686} context_t;
    8787
     88static inline uintptr_t context_get_fp(context_t *ctx)
     89{
     90        return ctx->fp;
     91}
     92
    8893
    8994#endif
  • uspace/lib/c/arch/arm32/include/istate.h

    r76e1121f r4687a26c  
    3636#define LIBC_arm32__ISTATE_H_
    3737
    38 #include <sys/types.h>
    39 
    40 /** Interrupt context.
    41  *
    42  * This is a copy of the kernel definition with which it must be kept in sync.
    43  */
    44 typedef struct istate {
    45         uint32_t spsr;
    46         uint32_t sp;
    47         uint32_t lr;
    48 
    49         uint32_t r0;
    50         uint32_t r1;
    51         uint32_t r2;
    52         uint32_t r3;
    53         uint32_t r4;
    54         uint32_t r5;
    55         uint32_t r6;
    56         uint32_t r7;
    57         uint32_t r8;
    58         uint32_t r9;
    59         uint32_t r10;
    60         uint32_t fp;
    61         uint32_t r12;
    62 
    63         uint32_t pc;
    64 } istate_t;
    65 
    66 static inline uintptr_t istate_get_pc(istate_t *istate)
    67 {
    68         return istate->pc;
    69 }
    70 
    71 static inline uintptr_t istate_get_fp(istate_t *istate)
    72 {
    73         return istate->fp;
    74 }
     38#include <arch/istate.h>
    7539
    7640#endif
  • uspace/lib/c/arch/ia32/include/fibril.h

    r76e1121f r4687a26c  
    6767} context_t;
    6868
     69static inline uintptr_t context_get_fp(context_t *ctx)
     70{
     71        return ctx->ebp;
     72}
     73
    6974#endif
    7075
  • uspace/lib/c/arch/ia32/include/istate.h

    r76e1121f r4687a26c  
    3636#define LIBC_ia32__ISTATE_H_
    3737
    38 #include <sys/types.h>
    39 
    40 /** Interrupt context.
    41  *
    42  * This is a copy of the kernel definition with which it must be kept in sync.
    43  */
    44 typedef struct istate {
    45         uint32_t eax;
    46         uint32_t ecx;
    47         uint32_t edx;
    48         uint32_t ebp;
    49 
    50         uint32_t gs;
    51         uint32_t fs;
    52         uint32_t es;
    53         uint32_t ds;
    54 
    55         uint32_t error_word;
    56         uint32_t eip;
    57         uint32_t cs;
    58         uint32_t eflags;
    59         uint32_t stack[];
    60 } istate_t;
    61 
    62 static inline uintptr_t istate_get_pc(istate_t *istate)
    63 {
    64         return istate->eip;
    65 }
    66 
    67 static inline uintptr_t istate_get_fp(istate_t *istate)
    68 {
    69         return istate->ebp;
    70 }
     38#include <arch/istate.h>
    7139
    7240#endif
  • uspace/lib/c/arch/ia64/include/fibril.h

    r76e1121f r4687a26c  
    130130} context_t;
    131131
     132static inline uintptr_t context_get_fp(context_t *ctx)
     133{
     134        return 0;       /* FIXME */
     135}
     136
    132137#endif
    133138
  • uspace/lib/c/arch/ia64/include/istate.h

    r76e1121f r4687a26c  
    3636#define LIBC_ia64_ISTATE_H_
    3737
    38 #include <sys/types.h>
    39 
    40 /** Interrupt context.
    41  *
    42  * This is a copy of the kernel definition with which it must be kept in sync.
    43  */
    44 typedef struct istate {
    45         /* TODO */
    46 } istate_t;
    47 
    48 static inline uintptr_t istate_get_pc(istate_t *istate)
    49 {
    50         /* TODO */
    51         return 0;
    52 }
    53 
    54 static inline uintptr_t istate_get_fp(istate_t *istate)
    55 {
    56         /* TODO */
    57         return 0;
    58 }
     38#include <arch/istate.h>
    5939
    6040#endif
  • uspace/lib/c/arch/mips32/include/fibril.h

    r76e1121f r4687a26c  
    8585} context_t;
    8686
     87static inline uintptr_t context_get_fp(context_t *ctx)
     88{
     89        return ctx->sp;
     90}
     91
    8792#endif
    8893
  • uspace/lib/c/arch/mips32/include/istate.h

    r76e1121f r4687a26c  
    3636#define LIBC_mips32__ISTATE_H_
    3737
    38 #include <sys/types.h>
    39 
    40 /** Interrupt context.
    41  *
    42  * This is a copy of the kernel definition with which it must be kept in sync.
    43  */
    44 typedef struct istate {
    45         uint32_t at;
    46         uint32_t v0;
    47         uint32_t v1;
    48         uint32_t a0;
    49         uint32_t a1;
    50         uint32_t a2;
    51         uint32_t a3;
    52         uint32_t t0;
    53         uint32_t t1;
    54         uint32_t t2;
    55         uint32_t t3;
    56         uint32_t t4;
    57         uint32_t t5;
    58         uint32_t t6;
    59         uint32_t t7;
    60         uint32_t t8;
    61         uint32_t t9;
    62         uint32_t gp;
    63         uint32_t sp;
    64         uint32_t ra;
    65 
    66         uint32_t lo;
    67         uint32_t hi;
    68 
    69         uint32_t status; /* cp0_status */
    70         uint32_t epc; /* cp0_epc */
    71         uint32_t k1; /* We use it as thread-local pointer */
    72 } istate_t;
    73 
    74 static inline uintptr_t istate_get_pc(istate_t *istate)
    75 {
    76         return istate->epc;
    77 }
    78 
    79 static inline uintptr_t istate_get_fp(istate_t *istate)
    80 {
    81         /* TODO */
    82         return 0;
    83 }
     38#include <arch/istate.h>
    8439
    8540#endif
  • uspace/lib/c/arch/ppc32/include/fibril.h

    r76e1121f r4687a26c  
    7878} __attribute__ ((packed)) context_t;
    7979
     80static inline uintptr_t context_get_fp(context_t *ctx)
     81{
     82        return ctx->sp;
     83}
     84
    8085#endif
    8186
  • uspace/lib/c/arch/sparc64/include/fibril.h

    r76e1121f r4687a26c  
    7777} context_t;
    7878
     79static inline uintptr_t context_get_fp(context_t *ctx)
     80{
     81        return ctx->sp + STACK_BIAS;
     82}
     83
    7984#endif
    8085
  • uspace/lib/c/arch/sparc64/include/istate.h

    r76e1121f r4687a26c  
    3636#define LIBC_sparc64_ISTATE_H_
    3737
    38 #include <sys/types.h>
    39 
    40 /** Interrupt context.
    41  *
    42  * This is a copy of the kernel definition with which it must be kept in sync.
    43  */
    44 typedef struct istate {
    45         /* TODO */
    46 } istate_t;
    47 
    48 static inline uintptr_t istate_get_pc(istate_t *istate)
    49 {
    50         /* TODO */
    51         return 0;
    52 }
    53 
    54 static inline uintptr_t istate_get_fp(istate_t *istate)
    55 {
    56         /* TODO */
    57         return 0;
    58 }
     38#include <arch/istate.h>
    5939
    6040#endif
  • uspace/lib/c/generic/ddi.c

    r76e1121f r4687a26c  
    9696}
    9797
    98 /** Interrupt control
    99  *
    100  * @param enable        1 - enable interrupts, 0 - disable interrupts
     98/** Enable an interrupt.
     99 *
     100 * @param irq the interrupt.
     101 *
     102 * @return Zero on success, negative error code otherwise.
    101103 */
    102 int preemption_control(int enable)
     104int interrupt_enable(int irq)
    103105{
    104         return __SYSCALL1(SYS_PREEMPT_CONTROL, (sysarg_t) enable);
     106        return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 1);
     107}
     108
     109/** Disable an interrupt.
     110 *
     111 * @param irq the interrupt.
     112 *
     113 * @return Zero on success, negative error code otherwise.
     114 */
     115int interrupt_disable(int irq)
     116{
     117        return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 0);
    105118}
    106119
  • uspace/lib/c/generic/device/hw_res.c

    r76e1121f r4687a26c  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2010 Lenka Trochtova
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    29 /** @addtogroup ip
     28 
     29 /** @addtogroup libc
    3030 * @{
    3131 */
     32/** @file
     33 */
     34 
     35#include <device/hw_res.h>
     36#include <errno.h>
     37#include <async.h>
     38#include <malloc.h>
    3239
    33 #ifndef __NET_IP_LOCAL_H__
    34 #define __NET_IP_LOCAL_H__
     40bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
     41{
     42        ipcarg_t count = 0;
     43        int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
     44        hw_resources->count = count;
     45        if (EOK != rc) {
     46                return false;
     47        }
     48       
     49        size_t size = count * sizeof(hw_resource_t);
     50        hw_resources->resources = (hw_resource_t *)malloc(size);
     51        if (NULL == hw_resources->resources) {
     52                return false;
     53        }
     54       
     55        rc = async_data_read_start(dev_phone, hw_resources->resources, size);
     56        if (EOK != rc) {
     57                free(hw_resources->resources);
     58                hw_resources->resources = NULL;
     59                return false;
     60        }
     61                 
     62        return true;     
     63}
    3564
    36 #include <async.h>
    37 #include <ipc/services.h>
    38 
    39 #include <ip_codes.h>
    40 #include <inet.h>
    41 #include <in.h>
    42 #include <socket.h>
    43 
    44 extern int ip_received_error_msg_local(int, device_id_t, packet_t, services_t,
    45     services_t);
    46 extern int ip_set_gateway_req_local(int, device_id_t, in_addr_t);
    47 extern int ip_packet_size_req_local(int, device_id_t, packet_dimension_ref);
    48 extern int ip_received_error_msg_local(int, device_id_t, packet_t, services_t,
    49     services_t);
    50 extern int ip_device_req_local(int, device_id_t, services_t);
    51 extern int ip_add_route_req_local(int, device_id_t, in_addr_t, in_addr_t,
    52     in_addr_t);
    53 extern int ip_send_msg_local(int, device_id_t, packet_t, services_t,
    54     services_t);
    55 extern int ip_get_route_req_local(int, ip_protocol_t, const struct sockaddr *,
    56     socklen_t, device_id_t *, void **, size_t *);
    57 
    58 #endif
    59 
    60 /** @}
     65bool enable_interrupt(int dev_phone)
     66{
     67        int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), ENABLE_INTERRUPT);
     68        return rc == EOK;
     69}
     70 
     71 
     72 
     73 /** @}
    6174 */
  • uspace/lib/c/generic/fibril.c

    r76e1121f r4687a26c  
    275275        fibril->func = func;
    276276        fibril->arg = arg;
     277
     278        fibril->waits_for = NULL;
    277279       
    278280        context_save(&fibril->ctx);
  • uspace/lib/c/generic/fibril_synch.c

    r76e1121f r4687a26c  
    4242#include <errno.h>
    4343#include <assert.h>
     44#include <stacktrace.h>
     45#include <stdlib.h>
    4446
    4547static void optimize_execution_power(void)
     
    5658}
    5759
     60static bool check_for_deadlock(fibril_owner_info_t *oi)
     61{
     62        while (oi && oi->owned_by) {
     63                if (oi->owned_by == (fibril_t *) fibril_get_id())
     64                        return true;
     65                oi = oi->owned_by->waits_for;
     66        }
     67
     68        return false;
     69}
     70
     71static void print_deadlock(fibril_owner_info_t *oi)
     72{
     73        fibril_t *f = (fibril_t *) fibril_get_id();
     74
     75        printf("Deadlock detected.\n");
     76        stacktrace_print();
     77
     78        printf("Fibril %p waits for primitive %p.\n", f, oi);
     79
     80        while (oi && oi->owned_by) {
     81                printf("Primitive %p is owned by fibril %p.\n",
     82                    oi, oi->owned_by);
     83                if (oi->owned_by == f)
     84                        break;
     85                stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx),
     86                    oi->owned_by->ctx.pc);
     87                printf("Fibril %p waits for primitive %p.\n",
     88                     oi->owned_by, oi->owned_by->waits_for);
     89                oi = oi->owned_by->waits_for;
     90        }
     91
     92        abort();
     93}
     94
    5895void fibril_mutex_initialize(fibril_mutex_t *fm)
    5996{
     97        fm->oi.owned_by = NULL;
    6098        fm->counter = 1;
    6199        list_initialize(&fm->waiters);
     
    64102void fibril_mutex_lock(fibril_mutex_t *fm)
    65103{
     104        fibril_t *f = (fibril_t *) fibril_get_id();
     105
    66106        futex_down(&async_futex);
    67107        if (fm->counter-- <= 0) {
     
    73113                link_initialize(&wdata.wu_event.link);
    74114                list_append(&wdata.wu_event.link, &fm->waiters);
     115
     116                if (check_for_deadlock(&fm->oi))
     117                        print_deadlock(&fm->oi);
     118                f->waits_for = &fm->oi;
     119
    75120                fibril_switch(FIBRIL_TO_MANAGER);
    76121        } else {
     122                fm->oi.owned_by = f;
    77123                futex_up(&async_futex);
    78124        }
     
    86132        if (fm->counter > 0) {
    87133                fm->counter--;
     134                fm->oi.owned_by = (fibril_t *) fibril_get_id();
    88135                locked = true;
    89136        }
     
    99146                link_t *tmp;
    100147                awaiter_t *wdp;
     148                fibril_t *f;
    101149       
    102150                assert(!list_empty(&fm->waiters));
     
    105153                wdp->active = true;
    106154                wdp->wu_event.inlist = false;
     155
     156                f = (fibril_t *) wdp->fid;
     157                fm->oi.owned_by = f;
     158                f->waits_for = NULL;
     159
    107160                list_remove(&wdp->wu_event.link);
    108161                fibril_add_ready(wdp->fid);
    109162                optimize_execution_power();
     163        } else {
     164                fm->oi.owned_by = NULL;
    110165        }
    111166}
     
    120175void fibril_rwlock_initialize(fibril_rwlock_t *frw)
    121176{
     177        frw->oi.owned_by = NULL;
    122178        frw->writers = 0;
    123179        frw->readers = 0;
  • uspace/lib/c/generic/net/icmp_common.c

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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 **);
     44extern int interrupt_enable(int);
     45extern int interrupt_disable(int);
    4546
    4647#endif
  • uspace/lib/c/include/err.h

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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.h

    r76e1121f r4687a26c  
    4848#define FIBRIL_WRITER      2
    4949
     50struct fibril;
     51
     52typedef struct {
     53        struct fibril *owned_by;
     54} fibril_owner_info_t;
     55
    5056typedef enum {
    5157        FIBRIL_PREEMPT,
     
    6874        int retval;
    6975        int flags;
     76
     77        fibril_owner_info_t *waits_for;
    7078} fibril_t;
    7179
  • uspace/lib/c/include/fibril_synch.h

    r76e1121f r4687a26c  
    4343
    4444typedef struct {
     45        fibril_owner_info_t oi;         /* Keep this the first thing. */
    4546        int counter;
    4647        link_t waiters;
    4748} fibril_mutex_t;
    4849
    49 #define FIBRIL_MUTEX_INITIALIZE(name) \
    50         fibril_mutex_t name = { \
     50#define FIBRIL_MUTEX_INITIALIZER(name) \
     51        { \
     52                .oi = { \
     53                        .owned_by = NULL \
     54                }, \
    5155                .counter = 1, \
    5256                .waiters = { \
     
    5559                } \
    5660        }
     61       
     62#define FIBRIL_MUTEX_INITIALIZE(name) \
     63        fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name)
    5764
    5865typedef struct {
     66        fibril_owner_info_t oi; /* Keep this the first thing. */
    5967        unsigned writers;
    6068        unsigned readers;
     
    6270} fibril_rwlock_t;
    6371
    64 #define FIBRIL_RWLOCK_INITIALIZE(name) \
    65         fibril_rwlock_t name = { \
     72#define FIBRIL_RWLOCK_INITIALIZER(name) \
     73        { \
     74                .oi = { \
     75                        .owned_by = NULL \
     76                }, \
    6677                .readers = 0, \
    6778                .writers = 0, \
     
    7283        }
    7384
     85#define FIBRIL_RWLOCK_INITIALIZE(name) \
     86        fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name)
     87
    7488typedef struct {
    7589        link_t waiters;
    7690} fibril_condvar_t;
    7791
    78 #define FIBRIL_CONDVAR_INITIALIZE(name) \
    79         fibril_condvar_t name = { \
     92#define FIBRIL_CONDVAR_INITIALIZER(name) \
     93        { \
    8094                .waiters = { \
    8195                        .next = &name.waiters, \
     
    8397                } \
    8498        }
     99
     100#define FIBRIL_CONDVAR_INITIALIZE(name) \
     101        fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name)
    85102
    86103extern void fibril_mutex_initialize(fibril_mutex_t *);
  • uspace/lib/c/include/ipc/arp.h

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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/services.h

    r76e1121f r4687a26c  
    4545        SERVICE_VFS,
    4646        SERVICE_DEVMAP,
     47        SERVICE_DEVMAN,
    4748        SERVICE_FHC,
    4849        SERVICE_OBIO,
  • uspace/lib/c/include/ipc/socket.h

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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#include <sys/types.h>
     45
     46/** ICMP type type definition. */
     47typedef uint8_t icmp_type_t;
     48
     49/** ICMP code type definition. */
     50typedef uint8_t icmp_code_t;
     51
     52/** ICMP parameter type definition. */
     53typedef uint16_t icmp_param_t;
     54
     55/** @name ICMP types definitions */
     56/*@{*/
     57
     58/** Echo Reply. */
    5859#define ICMP_ECHOREPLY          0
    5960
    60 /** Destination Unreachable.
    61  */
     61/** Destination Unreachable. */
    6262#define ICMP_DEST_UNREACH       3
    6363
    64 /** Source Quench.
    65  */
     64/** Source Quench. */
    6665#define ICMP_SOURCE_QUENCH      4
    6766
    68 /** Redirect.
    69  */
     67/** Redirect. */
    7068#define ICMP_REDIRECT           5
    7169
    72 /** Alternate Host Address.
    73  */
     70/** Alternate Host Address. */
    7471#define ICMP_ALTERNATE_ADDR     6
    7572
    76 /** Echo Request.
    77  */
    78 #define ICMP_ECHO                       8
    79 
    80 /** Router Advertisement.
    81  */
     73/** Echo Request. */
     74#define ICMP_ECHO               8
     75
     76/** Router Advertisement. */
    8277#define ICMP_ROUTER_ADV         9
    8378
    84 /** Router solicitation.
    85  */
     79/** Router solicitation. */
    8680#define ICMP_ROUTER_SOL         10
    8781
    88 /** Time Exceeded.
    89  */
     82/** Time Exceeded. */
    9083#define ICMP_TIME_EXCEEDED      11
    9184
    92 /** Parameter Problem.
    93  */
     85/** Parameter Problem. */
    9486#define ICMP_PARAMETERPROB      12
    9587
    96 /** Timestamp Request.
    97  */
     88/** Timestamp Request. */
    9889#define ICMP_TIMESTAMP          13
    9990
    100 /** Timestamp Reply.
    101  */
     91/** Timestamp Reply. */
    10292#define ICMP_TIMESTAMPREPLY     14
    10393
    104 /** Information Request.
    105  */
     94/** Information Request. */
    10695#define ICMP_INFO_REQUEST       15
    10796
    108 /** Information Reply.
    109  */
     97/** Information Reply. */
    11098#define ICMP_INFO_REPLY         16
    11199
    112 /** Address Mask Request.
    113  */
     100/** Address Mask Request. */
    114101#define ICMP_ADDRESS            17
    115102
    116 /** Address Mask Reply.
    117  */
     103/** Address Mask Reply. */
    118104#define ICMP_ADDRESSREPLY       18
    119105
    120 /** Traceroute.
    121  */
     106/** Traceroute. */
    122107#define ICMP_TRACEROUTE         30
    123108
    124 /** Datagram Conversion Error.
    125  */
     109/** Datagram Conversion Error. */
    126110#define ICMP_CONVERSION_ERROR   31
    127111
    128 /** Mobile Host Redirect.
    129  */
     112/** Mobile Host Redirect. */
    130113#define ICMP_REDIRECT_MOBILE    32
    131114
    132 /** IPv6 Where-Are-You.
    133  */
     115/** IPv6 Where-Are-You. */
    134116#define ICMP_IPV6_WHERE_ARE_YOU 33
    135117
    136 /** IPv6 I-Am-Here.
    137  */
     118/** IPv6 I-Am-Here. */
    138119#define ICMP_IPV6_I_AM_HERE     34
    139120
    140 /** Mobile Registration Request.
    141  */
     121/** Mobile Registration Request. */
    142122#define ICMP_MOBILE_REQUEST     35
    143123
    144 /** Mobile Registration Reply.
    145  */
     124/** Mobile Registration Reply. */
    146125#define ICMP_MOBILE_REPLY       36
    147126
    148 /** Domain name request.
    149  */
     127/** Domain name request. */
    150128#define ICMP_DN_REQUEST         37
    151129
    152 /** Domain name reply.
    153  */
     130/** Domain name reply. */
    154131#define ICMP_DN_REPLY           38
    155132
    156 /** SKIP.
    157  */
    158 #define ICMP_SKIP                       39
    159 
    160 /** Photuris.
    161  */
     133/** SKIP. */
     134#define ICMP_SKIP               39
     135
     136/** Photuris. */
    162137#define ICMP_PHOTURIS           40
    163138
     
    168143/*@{*/
    169144
    170 /** Network Unreachable.
    171  */
     145/** Network Unreachable. */
    172146#define ICMP_NET_UNREACH        0
    173147
    174 /** Host Unreachable.
    175  */
     148/** Host Unreachable. */
    176149#define ICMP_HOST_UNREACH       1
    177150
    178 /** Protocol Unreachable.
    179  */
     151/** Protocol Unreachable. */
    180152#define ICMP_PROT_UNREACH       2
    181153
    182 /** Port Unreachable.
    183  */
     154/** Port Unreachable. */
    184155#define ICMP_PORT_UNREACH       3
    185156
    186 /** Fragmentation needed but the Do Not Fragment bit was set.
    187  */
     157/** Fragmentation needed but the Do Not Fragment bit was set. */
    188158#define ICMP_FRAG_NEEDED        4
    189159
    190 /** Source Route failed.
    191  */
     160/** Source Route failed. */
    192161#define ICMP_SR_FAILED          5
    193162
    194 /** Destination network unknown.
    195  */
     163/** Destination network unknown. */
    196164#define ICMP_NET_UNKNOWN        6
    197165
    198 /** Destination host unknown.
    199  */
     166/** Destination host unknown. */
    200167#define ICMP_HOST_UNKNOWN       7
    201168
    202 /** Source host isolated (obsolete).
    203  */
     169/** Source host isolated (obsolete). */
    204170#define ICMP_HOST_ISOLATED      8
    205171
    206 /** Destination network administratively prohibited.
    207  */
     172/** Destination network administratively prohibited. */
    208173#define ICMP_NET_ANO            9
    209174
    210 /** Destination host administratively prohibited.
    211  */
     175/** Destination host administratively prohibited. */
    212176#define ICMP_HOST_ANO           10
    213177
    214 /** Network unreachable for this type of service.
    215  */
     178/** Network unreachable for this type of service. */
    216179#define ICMP_NET_UNR_TOS        11
    217180
    218 /** Host unreachable for this type of service.
    219  */
     181/** Host unreachable for this type of service. */
    220182#define ICMP_HOST_UNR_TOS       12
    221183
    222 /** Communication administratively prohibited by filtering.
    223  */
     184/** Communication administratively prohibited by filtering. */
    224185#define ICMP_PKT_FILTERED       13
    225186
    226 /** Host precedence violation.
    227  */
     187/** Host precedence violation. */
    228188#define ICMP_PREC_VIOLATION     14
    229189
    230 /** Precedence cutoff in effect.
    231  */
     190/** Precedence cutoff in effect. */
    232191#define ICMP_PREC_CUTOFF        15
    233192
    234193/*@}*/
    235194
    236 /** @name ICMP_REDIRECT codes definitions
    237  */
    238 /*@{*/
    239 
    240 /** Network redirect (or subnet).
    241  */
     195/** @name ICMP_REDIRECT codes definitions */
     196/*@{*/
     197
     198/** Network redirect (or subnet). */
    242199#define ICMP_REDIR_NET          0
    243200
    244 /** Host redirect.
    245  */
     201/** Host redirect. */
    246202#define ICMP_REDIR_HOST         1
    247203
    248 /** Network redirect for this type of service.
    249  */
     204/** Network redirect for this type of service. */
    250205#define ICMP_REDIR_NETTOS       2
    251206
    252 /** Host redirect for this type of service.
    253  */
     207/** Host redirect for this type of service. */
    254208#define ICMP_REDIR_HOSTTOS      3
    255209
    256210/*@}*/
    257211
    258 /** @name ICMP_ALTERNATE_ADDRESS codes definitions
    259  */
    260 /*@{*/
    261 
    262 /** Alternate address for host.
    263  */
     212/** @name ICMP_ALTERNATE_ADDRESS codes definitions */
     213/*@{*/
     214
     215/** Alternate address for host. */
    264216#define ICMP_ALTERNATE_HOST     0
    265217
    266218/*@}*/
    267219
    268 /** @name ICMP_ROUTER_ADV codes definitions
    269  */
    270 /*@{*/
    271 
    272 /** Normal router advertisement.
    273  */
     220/** @name ICMP_ROUTER_ADV codes definitions */
     221/*@{*/
     222
     223/** Normal router advertisement. */
    274224#define ICMP_ROUTER_NORMAL      0
    275225
    276 /** Does not route common traffic.
    277  */
     226/** Does not route common traffic. */
    278227#define ICMP_ROUTER_NO_NORMAL_TRAFFIC   16
    279228
    280229/*@}*/
    281230
    282 /** @name ICMP_TIME_EXCEEDED codes definitions
    283  */
    284 /*@{*/
    285 
    286 /** Transit TTL exceeded.
    287  */
     231/** @name ICMP_TIME_EXCEEDED codes definitions */
     232/*@{*/
     233
     234/** Transit TTL exceeded. */
    288235#define ICMP_EXC_TTL            0
    289236
    290 /** Reassembly TTL exceeded.
    291  */
     237/** Reassembly TTL exceeded. */
    292238#define ICMP_EXC_FRAGTIME       1
    293239
    294240/*@}*/
    295241
    296 /** @name ICMP_PARAMETERPROB codes definitions
    297  */
    298 /*@{*/
    299 
    300 /** Pointer indicates the error.
    301  */
     242/** @name ICMP_PARAMETERPROB codes definitions */
     243/*@{*/
     244
     245/** Pointer indicates the error. */
    302246#define ICMP_PARAM_POINTER      0
    303247
    304 /** Missing required option.
    305  */
     248/** Missing required option. */
    306249#define ICMP_PARAM_MISSING      1
    307250
    308 /** Bad length.
    309  */
     251/** Bad length. */
    310252#define ICMP_PARAM_LENGTH       2
    311253
    312254/*@}*/
    313255
    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  */
     256/** @name ICMP_PHOTURIS codes definitions */
     257/*@{*/
     258
     259/** Bad SPI. */
     260#define ICMP_PHOTURIS_BAD_SPI                   0
     261
     262/** Authentication failed. */
     263#define ICMP_PHOTURIS_AUTHENTICATION            1
     264
     265/** Decompression failed. */
    328266#define ICMP_PHOTURIS_DECOMPRESSION             2
    329267
    330 /** Decryption failed.
    331  */
    332 #define ICMP_PHOTURIS_DECRYPTION        3
    333 
    334 /** Need authentication.
    335  */
     268/** Decryption failed. */
     269#define ICMP_PHOTURIS_DECRYPTION                3
     270
     271/** Need authentication. */
    336272#define ICMP_PHOTURIS_NEED_AUTHENTICATION       4
    337273
    338 /** Need authorization.
    339  */
     274/** Need authorization. */
    340275#define ICMP_PHOTURIS_NEED_AUTHORIZATION        5
    341276
  • uspace/lib/c/include/net/icmp_common.h

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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/sys/time.h

    r76e1121f r4687a26c  
    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

    r76e1121f r4687a26c  
    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);
Note: See TracChangeset for help on using the changeset viewer.