Changeset 41811af in mainline for uspace/srv/net/il/ip/ip.c
- Timestamp:
- 2011-06-10T10:14:26Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab547063
- Parents:
- 9536e6e (diff), 390d80d (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
r9536e6e r41811af 77 77 #include <il_skel.h> 78 78 79 // FIXME: remove this header 80 #include <kernel/ipc/ipc_methods.h> 81 79 82 /** IP module name. */ 80 83 #define NAME "ip" … … 201 204 202 205 /* Set the destination address */ 203 switch ( header->version) {206 switch (GET_IP_HEADER_VERSION(header)) { 204 207 case IPVERSION: 205 208 addrlen = sizeof(dest_in); … … 635 638 636 639 /* Process all IP options */ 637 while (next < first->header_length) {640 while (next < GET_IP_HEADER_LENGTH(first)) { 638 641 option = (ip_option_t *) (((uint8_t *) first) + next); 639 642 /* Skip end or noop */ … … 656 659 if (length % 4) { 657 660 bzero(((uint8_t *) last) + length, 4 - (length % 4)); 658 last->header_length = length / 4 + 1;661 SET_IP_HEADER_LENGTH(last, (length / 4 + 1)); 659 662 } else { 660 last->header_length = length / 4;663 SET_IP_HEADER_LENGTH(last, (length / 4)); 661 664 } 662 665 … … 706 709 return rc; 707 710 708 header->version = IPV4;709 header->fragment_offset_high = 0;711 SET_IP_HEADER_VERSION(header, IPV4); 712 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, 0); 710 713 header->fragment_offset_low = 0; 711 714 header->header_checksum = 0; … … 735 738 memcpy(middle_header, last_header, 736 739 IP_HEADER_LENGTH(last_header)); 737 header->flags |= IPFLAG_MORE_FRAGMENTS; 740 SET_IP_HEADER_FLAGS(header, 741 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 738 742 middle_header->total_length = 739 743 htons(packet_get_data_length(next)); 740 middle_header->fragment_offset_high =741 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ;744 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header, 745 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length)); 742 746 middle_header->fragment_offset_low = 743 747 IP_COMPUTE_FRAGMENT_OFFSET_LOW(length); … … 768 772 middle_header->total_length = 769 773 htons(packet_get_data_length(next)); 770 middle_header->fragment_offset_high =771 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ;774 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header, 775 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length)); 772 776 middle_header->fragment_offset_low = 773 777 IP_COMPUTE_FRAGMENT_OFFSET_LOW(length); … … 785 789 length += packet_get_data_length(next); 786 790 free(last_header); 787 header->flags |= IPFLAG_MORE_FRAGMENTS; 791 SET_IP_HEADER_FLAGS(header, 792 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 788 793 } 789 794 … … 834 839 new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length); 835 840 offset = IP_FRAGMENT_OFFSET(header) + IP_HEADER_DATA_LENGTH(header); 836 new_header->fragment_offset_high =837 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset) ;841 SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(new_header, 842 IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset)); 838 843 new_header->fragment_offset_low = 839 844 IP_COMPUTE_FRAGMENT_OFFSET_LOW(offset); … … 865 870 return NULL; 866 871 memcpy(middle, last, IP_HEADER_LENGTH(last)); 867 middle->flags |= IPFLAG_MORE_FRAGMENTS; 872 SET_IP_HEADER_FLAGS(middle, 873 (GET_IP_HEADER_FLAGS(middle) | IPFLAG_MORE_FRAGMENTS)); 868 874 return middle; 869 875 } … … 922 928 923 929 /* Fragmentation forbidden? */ 924 if( header->flags& IPFLAG_DONT_FRAGMENT)930 if(GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT) 925 931 return EPERM; 926 932 … … 958 964 959 965 /* Mark the first as fragmented */ 960 header->flags |= IPFLAG_MORE_FRAGMENTS; 966 SET_IP_HEADER_FLAGS(header, 967 (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS)); 961 968 962 969 /* Create middle fragments */ … … 1319 1326 int rc; 1320 1327 1321 if (( header->flags& IPFLAG_MORE_FRAGMENTS) ||1328 if ((GET_IP_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) || 1322 1329 IP_FRAGMENT_OFFSET(header)) { 1323 1330 // TODO fragmented … … 1325 1332 } 1326 1333 1327 switch ( header->version) {1334 switch (GET_IP_HEADER_VERSION(header)) { 1328 1335 case IPVERSION: 1329 1336 addrlen = sizeof(src_in); … … 1447 1454 1448 1455 /* Set the destination address */ 1449 switch ( header->version) {1456 switch (GET_IP_HEADER_VERSION(header)) { 1450 1457 case IPVERSION: 1451 1458 addrlen = sizeof(addr_in); … … 1909 1916 1910 1917 *answer_count = 0; 1918 1919 if (!IPC_GET_IMETHOD(*call)) 1920 return EOK; 1921 1911 1922 switch (IPC_GET_IMETHOD(*call)) { 1912 case IPC_M_PHONE_HUNGUP:1913 return EOK;1914 1915 1923 case IPC_M_CONNECT_TO_ME: 1916 1924 return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call),
Note:
See TracChangeset
for help on using the changeset viewer.