Changeset 82d56184 in mainline for uspace/lib/net/include/ip_header.h


Ignore:
Timestamp:
2011-06-01T21:05:19Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5cac9cd
Parents:
682cfceb (diff), 5d1b3aa (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r682cfceb r82d56184  
    6464 */
    6565#define IP_FRAGMENT_OFFSET(header) \
    66         ((((header)->fragment_offset_high << 8) + \
     66        (((GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \
    6767            (header)->fragment_offset_low) * 8U)
    6868
     
    8383 */
    8484#define IP_HEADER_LENGTH(header) \
    85         ((header)->header_length * 4U)
     85        (GET_IP_HEADER_LENGTH(header) * 4U)
    8686
    8787/** Returns the actual IP packet total length.
     
    143143 */
    144144struct ip_header {
    145 #ifdef ARCH_IS_BIG_ENDIAN
    146         uint8_t version : 4;
    147         uint8_t header_length : 4;
    148 #else
    149         uint8_t header_length : 4;
    150         uint8_t version : 4;
    151 #endif
     145        uint8_t vhl; /* version, header_length */
     146
     147#define GET_IP_HEADER_VERSION(header) \
     148        (((header)->vhl & 0xf0) >> 4)
     149#define SET_IP_HEADER_VERSION(header, version) \
     150        ((header)->vhl = \
     151         ((version & 0x0f) << 4) | ((header)->vhl & 0x0f))
     152
     153#define GET_IP_HEADER_LENGTH(header) \
     154        ((header)->vhl & 0x0f)
     155#define SET_IP_HEADER_LENGTH(header, length) \
     156        ((header)->vhl = \
     157         (length & 0x0f) | ((header)->vhl & 0xf0))
    152158
    153159        uint8_t tos;
     
    155161        uint16_t identification;
    156162
    157 #ifdef ARCH_IS_BIG_ENDIAN
    158         uint8_t flags : 3;
    159         uint8_t fragment_offset_high : 5;
    160 #else
    161         uint8_t fragment_offset_high : 5;
    162         uint8_t flags : 3;
    163 #endif
     163        uint8_t ffoh; /* flags, fragment_offset_high */
     164
     165#define GET_IP_HEADER_FLAGS(header) \
     166        (((header)->ffoh & 0xe0) >> 5)
     167#define SET_IP_HEADER_FLAGS(header, flags) \
     168        ((header)->ffoh = \
     169         ((flags & 0x07) << 5) | ((header)->ffoh & 0x1f))
     170
     171#define GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) \
     172        ((header)->ffoh & 0x1f)
     173#define SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, fragment_offset_high) \
     174        ((header)->ffoh = \
     175         (fragment_offset_high & 0x1f) | ((header)->ffoh & 0xe0))
    164176
    165177        uint8_t fragment_offset_low;
     
    181193        uint8_t pointer;
    182194
    183 #ifdef ARCH_IS_BIG_ENDIAN
    184         uint8_t overflow : 4;
    185         uint8_t flags : 4;
    186 #else
    187         uint8_t flags : 4;
    188         uint8_t overflow : 4;
    189 #endif
     195        uint8_t of; /* overflow, flags */
     196
     197#define GET_IP_OPTION_OVERFLOW(option) \
     198        (((option)->of & 0xf0) >> 4)
     199#define SET_IP_OPTION_OVERFLOW(option, overflow) \
     200        ((option)->of = \
     201         ((overflow & 0x0f) << 4) | ((option)->of & 0x0f))
     202
     203#define GET_IP_OPTION_FLAGS(option) \
     204        ((option)->of & 0x0f)
     205#define SET_IP_OPTION_FLAGS(option, flags) \
     206        ((option)->of = \
     207         (flags & 0x0f) | ((option)->of & 0xf0))
     208
    190209} __attribute__ ((packed));
    191210
Note: See TracChangeset for help on using the changeset viewer.