Changeset aaa3f33a in mainline
- Timestamp:
- 2010-11-19T21:26:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a7811f17, cc3c2a1c
- Parents:
- 4eca056
- Location:
- uspace
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/net/socket_client.c
r4eca056 raaa3f33a 157 157 158 158 /** Active sockets. */ 159 sockets_ refsockets;159 sockets_t *sockets; 160 160 161 161 /** Safety lock. … … 180 180 * @returns The active sockets. 181 181 */ 182 static sockets_ refsocket_get_sockets(void)182 static sockets_t *socket_get_sockets(void) 183 183 { 184 184 if (!socket_globals.sockets) { 185 185 socket_globals.sockets = 186 (sockets_ ref) malloc(sizeof(sockets_t));186 (sockets_t *) malloc(sizeof(sockets_t)); 187 187 if (!socket_globals.sockets) 188 188 return NULL; … … 327 327 static int socket_generate_new_id(void) 328 328 { 329 sockets_ refsockets;329 sockets_t *sockets; 330 330 int socket_id = 0; 331 331 int count; -
uspace/lib/c/include/adt/generic_char_map.h
r4eca056 raaa3f33a 55 55 \ 56 56 typedef struct name name##_t; \ 57 typedef name##_t *name##_ref; \58 57 \ 59 58 struct name { \ … … 63 62 }; \ 64 63 \ 65 int name##_add(name##_ ref, const char *, const size_t, type *); \66 int name##_count(name##_ ref); \67 void name##_destroy(name##_ ref); \68 void name##_exclude(name##_ ref, const char *, const size_t); \69 type *name##_find(name##_ ref, const char *, const size_t); \70 int name##_initialize(name##_ ref); \71 int name##_is_valid(name##_ ref);64 int name##_add(name##_t *, const char *, const size_t, type *); \ 65 int name##_count(name##_t *); \ 66 void name##_destroy(name##_t *); \ 67 void name##_exclude(name##_t *, const char *, const size_t); \ 68 type *name##_find(name##_t *, const char *, const size_t); \ 69 int name##_initialize(name##_t *); \ 70 int name##_is_valid(name##_t *); 72 71 73 72 /** Character string to generic type map implementation. … … 81 80 GENERIC_FIELD_IMPLEMENT(name##_items, type) \ 82 81 \ 83 int name##_add(name##_ refmap, const char *name, const size_t length, \82 int name##_add(name##_t *map, const char *name, const size_t length, \ 84 83 type *value) \ 85 84 { \ … … 99 98 } \ 100 99 \ 101 int name##_count(name##_ refmap) \100 int name##_count(name##_t *map) \ 102 101 { \ 103 102 return name##_is_valid(map) ? \ … … 105 104 } \ 106 105 \ 107 void name##_destroy(name##_ refmap) \106 void name##_destroy(name##_t *map) \ 108 107 { \ 109 108 if (name##_is_valid(map)) { \ … … 113 112 } \ 114 113 \ 115 void name##_exclude(name##_ refmap, const char *name, \114 void name##_exclude(name##_t *map, const char *name, \ 116 115 const size_t length) \ 117 116 { \ … … 125 124 } \ 126 125 \ 127 type *name##_find(name##_ refmap, const char *name, \126 type *name##_find(name##_t *map, const char *name, \ 128 127 const size_t length) \ 129 128 { \ … … 138 137 } \ 139 138 \ 140 int name##_initialize(name##_ refmap) \139 int name##_initialize(name##_t *map) \ 141 140 { \ 142 141 int rc; \ … … 155 154 } \ 156 155 \ 157 int name##_is_valid(name##_ refmap) \156 int name##_is_valid(name##_t *map) \ 158 157 { \ 159 158 return map && (map->magic == GENERIC_CHAR_MAP_MAGIC_VALUE); \ -
uspace/lib/c/include/adt/generic_field.h
r4eca056 raaa3f33a 53 53 #define GENERIC_FIELD_DECLARE(name, type) \ 54 54 typedef struct name name##_t; \ 55 typedef name##_t *name##_ref; \56 55 \ 57 56 struct name { \ … … 62 61 }; \ 63 62 \ 64 int name##_add(name##_ ref, type *); \65 int name##_count(name##_ ref); \66 void name##_destroy(name##_ ref); \67 void name##_exclude_index(name##_ ref, int); \68 type **name##_get_field(name##_ ref); \69 type *name##_get_index(name##_ ref, int); \70 int name##_initialize(name##_ ref); \71 int name##_is_valid(name##_ ref);63 int name##_add(name##_t *, type *); \ 64 int name##_count(name##_t *); \ 65 void name##_destroy(name##_t *); \ 66 void name##_exclude_index(name##_t *, int); \ 67 type **name##_get_field(name##_t *); \ 68 type *name##_get_index(name##_t *, int); \ 69 int name##_initialize(name##_t *); \ 70 int name##_is_valid(name##_t *); 72 71 73 72 /** Generic type field implementation. … … 79 78 */ 80 79 #define GENERIC_FIELD_IMPLEMENT(name, type) \ 81 int name##_add(name##_ reffield, type *value) \80 int name##_add(name##_t *field, type *value) \ 82 81 { \ 83 82 if (name##_is_valid(field)) { \ … … 99 98 } \ 100 99 \ 101 int name##_count(name##_ reffield) \100 int name##_count(name##_t *field) \ 102 101 { \ 103 102 return name##_is_valid(field) ? field->next : -1; \ 104 103 } \ 105 104 \ 106 void name##_destroy(name##_ reffield) \105 void name##_destroy(name##_t *field) \ 107 106 { \ 108 107 if (name##_is_valid(field)) { \ … … 117 116 } \ 118 117 \ 119 void name##_exclude_index(name##_ reffield, int index) \118 void name##_exclude_index(name##_t *field, int index) \ 120 119 { \ 121 120 if (name##_is_valid(field) && (index >= 0) && \ … … 126 125 } \ 127 126 \ 128 type *name##_get_index(name##_ reffield, int index) \127 type *name##_get_index(name##_t *field, int index) \ 129 128 { \ 130 129 if (name##_is_valid(field) && (index >= 0) && \ … … 134 133 } \ 135 134 \ 136 type **name##_get_field(name##_ reffield) \135 type **name##_get_field(name##_t *field) \ 137 136 { \ 138 137 return name##_is_valid(field) ? field->items : NULL; \ 139 138 } \ 140 139 \ 141 int name##_initialize(name##_ reffield) \140 int name##_initialize(name##_t *field) \ 142 141 { \ 143 142 if (!field) \ … … 153 152 } \ 154 153 \ 155 int name##_is_valid(name##_ reffield) \154 int name##_is_valid(name##_t *field) \ 156 155 { \ 157 156 return field && (field->magic == GENERIC_FIELD_MAGIC_VALUE); \ -
uspace/lib/c/include/adt/int_map.h
r4eca056 raaa3f33a 56 56 #define INT_MAP_DECLARE(name, type) \ 57 57 typedef struct name name##_t; \ 58 typedef name##_t *name##_ref; \59 58 typedef struct name##_item name##_item_t; \ 60 typedef name##_item_t *name##_item_ref; \61 59 \ 62 60 struct name##_item { \ … … 69 67 int size; \ 70 68 int next; \ 71 name##_item_ refitems; \69 name##_item_t *items; \ 72 70 int magic; \ 73 71 }; \ 74 72 \ 75 int name##_add(name##_ ref, int, type *); \76 void name##_clear(name##_ ref); \77 int name##_count(name##_ ref); \78 void name##_destroy(name##_ ref); \79 void name##_exclude(name##_ ref, int); \80 void name##_exclude_index(name##_ ref, int); \81 type *name##_find(name##_ ref, int); \82 int name##_update(name##_ ref, int, int); \83 type *name##_get_index(name##_ ref, int); \84 int name##_initialize(name##_ ref); \85 int name##_is_valid(name##_ ref); \86 void name##_item_destroy(name##_item_ ref); \87 int name##_item_is_valid(name##_item_ ref);73 int name##_add(name##_t *, int, type *); \ 74 void name##_clear(name##_t *); \ 75 int name##_count(name##_t *); \ 76 void name##_destroy(name##_t *); \ 77 void name##_exclude(name##_t *, int); \ 78 void name##_exclude_index(name##_t *, int); \ 79 type *name##_find(name##_t *, int); \ 80 int name##_update(name##_t *, int, int); \ 81 type *name##_get_index(name##_t *, int); \ 82 int name##_initialize(name##_t *); \ 83 int name##_is_valid(name##_t *); \ 84 void name##_item_destroy(name##_item_t *); \ 85 int name##_item_is_valid(name##_item_t *); 88 86 89 87 /** Integer to generic type map implementation. … … 95 93 */ 96 94 #define INT_MAP_IMPLEMENT(name, type) \ 97 int name##_add(name##_ refmap, int key, type *value) \95 int name##_add(name##_t *map, int key, type *value) \ 98 96 { \ 99 97 if (name##_is_valid(map)) { \ 100 98 if (map->next == (map->size - 1)) { \ 101 name##_item_ reftmp; \102 tmp = (name##_item_ ref) realloc(map->items, \99 name##_item_t *tmp; \ 100 tmp = (name##_item_t *) realloc(map->items, \ 103 101 sizeof(name##_item_t) * 2 * map->size); \ 104 102 if (!tmp) \ … … 117 115 } \ 118 116 \ 119 void name##_clear(name##_ refmap) \117 void name##_clear(name##_t *map) \ 120 118 { \ 121 119 if (name##_is_valid(map)) { \ … … 132 130 } \ 133 131 \ 134 int name##_count(name##_ refmap) \132 int name##_count(name##_t *map) \ 135 133 { \ 136 134 return name##_is_valid(map) ? map->next : -1; \ 137 135 } \ 138 136 \ 139 void name##_destroy(name##_ refmap) \137 void name##_destroy(name##_t *map) \ 140 138 { \ 141 139 if (name##_is_valid(map)) { \ … … 152 150 } \ 153 151 \ 154 void name##_exclude(name##_ refmap, int key) \152 void name##_exclude(name##_t *map, int key) \ 155 153 { \ 156 154 if (name##_is_valid(map)) { \ … … 166 164 } \ 167 165 \ 168 void name##_exclude_index(name##_ refmap, int index) \166 void name##_exclude_index(name##_t *map, int index) \ 169 167 { \ 170 168 if (name##_is_valid(map) && (index >= 0) && \ … … 175 173 } \ 176 174 \ 177 type *name##_find(name##_ refmap, int key) \175 type *name##_find(name##_t *map, int key) \ 178 176 { \ 179 177 if (name##_is_valid(map)) { \ … … 189 187 } \ 190 188 \ 191 int name##_update(name##_ refmap, int key, int new_key) \189 int name##_update(name##_t *map, int key, int new_key) \ 192 190 { \ 193 191 if (name##_is_valid(map)) { \ … … 208 206 } \ 209 207 \ 210 type *name##_get_index(name##_ refmap, int index) \208 type *name##_get_index(name##_t *map, int index) \ 211 209 { \ 212 210 if (name##_is_valid(map) && (index >= 0) && \ … … 218 216 } \ 219 217 \ 220 int name##_initialize(name##_ refmap) \218 int name##_initialize(name##_t *map) \ 221 219 { \ 222 220 if (!map) \ … … 224 222 map->size = 2; \ 225 223 map->next = 0; \ 226 map->items = (name##_item_ ref) malloc(sizeof(name##_item_t) * \224 map->items = (name##_item_t *) malloc(sizeof(name##_item_t) * \ 227 225 map->size); \ 228 226 if (!map->items) \ … … 233 231 } \ 234 232 \ 235 int name##_is_valid(name##_ refmap) \233 int name##_is_valid(name##_t *map) \ 236 234 { \ 237 235 return map && (map->magic == INT_MAP_MAGIC_VALUE); \ 238 236 } \ 239 237 \ 240 void name##_item_destroy(name##_item_ refitem) \238 void name##_item_destroy(name##_item_t *item) \ 241 239 { \ 242 240 if (name##_item_is_valid(item)) { \ … … 249 247 } \ 250 248 \ 251 int name##_item_is_valid(name##_item_ refitem) \249 int name##_item_is_valid(name##_item_t *item) \ 252 250 { \ 253 251 return item && (item->magic == INT_MAP_ITEM_MAGIC_VALUE); \ -
uspace/lib/net/adt/module_map.c
r4eca056 raaa3f33a 63 63 */ 64 64 int 65 add_module(module_t **module, modules_ refmodules, const char *name,65 add_module(module_t **module, modules_t *modules, const char *name, 66 66 const char *filename, services_t service, task_id_t task_id, 67 67 connect_module_t connect_module) … … 104 104 * @returns NULL if there is no such module. 105 105 */ 106 module_t *get_running_module(modules_ refmodules, char *name)106 module_t *get_running_module(modules_t *modules, char *name) 107 107 { 108 108 module_t *module; -
uspace/lib/net/include/adt/module_map.h
r4eca056 raaa3f33a 72 72 }; 73 73 74 extern int add_module(module_t **, modules_ ref, const char *, const char *,74 extern int add_module(module_t **, modules_t *, const char *, const char *, 75 75 services_t, task_id_t, connect_module_t *); 76 extern module_t *get_running_module(modules_ ref, char *);76 extern module_t *get_running_module(modules_t *, char *); 77 77 extern task_id_t spawn(const char *); 78 78 -
uspace/lib/net/include/socket_core.h
r4eca056 raaa3f33a 108 108 INT_MAP_DECLARE(socket_ports, socket_port_t); 109 109 110 extern void socket_cores_release(int, socket_cores_ ref, socket_ports_ref,110 extern void socket_cores_release(int, socket_cores_t *, socket_ports_t *, 111 111 void (*)(socket_core_t *)); 112 extern int socket_bind(socket_cores_ ref, socket_ports_ref, int, void *, size_t,112 extern int socket_bind(socket_cores_t *, socket_ports_t *, int, void *, size_t, 113 113 int, int, int); 114 extern int socket_bind_free_port(socket_ports_ ref, socket_core_t *, int, int,114 extern int socket_bind_free_port(socket_ports_t *, socket_core_t *, int, int, 115 115 int); 116 extern int socket_create(socket_cores_ ref, int, void *, int *);117 extern int socket_destroy(int, int, socket_cores_ ref, socket_ports_ref,116 extern int socket_create(socket_cores_t *, int, void *, int *); 117 extern int socket_destroy(int, int, socket_cores_t *, socket_ports_t *, 118 118 void (*)(socket_core_t *)); 119 119 extern int socket_reply_packets(packet_t, size_t *); 120 extern socket_core_t *socket_port_find(socket_ports_ ref, int, const char *,120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const char *, 121 121 size_t); 122 extern void socket_port_release(socket_ports_ ref, socket_core_t *);123 extern int socket_port_add(socket_ports_ ref, int, socket_core_t *,122 extern void socket_port_release(socket_ports_t *, socket_core_t *); 123 extern int socket_port_add(socket_ports_t *, int, socket_core_t *, 124 124 const char *, size_t); 125 125 -
uspace/lib/net/tl/socket_core.c
r4eca056 raaa3f33a 86 86 static void 87 87 socket_destroy_core(int packet_phone, socket_core_t *socket, 88 socket_cores_ ref local_sockets, socket_ports_refglobal_sockets,88 socket_cores_t *local_sockets, socket_ports_t *global_sockets, 89 89 void (* socket_release)(socket_core_t *socket)) 90 90 { … … 121 121 */ 122 122 void 123 socket_cores_release(int packet_phone, socket_cores_ reflocal_sockets,124 socket_ports_ refglobal_sockets,123 socket_cores_release(int packet_phone, socket_cores_t *local_sockets, 124 socket_ports_t *global_sockets, 125 125 void (* socket_release)(socket_core_t *socket)) 126 126 { … … 200 200 */ 201 201 static int 202 socket_bind_insert(socket_ports_ refglobal_sockets, socket_core_t *socket,202 socket_bind_insert(socket_ports_t *global_sockets, socket_core_t *socket, 203 203 int port) 204 204 { … … 258 258 */ 259 259 int 260 socket_bind(socket_cores_ ref local_sockets, socket_ports_refglobal_sockets,260 socket_bind(socket_cores_t *local_sockets, socket_ports_t *global_sockets, 261 261 int socket_id, void *addr, size_t addrlen, int free_ports_start, 262 262 int free_ports_end, int last_used_port) … … 328 328 */ 329 329 int 330 socket_bind_free_port(socket_ports_ refglobal_sockets, socket_core_t *socket,330 socket_bind_free_port(socket_ports_t *global_sockets, socket_core_t *socket, 331 331 int free_ports_start, int free_ports_end, int last_used_port) 332 332 { … … 370 370 * @returns ELIMIT if there is no socket identifier available. 371 371 */ 372 static int socket_generate_new_id(socket_cores_ reflocal_sockets, int positive)372 static int socket_generate_new_id(socket_cores_t *local_sockets, int positive) 373 373 { 374 374 int socket_id; … … 415 415 */ 416 416 int 417 socket_create(socket_cores_ reflocal_sockets, int app_phone,417 socket_create(socket_cores_t *local_sockets, int app_phone, 418 418 void *specific_data, int *socket_id) 419 419 { … … 486 486 */ 487 487 int 488 socket_destroy(int packet_phone, int socket_id, socket_cores_ reflocal_sockets,489 socket_ports_ refglobal_sockets,488 socket_destroy(int packet_phone, int socket_id, socket_cores_t *local_sockets, 489 socket_ports_t *global_sockets, 490 490 void (*socket_release)(socket_core_t *socket)) 491 491 { … … 602 602 */ 603 603 socket_core_t * 604 socket_port_find(socket_ports_ refglobal_sockets, int port, const char *key,604 socket_port_find(socket_ports_t *global_sockets, int port, const char *key, 605 605 size_t key_length) 606 606 { … … 628 628 */ 629 629 void 630 socket_port_release(socket_ports_ refglobal_sockets, socket_core_t *socket)630 socket_port_release(socket_ports_t *global_sockets, socket_core_t *socket) 631 631 { 632 632 socket_port_t *socket_port; … … 679 679 */ 680 680 int 681 socket_port_add(socket_ports_ refglobal_sockets, int port,681 socket_port_add(socket_ports_t *global_sockets, int port, 682 682 socket_core_t *socket, const char *key, size_t key_length) 683 683 { -
uspace/srv/net/net/net.c
r4eca056 raaa3f33a 88 88 * 89 89 */ 90 int add_configuration(measured_strings_ refconfiguration, const char *name,90 int add_configuration(measured_strings_t *configuration, const char *name, 91 91 const char *value) 92 92 { … … 117 117 } 118 118 119 static int parse_line(measured_strings_ refconfiguration, char *line)119 static int parse_line(measured_strings_t *configuration, char *line) 120 120 { 121 121 int rc; … … 179 179 180 180 static int read_configuration_file(const char *directory, const char *filename, 181 measured_strings_ refconfiguration)181 measured_strings_t *configuration) 182 182 { 183 183 printf("%s: Reading configuration file %s/%s\n", NAME, directory, filename); … … 356 356 * 357 357 */ 358 static int net_get_conf(measured_strings_ refnetif_conf,358 static int net_get_conf(measured_strings_t *netif_conf, 359 359 measured_string_t *configuration, size_t count, char **data) 360 360 { -
uspace/srv/net/net/net.h
r4eca056 raaa3f33a 133 133 } net_globals_t; 134 134 135 extern int add_configuration(measured_strings_ ref, const char *, const char *);135 extern int add_configuration(measured_strings_t *, const char *, const char *); 136 136 extern int net_module_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, int *); 137 137 extern int net_initialize_build(async_client_conn_t); -
uspace/srv/net/tl/tcp/tcp.c
r4eca056 raaa3f33a 139 139 140 140 /** Local sockets. */ 141 socket_cores_ reflocal_sockets;141 socket_cores_t *local_sockets; 142 142 143 143 /** Socket identifier. */ … … 172 172 173 173 static int tcp_process_packet(device_id_t, packet_t, services_t); 174 static int tcp_connect_core(socket_core_t *, socket_cores_ ref,174 static int tcp_connect_core(socket_core_t *, socket_cores_t *, 175 175 struct sockaddr *, socklen_t); 176 176 static int tcp_queue_prepare_packet(socket_core_t *, tcp_socket_data_t *, … … 209 209 static int tcp_process_client_messages(ipc_callid_t, ipc_call_t); 210 210 211 static int tcp_listen_message(socket_cores_ ref, int, int);212 static int tcp_connect_message(socket_cores_ ref, int, struct sockaddr *,211 static int tcp_listen_message(socket_cores_t *, int, int); 212 static int tcp_connect_message(socket_cores_t *, int, struct sockaddr *, 213 213 socklen_t); 214 static int tcp_recvfrom_message(socket_cores_ ref, int, int, size_t *);215 static int tcp_send_message(socket_cores_ ref, int, int, size_t *, int);216 static int tcp_accept_message(socket_cores_ ref, int, int, size_t *, size_t *);217 static int tcp_close_message(socket_cores_ ref, int);214 static int tcp_recvfrom_message(socket_cores_t *, int, int, size_t *); 215 static int tcp_send_message(socket_cores_t *, int, int, size_t *, int); 216 static int tcp_accept_message(socket_cores_t *, int, int, size_t *, size_t *); 217 static int tcp_close_message(socket_cores_t *, int); 218 218 219 219 /** TCP global data. */ … … 1678 1678 } 1679 1679 1680 int tcp_listen_message(socket_cores_ reflocal_sockets, int socket_id,1680 int tcp_listen_message(socket_cores_t *local_sockets, int socket_id, 1681 1681 int backlog) 1682 1682 { … … 1704 1704 } 1705 1705 1706 int tcp_connect_message(socket_cores_ reflocal_sockets, int socket_id,1706 int tcp_connect_message(socket_cores_t *local_sockets, int socket_id, 1707 1707 struct sockaddr *addr, socklen_t addrlen) 1708 1708 { … … 1732 1732 } 1733 1733 1734 int tcp_connect_core(socket_core_t *socket, socket_cores_ reflocal_sockets,1734 int tcp_connect_core(socket_core_t *socket, socket_cores_t *local_sockets, 1735 1735 struct sockaddr *addr, socklen_t addrlen) 1736 1736 { … … 2091 2091 } 2092 2092 2093 int tcp_recvfrom_message(socket_cores_ reflocal_sockets, int socket_id,2093 int tcp_recvfrom_message(socket_cores_t *local_sockets, int socket_id, 2094 2094 int flags, size_t *addrlen) 2095 2095 { … … 2149 2149 } 2150 2150 2151 int tcp_send_message(socket_cores_ reflocal_sockets, int socket_id,2151 int tcp_send_message(socket_cores_t *local_sockets, int socket_id, 2152 2152 int fragments, size_t *data_fragment_size, int flags) 2153 2153 { … … 2225 2225 2226 2226 int 2227 tcp_close_message(socket_cores_ reflocal_sockets, int socket_id)2227 tcp_close_message(socket_cores_t *local_sockets, int socket_id) 2228 2228 { 2229 2229 socket_core_t *socket; … … 2327 2327 } 2328 2328 2329 int tcp_accept_message(socket_cores_ reflocal_sockets, int socket_id,2329 int tcp_accept_message(socket_cores_t *local_sockets, int socket_id, 2330 2330 int new_socket_id, size_t *data_fragment_size, size_t *addrlen) 2331 2331 { -
uspace/srv/net/tl/tcp/tcp.h
r4eca056 raaa3f33a 262 262 uint16_t dest_port; 263 263 /** Parent local sockets. */ 264 socket_cores_ reflocal_sockets;264 socket_cores_t *local_sockets; 265 265 266 266 /** Local sockets safety lock. -
uspace/srv/net/tl/udp/udp.c
r4eca056 raaa3f33a 453 453 * function. 454 454 */ 455 static int udp_sendto_message(socket_cores_ reflocal_sockets, int socket_id,455 static int udp_sendto_message(socket_cores_t *local_sockets, int socket_id, 456 456 const struct sockaddr *addr, socklen_t addrlen, int fragments, 457 457 size_t *data_fragment_size, int flags) … … 609 609 * function. 610 610 */ 611 static int udp_recvfrom_message(socket_cores_ reflocal_sockets, int socket_id,611 static int udp_recvfrom_message(socket_cores_t *local_sockets, int socket_id, 612 612 int flags, size_t *addrlen) 613 613 {
Note:
See TracChangeset
for help on using the changeset viewer.