Ignore:
File:
1 edited

Legend:

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

    r7bf12387 r28a3e74  
    201201
    202202        /* Set the destination address */
    203         switch (GET_IP_HEADER_VERSION(header)) {
     203        switch (header->version) {
    204204        case IPVERSION:
    205205                addrlen = sizeof(dest_in);
     
    365365               
    366366                if (ip_netif->dhcp) {
    367                         // TODO dhcp
     367                        /* TODO dhcp */
    368368                        net_free_settings(configuration, data);
    369369                        return ENOTSUP;
     
    398398                        }
    399399                } else {
    400                         // TODO ipv6 in separate module
     400                        /* TODO ipv6 in separate module */
    401401                        net_free_settings(configuration, data);
    402402                        return ENOTSUP;
     
    517517            ip_netif->dhcp ? "dhcp" : "static");
    518518       
    519         // TODO ipv6 addresses
     519        /* TODO ipv6 addresses */
    520520       
    521521        char address[INET_ADDRSTRLEN];
     
    635635
    636636        /* Process all IP options */
    637         while (next < GET_IP_HEADER_LENGTH(first)) {
     637        while (next < first->header_length) {
    638638                option = (ip_option_t *) (((uint8_t *) first) + next);
    639639                /* Skip end or noop */
     
    656656        if (length % 4) {
    657657                bzero(((uint8_t *) last) + length, 4 - (length % 4));
    658                 SET_IP_HEADER_LENGTH(last, (length / 4 + 1));
     658                last->header_length = length / 4 + 1;
    659659        } else {
    660                 SET_IP_HEADER_LENGTH(last, (length / 4));
     660                last->header_length = length / 4;
    661661        }
    662662
     
    706706                return rc;
    707707       
    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;
    710710        header->fragment_offset_low = 0;
    711711        header->header_checksum = 0;
     
    735735                        memcpy(middle_header, last_header,
    736736                            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;
    739738                        middle_header->total_length =
    740739                            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);
    743742                        middle_header->fragment_offset_low =
    744743                            IP_COMPUTE_FRAGMENT_OFFSET_LOW(length);
     
    769768                middle_header->total_length =
    770769                    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);
    773772                middle_header->fragment_offset_low =
    774773                    IP_COMPUTE_FRAGMENT_OFFSET_LOW(length);
     
    786785                length += packet_get_data_length(next);
    787786                free(last_header);
    788                 SET_IP_HEADER_FLAGS(header,
    789                     (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
     787                header->flags |= IPFLAG_MORE_FRAGMENTS;
    790788        }
    791789
     
    836834        new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length);
    837835        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);
    840838        new_header->fragment_offset_low =
    841839            IP_COMPUTE_FRAGMENT_OFFSET_LOW(offset);
     
    867865                return NULL;
    868866        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;
    871868        return middle;
    872869}
     
    925922
    926923        /* Fragmentation forbidden? */
    927         if(GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT)
     924        if(header->flags & IPFLAG_DONT_FRAGMENT)
    928925                return EPERM;
    929926
     
    949946
    950947        /* Greatest multiple of 8 lower than content */
    951         // TODO even fragmentation?
     948        /* TODO even fragmentation? */
    952949        length = length & ~0x7;
    953950       
     
    961958
    962959        /* 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;
    965961
    966962        /* Create middle fragments */
     
    12161212        }
    12171213       
    1218         /* If the local host is the destination */
     1214        /* Ff the local host is the destination */
    12191215        if ((route->address.s_addr == dest->s_addr) &&
    12201216            (dest->s_addr != IPV4_LOCALHOST_ADDRESS)) {
     
    12831279        in_addr_t destination;
    12841280
    1285         // TODO search set ipopt route?
     1281        /* TODO search set ipopt route? */
    12861282        destination.s_addr = header->destination_address;
    12871283        return destination;
     
    13231319        int rc;
    13241320
    1325         if ((GET_IP_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) ||
     1321        if ((header->flags & IPFLAG_MORE_FRAGMENTS) ||
    13261322            IP_FRAGMENT_OFFSET(header)) {
    1327                 // TODO fragmented
     1323                /* TODO fragmented */
    13281324                return ENOTSUP;
    13291325        }
    13301326       
    1331         switch (GET_IP_HEADER_VERSION(header)) {
     1327        switch (header->version) {
    13321328        case IPVERSION:
    13331329                addrlen = sizeof(src_in);
     
    14411437                phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    14421438                if (phone >= 0) {
    1443                         /* TTL exceeded ICMP */
     1439                        /* ttl exceeded ICMP */
    14441440                        icmp_time_exceeded_msg(phone, ICMP_EXC_TTL, packet);
    14451441                }
     
    14511447
    14521448        /* Set the destination address */
    1453         switch (GET_IP_HEADER_VERSION(header)) {
     1449        switch (header->version) {
    14541450        case IPVERSION:
    14551451                addrlen = sizeof(addr_in);
     
    17811777                if ((type != ICMP_DEST_UNREACH) ||
    17821778                    (code != ICMP_HOST_UNREACH)) {
    1783                         /* No, something else */
     1779                        /* No, something else */
    17841780                        break;
    17851781                }
Note: See TracChangeset for help on using the changeset viewer.