Changeset aadf01e in mainline for uspace/srv/net/il/ip/ip_header.h


Ignore:
Timestamp:
2010-03-07T15:13:28Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
936835e
Parents:
aa85487
Message:

Coding style (no functional change)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/il/ip/ip_header.h

    raa85487 raadf01e  
    4545 *  @param[in] header The IP packet header.
    4646 */
    47 #define IP_HEADER_LENGTH( header )              (( header )->header_length * 4u )
     47#define IP_HEADER_LENGTH(header)                ((header)->header_length * 4u)
    4848
    4949/** Returns the IP header length.
    5050 *  @param[in] length The IP header length in bytes.
    5151 */
    52 #define IP_COMPUTE_HEADER_LENGTH( length )              (( uint8_t ) (( length ) / 4u ))
     52#define IP_COMPUTE_HEADER_LENGTH(length)                ((uint8_t) ((length) / 4u))
    5353
    5454/** Returns the actual IP packet total length.
    5555 *  @param[in] header The IP packet header.
    5656 */
    57 #define IP_TOTAL_LENGTH( header )               ntohs(( header )->total_length )
     57#define IP_TOTAL_LENGTH(header)         ntohs((header)->total_length)
    5858
    5959/** Returns the actual IP packet data length.
    6060 *  @param[in] header The IP packet header.
    6161 */
    62 #define IP_HEADER_DATA_LENGTH( header ) ( IP_TOTAL_LENGTH( header ) - IP_HEADER_LENGTH( header ))
     62#define IP_HEADER_DATA_LENGTH(header)   (IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
    6363
    6464/** Returns the IP packet header checksum.
    6565 *  @param[in] header The IP packet header.
    6666 */
    67 #define IP_HEADER_CHECKSUM( header )    ( htons( ip_checksum(( uint8_t * )( header ), IP_HEADER_LENGTH( header ))))
     67#define IP_HEADER_CHECKSUM(header)      (htons(ip_checksum((uint8_t *)(header), IP_HEADER_LENGTH(header))))
    6868
    6969/** Returns the fragment offest.
    7070 *  @param[in] header The IP packet header.
    7171 */
    72 #define IP_FRAGMENT_OFFSET( header ) (((( header )->fragment_offset_high << 8 ) + ( header )->fragment_offset_low ) * 8u )
     72#define IP_FRAGMENT_OFFSET(header) ((((header)->fragment_offset_high << 8) + (header)->fragment_offset_low) * 8u)
    7373
    7474/** Returns the fragment offest high bits.
    7575 *  @param[in] length The prefixed data total length.
    7676 */
    77 #define IP_COMPUTE_FRAGMENT_OFFSET_HIGH( length ) (((( length ) / 8u ) & 0x1F00 ) >> 8 )
     77#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ((((length) / 8u) &0x1F00) >> 8)
    7878
    7979/** Returns the fragment offest low bits.
    8080 *  @param[in] length The prefixed data total length.
    8181 */
    82 #define IP_COMPUTE_FRAGMENT_OFFSET_LOW( length ) ((( length ) / 8u ) & 0xFF )
     82#define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) (((length) / 8u) &0xFF)
    8383
    8484/** Type definition of the internet header.
     
    9999        /** The Version field indicates the format of the internet header.
    100100         */
    101         uint8_t         version:4;
     101        uint8_t version:4;
    102102        /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
    103103         *  Note that the minimum value for a~correct header is~5.
    104104         */
    105         uint8_t         header_length:4;
     105        uint8_t header_length:4;
    106106#else
    107107        /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
    108108         *  Note that the minimum value for a~correct header is~5.
    109109         */
    110         uint8_t         header_length:4;
     110        uint8_t header_length:4;
    111111        /** The Version field indicates the format of the internet header.
    112112         */
    113         uint8_t         version:4;
     113        uint8_t version:4;
    114114#endif
    115115        /** The Type of Service provides an indication of the abstract parameters of the quality of service desired.
     
    118118         *  The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput.
    119119         */
    120         uint8_t         tos;
     120        uint8_t tos;
    121121        /** Total Length is the length of the datagram, measured in octets, including internet header and data.
    122122         *  This field allows the length of a~datagram to be up to 65,535~octets.
    123123         */
    124         uint16_t        total_length;
     124        uint16_t total_length;
    125125        /** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram.
    126126         */
    127         uint16_t        identification;
     127        uint16_t identification;
    128128#ifdef ARCH_IS_BIG_ENDIAN
    129129        /** Various control flags.
    130130         */
    131         uint8_t flags:3;
     131        uint8_t flags:3;
    132132        /** This field indicates where in the datagram this fragment belongs.
    133133         *  High bits.
    134134         */
    135         uint8_t fragment_offset_high:5;
     135        uint8_t fragment_offset_high:5;
    136136#else
    137137        /** This field indicates where in the datagram this fragment belongs.
    138138         *  High bits.
    139139         */
    140         uint8_t fragment_offset_high:5;
     140        uint8_t fragment_offset_high:5;
    141141        /** Various control flags.
    142142         */
    143         uint8_t flags:3;
     143        uint8_t flags:3;
    144144#endif
    145145        /** This field indicates where in the datagram this fragment belongs.
    146146         *  Low bits.
    147147         */
    148         uint8_t fragment_offset_low;
     148        uint8_t fragment_offset_low;
    149149        /** This field indicates the maximum time the datagram is allowed to remain in the internet system.
    150150         *  If this field contains the value zero, then the datagram must be destroyed.
     
    153153         *  The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.
    154154         */
    155         uint8_t         ttl;
     155        uint8_t ttl;
    156156        /** This field indicates the next level protocol used in the data portion of the internet datagram.
    157157         */
    158         uint8_t         protocol;
     158        uint8_t protocol;
    159159        /** A checksum of the header only.
    160160         *  Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed.
     
    162162         *  For purposes of computing the checksum, the value of the checksum field is zero.
    163163         */
    164         uint16_t        header_checksum;
     164        uint16_t header_checksum;
    165165        /** The source address.
    166166         */
    167         uint32_t        source_address;
     167        uint32_t source_address;
    168168        /** The destination address.
    169169         */
    170         uint32_t        destination_address;
     170        uint32_t destination_address;
    171171} __attribute__ ((packed));
    172172
     
    188188        /** A single octet of option-type.
    189189         */
    190         uint8_t         type;
     190        uint8_t type;
    191191        /** An option length octet.
    192192         */
    193         uint8_t         length;
     193        uint8_t length;
    194194        /** A~pointer.
    195195         */
    196         uint8_t         pointer;
     196        uint8_t pointer;
    197197#ifdef ARCH_IS_BIG_ENDIAN
    198198        /** The number of IP modules that cannot register timestamps due to lack of space.
    199199         */
    200         uint8_t overflow:4;
     200        uint8_t overflow:4;
    201201        /** Various internet timestamp control flags.
    202202         */
    203         uint8_t flags:4;
     203        uint8_t flags:4;
    204204#else
    205205        /** Various internet timestamp control flags.
    206206         */
    207         uint8_t flags:4;
     207        uint8_t flags:4;
    208208        /** The number of IP modules that cannot register timestamps due to lack of space.
    209209         */
    210         uint8_t overflow:4;
     210        uint8_t overflow:4;
    211211#endif
    212212} __attribute__ ((packed));
     
    227227 *  Allows the packet fragmentation.
    228228 */
    229 #define IPFLAG_MAY_FRAGMENT                     ( 0x0 << IPFLAG_FRAGMENT_SHIFT )
     229#define IPFLAG_MAY_FRAGMENT                     (0x0 << IPFLAG_FRAGMENT_SHIFT)
    230230
    231231/** Don't fragment flag value.
    232232 *  Permits the packet fragmentation.
    233233 */
    234 #define IPFLAG_DONT_FRAGMENT            ( 0x1 << IPFLAG_FRAGMENT_SHIFT )
     234#define IPFLAG_DONT_FRAGMENT            (0x1 << IPFLAG_FRAGMENT_SHIFT)
    235235
    236236/** Last fragment flag value.
    237237 *  Indicates the last packet fragment.
    238238 */
    239 #define IPFLAG_LAST_FRAGMENT            ( 0x0 << IPFLAG_FRAGMENTED_SHIFT )
     239#define IPFLAG_LAST_FRAGMENT            (0x0 << IPFLAG_FRAGMENTED_SHIFT)
    240240
    241241/** More fragments flag value.
    242242 *  Indicates that more packet fragments follow.
    243243 */
    244 #define IPFLAG_MORE_FRAGMENTS           ( 0x1 << IPFLAG_FRAGMENTED_SHIFT )
     244#define IPFLAG_MORE_FRAGMENTS           (0x1 << IPFLAG_FRAGMENTED_SHIFT)
    245245
    246246/*@}*/
     
    261261        /** The source address.
    262262         */
    263         uint32_t        source_address;
     263        uint32_t source_address;
    264264        /** The destination address.
    265265         */
    266         uint32_t        destination_address;
     266        uint32_t destination_address;
    267267        /** Reserved byte.
    268268         *  Must be zero.
    269269         */
    270         uint8_t         reserved;
     270        uint8_t reserved;
    271271        /** This field indicates the next level protocol used in the data portion of the internet datagram.
    272272         */
    273         uint8_t         protocol;
     273        uint8_t protocol;
    274274        /** Data length is the length of the datagram, measured in octets.
    275275         */
    276         uint16_t        data_length;
     276        uint16_t data_length;
    277277} __attribute__ ((packed));
    278278
Note: See TracChangeset for help on using the changeset viewer.