Changeset 41811af in mainline for uspace/srv/net/il/ip/ip.c


Ignore:
Timestamp:
2011-06-10T10:14:26Z (14 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
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.
Message:

Merge mainline

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/il/ip/ip.c

    r9536e6e r41811af  
    7777#include <il_skel.h>
    7878
     79// FIXME: remove this header
     80#include <kernel/ipc/ipc_methods.h>
     81
    7982/** IP module name. */
    8083#define NAME                    "ip"
     
    201204
    202205        /* Set the destination address */
    203         switch (header->version) {
     206        switch (GET_IP_HEADER_VERSION(header)) {
    204207        case IPVERSION:
    205208                addrlen = sizeof(dest_in);
     
    635638
    636639        /* Process all IP options */
    637         while (next < first->header_length) {
     640        while (next < GET_IP_HEADER_LENGTH(first)) {
    638641                option = (ip_option_t *) (((uint8_t *) first) + next);
    639642                /* Skip end or noop */
     
    656659        if (length % 4) {
    657660                bzero(((uint8_t *) last) + length, 4 - (length % 4));
    658                 last->header_length = length / 4 + 1;
     661                SET_IP_HEADER_LENGTH(last, (length / 4 + 1));
    659662        } else {
    660                 last->header_length = length / 4;
     663                SET_IP_HEADER_LENGTH(last, (length / 4));
    661664        }
    662665
     
    706709                return rc;
    707710       
    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);
    710713        header->fragment_offset_low = 0;
    711714        header->header_checksum = 0;
     
    735738                        memcpy(middle_header, last_header,
    736739                            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));
    738742                        middle_header->total_length =
    739743                            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));
    742746                        middle_header->fragment_offset_low =
    743747                            IP_COMPUTE_FRAGMENT_OFFSET_LOW(length);
     
    768772                middle_header->total_length =
    769773                    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));
    772776                middle_header->fragment_offset_low =
    773777                    IP_COMPUTE_FRAGMENT_OFFSET_LOW(length);
     
    785789                length += packet_get_data_length(next);
    786790                free(last_header);
    787                 header->flags |= IPFLAG_MORE_FRAGMENTS;
     791                SET_IP_HEADER_FLAGS(header,
     792                    (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
    788793        }
    789794
     
    834839        new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length);
    835840        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));
    838843        new_header->fragment_offset_low =
    839844            IP_COMPUTE_FRAGMENT_OFFSET_LOW(offset);
     
    865870                return NULL;
    866871        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));
    868874        return middle;
    869875}
     
    922928
    923929        /* Fragmentation forbidden? */
    924         if(header->flags & IPFLAG_DONT_FRAGMENT)
     930        if(GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT)
    925931                return EPERM;
    926932
     
    958964
    959965        /* 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));
    961968
    962969        /* Create middle fragments */
     
    13191326        int rc;
    13201327
    1321         if ((header->flags & IPFLAG_MORE_FRAGMENTS) ||
     1328        if ((GET_IP_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) ||
    13221329            IP_FRAGMENT_OFFSET(header)) {
    13231330                // TODO fragmented
     
    13251332        }
    13261333       
    1327         switch (header->version) {
     1334        switch (GET_IP_HEADER_VERSION(header)) {
    13281335        case IPVERSION:
    13291336                addrlen = sizeof(src_in);
     
    14471454
    14481455        /* Set the destination address */
    1449         switch (header->version) {
     1456        switch (GET_IP_HEADER_VERSION(header)) {
    14501457        case IPVERSION:
    14511458                addrlen = sizeof(addr_in);
     
    19091916       
    19101917        *answer_count = 0;
     1918       
     1919        if (!IPC_GET_IMETHOD(*call))
     1920                return EOK;
     1921       
    19111922        switch (IPC_GET_IMETHOD(*call)) {
    1912         case IPC_M_PHONE_HUNGUP:
    1913                 return EOK;
    1914        
    19151923        case IPC_M_CONNECT_TO_ME:
    19161924                return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call),
Note: See TracChangeset for help on using the changeset viewer.