Changeset fab2746 in mainline for uspace/lib/c/include
- Timestamp:
- 2015-04-08T21:25:30Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99ea91b2
- Parents:
- ba0eac5
- Location:
- uspace/lib/c/include
- Files:
-
- 1 added
- 8 deleted
- 3 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/errno.h
rba0eac5 rfab2746 68 68 #define ENAK (-303) 69 69 70 /** An API function is called while another blocking function is in progress. */71 #define EINPROGRESS (-10036)72 73 /** The socket identifier is not valid. */74 #define ENOTSOCK (-10038)75 76 /** The destination address required. */77 #define EDESTADDRREQ (-10039)78 79 /** Protocol is not supported. */80 #define EPROTONOSUPPORT (-10043)81 82 /** Socket type is not supported. */83 #define ESOCKTNOSUPPORT (-10044)84 85 /** Protocol family is not supported. */86 #define EPFNOSUPPORT (-10046)87 88 /** Address family is not supported. */89 #define EAFNOSUPPORT (-10047)90 91 /** Address is already in use. */92 #define EADDRINUSE (-10048)93 94 /** The socket is not connected or bound. */95 #define ENOTCONN (-10057)96 97 #define ECONNREFUSED (-10058)98 99 #define ECONNABORTED (-10059)100 101 70 /** The requested operation was not performed. Try again later. */ 102 71 #define EAGAIN (-11002) 103 104 /** No data. */105 #define NO_DATA (-11004)106 72 107 73 #endif -
uspace/lib/c/include/inet/addr.h
rba0eac5 rfab2746 37 37 38 38 #include <stdint.h> 39 #include <net/in.h>40 #include <net/in6.h>41 #include <net/socket.h>42 39 43 40 typedef uint32_t addr32_t; … … 126 123 extern void inet_addr_set(addr32_t, inet_addr_t *); 127 124 extern 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 *);129 125 130 126 extern void inet_addr_set6(addr128_t, inet_addr_t *); 131 127 extern 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 *);140 128 141 129 #endif -
uspace/lib/c/include/inet/endpoint.h
rba0eac5 rfab2746 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2015 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup libc 30 * @{ 30 * @{ 31 */ 32 /** @file 31 33 */ 32 34 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_ 39 37 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> 42 41 43 /** @name IP protocols definitions */ 44 /*@{*/ 42 /** Internet endpoint (address-port pair), a.k.a. socket */ 43 typedef struct { 44 inet_addr_t addr; 45 uint16_t port; 46 } inet_ep_t; 45 47 46 #define IPPROTO_ICMP 1 47 #define IPPROTO_TCP 6 48 #define IPPROTO_UDP 17 49 #define IPPROTO_ICMPV6 58 48 /** Internet endpoint pair */ 49 typedef struct { 50 service_id_t local_link; 51 inet_ep_t local; 52 inet_ep_t remote; 53 } inet_ep2_t; 50 54 51 /*@}*/ 55 extern void inet_ep_init(inet_ep_t *); 56 extern void inet_ep2_init(inet_ep2_t *); 52 57 53 58 #endif -
uspace/lib/c/include/inet/tcp.h
rba0eac5 rfab2746 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2015 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup libc 30 * @{ 30 * @{ 31 */ 32 /** @file 31 33 */ 32 34 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_ 37 37 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> 40 41 41 #include <sys/types.h> 42 typedef struct { 43 } tcp_conn_t; 42 44 43 /** @name Address families definitions */ 44 /*@{*/ 45 typedef struct { 46 } tcp_listener_t; 45 47 46 enum { 47 AF_NONE = 0, 48 AF_INET, /* IPv4 address */ 49 AF_INET6 /* IPv6 address */ 50 }; 48 typedef 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; 51 55 52 /*@}*/ 56 typedef struct { 57 void (*new_conn)(tcp_listener_t *, tcp_conn_t *); 58 } tcp_listen_cb_t; 53 59 54 /** @name Protocol families definitions 55 * Same as address families. 56 */ 57 /*@{*/ 60 typedef struct { 61 } tcp_t; 58 62 59 #define PF_INET AF_INET 60 #define PF_INET6 AF_INET6 63 extern int tcp_create(tcp_t **); 64 extern void tcp_destroy(tcp_t *); 65 extern int tcp_conn_create(tcp_t *, inet_ep2_t *, tcp_cb_t *, void *, 66 tcp_conn_t **); 67 extern void tcp_conn_destroy(tcp_conn_t *); 68 extern void *tcp_conn_userptr(tcp_conn_t *); 69 extern int tcp_listener_create(tcp_t *, inet_ep_t *, tcp_listen_cb_t *, void *, 70 tcp_cb_t *, void *, tcp_listener_t **); 71 extern void tcp_listener_destroy(tcp_listener_t *); 72 extern void *tcp_listener_userptr(tcp_listener_t *); 61 73 62 /*@}*/ 74 extern int tcp_conn_wait_connected(tcp_conn_t *); 75 extern int tcp_conn_send(tcp_conn_t *, const void *, size_t); 76 extern int tcp_conn_send_fin(tcp_conn_t *); 77 extern int tcp_conn_push(tcp_conn_t *); 78 extern void tcp_conn_reset(tcp_conn_t *); 63 79 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; 80 extern int tcp_conn_recv(tcp_conn_t *, void *, size_t, size_t *); 81 extern int tcp_conn_recv_wait(tcp_conn_t *, void *, size_t, size_t *); 73 82 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_IPLINK84 };85 83 86 84 #endif -
uspace/lib/c/include/inet/udp.h
rba0eac5 rfab2746 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2015 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup libc 30 * @{ 30 * @{ 31 */ 32 /** @file 31 33 */ 32 34 33 /** @file 34 * Character string to integer map. 35 */ 35 #ifndef LIBC_INET_UDP_H_ 36 #define LIBC_INET_UDP_H_ 36 37 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> 39 42 40 #include <libarch/types.h> 43 typedef enum { 44 udp_ls_down, 45 udp_ls_up 46 } udp_link_state_t; 41 47 42 /** Invalid assigned value used also if an entry does not exist. */ 43 #define CHAR_MAP_NULL (-1) 48 typedef struct { 49 struct udp *udp; 50 sysarg_t assoc_id; 51 size_t size; 52 inet_ep_t remote_ep; 53 } udp_rmsg_t; 44 54 45 /** Type definition of the character string to integer map. 46 * @see char_map 47 */ 48 typedef struct char_map char_map_t; 55 typedef struct { 56 } udp_rerr_t; 49 57 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 }; 58 typedef 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; 70 65 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); 66 typedef 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 72 typedef 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 79 extern int udp_create(udp_t **); 80 extern void udp_destroy(udp_t *); 81 extern int udp_assoc_create(udp_t *, inet_ep2_t *, udp_cb_t *, void *, 82 udp_assoc_t **); 83 extern void udp_assoc_destroy(udp_assoc_t *); 84 extern int udp_assoc_send_msg(udp_assoc_t *, inet_ep_t *, void *, size_t); 85 extern void *udp_assoc_userptr(udp_assoc_t *); 86 extern size_t udp_rmsg_size(udp_rmsg_t *); 87 extern int udp_rmsg_read(udp_rmsg_t *, size_t, void *, size_t); 88 extern void udp_rmsg_remote_ep(udp_rmsg_t *, inet_ep_t *); 89 extern uint8_t udp_rerr_type(udp_rerr_t *); 90 extern uint8_t udp_rerr_code(udp_rerr_t *); 77 91 78 92 #endif -
uspace/lib/c/include/ipc/services.h
rba0eac5 rfab2746 49 49 SERVICE_IRC = FOURCC('i', 'r', 'c', ' '), 50 50 SERVICE_CLIPBOARD = FOURCC('c', 'l', 'i', 'p'), 51 SERVICE_UDP = FOURCC('u', 'd', 'p', ' '),52 SERVICE_TCP = FOURCC('t', 'c', 'p', ' ')53 51 } services_t; 54 52 … … 61 59 #define SERVICE_NAME_INETPING6 "net/inetping6" 62 60 #define SERVICE_NAME_NETCONF "net/netconf" 61 #define SERVICE_NAME_UDP "net/udp" 62 #define SERVICE_NAME_TCP "net/tcp" 63 63 64 64 #endif -
uspace/lib/c/include/ipc/udp.h
rba0eac5 rfab2746 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2015 Jiri Svobda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup socket29 /** @addtogroup libcipc 30 30 * @{ 31 31 */ 32 33 32 /** @file 34 * Command-line argument parsing functions related to networking.35 33 */ 36 34 37 extern int socket_parse_address_family(const char *, int *); 38 extern int socket_parse_protocol_family(const char *, int *); 39 extern int socket_parse_socket_type(const char *, int *); 35 #ifndef LIBC_IPC_UDP_H_ 36 #define LIBC_IPC_UDP_H_ 37 38 #include <ipc/common.h> 39 40 typedef enum { 41 UDP_CALLBACK_CREATE = IPC_FIRST_USER_METHOD, 42 UDP_ASSOC_CREATE, 43 UDP_ASSOC_DESTROY, 44 UDP_ASSOC_SEND_MSG, 45 UDP_RMSG_INFO, 46 UDP_RMSG_READ, 47 UDP_RMSG_DISCARD 48 } udp_request_t; 49 50 typedef enum { 51 UDP_EV_DATA = IPC_FIRST_USER_METHOD 52 } udp_event_t; 53 54 #endif 40 55 41 56 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.