Changeset df3c6f02 in mainline for uspace/srv/net/il/ip/ip.c
- Timestamp:
- 2011-05-31T22:58:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d362410
- Parents:
- 82582e4 (diff), 4ce90544 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/ip/ip.c
r82582e4 rdf3c6f02 201 201 202 202 /* Set the destination address */ 203 switch ( header->version) {203 switch (GET_IP_HEADER_VERSION(header)) { 204 204 case IPVERSION: 205 205 addrlen = sizeof(dest_in); … … 365 365 366 366 if (ip_netif->dhcp) { 367 / * TODO dhcp */367 // TODO dhcp 368 368 net_free_settings(configuration, data); 369 369 return ENOTSUP; … … 398 398 } 399 399 } else { 400 / * TODO ipv6 in separate module */400 // TODO ipv6 in separate module 401 401 net_free_settings(configuration, data); 402 402 return ENOTSUP; … … 517 517 ip_netif->dhcp ? "dhcp" : "static"); 518 518 519 / * TODO ipv6 addresses */519 // TODO ipv6 addresses 520 520 521 521 char address[INET_ADDRSTRLEN]; … … 635 635 636 636 /* Process all IP options */ 637 while (next < first->header_length) {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 last->header_length = length / 4 + 1;658 SET_IP_HEADER_LENGTH(last, (length / 4 + 1)); 659 659 } else { 660 last->header_length = length / 4;660 SET_IP_HEADER_LENGTH(last, (length / 4)); 661 661 } 662 662 … … 706 706 return rc; 707 707 708 header->version = IPV4;709 header->fragment_offset_high = 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 header->flags |= IPFLAG_MORE_FRAGMENTS; 737 SET_IP_HEADER_FLAGS(header, 738 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 738 739 middle_header->total_length = 739 740 htons(packet_get_data_length(next)); 740 middle_header->fragment_offset_high =741 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ;741 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header, 742 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length)); 742 743 middle_header->fragment_offset_low = 743 744 IP_COMPUTE_FRAGMENT_OFFSET_LOW(length); … … 768 769 middle_header->total_length = 769 770 htons(packet_get_data_length(next)); 770 middle_header->fragment_offset_high =771 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ;771 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header, 772 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length)); 772 773 middle_header->fragment_offset_low = 773 774 IP_COMPUTE_FRAGMENT_OFFSET_LOW(length); … … 785 786 length += packet_get_data_length(next); 786 787 free(last_header); 787 header->flags |= IPFLAG_MORE_FRAGMENTS; 788 SET_IP_HEADER_FLAGS(header, 789 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 788 790 } 789 791 … … 834 836 new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length); 835 837 offset = IP_FRAGMENT_OFFSET(header) + IP_HEADER_DATA_LENGTH(header); 836 new_header->fragment_offset_high =837 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset) ;838 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(new_header, 839 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset)); 838 840 new_header->fragment_offset_low = 839 841 IP_COMPUTE_FRAGMENT_OFFSET_LOW(offset); … … 865 867 return NULL; 866 868 memcpy(middle, last, IP_HEADER_LENGTH(last)); 867 middle->flags |= IPFLAG_MORE_FRAGMENTS; 869 SET_IP_HEADER_FLAGS(middle, 870 (GET_IP_HEADER_FLAGS(middle) | IPFLAG_MORE_FRAGMENTS)); 868 871 return middle; 869 872 } … … 922 925 923 926 /* Fragmentation forbidden? */ 924 if( header->flags& IPFLAG_DONT_FRAGMENT)927 if(GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT) 925 928 return EPERM; 926 929 … … 946 949 947 950 /* Greatest multiple of 8 lower than content */ 948 / * TODO even fragmentation? */951 // TODO even fragmentation? 949 952 length = length & ~0x7; 950 953 … … 958 961 959 962 /* Mark the first as fragmented */ 960 header->flags |= IPFLAG_MORE_FRAGMENTS; 963 SET_IP_HEADER_FLAGS(header, 964 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 961 965 962 966 /* Create middle fragments */ … … 1212 1216 } 1213 1217 1214 /* Ff the local host is the destination */1218 /* If the local host is the destination */ 1215 1219 if ((route->address.s_addr == dest->s_addr) && 1216 1220 (dest->s_addr != IPV4_LOCALHOST_ADDRESS)) { … … 1279 1283 in_addr_t destination; 1280 1284 1281 / * TODO search set ipopt route? */1285 // TODO search set ipopt route? 1282 1286 destination.s_addr = header->destination_address; 1283 1287 return destination; … … 1319 1323 int rc; 1320 1324 1321 if (( header->flags& IPFLAG_MORE_FRAGMENTS) ||1325 if ((GET_IP_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) || 1322 1326 IP_FRAGMENT_OFFSET(header)) { 1323 / * TODO fragmented */1327 // TODO fragmented 1324 1328 return ENOTSUP; 1325 1329 } 1326 1330 1327 switch ( header->version) {1331 switch (GET_IP_HEADER_VERSION(header)) { 1328 1332 case IPVERSION: 1329 1333 addrlen = sizeof(src_in); … … 1437 1441 phone = ip_prepare_icmp_and_get_phone(0, packet, header); 1438 1442 if (phone >= 0) { 1439 /* ttlexceeded ICMP */1443 /* TTL exceeded ICMP */ 1440 1444 icmp_time_exceeded_msg(phone, ICMP_EXC_TTL, packet); 1441 1445 } … … 1447 1451 1448 1452 /* Set the destination address */ 1449 switch ( header->version) {1453 switch (GET_IP_HEADER_VERSION(header)) { 1450 1454 case IPVERSION: 1451 1455 addrlen = sizeof(addr_in); … … 1777 1781 if ((type != ICMP_DEST_UNREACH) || 1778 1782 (code != ICMP_HOST_UNREACH)) { 1779 1783 /* No, something else */ 1780 1784 break; 1781 1785 }
Note:
See TracChangeset
for help on using the changeset viewer.