Changeset fab2746 in mainline for uspace/lib/c/include/inet


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.

Location:
uspace/lib/c/include/inet
Files:
1 edited
3 moved

Legend:

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

    rba0eac5 rfab2746  
    3737
    3838#include <stdint.h>
    39 #include <net/in.h>
    40 #include <net/in6.h>
    41 #include <net/socket.h>
    4239
    4340typedef uint32_t addr32_t;
     
    126123extern void inet_addr_set(addr32_t, inet_addr_t *);
    127124extern void inet_naddr_set(addr32_t, uint8_t, inet_naddr_t *);
    128 extern void inet_sockaddr_in_addr(const sockaddr_in_t *, inet_addr_t *);
    129125
    130126extern void inet_addr_set6(addr128_t, inet_addr_t *);
    131127extern void inet_naddr_set6(addr128_t, uint8_t, inet_naddr_t *);
    132 extern void inet_sockaddr_in6_addr(const sockaddr_in6_t *, inet_addr_t *);
    133 
    134 extern uint16_t inet_addr_sockaddr_in(const inet_addr_t *, sockaddr_in_t *,
    135     sockaddr_in6_t *);
    136 
    137 extern ip_ver_t ipver_from_af(int af);
    138 extern int inet_addr_sockaddr(const inet_addr_t *, uint16_t, sockaddr_t **,
    139     socklen_t *);
    140128
    141129#endif
  • uspace/lib/c/include/inet/endpoint.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  * Internet protocol numbers according to the on-line IANA - Assigned Protocol
    35  * numbers:
    36  *
    37  * http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml
    38  */
     35#ifndef LIBC_INET_ASSOC_H_
     36#define LIBC_INET_ASSOC_H_
    3937
    40 #ifndef LIBC_IP_PROTOCOLS_H_
    41 #define LIBC_IP_PROTOCOLS_H_
     38#include <stdint.h>
     39#include <inet/addr.h>
     40#include <loc.h>
    4241
    43 /** @name IP protocols definitions */
    44 /*@{*/
     42/** Internet endpoint (address-port pair), a.k.a. socket */
     43typedef struct {
     44        inet_addr_t addr;
     45        uint16_t port;
     46} inet_ep_t;
    4547
    46 #define IPPROTO_ICMP    1
    47 #define IPPROTO_TCP     6
    48 #define IPPROTO_UDP     17
    49 #define IPPROTO_ICMPV6  58
     48/** Internet endpoint pair */
     49typedef struct {
     50        service_id_t local_link;
     51        inet_ep_t local;
     52        inet_ep_t remote;
     53} inet_ep2_t;
    5054
    51 /*@}*/
     55extern void inet_ep_init(inet_ep_t *);
     56extern void inet_ep2_init(inet_ep2_t *);
    5257
    5358#endif
  • uspace/lib/c/include/inet/tcp.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  *  Socket codes and definitions.
    35  *  This is a part of the network application library.
    36  */
     35#ifndef LIBC_INET_TCP_H_
     36#define LIBC_INET_TCP_H_
    3737
    38 #ifndef LIBC_SOCKET_CODES_H_
    39 #define LIBC_SOCKET_CODES_H_
     38#include <inet/addr.h>
     39#include <inet/endpoint.h>
     40#include <inet/inet.h>
    4041
    41 #include <sys/types.h>
     42typedef struct {
     43} tcp_conn_t;
    4244
    43 /** @name Address families definitions */
    44 /*@{*/
     45typedef struct {
     46} tcp_listener_t;
    4547
    46 enum {
    47         AF_NONE = 0,
    48         AF_INET,  /* IPv4 address */
    49         AF_INET6  /* IPv6 address */
    50 };
     48typedef struct {
     49        void (*connected)(tcp_conn_t *);
     50        void (*conn_failed)(tcp_conn_t *);
     51        void (*conn_reset)(tcp_conn_t *);
     52        void (*data_avail)(tcp_conn_t *);
     53        void (*urg_data)(tcp_conn_t *);
     54} tcp_cb_t;
    5155
    52 /*@}*/
     56typedef struct {
     57        void (*new_conn)(tcp_listener_t *, tcp_conn_t *);
     58} tcp_listen_cb_t;
    5359
    54 /** @name Protocol families definitions
    55  * Same as address families.
    56  */
    57 /*@{*/
     60typedef struct {
     61} tcp_t;
    5862
    59 #define PF_INET   AF_INET
    60 #define PF_INET6  AF_INET6
     63extern int tcp_create(tcp_t **);
     64extern void tcp_destroy(tcp_t *);
     65extern int tcp_conn_create(tcp_t *, inet_ep2_t *, tcp_cb_t *, void *,
     66    tcp_conn_t **);
     67extern void tcp_conn_destroy(tcp_conn_t *);
     68extern void *tcp_conn_userptr(tcp_conn_t *);
     69extern int tcp_listener_create(tcp_t *, inet_ep_t *, tcp_listen_cb_t *, void *,
     70    tcp_cb_t *, void *, tcp_listener_t **);
     71extern void tcp_listener_destroy(tcp_listener_t *);
     72extern void *tcp_listener_userptr(tcp_listener_t *);
    6173
    62 /*@}*/
     74extern int tcp_conn_wait_connected(tcp_conn_t *);
     75extern int tcp_conn_send(tcp_conn_t *, const void *, size_t);
     76extern int tcp_conn_send_fin(tcp_conn_t *);
     77extern int tcp_conn_push(tcp_conn_t *);
     78extern void tcp_conn_reset(tcp_conn_t *);
    6379
    64 /** Socket types. */
    65 typedef enum sock_type {
    66         /** Stream (connection oriented) socket. */
    67         SOCK_STREAM = 1,
    68         /** Datagram (connectionless oriented) socket. */
    69         SOCK_DGRAM = 2,
    70         /** Raw socket. */
    71         SOCK_RAW = 3
    72 } sock_type_t;
     80extern int tcp_conn_recv(tcp_conn_t *, void *, size_t, size_t *);
     81extern int tcp_conn_recv_wait(tcp_conn_t *, void *, size_t, size_t *);
    7382
    74 /** Type definition of the socket length. */
    75 typedef int32_t socklen_t;
    76 
    77 /* Socket options */
    78 
    79 enum {
    80         SOL_SOCKET = 1,
    81 
    82         /* IP link to transmit on */
    83         SO_IPLINK
    84 };
    8583
    8684#endif
  • 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.