Changeset 45bb1d2 in mainline


Ignore:
Timestamp:
2010-12-27T20:04:22Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b35fea3, e64e40b
Parents:
727f04f
Message:

Fix comment style in lib/c/generic/net.

Location:
uspace/lib/c/generic/net
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/net/icmp_api.c

    r727f04f r45bb1d2  
    8989            tos, (sysarg_t) dont_fragment, NULL);
    9090
    91         // send the address
     91        /* Send the address */
    9292        async_data_write_start(icmp_phone, addr, (size_t) addrlen);
    9393
  • uspace/lib/c/generic/net/inet.c

    r727f04f r45bb1d2  
    6464        switch (family) {
    6565        case AF_INET:
    66                 // check the output buffer size
     66                /* Check output buffer size */
    6767                if (length < INET_ADDRSTRLEN)
    6868                        return ENOMEM;
    6969                       
    70                 // fill the buffer with the IPv4 address
     70                /* Fill buffer with IPv4 address */
    7171                snprintf(address, length, "%hhu.%hhu.%hhu.%hhu",
    7272                    data[0], data[1], data[2], data[3]);
     
    7575
    7676        case AF_INET6:
    77                 // check the output buffer size
     77                /* Check output buffer size */
    7878                if (length < INET6_ADDRSTRLEN)
    7979                        return ENOMEM;
    8080               
    81                 // fill the buffer with the IPv6 address
     81                /* Fill buffer with IPv6 address */
    8282                snprintf(address, length,
    8383                    "%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:"
     
    124124                return EINVAL;
    125125
    126         // set the processing parameters
     126        /* Set processing parameters */
    127127        switch (family) {
    128128        case AF_INET:
     
    142142        }
    143143
    144         // erase if no address
     144        /* Erase if no address */
    145145        if (!address) {
    146146                bzero(data, count);
     
    148148        }
    149149
    150         // process the string from the beginning
     150        /* Process string from the beginning */
    151151        next = address;
    152152        index = 0;
    153153        do {
    154                 // if the actual character is set
     154                /* If the actual character is set */
    155155                if (next && *next) {
    156156
    157                         // if not on the first character
     157                        /* If not on the first character */
    158158                        if (index) {
    159                                 // move to the next character
     159                                /* Move to the next character */
    160160                                ++next;
    161161                        }
    162162
    163                         // parse the actual integral value
     163                        /* Parse the actual integral value */
    164164                        value = strtoul(next, &last, base);
    165                         // remember the last problematic character
    166                         // should be either '.' or ':' but is ignored to be more
    167                         // generic
     165                        /*
     166                         * Remember the last problematic character
     167                         * should be either '.' or ':' but is ignored to be
     168                         * more generic
     169                         */
    168170                        next = last;
    169171
    170                         // fill the address data byte by byte
     172                        /* Fill the address data byte by byte */
    171173                        shift = bytes - 1;
    172174                        do {
    173                                 // like little endian
     175                                /* like little endian */
    174176                                data[index + shift] = value;
    175177                                value >>= 8;
     
    178180                        index += bytes;
    179181                } else {
    180                         // erase the rest of the address
     182                        /* Erase the rest of the address */
    181183                        bzero(data + index, count - index);
    182184                        return EOK;
  • uspace/lib/c/generic/net/modules.c

    r727f04f r45bb1d2  
    6363    int answer_count)
    6464{
    65         // choose the most efficient answer function
     65        /* Choose the most efficient answer function */
    6666        if (answer || (!answer_count)) {
    6767                switch (answer_count) {
     
    178178        int phone;
    179179
    180         // if no timeout is set
     180        /* If no timeout is set */
    181181        if (timeout <= 0)
    182182                return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);
     
    187187                        return phone;
    188188
    189                 // end if no time is left
     189                /* Abort if no time is left */
    190190                if (timeout <= 0)
    191191                        return ETIMEOUT;
    192192
    193                 // wait the minimum of the module wait time and the timeout
     193                /* Wait the minimum of the module wait time and the timeout */
    194194                usleep((timeout <= MODULE_WAIT_TIME) ?
    195195                    timeout : MODULE_WAIT_TIME);
     
    214214        ipc_callid_t callid;
    215215
    216         // fetch the request
     216        /* Fetch the request */
    217217        if (!async_data_read_receive(&callid, &length))
    218218                return EINVAL;
    219219
    220         // check the requested data size
     220        /* Check the requested data size */
    221221        if (length < data_length) {
    222222                async_data_read_finalize(callid, data, length);
     
    224224        }
    225225
    226         // send the data
     226        /* Send the data */
    227227        return async_data_read_finalize(callid, data, data_length);
    228228}
     
    242242        if (answer) {
    243243                IPC_SET_RETVAL(*answer, 0);
    244                 // just to be precize
     244                /* Just to be precise */
    245245                IPC_SET_IMETHOD(*answer, 0);
    246246                IPC_SET_ARG1(*answer, 0);
  • uspace/lib/c/generic/net/packet.c

    r727f04f r45bb1d2  
    191191        }
    192192        gpm_destroy(&pm_globals.packet_map);
    193         // leave locked
     193        /* leave locked */
    194194}
    195195
  • uspace/lib/c/generic/net/socket_client.c

    r727f04f r45bb1d2  
    220220                fibril_rwlock_read_lock(&socket_globals.lock);
    221221
    222                 // find the socket
     222                /* Find the socket */
    223223                socket = sockets_find(socket_get_sockets(),
    224224                    SOCKET_GET_SOCKET_ID(call));
     
    232232                case NET_SOCKET_RECEIVED:
    233233                        fibril_mutex_lock(&socket->receive_lock);
    234                         // push the number of received packet fragments
     234                        /* Push the number of received packet fragments */
    235235                        rc = dyn_fifo_push(&socket->received,
    236236                            SOCKET_GET_DATA_FRAGMENTS(call),
    237237                            SOCKET_MAX_RECEIVED_SIZE);
    238238                        if (rc == EOK) {
    239                                 // signal the received packet
     239                                /* Signal the received packet */
    240240                                fibril_condvar_signal(&socket->receive_signal);
    241241                        }
     
    244244
    245245                case NET_SOCKET_ACCEPTED:
    246                         // push the new socket identifier
     246                        /* Push the new socket identifier */
    247247                        fibril_mutex_lock(&socket->accept_lock);
    248248                        rc = dyn_fifo_push(&socket->accepted, 1,
    249249                            SOCKET_MAX_ACCEPTED_SIZE);
    250250                        if (rc == EOK) {
    251                                 // signal the accepted socket
     251                                /* Signal the accepted socket */
    252252                                fibril_condvar_signal(&socket->accept_signal);
    253253                        }
     
    264264                        fibril_rwlock_write_lock(&socket->sending_lock);
    265265
    266                         // set the data fragment size
     266                        /* Set the data fragment size */
    267267                        socket->data_fragment_size =
    268268                            SOCKET_GET_DATA_FRAGMENT_SIZE(call);
     
    342342                        socket_id = 1;
    343343                        ++count;
    344                 // only this branch for last_id
     344                /* Only this branch for last_id */
    345345                } else {
    346346                        if (socket_id < INT_MAX) {
     
    408408        int rc;
    409409
    410         // find the appropriate service
     410        /* Find the appropriate service */
    411411        switch (domain) {
    412412        case PF_INET:
     
    457457                return phone;
    458458
    459         // create a new socket structure
     459        /* Create a new socket structure */
    460460        socket = (socket_t *) malloc(sizeof(socket_t));
    461461        if (!socket)
     
    465465        fibril_rwlock_write_lock(&socket_globals.lock);
    466466
    467         // request a new socket
     467        /* Request a new socket */
    468468        socket_id = socket_generate_new_id();
    469469        if (socket_id <= 0) {
     
    484484        socket->header_size = (size_t) header_size;
    485485
    486         // finish the new socket initialization
     486        /* Finish the new socket initialization */
    487487        socket_initialize(socket, socket_id, phone, service);
    488         // store the new socket
     488        /* Store the new socket */
    489489        rc = sockets_add(socket_get_sockets(), socket_id, socket);
    490490
     
    531531        fibril_rwlock_read_lock(&socket_globals.lock);
    532532
    533         // find the socket
     533        /* Find the socket */
    534534        socket = sockets_find(socket_get_sockets(), socket_id);
    535535        if (!socket) {
     
    538538        }
    539539
    540         // request the message
     540        /* Request the message */
    541541        message_id = async_send_3(socket->phone, message,
    542542            (sysarg_t) socket->socket_id, arg2, socket->service, NULL);
    543         // send the address
     543        /* Send the address */
    544544        async_data_write_start(socket->phone, data, datalength);
    545545
     
    566566                return EINVAL;
    567567
    568         // send the address
     568        /* Send the address */
    569569        return socket_send_data(socket_id, NET_SOCKET_BIND, 0, my_addr,
    570570            (size_t) addrlen);
     
    591591        fibril_rwlock_read_lock(&socket_globals.lock);
    592592
    593         // find the socket
     593        /* Find the socket */
    594594        socket = sockets_find(socket_get_sockets(), socket_id);
    595595        if (!socket) {
     
    598598        }
    599599
    600         // request listen backlog change
     600        /* Request listen backlog change */
    601601        result = (int) async_req_3_0(socket->phone, NET_SOCKET_LISTEN,
    602602            (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service);
     
    634634        fibril_rwlock_write_lock(&socket_globals.lock);
    635635
    636         // find the socket
     636        /* Find the socket */
    637637        socket = sockets_find(socket_get_sockets(), socket_id);
    638638        if (!socket) {
     
    643643        fibril_mutex_lock(&socket->accept_lock);
    644644
    645         // wait for an accepted socket
     645        /* Wait for an accepted socket */
    646646        ++ socket->blocked;
    647647        while (dyn_fifo_value(&socket->accepted) <= 0) {
    648648                fibril_rwlock_write_unlock(&socket_globals.lock);
    649649                fibril_condvar_wait(&socket->accept_signal, &socket->accept_lock);
    650                 // drop the accept lock to avoid deadlock
     650                /* Drop the accept lock to avoid deadlock */
    651651                fibril_mutex_unlock(&socket->accept_lock);
    652652                fibril_rwlock_write_lock(&socket_globals.lock);
     
    655655        -- socket->blocked;
    656656
    657         // create a new scoket
     657        /* Create a new socket */
    658658        new_socket = (socket_t *) malloc(sizeof(socket_t));
    659659        if (!new_socket) {
     
    681681        }
    682682
    683         // request accept
     683        /* Request accept */
    684684        message_id = async_send_5(socket->phone, NET_SOCKET_ACCEPT,
    685685            (sysarg_t) socket->socket_id, 0, socket->service, 0,
    686686            new_socket->socket_id, &answer);
    687687
    688         // read address
     688        /* Read address */
    689689        ipc_data_read_start(socket->phone, cliaddr, *addrlen);
    690690        fibril_rwlock_write_unlock(&socket_globals.lock);
     
    695695                        result = EINVAL;
    696696
    697                 // dequeue the accepted socket if successful
     697                /* Dequeue the accepted socket if successful */
    698698                dyn_fifo_pop(&socket->accepted);
    699                 // set address length
     699                /* Set address length */
    700700                *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer);
    701701                new_socket->data_fragment_size =
    702702                    SOCKET_GET_DATA_FRAGMENT_SIZE(answer);
    703703        } else if (result == ENOTSOCK) {
    704                 // empty the queue if no accepted sockets
     704                /* Empty the queue if no accepted sockets */
    705705                while (dyn_fifo_pop(&socket->accepted) > 0)
    706706                        ;
     
    731731                return EDESTADDRREQ;
    732732
    733         // send the address
     733        /* Send the address */
    734734        return socket_send_data(socket_id, NET_SOCKET_CONNECT, 0, serv_addr,
    735735            addrlen);
     
    744744        int accepted_id;
    745745
    746         // destroy all accepted sockets
     746        /* Destroy all accepted sockets */
    747747        while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0)
    748748                socket_destroy(sockets_find(socket_get_sockets(), accepted_id));
     
    780780        }
    781781
    782         // request close
     782        /* Request close */
    783783        rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE,
    784784            (sysarg_t) socket->socket_id, 0, socket->service);
     
    787787                return rc;
    788788        }
    789         // free the socket structure
     789        /* Free the socket structure */
    790790        socket_destroy(socket);
    791791
     
    833833        fibril_rwlock_read_lock(&socket_globals.lock);
    834834
    835         // find socket
     835        /* Find socket */
    836836        socket = sockets_find(socket_get_sockets(), socket_id);
    837837        if (!socket) {
     
    842842        fibril_rwlock_read_lock(&socket->sending_lock);
    843843
    844         // compute data fragment count
     844        /* Compute data fragment count */
    845845        if (socket->data_fragment_size > 0) {
    846846                fragments = (datalength + socket->header_size) /
     
    853853        }
    854854
    855         // request send
     855        /* Request send */
    856856        message_id = async_send_5(socket->phone, message,
    857857            (sysarg_t) socket->socket_id,
     
    859859            socket->service, (sysarg_t) flags, fragments, &answer);
    860860
    861         // send the address if given
     861        /* Send the address if given */
    862862        if (!toaddr ||
    863863            (async_data_write_start(socket->phone, toaddr, addrlen) == EOK)) {
    864864                if (fragments == 1) {
    865                         // send all if only one fragment
     865                        /* Send all if only one fragment */
    866866                        async_data_write_start(socket->phone, data, datalength);
    867867                } else {
    868                         // send the first fragment
     868                        /* Send the first fragment */
    869869                        async_data_write_start(socket->phone, data,
    870870                            socket->data_fragment_size - socket->header_size);
     
    872872                            socket->data_fragment_size - socket->header_size;
    873873       
    874                         // send the middle fragments
     874                        /* Send the middle fragments */
    875875                        while (--fragments > 1) {
    876876                                async_data_write_start(socket->phone, data,
     
    880880                        }
    881881
    882                         // send the last fragment
     882                        /* Send the last fragment */
    883883                        async_data_write_start(socket->phone, data,
    884884                            (datalength + socket->header_size) %
     
    892892            (SOCKET_GET_DATA_FRAGMENT_SIZE(answer) !=
    893893            socket->data_fragment_size)) {
    894                 // set the data fragment size
     894                /* Set the data fragment size */
    895895                socket->data_fragment_size =
    896896                    SOCKET_GET_DATA_FRAGMENT_SIZE(answer);
     
    917917int send(int socket_id, void *data, size_t datalength, int flags)
    918918{
    919         // without the address
     919        /* Without the address */
    920920        return sendto_core(NET_SOCKET_SEND, socket_id, data, datalength, flags,
    921921            NULL, 0);
     
    950950                return EDESTADDRREQ;
    951951
    952         // with the address
     952        /* With the address */
    953953        return sendto_core(NET_SOCKET_SENDTO, socket_id, data, datalength,
    954954            flags, toaddr, addrlen);
     
    998998        fibril_rwlock_read_lock(&socket_globals.lock);
    999999
    1000         // find the socket
     1000        /* Find the socket */
    10011001        socket = sockets_find(socket_get_sockets(), socket_id);
    10021002        if (!socket) {
     
    10061006
    10071007        fibril_mutex_lock(&socket->receive_lock);
    1008         // wait for a received packet
     1008        /* Wait for a received packet */
    10091009        ++socket->blocked;
    10101010        while ((result = dyn_fifo_value(&socket->received)) < 0) {
     
    10131013                    &socket->receive_lock);
    10141014
    1015                 // drop the receive lock to avoid deadlock
     1015                /* Drop the receive lock to avoid deadlock */
    10161016                fibril_mutex_unlock(&socket->receive_lock);
    10171017                fibril_rwlock_read_lock(&socket_globals.lock);
     
    10261026        }
    10271027
    1028         // prepare lengths if more fragments
     1028        /* Prepare lengths if more fragments */
    10291029        if (fragments > 1) {
    10301030                lengths = (size_t *) malloc(sizeof(size_t) * fragments +
     
    10361036                }
    10371037
    1038                 // request packet data
     1038                /* Request packet data */
    10391039                message_id = async_send_4(socket->phone, message,
    10401040                    (sysarg_t) socket->socket_id, 0, socket->service,
    10411041                    (sysarg_t) flags, &answer);
    10421042
    1043                 // read the address if desired
     1043                /* Read the address if desired */
    10441044                if(!fromaddr ||
    10451045                    (async_data_read_start(socket->phone, fromaddr,
    10461046                    *addrlen) == EOK)) {
    1047                         // read the fragment lengths
     1047                        /* Read the fragment lengths */
    10481048                        if (async_data_read_start(socket->phone, lengths,
    10491049                            sizeof(int) * (fragments + 1)) == EOK) {
    10501050                                if (lengths[fragments] <= datalength) {
    10511051
    1052                                         // read all fragments if long enough
     1052                                        /* Read all fragments if long enough */
    10531053                                        for (index = 0; index < fragments;
    10541054                                            ++index) {
     
    10651065                free(lengths);
    10661066        } else { /* fragments == 1 */
    1067                 // request packet data
     1067                /* Request packet data */
    10681068                message_id = async_send_4(socket->phone, message,
    10691069                    (sysarg_t) socket->socket_id, 0, socket->service,
    10701070                    (sysarg_t) flags, &answer);
    10711071
    1072                 // read the address if desired
     1072                /* Read the address if desired */
    10731073                if (!fromaddr ||
    10741074                    (async_data_read_start(socket->phone, fromaddr,
    10751075                        *addrlen) == EOK)) {
    1076                         // read all if only one fragment
     1076                        /* Read all if only one fragment */
    10771077                        async_data_read_start(socket->phone, data, datalength);
    10781078                }
     
    10821082        result = (int) ipc_result;
    10831083        if (result == EOK) {
    1084                 // dequeue the received packet
     1084                /* Dequeue the received packet */
    10851085                dyn_fifo_pop(&socket->received);
    1086                 // return read data length
     1086                /* Return read data length */
    10871087                retval = SOCKET_GET_READ_DATA_LENGTH(answer);
    1088                 // set address length
     1088                /* Set address length */
    10891089                if (fromaddr && addrlen)
    10901090                        *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer);
     
    11141114ssize_t recv(int socket_id, void *data, size_t datalength, int flags)
    11151115{
    1116         // without the address
     1116        /* Without the address */
    11171117        return recvfrom_core(NET_SOCKET_RECV, socket_id, data, datalength,
    11181118            flags, NULL, NULL);
     
    11461146                return NO_DATA;
    11471147
    1148         // with the address
     1148        /* With the address */
    11491149        return recvfrom_core(NET_SOCKET_RECVFROM, socket_id, data, datalength,
    11501150            flags, fromaddr, addrlen);
     
    11811181        fibril_rwlock_read_lock(&socket_globals.lock);
    11821182
    1183         // find the socket
     1183        /* Find the socket */
    11841184        socket = sockets_find(socket_get_sockets(), socket_id);
    11851185        if (!socket) {
     
    11881188        }
    11891189
    1190         // request option value
     1190        /* Request option value */
    11911191        message_id = async_send_3(socket->phone, NET_SOCKET_GETSOCKOPT,
    11921192            (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service,
    11931193            NULL);
    11941194
    1195         // read the length
     1195        /* Read the length */
    11961196        if (async_data_read_start(socket->phone, optlen,
    11971197            sizeof(*optlen)) == EOK) {
    1198                 // read the value
     1198                /* Read the value */
    11991199                async_data_read_start(socket->phone, value, *optlen);
    12001200        }
     
    12231223    size_t optlen)
    12241224{
    1225         // send the value
     1225        /* Send the value */
    12261226        return socket_send_data(socket_id, NET_SOCKET_SETSOCKOPT,
    12271227            (sysarg_t) optname, value, optlen);
Note: See TracChangeset for help on using the changeset viewer.