Changeset 7bf12387 in mainline
- Timestamp:
- 2011-05-28T19:44:42Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0743493a
- Parents:
- 40ffda8
- git-author:
- Jeff Rous <jeffrous@…> (2011-05-28 19:44:42)
- git-committer:
- Jakub Jermar <jakub@…> (2011-05-28 19:44:42)
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/il/ip_client.c
r40ffda8 r7bf12387 181 181 /* Set the header */ 182 182 header = (ip_header_t *) data; 183 SET_ HEADER_LENGTH(header, (IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t)184 183 SET_IP_HEADER_LENGTH(header, 184 (IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length))); 185 185 header->ttl = (ttl ? ttl : IPDEFTTL); 186 186 header->tos = tos; … … 188 188 189 189 if (dont_fragment) 190 SET_ HEADER_FLAGS(header, IPFLAG_DONT_FRAGMENT);190 SET_IP_HEADER_FLAGS(header, IPFLAG_DONT_FRAGMENT); 191 191 192 192 return EOK; … … 227 227 *tos = header->tos; 228 228 if (dont_fragment) 229 *dont_fragment = GET_ HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT;229 *dont_fragment = GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT; 230 230 if (ipopt_length) { 231 231 *ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t); -
uspace/lib/net/include/ip_header.h
r40ffda8 r7bf12387 64 64 */ 65 65 #define IP_FRAGMENT_OFFSET(header) \ 66 (((GET_ HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \66 (((GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \ 67 67 (header)->fragment_offset_low) * 8U) 68 68 … … 83 83 */ 84 84 #define IP_HEADER_LENGTH(header) \ 85 (GET_ HEADER_LENGTH(header) * 4U)85 (GET_IP_HEADER_LENGTH(header) * 4U) 86 86 87 87 /** Returns the actual IP packet total length. … … 145 145 uint8_t vhl; /* version, header_length */ 146 146 147 #define GET_ HEADER_VERSION(header) \147 #define GET_IP_HEADER_VERSION(header) \ 148 148 (((header)->vhl & 0xf0) >> 4) 149 #define SET_ HEADER_VERSION(header, version) \149 #define SET_IP_HEADER_VERSION(header, version) \ 150 150 ((header)->vhl = \ 151 151 ((version & 0x0f) << 4) | ((header)->vhl & 0x0f)) 152 152 153 #define GET_ HEADER_LENGTH(header) \153 #define GET_IP_HEADER_LENGTH(header) \ 154 154 ((header)->vhl & 0x0f) 155 #define SET_ HEADER_LENGTH(header, length) \155 #define SET_IP_HEADER_LENGTH(header, length) \ 156 156 ((header)->vhl = \ 157 157 (length & 0x0f) | ((header)->vhl & 0xf0)) … … 163 163 uint8_t ffoh; /* flags, fragment_offset_high */ 164 164 165 #define GET_ HEADER_FLAGS(header) \165 #define GET_IP_HEADER_FLAGS(header) \ 166 166 (((header)->ffoh & 0xe0) >> 5) 167 #define SET_ HEADER_FLAGS(header, flags) \167 #define SET_IP_HEADER_FLAGS(header, flags) \ 168 168 ((header)->ffoh = \ 169 169 ((flags & 0x07) << 5) | ((header)->ffoh & 0x1f)) 170 170 171 #define GET_ HEADER_FRAGMENT_OFFSET_HIGH(header) \171 #define GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) \ 172 172 ((header)->ffoh & 0x1f) 173 #define SET_ HEADER_FRAGMENT_OFFSET_HIGH(header, fragment_offset_high) \173 #define SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, fragment_offset_high) \ 174 174 ((header)->ffoh = \ 175 175 (fragment_offset_high & 0x1f) | ((header)->ffoh & 0xe0)) … … 195 195 uint8_t of; /* overflow, flags */ 196 196 197 #define GET_ OPTION_OVERFLOW(option) \197 #define GET_IP_OPTION_OVERFLOW(option) \ 198 198 (((option)->of & 0xf0) >> 4) 199 #define SET_ OPTION_OVERFLOW(option, overflow) \199 #define SET_IP_OPTION_OVERFLOW(option, overflow) \ 200 200 ((option)->of = \ 201 201 ((overflow & 0x0f) << 4) | ((option)->of & 0x0f)) 202 202 203 #define GET_ OPTION_FLAGS(option) \203 #define GET_IP_OPTION_FLAGS(option) \ 204 204 ((option)->of & 0x0f) 205 #define SET_ OPTION_FLAGS(option, flags) \205 #define SET_IP_OPTION_FLAGS(option, flags) \ 206 206 ((option)->of = \ 207 207 (flags & 0x0f) | ((option)->of & 0xf0)) -
uspace/srv/net/il/ip/ip.c
r40ffda8 r7bf12387 201 201 202 202 /* Set the destination address */ 203 switch (GET_ HEADER_VERSION(header)) {203 switch (GET_IP_HEADER_VERSION(header)) { 204 204 case IPVERSION: 205 205 addrlen = sizeof(dest_in); … … 635 635 636 636 /* Process all IP options */ 637 while (next < GET_ HEADER_LENGTH(first)) {637 while (next < GET_IP_HEADER_LENGTH(first)) { 638 638 option = (ip_option_t *) (((uint8_t *) first) + next); 639 639 /* Skip end or noop */ … … 656 656 if (length % 4) { 657 657 bzero(((uint8_t *) last) + length, 4 - (length % 4)); 658 SET_ HEADER_LENGTH(last, (length / 4 + 1));658 SET_IP_HEADER_LENGTH(last, (length / 4 + 1)); 659 659 } else { 660 SET_ HEADER_LENGTH(last, (length / 4));660 SET_IP_HEADER_LENGTH(last, (length / 4)); 661 661 } 662 662 … … 706 706 return rc; 707 707 708 SET_ HEADER_VERSION(header, IPV4);709 SET_ HEADER_FRAGMENT_OFFSET_HIGH(header, 0);708 SET_IP_HEADER_VERSION(header, IPV4); 709 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, 0); 710 710 header->fragment_offset_low = 0; 711 711 header->header_checksum = 0; … … 735 735 memcpy(middle_header, last_header, 736 736 IP_HEADER_LENGTH(last_header)); 737 SET_ HEADER_FLAGS(header,738 (GET_ HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));737 SET_IP_HEADER_FLAGS(header, 738 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 739 739 middle_header->total_length = 740 740 htons(packet_get_data_length(next)); 741 SET_ HEADER_FRAGMENT_OFFSET_HIGH(middle_header,741 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header, 742 742 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length)); 743 743 middle_header->fragment_offset_low = … … 769 769 middle_header->total_length = 770 770 htons(packet_get_data_length(next)); 771 SET_ HEADER_FRAGMENT_OFFSET_HIGH(middle_header,771 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header, 772 772 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length)); 773 773 middle_header->fragment_offset_low = … … 786 786 length += packet_get_data_length(next); 787 787 free(last_header); 788 SET_ HEADER_FLAGS(header,789 (GET_ HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));788 SET_IP_HEADER_FLAGS(header, 789 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 790 790 } 791 791 … … 836 836 new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length); 837 837 offset = IP_FRAGMENT_OFFSET(header) + IP_HEADER_DATA_LENGTH(header); 838 SET_ HEADER_FRAGMENT_OFFSET_HIGH(new_header,838 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(new_header, 839 839 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset)); 840 840 new_header->fragment_offset_low = … … 867 867 return NULL; 868 868 memcpy(middle, last, IP_HEADER_LENGTH(last)); 869 SET_ HEADER_FLAGS(middle,870 (GET_ HEADER_FLAGS(middle) | IPFLAG_MORE_FRAGMENTS));869 SET_IP_HEADER_FLAGS(middle, 870 (GET_IP_HEADER_FLAGS(middle) | IPFLAG_MORE_FRAGMENTS)); 871 871 return middle; 872 872 } … … 925 925 926 926 /* Fragmentation forbidden? */ 927 if(GET_ HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT)927 if(GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT) 928 928 return EPERM; 929 929 … … 961 961 962 962 /* Mark the first as fragmented */ 963 SET_ HEADER_FLAGS(header,964 (GET_ HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));963 SET_IP_HEADER_FLAGS(header, 964 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 965 965 966 966 /* Create middle fragments */ … … 1323 1323 int rc; 1324 1324 1325 if ((GET_ HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) ||1325 if ((GET_IP_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) || 1326 1326 IP_FRAGMENT_OFFSET(header)) { 1327 1327 // TODO fragmented … … 1329 1329 } 1330 1330 1331 switch (GET_ HEADER_VERSION(header)) {1331 switch (GET_IP_HEADER_VERSION(header)) { 1332 1332 case IPVERSION: 1333 1333 addrlen = sizeof(src_in); … … 1451 1451 1452 1452 /* Set the destination address */ 1453 switch (GET_ HEADER_VERSION(header)) {1453 switch (GET_IP_HEADER_VERSION(header)) { 1454 1454 case IPVERSION: 1455 1455 addrlen = sizeof(addr_in);
Note:
See TracChangeset
for help on using the changeset viewer.