Changeset 28a3e74 in mainline for uspace/lib/net/generic


Ignore:
Timestamp:
2011-04-02T09:22:46Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
250dbef, b2a081ae
Parents:
ea53529
Message:

Fix comment style.

Location:
uspace/lib/net/generic
Files:
3 edited

Legend:

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

    rea53529 r28a3e74  
    106106                return EBADMEM;
    107107
    108         // request the address
     108        /* Request the address */
    109109        message_id = async_send_1(phone, (sysarg_t) message,
    110110            (sysarg_t) device_id, NULL);
     
    112112        async_wait_for(message_id, &result);
    113113
    114         // if not successful
     114        /* If not successful */
    115115        if ((string == EOK) && (result != EOK)) {
    116                 // clear the data
     116                /* Clear the data */
    117117                free(*address);
    118118                free(*data);
     
    242242                return EBADMEM;
    243243
    244         // request the translation
     244        /* Request the translation */
    245245        message_id = async_send_3(phone, (sysarg_t) message,
    246246            (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);
     
    249249        async_wait_for(message_id, &result);
    250250
    251         // if not successful
     251        /* If not successful */
    252252        if ((string == EOK) && (result != EOK)) {
    253                 // clear the data
     253                /* Clear the data */
    254254                free(*translation);
    255255                free(*data);
  • uspace/lib/net/generic/net_checksum.c

    rea53529 r28a3e74  
    5252uint16_t compact_checksum(uint32_t sum)
    5353{
    54         // shorten to the 16 bits
     54        /* Shorten to the 16 bits */
    5555        while (sum >> 16)
    5656                sum = (sum & 0xffff) + (sum >> 16);
     
    7272        size_t index;
    7373
    74         // sum all the 16 bit fields
     74        /* Sum all the 16 bit fields */
    7575        for (index = 0; index + 1 < length; index += 2)
    7676                seed += (data[index] << 8) + data[index + 1];
    7777
    78         // last odd byte with zero padding
     78        /* Last odd byte with zero padding */
    7979        if (index + 1 == length)
    8080                seed += data[index] << 8;
     
    9494        size_t index;
    9595
    96         // process full bytes
     96        /* Process full bytes */
    9797        while (length >= 8) {
    98                 // add the data
     98                /* Add the data */
    9999                seed ^= (*data) << 24;
    100100               
    101                 // for each added bit
     101                /* For each added bit */
    102102                for (index = 0; index < 8; ++index) {
    103                         // if the first bit is set
     103                        /* If the first bit is set */
    104104                        if (seed & 0x80000000) {
    105                                 // shift and divide the checksum
     105                                /* Shift and divide the checksum */
    106106                                seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
    107107                        } else {
    108                                 // shift otherwise
     108                                /* shift otherwise */
    109109                                seed <<= 1;
    110110                        }
    111111                }
    112112               
    113                 // move to the next byte
     113                /* Move to the next byte */
    114114                ++data;
    115115                length -= 8;
    116116        }
    117117
    118         // process the odd bits
     118        /* Process the odd bits */
    119119        if (length > 0) {
    120                 // add the data with zero padding
     120                /* Add the data with zero padding */
    121121                seed ^= ((*data) & (0xff << (8 - length))) << 24;
    122122               
    123                 // for each added bit
     123                /* For each added bit */
    124124                for (index = 0; index < length; ++index) {
    125                         // if the first bit is set
     125                        /* If the first bit is set */
    126126                        if (seed & 0x80000000) {
    127                                 // shift and divide the checksum
     127                                /* Shift and divide the checksum */
    128128                                seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
    129129                        } else {
    130                                 // shift otherwise
     130                                /* Shift otherwise */
    131131                                seed <<= 1;
    132132                        }
     
    148148        size_t index;
    149149
    150         // process full bytes
     150        /* Process full bytes */
    151151        while (length >= 8) {
    152                 // add the data
     152                /* Add the data */
    153153                seed ^= (*data);
    154154               
    155                 // for each added bit
     155                /* For each added bit */
    156156                for (index = 0; index < 8; ++index) {
    157                         // if the last bit is set
     157                        /* If the last bit is set */
    158158                        if (seed & 1) {
    159                                 // shift and divide the checksum
     159                                /* Shift and divide the checksum */
    160160                                seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
    161161                        } else {
    162                                 // shift otherwise
     162                                /* Shift otherwise */
    163163                                seed >>= 1;
    164164                        }
    165165                }
    166166               
    167                 // move to the next byte
     167                /* Move to the next byte */
    168168                ++data;
    169169                length -= 8;
    170170        }
    171171
    172         // process the odd bits
     172        /* Process the odd bits */
    173173        if (length > 0) {
    174                 // add the data with zero padding
     174                /* Add the data with zero padding */
    175175                seed ^= (*data) >> (8 - length);
    176176               
    177177                for (index = 0; index < length; ++index) {
    178                         // if the last bit is set
     178                        /* If the last bit is set */
    179179                        if (seed & 1) {
    180                                 // shift and divide the checksum
     180                                /* Shift and divide the checksum */
    181181                                seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
    182182                        } else {
    183                                 // shift otherwise
     183                                /* Shift otherwise */
    184184                                seed >>= 1;
    185185                        }
     
    198198uint16_t flip_checksum(uint16_t checksum)
    199199{
    200         // flip, zero is returned as 0xFFFF (not flipped)
     200        /* Flip, zero is returned as 0xFFFF (not flipped) */
    201201        checksum = ~checksum;
    202202        return checksum ? checksum : IP_CHECKSUM_ZERO;
     
    216216uint16_t ip_checksum(uint8_t *data, size_t length)
    217217{
    218         // compute, compact and flip the data checksum
     218        /* Compute, compact and flip the data checksum */
    219219        return flip_checksum(compact_checksum(compute_checksum(0, data,
    220220            length)));
  • uspace/lib/net/generic/packet_client.c

    rea53529 r28a3e74  
    267267                return NULL;
    268268
    269         // get a new packet
     269        /* Get a new packet */
    270270        copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet),
    271271            PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix,
     
    274274                return NULL;
    275275
    276         // get addresses
     276        /* Get addresses */
    277277        addrlen = packet_get_addr(packet, &src, &dest);
    278         // copy data
     278        /* Copy data */
    279279        if ((packet_copy_data(copy, packet_get_data(packet),
    280280            PACKET_DATA_LENGTH(packet)) == EOK) &&
    281             // copy addresses if present
     281            /* Copy addresses if present */
    282282            ((addrlen <= 0) ||
    283283            (packet_set_addr(copy, src, dest, addrlen) == EOK))) {
Note: See TracChangeset for help on using the changeset viewer.