Changeset 61bfc370 in mainline
- Timestamp:
- 2011-01-07T18:57:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e08a733
- Parents:
- 7c34b28f
- Location:
- uspace
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/char_map.c
r7c34b28f r61bfc370 65 65 */ 66 66 static int 67 char_map_add_item(char_map_t *map, const char*identifier, size_t length,67 char_map_add_item(char_map_t *map, const uint8_t *identifier, size_t length, 68 68 const int value) 69 69 { … … 139 139 */ 140 140 int 141 char_map_add(char_map_t *map, const char*identifier, size_t length,141 char_map_add(char_map_t *map, const uint8_t *identifier, size_t length, 142 142 const int value) 143 143 { … … 200 200 */ 201 201 static char_map_t * 202 char_map_find_node(const char_map_t *map, const char*identifier,202 char_map_find_node(const char_map_t *map, const uint8_t *identifier, 203 203 size_t length) 204 204 { … … 241 241 * @return CHAR_MAP_NULL if the key is not assigned a value. 242 242 */ 243 int char_map_exclude(char_map_t *map, const char*identifier, size_t length)243 int char_map_exclude(char_map_t *map, const uint8_t *identifier, size_t length) 244 244 { 245 245 char_map_t *node; … … 269 269 * @return CHAR_MAP_NULL if the key is not assigned a value. 270 270 */ 271 int char_map_find(const char_map_t *map, const char*identifier, size_t length)271 int char_map_find(const char_map_t *map, const uint8_t *identifier, size_t length) 272 272 { 273 273 char_map_t *node; … … 329 329 */ 330 330 int 331 char_map_update(char_map_t *map, const char*identifier, const size_t length,331 char_map_update(char_map_t *map, const uint8_t *identifier, const size_t length, 332 332 const int value) 333 333 { -
uspace/lib/c/generic/adt/measured_strings.c
r7c34b28f r61bfc370 59 59 */ 60 60 measured_string_t * 61 measured_string_create_bulk(const char*string, size_t length)61 measured_string_create_bulk(const uint8_t *string, size_t length) 62 62 { 63 63 measured_string_t *new; … … 68 68 } 69 69 new = (measured_string_t *) malloc(sizeof(measured_string_t) + 70 (sizeof( char) * (length + 1)));70 (sizeof(uint8_t) * (length + 1))); 71 71 if (!new) 72 72 return NULL; 73 73 74 74 new->length = length; 75 new->value = (( char*) new) + sizeof(measured_string_t);75 new->value = ((uint8_t *) new) + sizeof(measured_string_t); 76 76 // append terminating zero explicitly - to be safe 77 77 memcpy(new->value, string, new->length); … … 97 97 new = (measured_string_t *) malloc(sizeof(measured_string_t)); 98 98 if (new) { 99 new->value = ( char*) malloc(source->length + 1);99 new->value = (uint8_t *) malloc(source->length + 1); 100 100 if (new->value) { 101 101 new->length = source->length; … … 131 131 */ 132 132 int 133 measured_strings_receive(measured_string_t **strings, char**data,133 measured_strings_receive(measured_string_t **strings, uint8_t **data, 134 134 size_t count) 135 135 { … … 137 137 size_t index; 138 138 size_t length; 139 char*next;139 uint8_t *next; 140 140 ipc_callid_t callid; 141 141 int rc; … … 311 311 */ 312 312 int 313 measured_strings_return(int phone, measured_string_t **strings, char**data,313 measured_strings_return(int phone, measured_string_t **strings, uint8_t **data, 314 314 size_t count) 315 315 { 316 316 size_t *lengths; 317 317 size_t index; 318 char*next;318 uint8_t *next; 319 319 int rc; 320 320 -
uspace/lib/c/generic/mem.c
r7c34b28f r61bfc370 222 222 /** Compare two memory areas. 223 223 * 224 * @param s1 Pointer to the first area to compare. 225 * @param s2 Pointer to the second area to compare. 226 * @param len Size of the first area in bytes. Both areas must have 227 * the same length. 228 * @return If len is 0, return zero. If the areas match, return 229 * zero. Otherwise return non-zero. 230 */ 231 int bcmp(const char *s1, const char *s2, size_t len) 232 { 233 for (; len && *s1++ == *s2++; len--) 234 ; 224 * @param s1 Pointer to the first area to compare. 225 * @param s2 Pointer to the second area to compare. 226 * @param len Size of the first area in bytes. Both areas must have 227 * the same length. 228 * 229 * @return If len is 0, return zero. If the areas match, return 230 * zero. Otherwise return non-zero. 231 * 232 */ 233 int bcmp(const void *s1, const void *s2, size_t len) 234 { 235 uint8_t *u1 = (uint8_t *) s1; 236 uint8_t *u2 = (uint8_t *) s2; 237 238 for (; (len != 0) && (*u1++ == *u2++); len--); 239 235 240 return len; 236 241 } -
uspace/lib/c/include/adt/char_map.h
r7c34b28f r61bfc370 41 41 42 42 /** Invalid assigned value used also if an entry does not exist. */ 43 #define CHAR_MAP_NULL 43 #define CHAR_MAP_NULL (-1) 44 44 45 45 /** Type definition of the character string to integer map. 46 46 * @see char_map 47 47 */ 48 typedef struct char_map 48 typedef struct char_map char_map_t; 49 49 50 50 /** Character string to integer map item. … … 56 56 struct char_map { 57 57 /** Actually mapped character. */ 58 charc;58 uint8_t c; 59 59 /** Stored integral value. */ 60 60 int value; … … 71 71 extern int char_map_initialize(char_map_t *); 72 72 extern void char_map_destroy(char_map_t *); 73 extern int char_map_exclude(char_map_t *, const char*, size_t);74 extern int char_map_add(char_map_t *, const char*, size_t, const int);75 extern int char_map_find(const char_map_t *, const char*, size_t);76 extern int char_map_update(char_map_t *, const char*, size_t, const int);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); 77 77 78 78 #endif -
uspace/lib/c/include/adt/generic_char_map.h
r7c34b28f r61bfc370 62 62 }; \ 63 63 \ 64 int name##_add(name##_t *, const char*, const size_t, type *); \64 int name##_add(name##_t *, const uint8_t *, const size_t, type *); \ 65 65 int name##_count(name##_t *); \ 66 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); \67 void name##_exclude(name##_t *, const uint8_t *, const size_t); \ 68 type *name##_find(name##_t *, const uint8_t *, const size_t); \ 69 69 int name##_initialize(name##_t *); \ 70 70 int name##_is_valid(name##_t *); … … 74 74 * Should follow declaration with the same parameters. 75 75 * 76 * @param[in] name Name of the map. 77 * @param[in] type Inner object type. 76 * @param[in] name Name of the map. 77 * @param[in] type Inner object type. 78 * 78 79 */ 79 80 #define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \ 80 81 GENERIC_FIELD_IMPLEMENT(name##_items, type) \ 81 82 \ 82 int name##_add(name##_t *map, const char*name, const size_t length, \83 int name##_add(name##_t *map, const uint8_t *name, const size_t length, \ 83 84 type *value) \ 84 85 { \ … … 112 113 } \ 113 114 \ 114 void name##_exclude(name##_t *map, const char*name, \115 void name##_exclude(name##_t *map, const uint8_t *name, \ 115 116 const size_t length) \ 116 117 { \ … … 124 125 } \ 125 126 \ 126 type *name##_find(name##_t *map, const char*name, \127 type *name##_find(name##_t *map, const uint8_t *name, \ 127 128 const size_t length) \ 128 129 { \ -
uspace/lib/c/include/adt/measured_strings.h
r7c34b28f r61bfc370 54 54 struct measured_string { 55 55 /** Character string data. */ 56 char*value;56 uint8_t *value; 57 57 /** Character string length. */ 58 58 size_t length; 59 59 }; 60 60 61 extern measured_string_t *measured_string_create_bulk(const char*, size_t);61 extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t); 62 62 extern measured_string_t *measured_string_copy(measured_string_t *); 63 extern int measured_strings_receive(measured_string_t **, char**, size_t);63 extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t); 64 64 extern int measured_strings_reply(const measured_string_t *, size_t); 65 extern int measured_strings_return(int, measured_string_t **, char**, size_t);65 extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t); 66 66 extern int measured_strings_send(int, const measured_string_t *, size_t); 67 67 -
uspace/lib/c/include/mem.h
r7c34b28f r61bfc370 44 44 extern void *memmove(void *, const void *, size_t); 45 45 46 extern int bcmp(const char *, const char*, size_t);46 extern int bcmp(const void *, const void *, size_t); 47 47 48 48 #endif -
uspace/lib/net/adt/module_map.c
r7c34b28f r61bfc370 63 63 */ 64 64 int 65 add_module(module_t **module, modules_t *modules, const char*name,66 const char*filename, services_t service, task_id_t task_id,65 add_module(module_t **module, modules_t *modules, const uint8_t *name, 66 const uint8_t *filename, services_t service, task_id_t task_id, 67 67 connect_module_t connect_module) 68 68 { … … 104 104 * @return NULL if there is no such module. 105 105 */ 106 module_t *get_running_module(modules_t *modules, char*name)106 module_t *get_running_module(modules_t *modules, uint8_t *name) 107 107 { 108 108 module_t *module; … … 113 113 114 114 if (!module->task_id) { 115 module->task_id = spawn(module->filename);115 module->task_id = net_spawn(module->filename); 116 116 if (!module->task_id) 117 117 return NULL; … … 123 123 } 124 124 125 /** Start sthe given module.125 /** Start the given module. 126 126 * 127 * @param[in] fname The module full or relative path filename. 128 * @return The new module task identifier on success. 129 * @return Zero if there is no such module. 127 * @param[in] fname The module full or relative path filename. 128 * 129 * @return The new module task identifier on success. 130 * @return Zero if there is no such module. 131 * 130 132 */ 131 task_id_t spawn(const char*fname)133 task_id_t net_spawn(const uint8_t *fname) 132 134 { 133 135 task_id_t id; 134 136 int rc; 135 137 136 rc = task_spawnl(&id, fname,fname, NULL);138 rc = task_spawnl(&id, (const char *) fname, (const char *) fname, NULL); 137 139 if (rc != EOK) 138 140 return 0; -
uspace/lib/net/generic/generic.c
r7c34b28f r61bfc370 112 112 message_id = async_send_1(phone, (sysarg_t) message, 113 113 (sysarg_t) device_id, NULL); 114 string = measured_strings_return(phone, address, (char **)data, 1);114 string = measured_strings_return(phone, address, data, 1); 115 115 async_wait_for(message_id, &result); 116 116 … … 234 234 generic_translate_req(int phone, int message, device_id_t device_id, 235 235 services_t service, measured_string_t *configuration, size_t count, 236 measured_string_t **translation, char**data)236 measured_string_t **translation, uint8_t **data) 237 237 { 238 238 aid_t message_id; -
uspace/lib/net/generic/net_remote.c
r7c34b28f r61bfc370 63 63 * @see net_get_conf_req() 64 64 */ 65 void net_free_settings(measured_string_t *settings, char*data)65 void net_free_settings(measured_string_t *settings, uint8_t *data) 66 66 { 67 67 if (settings) … … 91 91 int 92 92 net_get_conf_req(int net_phone, measured_string_t **configuration, 93 size_t count, char**data)93 size_t count, uint8_t **data) 94 94 { 95 95 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, … … 118 118 int 119 119 net_get_device_conf_req(int net_phone, device_id_t device_id, 120 measured_string_t **configuration, size_t count, char**data)120 measured_string_t **configuration, size_t count, uint8_t **data) 121 121 { 122 122 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, -
uspace/lib/net/il/arp_remote.c
r7c34b28f r61bfc370 165 165 int 166 166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, 167 measured_string_t *address, measured_string_t **translation, char**data)167 measured_string_t *address, measured_string_t **translation, uint8_t **data) 168 168 { 169 169 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, -
uspace/lib/net/include/adt/module_map.h
r7c34b28f r61bfc370 65 65 int usage; 66 66 /** Module name. */ 67 const char*name;67 const uint8_t *name; 68 68 /** Module full path filename. */ 69 const char*filename;69 const uint8_t *filename; 70 70 /** Connecting function. */ 71 71 connect_module_t *connect_module; 72 72 }; 73 73 74 extern int add_module(module_t **, modules_t *, const char *, const char*,75 services_t, task_id_t, connect_module_t *);76 extern module_t *get_running_module(modules_t *, char*);77 extern task_id_t spawn(const char*);74 extern int add_module(module_t **, modules_t *, const uint8_t *, 75 const uint8_t *, services_t, task_id_t, connect_module_t *); 76 extern module_t *get_running_module(modules_t *, uint8_t *); 77 extern task_id_t net_spawn(const uint8_t *); 78 78 79 79 #endif -
uspace/lib/net/include/arp_interface.h
r7c34b28f r61bfc370 50 50 measured_string_t *); 51 51 extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *, 52 measured_string_t **, char**);52 measured_string_t **, uint8_t **); 53 53 extern int arp_clear_device_req(int, device_id_t); 54 54 extern int arp_clear_address_req(int, device_id_t, services_t, -
uspace/lib/net/include/generic.h
r7c34b28f r61bfc370 58 58 services_t, services_t); 59 59 extern int generic_translate_req(int, int, device_id_t, services_t, 60 measured_string_t *, size_t, measured_string_t **, char**);60 measured_string_t *, size_t, measured_string_t **, uint8_t **); 61 61 62 62 #endif -
uspace/lib/net/include/net_interface.h
r7c34b28f r61bfc370 45 45 46 46 extern int net_get_device_conf_req(int, device_id_t, measured_string_t **, 47 size_t, char**);48 extern int net_get_conf_req(int, measured_string_t **, size_t, char**);49 extern void net_free_settings(measured_string_t *, char*);47 size_t, uint8_t **); 48 extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **); 49 extern void net_free_settings(measured_string_t *, uint8_t *); 50 50 extern int net_connect_module(void); 51 51 -
uspace/lib/net/include/socket_core.h
r7c34b28f r61bfc370 86 86 void *specific_data; 87 87 /** Socket ports map key. */ 88 const char*key;88 const uint8_t *key; 89 89 /** Length of the Socket ports map key. */ 90 90 size_t key_length; … … 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_t *, int, const char*,120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *, 121 121 size_t); 122 122 extern void socket_port_release(socket_ports_t *, socket_core_t *); 123 123 extern int socket_port_add(socket_ports_t *, int, socket_core_t *, 124 const char*, size_t);124 const uint8_t *, size_t); 125 125 126 126 #endif -
uspace/lib/net/netif/netif_local.c
r7c34b28f r61bfc370 221 221 fibril_rwlock_read_unlock(&netif_globals.lock); 222 222 223 *data = ( uint8_t *) (**address).value;223 *data = (**address).value; 224 224 225 225 return rc; -
uspace/lib/net/tl/socket_core.c
r7c34b28f r61bfc370 161 161 static int 162 162 socket_port_add_core(socket_port_t *socket_port, socket_core_t *socket, 163 const char*key, size_t key_length)163 const uint8_t *key, size_t key_length) 164 164 { 165 165 socket_core_t **socket_ref; … … 216 216 goto fail; 217 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,219 0);218 rc = socket_port_add_core(socket_port, socket, 219 (const uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 220 220 if (rc != EOK) 221 221 goto fail; … … 602 602 */ 603 603 socket_core_t * 604 socket_port_find(socket_ports_t *global_sockets, int port, const char*key,604 socket_port_find(socket_ports_t *global_sockets, int port, const uint8_t *key, 605 605 size_t key_length) 606 606 { … … 680 680 int 681 681 socket_port_add(socket_ports_t *global_sockets, int port, 682 socket_core_t *socket, const char*key, size_t key_length)682 socket_core_t *socket, const uint8_t *key, size_t key_length) 683 683 { 684 684 socket_port_t *socket_port; -
uspace/srv/hw/netif/dp8390/dp8390.c
r7c34b28f r61bfc370 550 550 if ((length < ETH_MIN_PACK_SIZE) || (length > ETH_MAX_PACK_SIZE_TAGGED)) { 551 551 printf("Packet with strange length arrived: %zu\n", length); 552 next = curr;552 next = curr; 553 553 } else if ((next < dep->de_startpage) || (next >= dep->de_stoppage)) { 554 554 printf("Strange next page\n"); 555 next = curr;555 next = curr; 556 556 } else if (header.dr_status & RSR_FO) { 557 557 /* -
uspace/srv/hw/netif/dp8390/dp8390_module.c
r7c34b28f r61bfc370 213 213 return rc; 214 214 215 address->value = ( char *) (&((dpeth_t *) device->specific)->de_address);215 address->value = (uint8_t *) &((dpeth_t *) device->specific)->de_address; 216 216 address->length = sizeof(ether_addr_t); 217 217 return EOK; -
uspace/srv/hw/netif/dp8390/dp8390_port.h
r7c34b28f r61bfc370 43 43 #include <libarch/ddi.h> 44 44 #include <sys/types.h> 45 46 /** Compares two memory blocks.47 * @param[in] first The first memory block.48 * @param[in] second The second memory block.49 * @param[in] size The blocks size in bytes.50 * @returns 0 if equeal.51 * @returns -1 if the first is greater than the second.52 * @returns 1 if the second is greater than the first.53 */54 #define memcmp(first, second, size) bcmp((char *) (first), (char *) (second), (size))55 45 56 46 /** Reads 1 byte. -
uspace/srv/hw/netif/dp8390/ne2000.c
r7c34b28f r61bfc370 241 241 buf[i] = inb_ne(dep, NE_DATA); 242 242 243 return ( memcmp(buf, pat, 4) == 0);243 return (bcmp(buf, pat, 4) == 0); 244 244 } 245 245 … … 280 280 *(uint16_t *)(buf + i) = inw_ne(dep, NE_DATA); 281 281 282 return ( memcmp(buf, pat, 4) == 0);282 return (bcmp(buf, pat, 4) == 0); 283 283 } 284 284 -
uspace/srv/net/il/arp/arp.c
r7c34b28f r61bfc370 215 215 (*proto)->service = service; 216 216 (*proto)->addr = address; 217 (*proto)->addr_data = (uint8_t *)address->value;217 (*proto)->addr_data = address->value; 218 218 219 219 rc = arp_addr_initialize(&(*proto)->addresses); … … 267 267 free(proto->addr_data); 268 268 proto->addr = address; 269 proto->addr_data = (uint8_t *)address->value;269 proto->addr_data = address->value; 270 270 } else { 271 271 rc = arp_proto_create(&proto, protocol, address); … … 482 482 des_hw = src_proto + header->protocol_length; 483 483 des_proto = des_hw + header->hardware_length; 484 trans = arp_addr_find(&proto->addresses, (char *)src_proto,484 trans = arp_addr_find(&proto->addresses, src_proto, 485 485 header->protocol_length); 486 486 /* Exists? */ … … 493 493 if (proto->addr->length != header->protocol_length) 494 494 return EINVAL; 495 if (!str_lcmp(proto->addr->value, (char *) des_proto,496 495 496 if (!bcmp(proto->addr->value, des_proto, proto->addr->length)) { 497 497 /* Not already updated? */ 498 498 if (!trans) { … … 502 502 trans->hw_addr = NULL; 503 503 fibril_condvar_initialize(&trans->cv); 504 rc = arp_addr_add(&proto->addresses, (char *)src_proto,504 rc = arp_addr_add(&proto->addresses, src_proto, 505 505 header->protocol_length, trans); 506 506 if (rc != EOK) { … … 510 510 } 511 511 if (!trans->hw_addr) { 512 trans->hw_addr = measured_string_create_bulk( 513 (char *) src_hw,header->hardware_length);512 trans->hw_addr = measured_string_create_bulk(src_hw, 513 header->hardware_length); 514 514 if (!trans->hw_addr) 515 515 return ENOMEM; 516 516 517 517 /* Notify the fibrils that wait for the translation. */ 518 518 fibril_condvar_broadcast(&trans->cv); … … 681 681 measured_string_t *address; 682 682 measured_string_t *translation; 683 char*data;683 uint8_t *data; 684 684 packet_t *packet; 685 685 packet_t *next; … … 748 748 749 749 case NET_IL_RECEIVED: 750 750 751 rc = packet_translate_remote(arp_globals.net_phone, &packet, 751 752 IPC_GET_PACKET(call)); -
uspace/srv/net/il/ip/ip.c
r7c34b28f r61bfc370 275 275 if (rc != EOK) 276 276 goto out; 277 rc = add_module(NULL, &ip_globals.modules, ARP_NAME, ARP_FILENAME,278 SERVICE_ARP, 0, arp_connect_module);277 rc = add_module(NULL, &ip_globals.modules, (uint8_t *) ARP_NAME, 278 (uint8_t *) ARP_FILENAME, SERVICE_ARP, 0, arp_connect_module); 279 279 280 280 out: … … 312 312 measured_string_t names[] = { 313 313 { 314 ( char*) "IPV",314 (uint8_t *) "IPV", 315 315 3 316 316 }, 317 317 { 318 ( char*) "IP_CONFIG",318 (uint8_t *) "IP_CONFIG", 319 319 9 320 320 }, 321 321 { 322 ( char*) "IP_ADDR",322 (uint8_t *) "IP_ADDR", 323 323 7 324 324 }, 325 325 { 326 ( char*) "IP_NETMASK",326 (uint8_t *) "IP_NETMASK", 327 327 10 328 328 }, 329 329 { 330 ( char*) "IP_GATEWAY",330 (uint8_t *) "IP_GATEWAY", 331 331 10 332 332 }, 333 333 { 334 ( char*) "IP_BROADCAST",334 (uint8_t *) "IP_BROADCAST", 335 335 12 336 336 }, 337 337 { 338 ( char*) "ARP",338 (uint8_t *) "ARP", 339 339 3 340 340 }, 341 341 { 342 ( char*) "IP_ROUTING",342 (uint8_t *) "IP_ROUTING", 343 343 10 344 344 } … … 346 346 measured_string_t *configuration; 347 347 size_t count = sizeof(names) / sizeof(measured_string_t); 348 char*data;348 uint8_t *data; 349 349 measured_string_t address; 350 350 ip_route_t *route; … … 368 368 if (configuration) { 369 369 if (configuration[0].value) 370 ip_netif->ipv = strtol( configuration[0].value, NULL, 0);371 372 ip_netif->dhcp = !str_lcmp( configuration[1].value, "dhcp",370 ip_netif->ipv = strtol((char *) configuration[0].value, NULL, 0); 371 372 ip_netif->dhcp = !str_lcmp((char *) configuration[1].value, "dhcp", 373 373 configuration[1].length); 374 374 … … 394 394 } 395 395 396 if ((inet_pton(AF_INET, configuration[2].value,396 if ((inet_pton(AF_INET, (char *) configuration[2].value, 397 397 (uint8_t *) &route->address.s_addr) != EOK) || 398 (inet_pton(AF_INET, configuration[3].value,398 (inet_pton(AF_INET, (char *) configuration[3].value, 399 399 (uint8_t *) &route->netmask.s_addr) != EOK) || 400 (inet_pton(AF_INET, configuration[4].value,400 (inet_pton(AF_INET, (char *) configuration[4].value, 401 401 (uint8_t *) &gateway.s_addr) == EINVAL) || 402 (inet_pton(AF_INET, configuration[5].value,402 (inet_pton(AF_INET, (char *) configuration[5].value, 403 403 (uint8_t *) &ip_netif->broadcast.s_addr) == EINVAL)) 404 404 { … … 441 441 if (ip_netif->arp) { 442 442 if (route) { 443 address.value = ( char*) &route->address.s_addr;443 address.value = (uint8_t *) &route->address.s_addr; 444 444 address.length = sizeof(in_addr_t); 445 445 … … 997 997 measured_string_t destination; 998 998 measured_string_t *translation; 999 char*data;999 uint8_t *data; 1000 1000 int phone; 1001 1001 int rc; … … 1004 1004 if (netif->arp && (route->address.s_addr != dest.s_addr)) { 1005 1005 destination.value = route->gateway.s_addr ? 1006 ( char *) &route->gateway.s_addr : (char*) &dest.s_addr;1006 (uint8_t *) &route->gateway.s_addr : (uint8_t *) &dest.s_addr; 1007 1007 destination.length = sizeof(dest.s_addr); 1008 1008 … … 1756 1756 (header->destination_address & route->netmask.s_addr))) { 1757 1757 // clear the ARP mapping if any 1758 address.value = ( char*) &header->destination_address;1758 address.value = (uint8_t *) &header->destination_address; 1759 1759 address.length = sizeof(header->destination_address); 1760 1760 arp_clear_address_req(netif->arp->phone, -
uspace/srv/net/net/net.c
r7c34b28f r61bfc370 90 90 * 91 91 */ 92 int add_configuration(measured_strings_t *configuration, const char*name,93 const char*value)92 int add_configuration(measured_strings_t *configuration, const uint8_t *name, 93 const uint8_t *value) 94 94 { 95 95 int rc; … … 119 119 } 120 120 121 static int parse_line(measured_strings_t *configuration, char*line)121 static int parse_line(measured_strings_t *configuration, uint8_t *line) 122 122 { 123 123 int rc; 124 124 125 125 /* From the beginning */ 126 char*name = line;126 uint8_t *name = line; 127 127 128 128 /* Skip comments and blank lines */ … … 135 135 136 136 /* Remember the name start */ 137 char*value = name;137 uint8_t *value = name; 138 138 139 139 /* Skip the name */ … … 186 186 187 187 /* Construct the full filename */ 188 char line[BUFFER_SIZE];189 if (snprintf( line, BUFFER_SIZE, "%s/%s", directory, filename) > BUFFER_SIZE)188 char fname[BUFFER_SIZE]; 189 if (snprintf(fname, BUFFER_SIZE, "%s/%s", directory, filename) > BUFFER_SIZE) 190 190 return EOVERFLOW; 191 191 192 192 /* Open the file */ 193 FILE *cfg = fopen( line, "r");193 FILE *cfg = fopen(fname, "r"); 194 194 if (!cfg) 195 195 return ENOENT; … … 201 201 unsigned int line_number = 0; 202 202 size_t index = 0; 203 uint8_t line[BUFFER_SIZE]; 204 203 205 while (!ferror(cfg) && !feof(cfg)) { 204 206 int read = fgetc(cfg); … … 207 209 line[BUFFER_SIZE - 1] = '\0'; 208 210 fprintf(stderr, "%s: Configuration line %u too " 209 "long: %s\n", NAME, line_number, line);211 "long: %s\n", NAME, line_number, (char *) line); 210 212 211 213 /* No space left in the line buffer */ … … 213 215 } 214 216 /* Append the character */ 215 line[index] = ( char) read;217 line[index] = (uint8_t) read; 216 218 index++; 217 219 } else { … … 221 223 if (parse_line(configuration, line) != EOK) { 222 224 fprintf(stderr, "%s: Configuration error on " 223 "line %u: %s\n", NAME, line_number, line);225 "line %u: %s\n", NAME, line_number, (char *) line); 224 226 } 225 227 … … 282 284 return rc; 283 285 284 rc = add_module(NULL, &net_globals.modules, LO_NAME, LO_FILENAME,285 SERVICE_LO, 0, connect_to_service);286 if (rc != EOK) 287 return rc; 288 rc = add_module(NULL, &net_globals.modules, DP8390_NAME,289 DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service);290 if (rc != EOK) 291 return rc; 292 rc = add_module(NULL, &net_globals.modules, ETHERNET_NAME,293 ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service);294 if (rc != EOK) 295 return rc; 296 rc = add_module(NULL, &net_globals.modules, NILDUMMY_NAME,297 NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service);286 rc = add_module(NULL, &net_globals.modules, (uint8_t *) LO_NAME, 287 (uint8_t *) LO_FILENAME, SERVICE_LO, 0, connect_to_service); 288 if (rc != EOK) 289 return rc; 290 rc = add_module(NULL, &net_globals.modules, (uint8_t *) DP8390_NAME, 291 (uint8_t *) DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service); 292 if (rc != EOK) 293 return rc; 294 rc = add_module(NULL, &net_globals.modules, (uint8_t *) ETHERNET_NAME, 295 (uint8_t *) ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service); 296 if (rc != EOK) 297 return rc; 298 rc = add_module(NULL, &net_globals.modules, (uint8_t *) NILDUMMY_NAME, 299 (uint8_t *) NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service); 298 300 if (rc != EOK) 299 301 return rc; … … 364 366 */ 365 367 static int net_get_conf(measured_strings_t *netif_conf, 366 measured_string_t *configuration, size_t count, char**data)368 measured_string_t *configuration, size_t count, uint8_t **data) 367 369 { 368 370 if (data) … … 390 392 391 393 int net_get_conf_req(int net_phone, measured_string_t **configuration, 392 size_t count, char**data)394 size_t count, uint8_t **data) 393 395 { 394 396 if (!configuration || (count <= 0)) … … 399 401 400 402 int net_get_device_conf_req(int net_phone, device_id_t device_id, 401 measured_string_t **configuration, size_t count, char**data)403 measured_string_t **configuration, size_t count, uint8_t **data) 402 404 { 403 405 if ((!configuration) || (count == 0)) … … 411 413 } 412 414 413 void net_free_settings(measured_string_t *settings, char*data)415 void net_free_settings(measured_string_t *settings, uint8_t *data) 414 416 { 415 417 } … … 437 439 /* Mandatory netif */ 438 440 measured_string_t *setting = 439 measured_strings_find(&netif->configuration, CONF_NETIF, 0);441 measured_strings_find(&netif->configuration, (uint8_t *) CONF_NETIF, 0); 440 442 441 443 netif->driver = get_running_module(&net_globals.modules, setting->value); … … 447 449 448 450 /* Optional network interface layer */ 449 setting = measured_strings_find(&netif->configuration, CONF_NIL, 0);451 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_NIL, 0); 450 452 if (setting) { 451 453 netif->nil = get_running_module(&net_globals.modules, setting->value); … … 459 461 460 462 /* Mandatory internet layer */ 461 setting = measured_strings_find(&netif->configuration, CONF_IL, 0);463 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IL, 0); 462 464 netif->il = get_running_module(&net_globals.modules, setting->value); 463 465 if (!netif->il) { … … 468 470 469 471 /* Hardware configuration */ 470 setting = measured_strings_find(&netif->configuration, CONF_IRQ, 0);471 int irq = setting ? strtol( setting->value, NULL, 10) : 0;472 473 setting = measured_strings_find(&netif->configuration, CONF_IO, 0);474 int io = setting ? strtol( setting->value, NULL, 16) : 0;472 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IRQ, 0); 473 int irq = setting ? strtol((char *) setting->value, NULL, 10) : 0; 474 475 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IO, 0); 476 int io = setting ? strtol((char *) setting->value, NULL, 16) : 0; 475 477 476 478 rc = netif_probe_req_remote(netif->driver->phone, netif->id, irq, io); … … 481 483 services_t internet_service; 482 484 if (netif->nil) { 483 setting = measured_strings_find(&netif->configuration, CONF_MTU, 0);485 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_MTU, 0); 484 486 if (!setting) 485 487 setting = measured_strings_find(&net_globals.configuration, 486 CONF_MTU, 0);487 488 int mtu = setting ? strtol( setting->value, NULL, 10) : 0;488 (uint8_t *) CONF_MTU, 0); 489 490 int mtu = setting ? strtol((char *) setting->value, NULL, 10) : 0; 489 491 490 492 rc = nil_device_req(netif->nil->phone, netif->id, mtu, … … 558 560 /* Mandatory name */ 559 561 measured_string_t *setting = 560 measured_strings_find(&netif->configuration, CONF_NAME, 0);562 measured_strings_find(&netif->configuration, (uint8_t *) CONF_NAME, 0); 561 563 if (!setting) { 562 564 fprintf(stderr, "%s: Network interface name is missing\n", NAME); … … 602 604 printf("%s: Network interface started (name: %s, id: %d, driver: %s, " 603 605 "nil: %s, il: %s)\n", NAME, netif->name, netif->id, 604 netif->driver->name, netif->nil ?netif->nil->name : "[none]",606 netif->driver->name, netif->nil ? (char *) netif->nil->name : "[none]", 605 607 netif->il->name); 606 608 } … … 628 630 { 629 631 measured_string_t *strings; 630 char*data;632 uint8_t *data; 631 633 int rc; 632 634 -
uspace/srv/net/net/net.h
r7c34b28f r61bfc370 105 105 module_t *driver; 106 106 107 device_id_t id; 108 module_t *il; 109 char *name;/**< System-unique network interface name. */110 module_t *nil; 107 device_id_t id; /**< System-unique network interface identifier. */ 108 module_t *il; /**< Serving internet layer module index. */ 109 uint8_t *name; /**< System-unique network interface name. */ 110 module_t *nil; /**< Serving link layer module index. */ 111 111 } netif_t; 112 112 … … 133 133 } net_globals_t; 134 134 135 extern int add_configuration(measured_strings_t *, const char *, const char *); 135 extern int add_configuration(measured_strings_t *, const uint8_t *, 136 const uint8_t *); 136 137 extern int net_module_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, int *); 137 138 extern int net_initialize_build(async_client_conn_t); -
uspace/srv/net/net/net_standalone.c
r7c34b28f r61bfc370 63 63 int rc; 64 64 65 task_id_t task_id = spawn("/srv/ip");65 task_id_t task_id = net_spawn((uint8_t *) "/srv/ip"); 66 66 if (!task_id) 67 67 return EINVAL; 68 68 69 rc = add_module(NULL, &net_globals.modules, IP_NAME,70 IP_FILENAME, SERVICE_IP, task_id, ip_connect_module);69 rc = add_module(NULL, &net_globals.modules, (uint8_t *) IP_NAME, 70 (uint8_t *) IP_FILENAME, SERVICE_IP, task_id, ip_connect_module); 71 71 if (rc != EOK) 72 72 return rc; 73 73 74 if (! spawn("/srv/icmp"))74 if (!net_spawn((uint8_t *) "/srv/icmp")) 75 75 return EINVAL; 76 76 77 if (! spawn("/srv/udp"))77 if (!net_spawn((uint8_t *) "/srv/udp")) 78 78 return EINVAL; 79 79 80 if (! spawn("/srv/tcp"))80 if (!net_spawn((uint8_t *) "/srv/tcp")) 81 81 return EINVAL; 82 82 -
uspace/srv/net/netif/lo/lo.c
r7c34b28f r61bfc370 53 53 54 54 /** Default hardware address. */ 55 #define DEFAULT_ADDR "\0\0\0\0\0\0"55 #define DEFAULT_ADDR 0 56 56 57 57 /** Default address length. */ 58 #define DEFAULT_ADDR_LEN (sizeof(DEFAULT_ADDR) / sizeof(char))58 #define DEFAULT_ADDR_LEN 6 59 59 60 60 /** Loopback module name. */ … … 62 62 63 63 /** Network interface global data. */ 64 netif_globals_t 64 netif_globals_t netif_globals; 65 65 66 66 int netif_specific_message(ipc_callid_t callid, ipc_call_t *call, … … 74 74 if (!address) 75 75 return EBADMEM; 76 77 address->value = str_dup(DEFAULT_ADDR); 76 77 uint8_t *addr = (uint8_t *) malloc(DEFAULT_ADDR_LEN); 78 memset(addr, DEFAULT_ADDR, DEFAULT_ADDR_LEN); 79 80 address->value = addr; 78 81 address->length = DEFAULT_ADDR_LEN; 79 82 80 83 return EOK; 81 84 } -
uspace/srv/net/nil/eth/eth.c
r7c34b28f r61bfc370 201 201 202 202 eth_globals.broadcast_addr = 203 measured_string_create_bulk( "\xFF\xFF\xFF\xFF\xFF\xFF", ETH_ADDR);203 measured_string_create_bulk((uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF", ETH_ADDR); 204 204 if (!eth_globals.broadcast_addr) { 205 205 rc = ENOMEM; … … 284 284 measured_string_t names[2] = { 285 285 { 286 ( char*) "ETH_MODE",286 (uint8_t *) "ETH_MODE", 287 287 8 288 288 }, 289 289 { 290 ( char*) "ETH_DUMMY",290 (uint8_t *) "ETH_DUMMY", 291 291 9 292 292 } … … 294 294 measured_string_t *configuration; 295 295 size_t count = sizeof(names) / sizeof(measured_string_t); 296 char*data;296 uint8_t *data; 297 297 eth_proto_t *proto; 298 298 int rc; … … 358 358 359 359 if (configuration) { 360 if (!str_lcmp( configuration[0].value, "DIX",360 if (!str_lcmp((char *) configuration[0].value, "DIX", 361 361 configuration[0].length)) { 362 362 device->flags |= ETH_DIX; 363 } else if(!str_lcmp( configuration[0].value, "8023_2_LSAP",363 } else if(!str_lcmp((char *) configuration[0].value, "8023_2_LSAP", 364 364 configuration[0].length)) { 365 365 device->flags |= ETH_8023_2_LSAP; -
uspace/srv/net/tl/icmp/icmp.c
r7c34b28f r61bfc370 405 405 measured_string_t names[] = { 406 406 { 407 ( char*) "ICMP_ERROR_REPORTING",407 (uint8_t *) "ICMP_ERROR_REPORTING", 408 408 20 409 409 }, 410 410 { 411 ( char*) "ICMP_ECHO_REPLYING",411 (uint8_t *) "ICMP_ECHO_REPLYING", 412 412 18 413 413 } … … 415 415 measured_string_t *configuration; 416 416 size_t count = sizeof(names) / sizeof(measured_string_t); 417 char*data;417 uint8_t *data; 418 418 int rc; 419 419 -
uspace/srv/net/tl/tcp/tcp.c
r7c34b28f r61bfc370 154 154 155 155 /** Port map key. */ 156 char*key;156 uint8_t *key; 157 157 158 158 /** Port map key length. */ … … 358 358 /* Find the destination socket */ 359 359 socket = socket_port_find(&tcp_globals.sockets, 360 ntohs(header->destination_port), ( const char*) src, addrlen);360 ntohs(header->destination_port), (uint8_t *) src, addrlen); 361 361 if (!socket) { 362 362 /* Find the listening destination socket */ 363 363 socket = socket_port_find(&tcp_globals.sockets, 364 ntohs(header->destination_port), SOCKET_MAP_KEY_LISTENING,365 0);364 ntohs(header->destination_port), 365 (uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 366 366 } 367 367 … … 998 998 /* Find the destination socket */ 999 999 listening_socket = socket_port_find(&tcp_globals.sockets, 1000 listening_port, SOCKET_MAP_KEY_LISTENING, 0);1000 listening_port, (uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 1001 1001 if (!listening_socket || 1002 1002 (listening_socket->socket_id != listening_socket_id)) { … … 1022 1022 1023 1023 rc = socket_port_add(&tcp_globals.sockets, listening_port, socket, 1024 ( const char*) socket_data->addr, socket_data->addrlen);1024 (uint8_t *) socket_data->addr, socket_data->addrlen); 1025 1025 assert(socket == socket_port_find(&tcp_globals.sockets, listening_port, 1026 ( const char*) socket_data->addr, socket_data->addrlen));1026 (uint8_t *) socket_data->addr, socket_data->addrlen)); 1027 1027 1028 1028 // rc = socket_bind_free_port(&tcp_globals.sockets, socket, … … 2109 2109 2110 2110 /* Copy the key */ 2111 operation_timeout->key = (( char*) operation_timeout) +2111 operation_timeout->key = ((uint8_t *) operation_timeout) + 2112 2112 sizeof(*operation_timeout); 2113 2113 operation_timeout->key_length = socket->key_length; -
uspace/srv/net/tl/udp/udp.c
r7c34b28f r61bfc370 104 104 measured_string_t names[] = { 105 105 { 106 ( char*) "UDP_CHECKSUM_COMPUTING",106 (uint8_t *) "UDP_CHECKSUM_COMPUTING", 107 107 22 108 108 }, 109 109 { 110 ( char*) "UDP_AUTOBINDING",110 (uint8_t *) "UDP_AUTOBINDING", 111 111 15 112 112 } … … 114 114 measured_string_t *configuration; 115 115 size_t count = sizeof(names) / sizeof(measured_string_t); 116 char*data;116 uint8_t *data; 117 117 int rc; 118 118 … … 283 283 /* Find the destination socket */ 284 284 socket = socket_port_find(&udp_globals.sockets, 285 ntohs(header->destination_port),SOCKET_MAP_KEY_LISTENING, 0);285 ntohs(header->destination_port), (uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 286 286 if (!socket) { 287 287 if (tl_prepare_icmp_packet(udp_globals.net_phone,
Note:
See TracChangeset
for help on using the changeset viewer.