Changes in uspace/srv/net/il/ip/ip_header.h [21580dd:aadf01e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/ip/ip_header.h
r21580dd raadf01e 45 45 * @param[in] header The IP packet header. 46 46 */ 47 #define IP_HEADER_LENGTH( header ) (( header )->header_length * 4u)47 #define IP_HEADER_LENGTH(header) ((header)->header_length * 4u) 48 48 49 49 /** Returns the IP header length. 50 50 * @param[in] length The IP header length in bytes. 51 51 */ 52 #define IP_COMPUTE_HEADER_LENGTH( length ) (( uint8_t ) (( length ) / 4u))52 #define IP_COMPUTE_HEADER_LENGTH(length) ((uint8_t) ((length) / 4u)) 53 53 54 54 /** Returns the actual IP packet total length. 55 55 * @param[in] header The IP packet header. 56 56 */ 57 #define IP_TOTAL_LENGTH( header ) ntohs(( header )->total_length)57 #define IP_TOTAL_LENGTH(header) ntohs((header)->total_length) 58 58 59 59 /** Returns the actual IP packet data length. 60 60 * @param[in] header The IP packet header. 61 61 */ 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)) 63 63 64 64 /** Returns the IP packet header checksum. 65 65 * @param[in] header The IP packet header. 66 66 */ 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)))) 68 68 69 69 /** Returns the fragment offest. 70 70 * @param[in] header The IP packet header. 71 71 */ 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) 73 73 74 74 /** Returns the fragment offest high bits. 75 75 * @param[in] length The prefixed data total length. 76 76 */ 77 #define IP_COMPUTE_FRAGMENT_OFFSET_HIGH( length ) (((( length ) / 8u ) & 0x1F00 ) >> 8)77 #define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ((((length) / 8u) &0x1F00) >> 8) 78 78 79 79 /** Returns the fragment offest low bits. 80 80 * @param[in] length The prefixed data total length. 81 81 */ 82 #define IP_COMPUTE_FRAGMENT_OFFSET_LOW( length ) ((( length ) / 8u ) & 0xFF)82 #define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) (((length) / 8u) &0xFF) 83 83 84 84 /** Type definition of the internet header. … … 99 99 /** The Version field indicates the format of the internet header. 100 100 */ 101 uint8_t 101 uint8_t version:4; 102 102 /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. 103 103 * Note that the minimum value for a~correct header is~5. 104 104 */ 105 uint8_t 105 uint8_t header_length:4; 106 106 #else 107 107 /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. 108 108 * Note that the minimum value for a~correct header is~5. 109 109 */ 110 uint8_t 110 uint8_t header_length:4; 111 111 /** The Version field indicates the format of the internet header. 112 112 */ 113 uint8_t 113 uint8_t version:4; 114 114 #endif 115 115 /** The Type of Service provides an indication of the abstract parameters of the quality of service desired. … … 118 118 * The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput. 119 119 */ 120 uint8_t 120 uint8_t tos; 121 121 /** Total Length is the length of the datagram, measured in octets, including internet header and data. 122 122 * This field allows the length of a~datagram to be up to 65,535~octets. 123 123 */ 124 uint16_t 124 uint16_t total_length; 125 125 /** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram. 126 126 */ 127 uint16_t 127 uint16_t identification; 128 128 #ifdef ARCH_IS_BIG_ENDIAN 129 129 /** Various control flags. 130 130 */ 131 uint8_t 131 uint8_t flags:3; 132 132 /** This field indicates where in the datagram this fragment belongs. 133 133 * High bits. 134 134 */ 135 uint8_t 135 uint8_t fragment_offset_high:5; 136 136 #else 137 137 /** This field indicates where in the datagram this fragment belongs. 138 138 * High bits. 139 139 */ 140 uint8_t 140 uint8_t fragment_offset_high:5; 141 141 /** Various control flags. 142 142 */ 143 uint8_t 143 uint8_t flags:3; 144 144 #endif 145 145 /** This field indicates where in the datagram this fragment belongs. 146 146 * Low bits. 147 147 */ 148 uint8_t 148 uint8_t fragment_offset_low; 149 149 /** This field indicates the maximum time the datagram is allowed to remain in the internet system. 150 150 * If this field contains the value zero, then the datagram must be destroyed. … … 153 153 * The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime. 154 154 */ 155 uint8_t 155 uint8_t ttl; 156 156 /** This field indicates the next level protocol used in the data portion of the internet datagram. 157 157 */ 158 uint8_t 158 uint8_t protocol; 159 159 /** A checksum of the header only. 160 160 * Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed. … … 162 162 * For purposes of computing the checksum, the value of the checksum field is zero. 163 163 */ 164 uint16_t 164 uint16_t header_checksum; 165 165 /** The source address. 166 166 */ 167 uint32_t 167 uint32_t source_address; 168 168 /** The destination address. 169 169 */ 170 uint32_t 170 uint32_t destination_address; 171 171 } __attribute__ ((packed)); 172 172 … … 188 188 /** A single octet of option-type. 189 189 */ 190 uint8_t 190 uint8_t type; 191 191 /** An option length octet. 192 192 */ 193 uint8_t 193 uint8_t length; 194 194 /** A~pointer. 195 195 */ 196 uint8_t 196 uint8_t pointer; 197 197 #ifdef ARCH_IS_BIG_ENDIAN 198 198 /** The number of IP modules that cannot register timestamps due to lack of space. 199 199 */ 200 uint8_t 200 uint8_t overflow:4; 201 201 /** Various internet timestamp control flags. 202 202 */ 203 uint8_t 203 uint8_t flags:4; 204 204 #else 205 205 /** Various internet timestamp control flags. 206 206 */ 207 uint8_t 207 uint8_t flags:4; 208 208 /** The number of IP modules that cannot register timestamps due to lack of space. 209 209 */ 210 uint8_t 210 uint8_t overflow:4; 211 211 #endif 212 212 } __attribute__ ((packed)); … … 227 227 * Allows the packet fragmentation. 228 228 */ 229 #define IPFLAG_MAY_FRAGMENT ( 0x0 << IPFLAG_FRAGMENT_SHIFT)229 #define IPFLAG_MAY_FRAGMENT (0x0 << IPFLAG_FRAGMENT_SHIFT) 230 230 231 231 /** Don't fragment flag value. 232 232 * Permits the packet fragmentation. 233 233 */ 234 #define IPFLAG_DONT_FRAGMENT ( 0x1 << IPFLAG_FRAGMENT_SHIFT)234 #define IPFLAG_DONT_FRAGMENT (0x1 << IPFLAG_FRAGMENT_SHIFT) 235 235 236 236 /** Last fragment flag value. 237 237 * Indicates the last packet fragment. 238 238 */ 239 #define IPFLAG_LAST_FRAGMENT ( 0x0 << IPFLAG_FRAGMENTED_SHIFT)239 #define IPFLAG_LAST_FRAGMENT (0x0 << IPFLAG_FRAGMENTED_SHIFT) 240 240 241 241 /** More fragments flag value. 242 242 * Indicates that more packet fragments follow. 243 243 */ 244 #define IPFLAG_MORE_FRAGMENTS ( 0x1 << IPFLAG_FRAGMENTED_SHIFT)244 #define IPFLAG_MORE_FRAGMENTS (0x1 << IPFLAG_FRAGMENTED_SHIFT) 245 245 246 246 /*@}*/ … … 261 261 /** The source address. 262 262 */ 263 uint32_t 263 uint32_t source_address; 264 264 /** The destination address. 265 265 */ 266 uint32_t 266 uint32_t destination_address; 267 267 /** Reserved byte. 268 268 * Must be zero. 269 269 */ 270 uint8_t 270 uint8_t reserved; 271 271 /** This field indicates the next level protocol used in the data portion of the internet datagram. 272 272 */ 273 uint8_t 273 uint8_t protocol; 274 274 /** Data length is the length of the datagram, measured in octets. 275 275 */ 276 uint16_t 276 uint16_t data_length; 277 277 } __attribute__ ((packed)); 278 278
Note:
See TracChangeset
for help on using the changeset viewer.