Changeset 0773396 in mainline for uspace/srv/net/udp/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/udp/pdu.c

    rf4a47e52 r0773396  
    8585}
    8686
    87 static uint16_t udp_phdr_setup(udp_pdu_t *pdu, udp_phdr_t *phdr,
     87static ip_ver_t udp_phdr_setup(udp_pdu_t *pdu, udp_phdr_t *phdr,
    8888    udp_phdr6_t *phdr6)
    8989{
    9090        addr32_t src_v4;
    9191        addr128_t src_v6;
    92         uint16_t src_af = inet_addr_get(&pdu->src, &src_v4, &src_v6);
    93        
     92        ip_ver_t src_ver = inet_addr_get(&pdu->src, &src_v4, &src_v6);
     93
    9494        addr32_t dest_v4;
    9595        addr128_t dest_v6;
    96         uint16_t dest_af = inet_addr_get(&pdu->dest, &dest_v4, &dest_v6);
    97        
    98         assert(src_af == dest_af);
    99        
    100         switch (src_af) {
    101         case AF_INET:
     96        ip_ver_t dest_ver = inet_addr_get(&pdu->dest, &dest_v4, &dest_v6);
     97
     98        assert(src_ver == dest_ver);
     99
     100        switch (src_ver) {
     101        case ip_v4:
    102102                phdr->src_addr = host2uint32_t_be(src_v4);
    103103                phdr->dest_addr = host2uint32_t_be(dest_v4);
     
    106106                phdr->udp_length = host2uint16_t_be(pdu->data_size);
    107107                break;
    108         case AF_INET6:
     108        case ip_v6:
    109109                host2addr128_t_be(src_v6, phdr6->src_addr);
    110110                host2addr128_t_be(dest_v6, phdr6->dest_addr);
     
    116116                assert(false);
    117117        }
    118        
    119         return src_af;
     118
     119        return src_ver;
    120120}
    121121
     
    136136        udp_phdr_t phdr;
    137137        udp_phdr6_t phdr6;
    138        
    139         uint16_t af = udp_phdr_setup(pdu, &phdr, &phdr6);
    140         switch (af) {
    141         case AF_INET:
     138
     139        ip_ver_t ver = udp_phdr_setup(pdu, &phdr, &phdr6);
     140        switch (ver) {
     141        case ip_v4:
    142142                cs_phdr = udp_checksum_calc(UDP_CHECKSUM_INIT, (void *) &phdr,
    143143                    sizeof(udp_phdr_t));
    144144                break;
    145         case AF_INET6:
     145        case ip_v6:
    146146                cs_phdr = udp_checksum_calc(UDP_CHECKSUM_INIT, (void *) &phdr6,
    147147                    sizeof(udp_phdr6_t));
     
    150150                assert(false);
    151151        }
    152        
     152
    153153        return udp_checksum_calc(cs_phdr, pdu->data, pdu->data_size);
    154154}
     
    215215                return ENOMEM;
    216216
     217        npdu->iplink = sp->iplink;
    217218        npdu->src = sp->local.addr;
    218219        npdu->dest = sp->foreign.addr;
Note: See TracChangeset for help on using the changeset viewer.