Changeset 61bfc370 in mainline


Ignore:
Timestamp:
2011-01-07T18:57:55Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e08a733
Parents:
7c34b28f
Message:
  • make measured_string and other network-related data types binary-safe
  • fix several network-related routines binary-safe (replace clearly suspicious use of str_lcmp() with bcmp())
  • rename spawn() to net_spawn()
Location:
uspace
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/char_map.c

    r7c34b28f r61bfc370  
    6565 */
    6666static int
    67 char_map_add_item(char_map_t *map, const char *identifier, size_t length,
     67char_map_add_item(char_map_t *map, const uint8_t *identifier, size_t length,
    6868    const int value)
    6969{
     
    139139 */
    140140int
    141 char_map_add(char_map_t *map, const char *identifier, size_t length,
     141char_map_add(char_map_t *map, const uint8_t *identifier, size_t length,
    142142    const int value)
    143143{
     
    200200 */
    201201static char_map_t *
    202 char_map_find_node(const char_map_t *map, const char *identifier,
     202char_map_find_node(const char_map_t *map, const uint8_t *identifier,
    203203    size_t length)
    204204{
     
    241241 * @return              CHAR_MAP_NULL if the key is not assigned a value.
    242242 */
    243 int char_map_exclude(char_map_t *map, const char *identifier, size_t length)
     243int char_map_exclude(char_map_t *map, const uint8_t *identifier, size_t length)
    244244{
    245245        char_map_t *node;
     
    269269 *  @return             CHAR_MAP_NULL if the key is not assigned a value.
    270270 */
    271 int char_map_find(const char_map_t *map, const char *identifier, size_t length)
     271int char_map_find(const char_map_t *map, const uint8_t *identifier, size_t length)
    272272{
    273273        char_map_t *node;
     
    329329 */
    330330int
    331 char_map_update(char_map_t *map, const char *identifier, const size_t length,
     331char_map_update(char_map_t *map, const uint8_t *identifier, const size_t length,
    332332    const int value)
    333333{
  • uspace/lib/c/generic/adt/measured_strings.c

    r7c34b28f r61bfc370  
    5959 */
    6060measured_string_t *
    61 measured_string_create_bulk(const char *string, size_t length)
     61measured_string_create_bulk(const uint8_t *string, size_t length)
    6262{
    6363        measured_string_t *new;
     
    6868        }
    6969        new = (measured_string_t *) malloc(sizeof(measured_string_t) +
    70             (sizeof(char) * (length + 1)));
     70            (sizeof(uint8_t) * (length + 1)));
    7171        if (!new)
    7272                return NULL;
    7373
    7474        new->length = length;
    75         new->value = ((char *) new) + sizeof(measured_string_t);
     75        new->value = ((uint8_t *) new) + sizeof(measured_string_t);
    7676        // append terminating zero explicitly - to be safe
    7777        memcpy(new->value, string, new->length);
     
    9797        new = (measured_string_t *) malloc(sizeof(measured_string_t));
    9898        if (new) {
    99                 new->value = (char *) malloc(source->length + 1);
     99                new->value = (uint8_t *) malloc(source->length + 1);
    100100                if (new->value) {
    101101                        new->length = source->length;
     
    131131 */
    132132int
    133 measured_strings_receive(measured_string_t **strings, char **data,
     133measured_strings_receive(measured_string_t **strings, uint8_t **data,
    134134    size_t count)
    135135{
     
    137137        size_t index;
    138138        size_t length;
    139         char *next;
     139        uint8_t *next;
    140140        ipc_callid_t callid;
    141141        int rc;
     
    311311 */
    312312int
    313 measured_strings_return(int phone, measured_string_t **strings, char **data,
     313measured_strings_return(int phone, measured_string_t **strings, uint8_t **data,
    314314    size_t count)
    315315{
    316316        size_t *lengths;
    317317        size_t index;
    318         char *next;
     318        uint8_t *next;
    319319        int rc;
    320320
  • uspace/lib/c/generic/mem.c

    r7c34b28f r61bfc370  
    222222/** Compare two memory areas.
    223223 *
    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 */
     233int 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       
    235240        return len;
    236241}
  • uspace/lib/c/include/adt/char_map.h

    r7c34b28f r61bfc370  
    4141
    4242/** Invalid assigned value used also if an&nbsp;entry does not exist. */
    43 #define CHAR_MAP_NULL   (-1)
     43#define CHAR_MAP_NULL  (-1)
    4444
    4545/** Type definition of the character string to integer map.
    4646 *  @see char_map
    4747 */
    48 typedef struct char_map char_map_t;
     48typedef struct char_map char_map_t;
    4949
    5050/** Character string to integer map item.
     
    5656struct char_map {
    5757        /** Actually mapped character. */
    58         char c;
     58        uint8_t c;
    5959        /** Stored integral value. */
    6060        int value;
     
    7171extern int char_map_initialize(char_map_t *);
    7272extern 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);
     73extern int char_map_exclude(char_map_t *, const uint8_t *, size_t);
     74extern int char_map_add(char_map_t *, const uint8_t *, size_t, const int);
     75extern int char_map_find(const char_map_t *, const uint8_t *, size_t);
     76extern int char_map_update(char_map_t *, const uint8_t *, size_t, const int);
    7777
    7878#endif
  • uspace/lib/c/include/adt/generic_char_map.h

    r7c34b28f r61bfc370  
    6262        }; \
    6363        \
    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 *); \
    6565        int name##_count(name##_t *); \
    6666        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); \
    6969        int name##_initialize(name##_t *); \
    7070        int name##_is_valid(name##_t *);
     
    7474 * Should follow declaration with the same parameters.
    7575 *
    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 *
    7879 */
    7980#define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \
    8081        GENERIC_FIELD_IMPLEMENT(name##_items, type) \
    8182        \
    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, \
    8384             type *value) \
    8485        { \
     
    112113        } \
    113114        \
    114         void name##_exclude(name##_t *map, const char *name, \
     115        void name##_exclude(name##_t *map, const uint8_t *name, \
    115116            const size_t length) \
    116117        { \
     
    124125        } \
    125126        \
    126         type *name##_find(name##_t *map, const char *name, \
     127        type *name##_find(name##_t *map, const uint8_t *name, \
    127128            const size_t length) \
    128129        { \
  • uspace/lib/c/include/adt/measured_strings.h

    r7c34b28f r61bfc370  
    5454struct measured_string {
    5555        /** Character string data. */
    56         char *value;
     56        uint8_t *value;
    5757        /** Character string length. */
    5858        size_t length;
    5959};
    6060
    61 extern measured_string_t *measured_string_create_bulk(const char *, size_t);
     61extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t);
    6262extern measured_string_t *measured_string_copy(measured_string_t *);
    63 extern int measured_strings_receive(measured_string_t **, char **, size_t);
     63extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t);
    6464extern int measured_strings_reply(const measured_string_t *, size_t);
    65 extern int measured_strings_return(int, measured_string_t **, char **, size_t);
     65extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t);
    6666extern int measured_strings_send(int, const measured_string_t *, size_t);
    6767
  • uspace/lib/c/include/mem.h

    r7c34b28f r61bfc370  
    4444extern void *memmove(void *, const void *, size_t);
    4545
    46 extern int bcmp(const char *, const char *, size_t);
     46extern int bcmp(const void *, const void *, size_t);
    4747
    4848#endif
  • uspace/lib/net/adt/module_map.c

    r7c34b28f r61bfc370  
    6363 */
    6464int
    65 add_module(module_t **module, modules_t *modules, const char *name,
    66     const char *filename, services_t service, task_id_t task_id,
     65add_module(module_t **module, modules_t *modules, const uint8_t *name,
     66    const uint8_t *filename, services_t service, task_id_t task_id,
    6767    connect_module_t connect_module)
    6868{
     
    104104 * @return              NULL if there is no such module.
    105105 */
    106 module_t *get_running_module(modules_t *modules, char *name)
     106module_t *get_running_module(modules_t *modules, uint8_t *name)
    107107{
    108108        module_t *module;
     
    113113
    114114        if (!module->task_id) {
    115                 module->task_id = spawn(module->filename);
     115                module->task_id = net_spawn(module->filename);
    116116                if (!module->task_id)
    117117                        return NULL;
     
    123123}
    124124
    125 /** Starts the given module.
     125/** Start the given module.
    126126 *
    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 *
    130132 */
    131 task_id_t spawn(const char *fname)
     133task_id_t net_spawn(const uint8_t *fname)
    132134{
    133135        task_id_t id;
    134136        int rc;
    135137       
    136         rc = task_spawnl(&id, fname, fname, NULL);
     138        rc = task_spawnl(&id, (const char *) fname, (const char *) fname, NULL);
    137139        if (rc != EOK)
    138140                return 0;
  • uspace/lib/net/generic/generic.c

    r7c34b28f r61bfc370  
    112112        message_id = async_send_1(phone, (sysarg_t) message,
    113113            (sysarg_t) device_id, NULL);
    114         string = measured_strings_return(phone, address, (char **) data, 1);
     114        string = measured_strings_return(phone, address, data, 1);
    115115        async_wait_for(message_id, &result);
    116116
     
    234234generic_translate_req(int phone, int message, device_id_t device_id,
    235235    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)
    237237{
    238238        aid_t message_id;
  • uspace/lib/net/generic/net_remote.c

    r7c34b28f r61bfc370  
    6363 * @see net_get_conf_req()
    6464 */
    65 void net_free_settings(measured_string_t *settings, char *data)
     65void net_free_settings(measured_string_t *settings, uint8_t *data)
    6666{
    6767        if (settings)
     
    9191int
    9292net_get_conf_req(int net_phone, measured_string_t **configuration,
    93     size_t count, char **data)
     93    size_t count, uint8_t **data)
    9494{
    9595        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,
     
    118118int
    119119net_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)
    121121{
    122122        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
  • uspace/lib/net/il/arp_remote.c

    r7c34b28f r61bfc370  
    165165int
    166166arp_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)
    168168{
    169169        return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
  • uspace/lib/net/include/adt/module_map.h

    r7c34b28f r61bfc370  
    6565        int usage;
    6666        /** Module name. */
    67         const char *name;
     67        const uint8_t *name;
    6868        /** Module full path filename. */
    69         const char *filename;
     69        const uint8_t *filename;
    7070        /** Connecting function. */
    7171        connect_module_t *connect_module;
    7272};
    7373
    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 *);
     74extern int add_module(module_t **, modules_t *, const uint8_t *,
     75    const uint8_t *, services_t, task_id_t, connect_module_t *);
     76extern module_t *get_running_module(modules_t *, uint8_t *);
     77extern task_id_t net_spawn(const uint8_t *);
    7878
    7979#endif
  • uspace/lib/net/include/arp_interface.h

    r7c34b28f r61bfc370  
    5050    measured_string_t *);
    5151extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *,
    52     measured_string_t **, char **);
     52    measured_string_t **, uint8_t **);
    5353extern int arp_clear_device_req(int, device_id_t);
    5454extern int arp_clear_address_req(int, device_id_t, services_t,
  • uspace/lib/net/include/generic.h

    r7c34b28f r61bfc370  
    5858    services_t, services_t);
    5959extern 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 **);
    6161
    6262#endif
  • uspace/lib/net/include/net_interface.h

    r7c34b28f r61bfc370  
    4545
    4646extern 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 **);
     48extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **);
     49extern void net_free_settings(measured_string_t *, uint8_t *);
    5050extern int net_connect_module(void);
    5151
  • uspace/lib/net/include/socket_core.h

    r7c34b28f r61bfc370  
    8686        void *specific_data;
    8787        /** Socket ports map key. */
    88         const char *key;
     88        const uint8_t *key;
    8989        /** Length of the Socket ports map key. */
    9090        size_t key_length;
     
    118118    void (*)(socket_core_t *));
    119119extern int socket_reply_packets(packet_t *, size_t *);
    120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const char *,
     120extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *,
    121121    size_t);
    122122extern void socket_port_release(socket_ports_t *, socket_core_t *);
    123123extern int socket_port_add(socket_ports_t *, int, socket_core_t *,
    124     const char *, size_t);
     124    const uint8_t *, size_t);
    125125
    126126#endif
  • uspace/lib/net/netif/netif_local.c

    r7c34b28f r61bfc370  
    221221        fibril_rwlock_read_unlock(&netif_globals.lock);
    222222       
    223         *data = (uint8_t *) (**address).value;
     223        *data = (**address).value;
    224224       
    225225        return rc;
  • uspace/lib/net/tl/socket_core.c

    r7c34b28f r61bfc370  
    161161static int
    162162socket_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)
    164164{
    165165        socket_core_t **socket_ref;
     
    216216                goto fail;
    217217       
    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);
    220220        if (rc != EOK)
    221221                goto fail;
     
    602602 */
    603603socket_core_t *
    604 socket_port_find(socket_ports_t *global_sockets, int port, const char *key,
     604socket_port_find(socket_ports_t *global_sockets, int port, const uint8_t *key,
    605605    size_t key_length)
    606606{
     
    680680int
    681681socket_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)
    683683{
    684684        socket_port_t *socket_port;
  • uspace/srv/hw/netif/dp8390/dp8390.c

    r7c34b28f r61bfc370  
    550550                if ((length < ETH_MIN_PACK_SIZE) || (length > ETH_MAX_PACK_SIZE_TAGGED)) {
    551551                        printf("Packet with strange length arrived: %zu\n", length);
    552                         next= curr;
     552                        next = curr;
    553553                } else if ((next < dep->de_startpage) || (next >= dep->de_stoppage)) {
    554554                        printf("Strange next page\n");
    555                         next= curr;
     555                        next = curr;
    556556                } else if (header.dr_status & RSR_FO) {
    557557                        /*
  • uspace/srv/hw/netif/dp8390/dp8390_module.c

    r7c34b28f r61bfc370  
    213213                return rc;
    214214       
    215         address->value = (char *) (&((dpeth_t *) device->specific)->de_address);
     215        address->value = (uint8_t *) &((dpeth_t *) device->specific)->de_address;
    216216        address->length = sizeof(ether_addr_t);
    217217        return EOK;
  • uspace/srv/hw/netif/dp8390/dp8390_port.h

    r7c34b28f r61bfc370  
    4343#include <libarch/ddi.h>
    4444#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))
    5545
    5646/** Reads 1 byte.
  • uspace/srv/hw/netif/dp8390/ne2000.c

    r7c34b28f r61bfc370  
    241241                buf[i] = inb_ne(dep, NE_DATA);
    242242       
    243         return (memcmp(buf, pat, 4) == 0);
     243        return (bcmp(buf, pat, 4) == 0);
    244244}
    245245
     
    280280                *(uint16_t *)(buf + i) = inw_ne(dep, NE_DATA);
    281281       
    282         return (memcmp(buf, pat, 4) == 0);
     282        return (bcmp(buf, pat, 4) == 0);
    283283}
    284284
  • uspace/srv/net/il/arp/arp.c

    r7c34b28f r61bfc370  
    215215        (*proto)->service = service;
    216216        (*proto)->addr = address;
    217         (*proto)->addr_data = (uint8_t *) address->value;
     217        (*proto)->addr_data = address->value;
    218218       
    219219        rc = arp_addr_initialize(&(*proto)->addresses);
     
    267267                        free(proto->addr_data);
    268268                        proto->addr = address;
    269                         proto->addr_data = (uint8_t *) address->value;
     269                        proto->addr_data = address->value;
    270270                } else {
    271271                        rc = arp_proto_create(&proto, protocol, address);
     
    482482        des_hw = src_proto + header->protocol_length;
    483483        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,
    485485            header->protocol_length);
    486486        /* Exists? */
     
    493493        if (proto->addr->length != header->protocol_length)
    494494                return EINVAL;
    495         if (!str_lcmp(proto->addr->value, (char *) des_proto,
    496             proto->addr->length)) {
     495       
     496        if (!bcmp(proto->addr->value, des_proto, proto->addr->length)) {
    497497                /* Not already updated? */
    498498                if (!trans) {
     
    502502                        trans->hw_addr = NULL;
    503503                        fibril_condvar_initialize(&trans->cv);
    504                         rc = arp_addr_add(&proto->addresses, (char *) src_proto,
     504                        rc = arp_addr_add(&proto->addresses, src_proto,
    505505                            header->protocol_length, trans);
    506506                        if (rc != EOK) {
     
    510510                }
    511511                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);
    514514                        if (!trans->hw_addr)
    515515                                return ENOMEM;
    516 
     516                       
    517517                        /* Notify the fibrils that wait for the translation. */
    518518                        fibril_condvar_broadcast(&trans->cv);
     
    681681        measured_string_t *address;
    682682        measured_string_t *translation;
    683         char *data;
     683        uint8_t *data;
    684684        packet_t *packet;
    685685        packet_t *next;
     
    748748       
    749749        case NET_IL_RECEIVED:
     750               
    750751                rc = packet_translate_remote(arp_globals.net_phone, &packet,
    751752                    IPC_GET_PACKET(call));
  • uspace/srv/net/il/ip/ip.c

    r7c34b28f r61bfc370  
    275275        if (rc != EOK)
    276276                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);
    279279
    280280out:
     
    312312        measured_string_t names[] = {
    313313                {
    314                         (char *) "IPV",
     314                        (uint8_t *) "IPV",
    315315                        3
    316316                },
    317317                {
    318                         (char *) "IP_CONFIG",
     318                        (uint8_t *) "IP_CONFIG",
    319319                        9
    320320                },
    321321                {
    322                         (char *) "IP_ADDR",
     322                        (uint8_t *) "IP_ADDR",
    323323                        7
    324324                },
    325325                {
    326                         (char *) "IP_NETMASK",
     326                        (uint8_t *) "IP_NETMASK",
    327327                        10
    328328                },
    329329                {
    330                         (char *) "IP_GATEWAY",
     330                        (uint8_t *) "IP_GATEWAY",
    331331                        10
    332332                },
    333333                {
    334                         (char *) "IP_BROADCAST",
     334                        (uint8_t *) "IP_BROADCAST",
    335335                        12
    336336                },
    337337                {
    338                         (char *) "ARP",
     338                        (uint8_t *) "ARP",
    339339                        3
    340340                },
    341341                {
    342                         (char *) "IP_ROUTING",
     342                        (uint8_t *) "IP_ROUTING",
    343343                        10
    344344                }
     
    346346        measured_string_t *configuration;
    347347        size_t count = sizeof(names) / sizeof(measured_string_t);
    348         char *data;
     348        uint8_t *data;
    349349        measured_string_t address;
    350350        ip_route_t *route;
     
    368368        if (configuration) {
    369369                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",
    373373                    configuration[1].length);
    374374               
     
    394394                        }
    395395                       
    396                         if ((inet_pton(AF_INET, configuration[2].value,
     396                        if ((inet_pton(AF_INET, (char *) configuration[2].value,
    397397                            (uint8_t *) &route->address.s_addr) != EOK) ||
    398                             (inet_pton(AF_INET, configuration[3].value,
     398                            (inet_pton(AF_INET, (char *) configuration[3].value,
    399399                            (uint8_t *) &route->netmask.s_addr) != EOK) ||
    400                             (inet_pton(AF_INET, configuration[4].value,
     400                            (inet_pton(AF_INET, (char *) configuration[4].value,
    401401                            (uint8_t *) &gateway.s_addr) == EINVAL) ||
    402                             (inet_pton(AF_INET, configuration[5].value,
     402                            (inet_pton(AF_INET, (char *) configuration[5].value,
    403403                            (uint8_t *) &ip_netif->broadcast.s_addr) == EINVAL))
    404404                            {
     
    441441        if (ip_netif->arp) {
    442442                if (route) {
    443                         address.value = (char *) &route->address.s_addr;
     443                        address.value = (uint8_t *) &route->address.s_addr;
    444444                        address.length = sizeof(in_addr_t);
    445445                       
     
    997997        measured_string_t destination;
    998998        measured_string_t *translation;
    999         char *data;
     999        uint8_t *data;
    10001000        int phone;
    10011001        int rc;
     
    10041004        if (netif->arp && (route->address.s_addr != dest.s_addr)) {
    10051005                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;
    10071007                destination.length = sizeof(dest.s_addr);
    10081008
     
    17561756                    (header->destination_address & route->netmask.s_addr))) {
    17571757                        // clear the ARP mapping if any
    1758                         address.value = (char *) &header->destination_address;
     1758                        address.value = (uint8_t *) &header->destination_address;
    17591759                        address.length = sizeof(header->destination_address);
    17601760                        arp_clear_address_req(netif->arp->phone,
  • uspace/srv/net/net/net.c

    r7c34b28f r61bfc370  
    9090 *
    9191 */
    92 int add_configuration(measured_strings_t *configuration, const char *name,
    93     const char *value)
     92int add_configuration(measured_strings_t *configuration, const uint8_t *name,
     93    const uint8_t *value)
    9494{
    9595        int rc;
     
    119119}
    120120
    121 static int parse_line(measured_strings_t *configuration, char *line)
     121static int parse_line(measured_strings_t *configuration, uint8_t *line)
    122122{
    123123        int rc;
    124124       
    125125        /* From the beginning */
    126         char *name = line;
     126        uint8_t *name = line;
    127127       
    128128        /* Skip comments and blank lines */
     
    135135       
    136136        /* Remember the name start */
    137         char *value = name;
     137        uint8_t *value = name;
    138138       
    139139        /* Skip the name */
     
    186186       
    187187        /* 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)
    190190                return EOVERFLOW;
    191191       
    192192        /* Open the file */
    193         FILE *cfg = fopen(line, "r");
     193        FILE *cfg = fopen(fname, "r");
    194194        if (!cfg)
    195195                return ENOENT;
     
    201201        unsigned int line_number = 0;
    202202        size_t index = 0;
     203        uint8_t line[BUFFER_SIZE];
     204       
    203205        while (!ferror(cfg) && !feof(cfg)) {
    204206                int read = fgetc(cfg);
     
    207209                                line[BUFFER_SIZE - 1] = '\0';
    208210                                fprintf(stderr, "%s: Configuration line %u too "
    209                                     "long: %s\n", NAME, line_number, line);
     211                                    "long: %s\n", NAME, line_number, (char *) line);
    210212                               
    211213                                /* No space left in the line buffer */
     
    213215                        }
    214216                        /* Append the character */
    215                         line[index] = (char) read;
     217                        line[index] = (uint8_t) read;
    216218                        index++;
    217219                } else {
     
    221223                        if (parse_line(configuration, line) != EOK) {
    222224                                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);
    224226                        }
    225227                       
     
    282284                return rc;
    283285       
    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);
    298300        if (rc != EOK)
    299301                return rc;
     
    364366 */
    365367static 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)
    367369{
    368370        if (data)
     
    390392
    391393int net_get_conf_req(int net_phone, measured_string_t **configuration,
    392     size_t count, char **data)
     394    size_t count, uint8_t **data)
    393395{
    394396        if (!configuration || (count <= 0))
     
    399401
    400402int 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)
    402404{
    403405        if ((!configuration) || (count == 0))
     
    411413}
    412414
    413 void net_free_settings(measured_string_t *settings, char *data)
     415void net_free_settings(measured_string_t *settings, uint8_t *data)
    414416{
    415417}
     
    437439        /* Mandatory netif */
    438440        measured_string_t *setting =
    439             measured_strings_find(&netif->configuration, CONF_NETIF, 0);
     441            measured_strings_find(&netif->configuration, (uint8_t *) CONF_NETIF, 0);
    440442       
    441443        netif->driver = get_running_module(&net_globals.modules, setting->value);
     
    447449       
    448450        /* 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);
    450452        if (setting) {
    451453                netif->nil = get_running_module(&net_globals.modules, setting->value);
     
    459461       
    460462        /* 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);
    462464        netif->il = get_running_module(&net_globals.modules, setting->value);
    463465        if (!netif->il) {
     
    468470       
    469471        /* 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;
    475477       
    476478        rc = netif_probe_req_remote(netif->driver->phone, netif->id, irq, io);
     
    481483        services_t internet_service;
    482484        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);
    484486                if (!setting)
    485487                        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;
    489491               
    490492                rc = nil_device_req(netif->nil->phone, netif->id, mtu,
     
    558560                /* Mandatory name */
    559561                measured_string_t *setting =
    560                     measured_strings_find(&netif->configuration, CONF_NAME, 0);
     562                    measured_strings_find(&netif->configuration, (uint8_t *) CONF_NAME, 0);
    561563                if (!setting) {
    562564                        fprintf(stderr, "%s: Network interface name is missing\n", NAME);
     
    602604                printf("%s: Network interface started (name: %s, id: %d, driver: %s, "
    603605                    "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]",
    605607                    netif->il->name);
    606608        }
     
    628630{
    629631        measured_string_t *strings;
    630         char *data;
     632        uint8_t *data;
    631633        int rc;
    632634       
  • uspace/srv/net/net/net.h

    r7c34b28f r61bfc370  
    105105        module_t *driver;
    106106       
    107         device_id_t id; /**< System-unique network interface identifier. */
    108         module_t *il;   /**< Serving internet layer module index. */
    109         char *name;     /**< System-unique network interface name. */
    110         module_t *nil;  /**< Serving link layer module index. */
     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. */
    111111} netif_t;
    112112
     
    133133} net_globals_t;
    134134
    135 extern int add_configuration(measured_strings_t *, const char *, const char *);
     135extern int add_configuration(measured_strings_t *, const uint8_t *,
     136    const uint8_t *);
    136137extern int net_module_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, int *);
    137138extern int net_initialize_build(async_client_conn_t);
  • uspace/srv/net/net/net_standalone.c

    r7c34b28f r61bfc370  
    6363        int rc;
    6464       
    65         task_id_t task_id = spawn("/srv/ip");
     65        task_id_t task_id = net_spawn((uint8_t *) "/srv/ip");
    6666        if (!task_id)
    6767                return EINVAL;
    6868       
    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);
    7171        if (rc != EOK)
    7272                return rc;
    7373       
    74         if (!spawn("/srv/icmp"))
     74        if (!net_spawn((uint8_t *) "/srv/icmp"))
    7575                return EINVAL;
    7676       
    77         if (!spawn("/srv/udp"))
     77        if (!net_spawn((uint8_t *) "/srv/udp"))
    7878                return EINVAL;
    7979       
    80         if (!spawn("/srv/tcp"))
     80        if (!net_spawn((uint8_t *) "/srv/tcp"))
    8181                return EINVAL;
    8282       
  • uspace/srv/net/netif/lo/lo.c

    r7c34b28f r61bfc370  
    5353
    5454/** Default hardware address. */
    55 #define DEFAULT_ADDR            "\0\0\0\0\0\0"
     55#define DEFAULT_ADDR  0
    5656
    5757/** Default address length. */
    58 #define DEFAULT_ADDR_LEN        (sizeof(DEFAULT_ADDR) / sizeof(char))
     58#define DEFAULT_ADDR_LEN  6
    5959
    6060/** Loopback module name. */
     
    6262
    6363/** Network interface global data. */
    64 netif_globals_t netif_globals;
     64netif_globals_t netif_globals;
    6565
    6666int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
     
    7474        if (!address)
    7575                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;
    7881        address->length = DEFAULT_ADDR_LEN;
    79 
     82       
    8083        return EOK;
    8184}
  • uspace/srv/net/nil/eth/eth.c

    r7c34b28f r61bfc370  
    201201
    202202        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);
    204204        if (!eth_globals.broadcast_addr) {
    205205                rc = ENOMEM;
     
    284284        measured_string_t names[2] = {
    285285                {
    286                         (char *) "ETH_MODE",
     286                        (uint8_t *) "ETH_MODE",
    287287                        8
    288288                },
    289289                {
    290                         (char *) "ETH_DUMMY",
     290                        (uint8_t *) "ETH_DUMMY",
    291291                        9
    292292                }
     
    294294        measured_string_t *configuration;
    295295        size_t count = sizeof(names) / sizeof(measured_string_t);
    296         char *data;
     296        uint8_t *data;
    297297        eth_proto_t *proto;
    298298        int rc;
     
    358358
    359359        if (configuration) {
    360                 if (!str_lcmp(configuration[0].value, "DIX",
     360                if (!str_lcmp((char *) configuration[0].value, "DIX",
    361361                    configuration[0].length)) {
    362362                        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",
    364364                    configuration[0].length)) {
    365365                        device->flags |= ETH_8023_2_LSAP;
  • uspace/srv/net/tl/icmp/icmp.c

    r7c34b28f r61bfc370  
    405405        measured_string_t names[] = {
    406406                {
    407                         (char *) "ICMP_ERROR_REPORTING",
     407                        (uint8_t *) "ICMP_ERROR_REPORTING",
    408408                        20
    409409                },
    410410                {
    411                         (char *) "ICMP_ECHO_REPLYING",
     411                        (uint8_t *) "ICMP_ECHO_REPLYING",
    412412                        18
    413413                }
     
    415415        measured_string_t *configuration;
    416416        size_t count = sizeof(names) / sizeof(measured_string_t);
    417         char *data;
     417        uint8_t *data;
    418418        int rc;
    419419
  • uspace/srv/net/tl/tcp/tcp.c

    r7c34b28f r61bfc370  
    154154
    155155        /** Port map key. */
    156         char *key;
     156        uint8_t *key;
    157157
    158158        /** Port map key length. */
     
    358358        /* Find the destination socket */
    359359        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);
    361361        if (!socket) {
    362362                /* Find the listening destination socket */
    363363                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);
    366366        }
    367367
     
    998998        /* Find the destination socket */
    999999        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);
    10011001        if (!listening_socket ||
    10021002            (listening_socket->socket_id != listening_socket_id)) {
     
    10221022
    10231023        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);
    10251025        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));
    10271027
    10281028//      rc = socket_bind_free_port(&tcp_globals.sockets, socket,
     
    21092109
    21102110        /* Copy the key */
    2111         operation_timeout->key = ((char *) operation_timeout) +
     2111        operation_timeout->key = ((uint8_t *) operation_timeout) +
    21122112            sizeof(*operation_timeout);
    21132113        operation_timeout->key_length = socket->key_length;
  • uspace/srv/net/tl/udp/udp.c

    r7c34b28f r61bfc370  
    104104        measured_string_t names[] = {
    105105                {
    106                         (char *) "UDP_CHECKSUM_COMPUTING",
     106                        (uint8_t *) "UDP_CHECKSUM_COMPUTING",
    107107                        22
    108108                },
    109109                {
    110                         (char *) "UDP_AUTOBINDING",
     110                        (uint8_t *) "UDP_AUTOBINDING",
    111111                        15
    112112                }
     
    114114        measured_string_t *configuration;
    115115        size_t count = sizeof(names) / sizeof(measured_string_t);
    116         char *data;
     116        uint8_t *data;
    117117        int rc;
    118118
     
    283283        /* Find the destination socket */
    284284        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);
    286286        if (!socket) {
    287287                if (tl_prepare_icmp_packet(udp_globals.net_phone,
Note: See TracChangeset for help on using the changeset viewer.