Changes in uspace/lib/net/include/ip_header.h [7bf12387:88a1bb9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/include/ip_header.h
r7bf12387 r88a1bb9 64 64 */ 65 65 #define IP_FRAGMENT_OFFSET(header) \ 66 ((( GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header)<< 8) + \66 ((((header)->fragment_offset_high << 8) + \ 67 67 (header)->fragment_offset_low) * 8U) 68 68 … … 83 83 */ 84 84 #define IP_HEADER_LENGTH(header) \ 85 ( GET_IP_HEADER_LENGTH(header)* 4U)85 ((header)->header_length * 4U) 86 86 87 87 /** Returns the actual IP packet total length. … … 143 143 */ 144 144 struct 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 158 152 159 153 uint8_t tos; … … 161 155 uint16_t identification; 162 156 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 176 164 177 165 uint8_t fragment_offset_low; … … 193 181 uint8_t pointer; 194 182 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 209 190 } __attribute__ ((packed)); 210 191
Note:
See TracChangeset
for help on using the changeset viewer.