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