Changeset fab2746 in mainline for uspace/lib/c/include/inet/udp.h


Ignore:
Timestamp:
2015-04-08T21:25:30Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
99ea91b2
Parents:
ba0eac5
Message:

New transport layer API. Only UDP implemented.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/inet/udp.h

    rba0eac5 rfab2746  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2015 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup libc
    30  *  @{
     30 * @{
     31 */
     32/** @file
    3133 */
    3234
    33 /** @file
    34  *  Character string to integer map.
    35  */
     35#ifndef LIBC_INET_UDP_H_
     36#define LIBC_INET_UDP_H_
    3637
    37 #ifndef LIBC_CHAR_MAP_H_
    38 #define LIBC_CHAR_MAP_H_
     38#include <async.h>
     39#include <inet/addr.h>
     40#include <inet/endpoint.h>
     41#include <inet/inet.h>
    3942
    40 #include <libarch/types.h>
     43typedef enum {
     44        udp_ls_down,
     45        udp_ls_up
     46} udp_link_state_t;
    4147
    42 /** Invalid assigned value used also if an&nbsp;entry does not exist. */
    43 #define CHAR_MAP_NULL  (-1)
     48typedef struct {
     49        struct udp *udp;
     50        sysarg_t assoc_id;
     51        size_t size;
     52        inet_ep_t remote_ep;
     53} udp_rmsg_t;
    4454
    45 /** Type definition of the character string to integer map.
    46  *  @see char_map
    47  */
    48 typedef struct char_map char_map_t;
     55typedef struct {
     56} udp_rerr_t;
    4957
    50 /** Character string to integer map item.
    51  *
    52  * This structure recursivelly contains itself as a character by character tree.
    53  * The actually mapped character string consists of all the parent characters
    54  * and the actual one.
    55  */
    56 struct char_map {
    57         /** Actually mapped character. */
    58         uint8_t c;
    59         /** Stored integral value. */
    60         int value;
    61         /** Next character array size. */
    62         int size;
    63         /** First free position in the next character array. */
    64         int next;
    65         /** Next character array. */
    66         char_map_t **items;
    67         /** Consistency check magic value. */
    68         int magic;
    69 };
     58typedef struct {
     59        struct udp *udp;
     60        link_t ludp;
     61        sysarg_t id;
     62        struct udp_cb *cb;
     63        void *cb_arg;
     64} udp_assoc_t;
    7065
    71 extern int char_map_initialize(char_map_t *);
    72 extern void char_map_destroy(char_map_t *);
    73 extern int char_map_exclude(char_map_t *, const uint8_t *, size_t);
    74 extern int char_map_add(char_map_t *, const uint8_t *, size_t, const int);
    75 extern int char_map_find(const char_map_t *, const uint8_t *, size_t);
    76 extern int char_map_update(char_map_t *, const uint8_t *, size_t, const int);
     66typedef struct udp_cb {
     67        void (*recv_msg)(udp_assoc_t *, udp_rmsg_t *);
     68        void (*recv_err)(udp_assoc_t *, udp_rerr_t *);
     69        void (*link_state)(udp_assoc_t *, udp_link_state_t);
     70} udp_cb_t;
     71
     72typedef struct udp {
     73        /** UDP session */
     74        async_sess_t *sess;
     75        /** List of associations */
     76        list_t assoc; /* of udp_assoc_t */
     77} udp_t;
     78
     79extern int udp_create(udp_t **);
     80extern void udp_destroy(udp_t *);
     81extern int udp_assoc_create(udp_t *, inet_ep2_t *, udp_cb_t *, void *,
     82    udp_assoc_t **);
     83extern void udp_assoc_destroy(udp_assoc_t *);
     84extern int udp_assoc_send_msg(udp_assoc_t *, inet_ep_t *, void *, size_t);
     85extern void *udp_assoc_userptr(udp_assoc_t *);
     86extern size_t udp_rmsg_size(udp_rmsg_t *);
     87extern int udp_rmsg_read(udp_rmsg_t *, size_t, void *, size_t);
     88extern void udp_rmsg_remote_ep(udp_rmsg_t *, inet_ep_t *);
     89extern uint8_t udp_rerr_type(udp_rerr_t *);
     90extern uint8_t udp_rerr_code(udp_rerr_t *);
    7791
    7892#endif
Note: See TracChangeset for help on using the changeset viewer.