Ignore:
File:
1 edited

Legend:

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

    r7bf12387 r88a1bb9  
    6464 */
    6565#define IP_FRAGMENT_OFFSET(header) \
    66         (((GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \
     66        ((((header)->fragment_offset_high << 8) + \
    6767            (header)->fragment_offset_low) * 8U)
    6868
     
    8383 */
    8484#define IP_HEADER_LENGTH(header) \
    85         (GET_IP_HEADER_LENGTH(header) * 4U)
     85        ((header)->header_length * 4U)
    8686
    8787/** Returns the actual IP packet total length.
     
    143143 */
    144144struct ip_header {
    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))
     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
    158152
    159153        uint8_t tos;
     
    161155        uint16_t identification;
    162156
    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))
     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
    176164
    177165        uint8_t fragment_offset_low;
     
    193181        uint8_t pointer;
    194182
    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 
     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
    209190} __attribute__ ((packed));
    210191
Note: See TracChangeset for help on using the changeset viewer.