Changeset 7bf12387 in mainline


Ignore:
Timestamp:
2011-05-28T19:44:42Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0743493a
Parents:
40ffda8
git-author:
Jeff Rous <jeffrous@…> (2011-05-28 19:44:42)
git-committer:
Jakub Jermar <jakub@…> (2011-05-28 19:44:42)
Message:

ip: Rename the defines so they don't conflict with similar TCP changes

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/il/ip_client.c

    r40ffda8 r7bf12387  
    181181        /* Set the header */
    182182        header = (ip_header_t *) data;
    183         SET_HEADER_LENGTH(header, (IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t)
    184         + ipopt_length)));
     183        SET_IP_HEADER_LENGTH(header,
     184            (IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length)));
    185185        header->ttl = (ttl ? ttl : IPDEFTTL);
    186186        header->tos = tos;
     
    188188
    189189        if (dont_fragment)
    190                 SET_HEADER_FLAGS(header, IPFLAG_DONT_FRAGMENT);
     190                SET_IP_HEADER_FLAGS(header, IPFLAG_DONT_FRAGMENT);
    191191
    192192        return EOK;
     
    227227                *tos = header->tos;
    228228        if (dont_fragment)
    229                 *dont_fragment = GET_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT;
     229                *dont_fragment = GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT;
    230230        if (ipopt_length) {
    231231                *ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t);
  • uspace/lib/net/include/ip_header.h

    r40ffda8 r7bf12387  
    6464 */
    6565#define IP_FRAGMENT_OFFSET(header) \
    66         (((GET_HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \
     66        (((GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \
    6767            (header)->fragment_offset_low) * 8U)
    6868
     
    8383 */
    8484#define IP_HEADER_LENGTH(header) \
    85         (GET_HEADER_LENGTH(header) * 4U)
     85        (GET_IP_HEADER_LENGTH(header) * 4U)
    8686
    8787/** Returns the actual IP packet total length.
     
    145145        uint8_t vhl; /* version, header_length */
    146146
    147 #define GET_HEADER_VERSION(header) \
     147#define GET_IP_HEADER_VERSION(header) \
    148148        (((header)->vhl & 0xf0) >> 4)
    149 #define SET_HEADER_VERSION(header, version) \
     149#define SET_IP_HEADER_VERSION(header, version) \
    150150        ((header)->vhl = \
    151151         ((version & 0x0f) << 4) | ((header)->vhl & 0x0f))
    152152
    153 #define GET_HEADER_LENGTH(header) \
     153#define GET_IP_HEADER_LENGTH(header) \
    154154        ((header)->vhl & 0x0f)
    155 #define SET_HEADER_LENGTH(header, length) \
     155#define SET_IP_HEADER_LENGTH(header, length) \
    156156        ((header)->vhl = \
    157157         (length & 0x0f) | ((header)->vhl & 0xf0))
     
    163163        uint8_t ffoh; /* flags, fragment_offset_high */
    164164
    165 #define GET_HEADER_FLAGS(header) \
     165#define GET_IP_HEADER_FLAGS(header) \
    166166        (((header)->ffoh & 0xe0) >> 5)
    167 #define SET_HEADER_FLAGS(header, flags) \
     167#define SET_IP_HEADER_FLAGS(header, flags) \
    168168        ((header)->ffoh = \
    169169         ((flags & 0x07) << 5) | ((header)->ffoh & 0x1f))
    170170
    171 #define GET_HEADER_FRAGMENT_OFFSET_HIGH(header) \
     171#define GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) \
    172172        ((header)->ffoh & 0x1f)
    173 #define SET_HEADER_FRAGMENT_OFFSET_HIGH(header, fragment_offset_high) \
     173#define SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, fragment_offset_high) \
    174174        ((header)->ffoh = \
    175175         (fragment_offset_high & 0x1f) | ((header)->ffoh & 0xe0))
     
    195195        uint8_t of; /* overflow, flags */
    196196
    197 #define GET_OPTION_OVERFLOW(option) \
     197#define GET_IP_OPTION_OVERFLOW(option) \
    198198        (((option)->of & 0xf0) >> 4)
    199 #define SET_OPTION_OVERFLOW(option, overflow) \
     199#define SET_IP_OPTION_OVERFLOW(option, overflow) \
    200200        ((option)->of = \
    201201         ((overflow & 0x0f) << 4) | ((option)->of & 0x0f))
    202202
    203 #define GET_OPTION_FLAGS(option) \
     203#define GET_IP_OPTION_FLAGS(option) \
    204204        ((option)->of & 0x0f)
    205 #define SET_OPTION_FLAGS(option, flags) \
     205#define SET_IP_OPTION_FLAGS(option, flags) \
    206206        ((option)->of = \
    207207         (flags & 0x0f) | ((option)->of & 0xf0))
  • uspace/srv/net/il/ip/ip.c

    r40ffda8 r7bf12387  
    201201
    202202        /* Set the destination address */
    203         switch (GET_HEADER_VERSION(header)) {
     203        switch (GET_IP_HEADER_VERSION(header)) {
    204204        case IPVERSION:
    205205                addrlen = sizeof(dest_in);
     
    635635
    636636        /* Process all IP options */
    637         while (next < GET_HEADER_LENGTH(first)) {
     637        while (next < GET_IP_HEADER_LENGTH(first)) {
    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_HEADER_LENGTH(last, (length / 4 + 1));
     658                SET_IP_HEADER_LENGTH(last, (length / 4 + 1));
    659659        } else {
    660                 SET_HEADER_LENGTH(last, (length / 4));
     660                SET_IP_HEADER_LENGTH(last, (length / 4));
    661661        }
    662662
     
    706706                return rc;
    707707       
    708         SET_HEADER_VERSION(header, IPV4);
    709         SET_HEADER_FRAGMENT_OFFSET_HIGH(header, 0);
     708        SET_IP_HEADER_VERSION(header, IPV4);
     709        SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, 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_HEADER_FLAGS(header,
    738                             (GET_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
     737                        SET_IP_HEADER_FLAGS(header,
     738                            (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
    739739                        middle_header->total_length =
    740740                            htons(packet_get_data_length(next));
    741                         SET_HEADER_FRAGMENT_OFFSET_HIGH(middle_header,
     741                        SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header,
    742742                            IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length));
    743743                        middle_header->fragment_offset_low =
     
    769769                middle_header->total_length =
    770770                    htons(packet_get_data_length(next));
    771                 SET_HEADER_FRAGMENT_OFFSET_HIGH(middle_header,
     771                SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header,
    772772                    IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length));
    773773                middle_header->fragment_offset_low =
     
    786786                length += packet_get_data_length(next);
    787787                free(last_header);
    788                 SET_HEADER_FLAGS(header,
    789                     (GET_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
     788                SET_IP_HEADER_FLAGS(header,
     789                    (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
    790790        }
    791791
     
    836836        new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length);
    837837        offset = IP_FRAGMENT_OFFSET(header) + IP_HEADER_DATA_LENGTH(header);
    838         SET_HEADER_FRAGMENT_OFFSET_HIGH(new_header,
     838        SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(new_header,
    839839            IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset));
    840840        new_header->fragment_offset_low =
     
    867867                return NULL;
    868868        memcpy(middle, last, IP_HEADER_LENGTH(last));
    869         SET_HEADER_FLAGS(middle,
    870             (GET_HEADER_FLAGS(middle) | IPFLAG_MORE_FRAGMENTS));
     869        SET_IP_HEADER_FLAGS(middle,
     870            (GET_IP_HEADER_FLAGS(middle) | IPFLAG_MORE_FRAGMENTS));
    871871        return middle;
    872872}
     
    925925
    926926        /* Fragmentation forbidden? */
    927         if(GET_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT)
     927        if(GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT)
    928928                return EPERM;
    929929
     
    961961
    962962        /* Mark the first as fragmented */
    963         SET_HEADER_FLAGS(header,
    964             (GET_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
     963        SET_IP_HEADER_FLAGS(header,
     964            (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
    965965
    966966        /* Create middle fragments */
     
    13231323        int rc;
    13241324
    1325         if ((GET_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) ||
     1325        if ((GET_IP_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) ||
    13261326            IP_FRAGMENT_OFFSET(header)) {
    13271327                // TODO fragmented
     
    13291329        }
    13301330       
    1331         switch (GET_HEADER_VERSION(header)) {
     1331        switch (GET_IP_HEADER_VERSION(header)) {
    13321332        case IPVERSION:
    13331333                addrlen = sizeof(src_in);
     
    14511451
    14521452        /* Set the destination address */
    1453         switch (GET_HEADER_VERSION(header)) {
     1453        switch (GET_IP_HEADER_VERSION(header)) {
    14541454        case IPVERSION:
    14551455                addrlen = sizeof(addr_in);
Note: See TracChangeset for help on using the changeset viewer.