Changeset ffaba00 in mainline


Ignore:
Timestamp:
2011-01-17T16:04:26Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a2d8d59
Parents:
f1938c6
Message:

improve cstyle and comments

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/include/icmp_header.h

    rf1938c6 rffaba00  
    4545
    4646/** ICMP header size in bytes. */
    47 #define ICMP_HEADER_SIZE        sizeof(icmp_header_t)
    48 
    49 /** Type definition of the echo specific data.
    50  * @see icmp_echo
    51  */
    52 typedef struct icmp_echo icmp_echo_t;
     47#define ICMP_HEADER_SIZE  sizeof(icmp_header_t)
    5348
    5449/** Echo specific data. */
    55 struct icmp_echo {
     50typedef struct icmp_echo {
    5651        /** Message idintifier. */
    5752        icmp_param_t identifier;
    5853        /** Message sequence number. */
    5954        icmp_param_t sequence_number;
    60 } __attribute__ ((packed));
    61 
    62 /** Type definition of the internet control message header.
    63  * @see icmp_header
    64  */
    65 typedef struct icmp_header icmp_header_t;
     55} __attribute__((packed)) icmp_echo_t;
    6656
    6757/** Internet control message header. */
    68 struct icmp_header {
     58typedef struct icmp_header {
    6959        /** The type of the message. */
    7060        uint8_t type;
     
    8373         */
    8474        uint16_t checksum;
    85 
     75       
    8676        /** Message specific data. */
    8777        union {
    8878                /** Echo specific data. */
    89                 icmp_echo_t  echo;
     79                icmp_echo_t echo;
    9080                /** Proposed gateway value. */
    9181                in_addr_t gateway;
     
    10797                } param;
    10898        } un;
    109 } __attribute__ ((packed));
     99} __attribute__((packed)) icmp_header_t;
    110100
    111101#endif
  • uspace/srv/net/tl/icmp/icmp.c

    rf1938c6 rffaba00  
    123123static bool error_reporting = true;
    124124static bool echo_replying = true;
     125static packet_dimension_t icmp_dimension;
    125126
    126127/** ICMP client identification counter */
    127128static atomic_t icmp_client;
    128 static packet_dimension_t icmp_dimension;
    129 
    130 /** ICMP identifier and sequence number */
     129
     130/** ICMP identifier and sequence number (client-specific) */
    131131static fibril_local icmp_param_t icmp_id;
    132132static fibril_local icmp_param_t icmp_seq;
     
    142142         * are 16-bit values.
    143143         */
    144         hash_index_t index = (key[0] & 0xffff) << 16 | (key[1] & 0xffff);
    145         return index % REPLY_BUCKETS;
     144        hash_index_t index = ((key[0] & 0xffff) << 16) | (key[1] & 0xffff);
     145        return (index % REPLY_BUCKETS);
    146146}
    147147
     
    209209        header->type = type;
    210210        header->code = code;
     211       
     212        /*
     213         * The checksum needs to be calculated
     214         * with a virtual checksum field set to
     215         * zero.
     216         */
    211217        header->checksum = 0;
    212218        header->checksum = ICMP_CHECKSUM(header,
     
    281287 *         zero.
    282288 * @return ENOMEM if there is not enough memory left.
    283  * @return EPARTY if there was an internal error.
    284289 *
    285290 */
     
    328333        }
    329334       
    330         bzero(header, sizeof(*header));
     335        bzero(header, sizeof(icmp_header_t));
    331336        header->un.echo.identifier = id;
    332337        header->un.echo.sequence_number = sequence;
     
    439444        unsigned long key[REPLY_KEYS] =
    440445            {header->un.echo.identifier, header->un.echo.sequence_number};
     446       
     447        /* The packet is no longer needed */
    441448        icmp_release(packet);
    442449       
     
    698705/** Per-connection initialization
    699706 *
     707 * Initialize client-specific global variables.
     708 *
    700709 */
    701710void tl_connection(void)
Note: See TracChangeset for help on using the changeset viewer.