Changeset fab2746 in mainline for uspace/lib/c/include/inet/udp.h
- 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
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.