Changeset 0773396 in mainline for uspace/srv/net/tcp/pdu.c


Ignore:
Timestamp:
2013-12-25T13:05:25Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bc54126c
Parents:
f4a47e52 (diff), 6946f23 (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 changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/pdu.c

    rf4a47e52 r0773396  
    4040#include <mem.h>
    4141#include <stdlib.h>
    42 #include <net/socket_codes.h>
    4342#include "pdu.h"
    4443#include "segment.h"
     
    145144}
    146145
    147 static uint16_t tcp_phdr_setup(tcp_pdu_t *pdu, tcp_phdr_t *phdr,
     146static ip_ver_t tcp_phdr_setup(tcp_pdu_t *pdu, tcp_phdr_t *phdr,
    148147    tcp_phdr6_t *phdr6)
    149148{
    150149        addr32_t src_v4;
    151150        addr128_t src_v6;
    152         uint16_t src_af = inet_addr_get(&pdu->src, &src_v4, &src_v6);
    153        
     151        uint16_t src_ver = inet_addr_get(&pdu->src, &src_v4, &src_v6);
     152
    154153        addr32_t dest_v4;
    155154        addr128_t dest_v6;
    156         uint16_t dest_af = inet_addr_get(&pdu->dest, &dest_v4, &dest_v6);
    157        
    158         assert(src_af == dest_af);
    159        
    160         switch (src_af) {
    161         case AF_INET:
     155        uint16_t dest_ver = inet_addr_get(&pdu->dest, &dest_v4, &dest_v6);
     156
     157        assert(src_ver == dest_ver);
     158
     159        switch (src_ver) {
     160        case ip_v4:
    162161                phdr->src = host2uint32_t_be(src_v4);
    163162                phdr->dest = host2uint32_t_be(dest_v4);
     
    167166                    host2uint16_t_be(pdu->header_size + pdu->text_size);
    168167                break;
    169         case AF_INET6:
     168        case ip_v6:
    170169                host2addr128_t_be(src_v6, phdr6->src);
    171170                host2addr128_t_be(dest_v6, phdr6->dest);
     
    178177                assert(false);
    179178        }
    180        
    181         return src_af;
     179
     180        return src_ver;
    182181}
    183182
     
    266265        tcp_phdr_t phdr;
    267266        tcp_phdr6_t phdr6;
    268        
    269         uint16_t af = tcp_phdr_setup(pdu, &phdr, &phdr6);
    270         switch (af) {
    271         case AF_INET:
     267
     268        ip_ver_t ver = tcp_phdr_setup(pdu, &phdr, &phdr6);
     269        switch (ver) {
     270        case ip_v4:
    272271                cs_phdr = tcp_checksum_calc(TCP_CHECKSUM_INIT, (void *) &phdr,
    273272                    sizeof(tcp_phdr_t));
    274273                break;
    275         case AF_INET6:
     274        case ip_v6:
    276275                cs_phdr = tcp_checksum_calc(TCP_CHECKSUM_INIT, (void *) &phdr6,
    277276                    sizeof(tcp_phdr6_t));
     
    280279                assert(false);
    281280        }
    282        
     281
    283282        cs_headers = tcp_checksum_calc(cs_phdr, pdu->header, pdu->header_size);
    284283        return tcp_checksum_calc(cs_headers, pdu->text, pdu->text_size);
Note: See TracChangeset for help on using the changeset viewer.